From b7638936d350eb1f48c02895b9275c79587726ce Mon Sep 17 00:00:00 2001
From: 陈嘉乐 <cjl@hdlchina.com.cn>
Date: 星期二, 15 十二月 2020 17:18:48 +0800
Subject: [PATCH] 2020-12-15-3

---
 HDL_ON/UI/UI2/3-Intelligence/Automation/AddLogic.cs |  119 ++++++++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 93 insertions(+), 26 deletions(-)

diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation/AddLogic.cs b/HDL_ON/UI/UI2/3-Intelligence/Automation/AddLogic.cs
index 426ebe3..133eb88 100644
--- a/HDL_ON/UI/UI2/3-Intelligence/Automation/AddLogic.cs
+++ b/HDL_ON/UI/UI2/3-Intelligence/Automation/AddLogic.cs
@@ -35,7 +35,7 @@
                 topView.setBtn.Visible = true;
                 topView.clickSetBtn.Visible = true;
             }
-           
+
 
             VerticalScrolViewLayout viewLayout = new VerticalScrolViewLayout
             {
@@ -55,7 +55,7 @@
             titleCondition.frameLayout.SetCornerWithSameRadius(Application.GetRealHeight(12), HDLUtils.RectCornerTopLeft | HDLUtils.RectCornerTopRight);
             titleCondition.btnText.TextID = StringId.andCondition;
             viewLayout.AddChidren(titleCondition.FLayoutView());
-         
+
             if (Logic.currlogic.relation == "and")
             {
                 titleCondition.btnText.Text = Language.StringByID(StringId.andCondition);
@@ -91,7 +91,7 @@
             LogicView.LogicAddView addOutputIcon = new LogicView.LogicAddView();
             addOutputIcon.frameLayout.SetCornerWithSameRadius(Application.GetRealHeight(12), HDLUtils.RectCornerBottomLeft | HDLUtils.RectCornerBottomRight);
             viewLayout.AddChidren(addOutputIcon.FLayoutView());
-           
+
             #endregion
 
             #region  寰幆鏂瑰紡
@@ -105,7 +105,7 @@
             cyclicTitle.frameLayout.Radius = (uint)Application.GetRealHeight(12);
             cyclicTitle.btnText.Text = MainView.GetWeekText(Logic.currlogic);
             viewLayout.AddChidren(cyclicTitle.FLayoutView());
-          
+
             #endregion
 
             #region  鎵ц鎺ㄩ�� 鍙戦�侀�氱煡
@@ -138,7 +138,7 @@
             this.AddChidren(saveView.FLayoutView());
 
             #endregion
-#endregion
+            #endregion
 
             #region  鐣岄潰鍚勭鐐瑰嚮浜嬩欢
             ///璁剧疆鍥炬爣鐐瑰嚮浜嬩欢
@@ -184,6 +184,9 @@
             ///淇濆瓨鐐瑰嚮浜嬩欢
             saveView.btnClick.MouseUpEventHandler += (sender, e) =>
             {
+                Loading loading = new Loading();
+                this.AddChidren(loading);
+                HDL_ON.DAL.Server.ResponsePackNew responsePackNew = null;
                 if (string.IsNullOrEmpty(Logic.currlogic.userLogicId))
                 {
                     List<string> list = new List<string>();
@@ -195,35 +198,99 @@
                     {
                         Logic.currlogic.name = logicName;
                         Logic.currlogic.sid = LogicMethod.NewSid();
-                        //鍙戦�佹柊鍔犱慨鏀归�昏緫鍛戒护锛�
-                        var responsePackNew = Send.AddLogic(Logic.currlogic);
-                        if (responsePackNew.Code == "0")
+                        loading.Start();
+                        new System.Threading.Thread(() =>
                         {
-                            Logic.LogicList.Add(Logic.currlogic);
-                            LogicMethod.RemoveAllView();
-                            MainView.MainShow();
-                        }
-                        else
-                        {
-                            new LogicView.TipPopView().FlashingBox(Language.StringByID(StringId.saveFail));
-                        }
+
+                            try
+                            {
+                                //鍙戦�佹柊鍔犻�昏緫鍛戒护锛�
+                                responsePackNew = Send.AddLogic(Logic.currlogic);
+
+                            }
+                            catch { }
+                            finally
+                            {
+                                Application.RunOnMainThread(() =>
+                                {
+                                    loading.Hide();
+                                    if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "")
+                                    {
+
+
+                                        //鑾峰彇閫昏緫璇︾粏杩斿洖鏄竴涓暟缁�(object绫诲瀷杞崲涓烘暟缁�);
+                                        var jArray = Newtonsoft.Json.Linq.JArray.Parse(responsePackNew.Data.ToString());
+                                        for (int a = 0; a < jArray.Count; a++)
+                                        {
+                                            var jay = jArray[a];
+                                            //鏁版嵁杩斿簭鍒楀寲涓篖ogic瀵硅薄
+                                            var str = Newtonsoft.Json.JsonConvert.SerializeObject(jay);
+                                            var logic = Newtonsoft.Json.JsonConvert.DeserializeObject<Logic>(str);
+                                            if (logic.userLogicId!="")
+                                            {
+                                                //鏇存柊浜戠鍞竴鑷姩鍖杋d;
+                                                Logic.currlogic.userLogicId = logic.userLogicId;
+                                            }
+                                            else
+                                            {
+                                                //鑷繁鐪嬬殑鎵�浠ヤ笉闇�瑕佹敮鎸佷腑鑻辨枃
+                                                new LogicView.TipPopView().FlashingBox("娌℃湁杩斿洖浜戠鍞竴鑷姩鍖杋d");
+                                            }
+
+                                        }
+
+                                        Logic.LogicList.Add(Logic.currlogic);
+                                        LogicMethod.RemoveAllView();
+                                        MainView.MainShow();
+                                    }
+                                    else
+                                    {
+                                        new LogicView.TipPopView().FlashingBox(Language.StringByID(StringId.saveFail));
+                                    }
+                                });
+                            }
+
+                        })
+                        { IsBackground = true }.Start();
 
                     });
 
                 }
                 else
                 {
-                    //鍙戦�佹柊鍔犱慨鏀归�昏緫鍛戒护锛�
-                    var responsePackNew = Send.updateLogic(Logic.currlogic);
-                    if (responsePackNew.Code == "0")
+                    loading.Start();
+                    new System.Threading.Thread(() =>
                     {
-                        LogicMethod.RemoveAllView();
-                        MainView.MainShow();
-                    }
-                    else
-                    {
-                        new LogicView.TipPopView().FlashingBox(Language.StringByID(StringId.saveFail));
-                    }
+
+                        try
+                        {
+                            //鍙戦�佷慨鏀归�昏緫鍛戒护锛�
+                            responsePackNew = Send.updateLogic(Logic.currlogic);
+
+                        }
+                        catch { }
+                        finally
+                        {
+                            Application.RunOnMainThread(() =>
+                            {
+                                loading.Hide();
+                                if (responsePackNew != null && responsePackNew.Code == "0")
+                                {
+                                    LogicMethod.RemoveAllView();
+                                    MainView.MainShow();
+                                }
+                                else
+                                {
+                                    new LogicView.TipPopView().FlashingBox(Language.StringByID(StringId.saveFail));
+                                }
+                            });
+                        }
+
+
+
+                    })
+                    { IsBackground = true }.Start();
+
                 }
 
             };

--
Gitblit v1.8.0