From b83a01eec16b236d099dcea3e7a5051c8cae9c6c Mon Sep 17 00:00:00 2001
From: wells.liu <wells.liu@broconcentric.com>
Date: 星期五, 03 七月 2020 10:48:37 +0800
Subject: [PATCH] Merge branch 'master' of http://gitblit.broconcentric.com:8088/r/M071

---
 src/Bro.Process/ProcessControl.cs |   35 ++++++++++++++++++++++++++++++-----
 1 files changed, 30 insertions(+), 5 deletions(-)

diff --git a/src/Bro.Process/ProcessControl.cs b/src/Bro.Process/ProcessControl.cs
index 0edf765..29d3170 100644
--- a/src/Bro.Process/ProcessControl.cs
+++ b/src/Bro.Process/ProcessControl.cs
@@ -32,8 +32,8 @@
             #region AutoFac娉ㄥ唽
             GlobalVar.Builder.RegisterInstance(this).As<IProcess>().ExternallyOwned();
             GlobalVar.Builder.RegisterInstance(IConfig).As<IProcessConfig>().ExternallyOwned();
-            GlobalVar.Builder.RegisterInstance(DeviceCollection);
-            GlobalVar.Builder.RegisterInstance(ProcessMethodCollection);
+            GlobalVar.Builder.RegisterInstance(DeviceCollection).ExternallyOwned();
+            GlobalVar.Builder.RegisterInstance(ProcessMethodCollection).ExternallyOwned();
 
             //if (isBuild)
             //{
@@ -342,6 +342,31 @@
             }
         }
 
+        public void CreateNewConfig(IProcessConfig config, string newProductionCode)
+        {
+            try
+            {
+                if (config == null)
+                    throw new ProcessException("淇濆瓨鐨勯厤缃俊鎭笉鑳戒负绌�");
+                ProductionCode = newProductionCode;
+                //鐢熸垚config.json
+                string newConfig = JsonConvert.SerializeObject(config, new JsonSerializerSettings() { TypeNameHandling = TypeNameHandling.All });
+                using (StreamWriter writer = new StreamWriter(_configPath, false, System.Text.Encoding.UTF8))
+                {
+                    writer.Write(newConfig);
+                    writer.Flush();
+                    writer.Close();
+                }
+
+                //娣诲姞鍒癝etting.json
+                SettingHelper.AddNewProductionCode(ProductionCode);
+            }
+            catch (Exception ex)
+            {
+                throw new ProcessException(ex.Message, null);
+            }
+        }
+
         private void SaveBackupConfig()
         {
             string backPath = Path.GetDirectoryName(_configPath);
@@ -484,7 +509,7 @@
         #endregion
 
         #region IMonitor鐩戝惉
-        protected virtual void OnMonitorInvoke(DateTime dt, string deviceId, IDevice sourceDevice, MonitorSet monitorSet)
+        protected virtual void OnMonitorInvoke(DateTime dt, string deviceId, IDevice sourceDevice, IMonitorSet monitorSet)
         {
             string methodCode = monitorSet.MethodCode;
 
@@ -642,9 +667,9 @@
         #endregion
 
         #region 鎶ヨ鍜孌ownTime
-        ObservableCollection<WarningSet> _warningRemains = new ObservableCollection<WarningSet>();
+        ObservableCollection<IWarningSet> _warningRemains = new ObservableCollection<IWarningSet>();
 
-        protected virtual void OnMonitorAlarm(DateTime dt, IDevice device, WarningSet warning)
+        protected virtual void OnMonitorAlarm(DateTime dt, IDevice device, IWarningSet warning)
         {
             if (warning.CurrentStatus)
             {

--
Gitblit v1.8.0