From 5241a8f6377dfd1618610dd15fd05ed6f51c8ba2 Mon Sep 17 00:00:00 2001
From: patrick.xu <patrick.xu@broconcentric.com>
Date: 星期三, 16 十二月 2020 11:19:45 +0800
Subject: [PATCH] 1. 添加默认流程和默认产品功能 2. 修改批量建立检测项功能

---
 src/Bro.Process/ProcessControl.cs |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/Bro.Process/ProcessControl.cs b/src/Bro.Process/ProcessControl.cs
index ca587d2..359e771 100644
--- a/src/Bro.Process/ProcessControl.cs
+++ b/src/Bro.Process/ProcessControl.cs
@@ -45,7 +45,6 @@
 
         #region Event
         public event Action<string, Bitmap, string> OnBitmapOutput;
-        //public event Action<string, object> OnObjectOutput;
         public Action<DateTime, Exception> OnExceptionOccured { get; set; }
         public event Action<DeviceState> OnProcessStateChanged;
         public event Action<DateTime, string, string> OnLog;
@@ -348,10 +347,16 @@
             {
                 if (config == null)
                     throw new ProcessException("淇濆瓨鐨勯厤缃俊鎭笉鑳戒负绌�");
-                ProductionCode = newProductionCode;
+
+                string newConfigPath = Path.Combine(Path.GetDirectoryName(_configPath), $"Config_{newProductionCode}.json");
+                if (File.Exists(newConfigPath))
+                {
+                    throw new ProcessException($"{newProductionCode}閰嶇疆鏂囦欢宸茬粡瀛樺湪");
+                }
+
                 //鐢熸垚config.json
                 string newConfig = JsonConvert.SerializeObject(config, new JsonSerializerSettings() { TypeNameHandling = TypeNameHandling.All });
-                using (StreamWriter writer = new StreamWriter(_configPath, false, System.Text.Encoding.UTF8))
+                using (StreamWriter writer = new StreamWriter(newConfigPath, false, System.Text.Encoding.UTF8))
                 {
                     writer.Write(newConfig);
                     writer.Flush();
@@ -359,7 +364,7 @@
                 }
 
                 //娣诲姞鍒癝etting.json
-                SettingHelper.AddNewProductionCode(ProductionCode);
+                SettingHelper.AddNewProductionCode(newProductionCode);
             }
             catch (Exception ex)
             {

--
Gitblit v1.8.0