wanshenmean
11 小时以前 34f1e65179910f3c02f0ac6813dbfefb4244d4d7
Code/²âÊÔ¹¤¾ß/WIDESEAWCS_S7Simulator/WIDESEAWCS_S7Simulator.Application/InstanceSyncService.cs
@@ -116,7 +116,27 @@
                // 4.4 åˆ›å»ºæˆ–更新实例
                if (_instanceManager.InstanceExists(device.DeviceCode))
                {
                    _logger.LogInformation("实例 {DeviceCode} å·²å­˜åœ¨ï¼Œè·³è¿‡åˆ›å»º", device.DeviceCode);
                    // å®žä¾‹å·²å­˜åœ¨ï¼Œæ›´æ–°é…ç½®
                    var instance = _instanceManager.GetInstance(device.DeviceCode);
                    if (instance != null)
                    {
                        var oldState = instance.GetState();
                        var wasRunning = oldState.Status == InstanceStatus.Running;
                        // åœæ­¢æ—§å®žä¾‹
                        await _instanceManager.StopInstanceAsync(device.DeviceCode);
                        // åˆ é™¤æ—§å®žä¾‹ï¼ˆä¿ç•™é…ç½®ï¼‰
                        await _instanceManager.DeleteInstanceAsync(device.DeviceCode, deleteConfig: false);
                        // é‡æ–°åˆ›å»ºå®žä¾‹
                        var newInstance = await _instanceManager.CreateInstanceAsync(config);
                        if (wasRunning)
                        {
                            await _instanceManager.StartInstanceAsync(device.DeviceCode);
                        }
                        _logger.LogInformation("已更新实例 {DeviceCode} (端口:{Port})", device.DeviceCode, device.DevicePort);
                    }
                }
                else
                {