From d07d62be7111d78b2aaa44c9cdee23a7d22b4dda Mon Sep 17 00:00:00 2001
From: wei <kaede@kaededeMacBook-Air.local>
Date: 星期二, 22 十二月 2020 10:38:15 +0800
Subject: [PATCH] 20201222-1
---
HDL_ON/UI/UI2/3-Intelligence/Automation/AddLogic.cs | 158 ++++++++++++++++++++++++++++++++++++++--------------
1 files changed, 116 insertions(+), 42 deletions(-)
diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation/AddLogic.cs b/HDL_ON/UI/UI2/3-Intelligence/Automation/AddLogic.cs
old mode 100644
new mode 100755
index 426ebe3..f6bb95b
--- 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,24 @@
///淇濆瓨鐐瑰嚮浜嬩欢
saveView.btnClick.MouseUpEventHandler += (sender, e) =>
{
+ if (Logic.currlogic.input.Count == 0&& Logic.currlogic.output.Count == 0)
+ {
+ new LogicView.TipPopView().TipBox(StringId.tip, StringId.conditioncNullOrtargetNull);
+ return;
+ }
+ if (Logic.currlogic.input.Count == 0)
+ {
+ new LogicView.TipPopView().TipBox(StringId.tip, StringId.conditioncNull);
+ return;
+ }
+ if (Logic.currlogic.output.Count == 0)
+ {
+ new LogicView.TipPopView().TipBox(StringId.tip, StringId.targetNull);
+ return;
+ }
+ 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 +213,107 @@
{
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 if (responsePackNew != null && responsePackNew.Code == "14005")
+ {
+ new LogicView.TipPopView().FlashingBox(Language.StringByID(StringId.gatewayNotOnline));
+ }
+ 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 if (responsePackNew != null && responsePackNew.Code == "14005")
+ {
+ new LogicView.TipPopView().FlashingBox(Language.StringByID(StringId.gatewayNotOnline));
+ }
+ else
+ {
+ new LogicView.TipPopView().FlashingBox(Language.StringByID(StringId.saveFail));
+ }
+ });
+ }
+
+
+
+ })
+ { IsBackground = true }.Start();
+
}
};
@@ -544,21 +634,5 @@
return stateList;
}
- /// <summary>
- /// 鐏拌壊寮规鐖舵帶浠�
- /// </summary>
- /// <param name="frame">鏄剧ず鍦ㄥ摢涓晫闈�</param>
- /// <returns></returns>
- public FrameLayout GetFrame(FrameLayout frame, string tagKey)
- {
- FrameLayout fLayout = new FrameLayout
- {
- BackgroundColor = CSS.CSS_Color.viewTrans60lucence,
- Tag = tagKey,
-
- };
- frame.AddChidren(fLayout);
- return fLayout;
- }
}
}
--
Gitblit v1.8.0