From 3793a9a38ac6c4c4111c2bba3a35a71c30601e82 Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期一, 13 四月 2020 19:38:24 +0800
Subject: [PATCH] 上传个东西

---
 ZigbeeApp/Shared/Phone/Device/Logic/SkipView.cs |  188 +++++++++++++++++++++++++---------------------
 1 files changed, 103 insertions(+), 85 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/Device/Logic/SkipView.cs b/ZigbeeApp/Shared/Phone/Device/Logic/SkipView.cs
index e20c360..78b35c0 100755
--- a/ZigbeeApp/Shared/Phone/Device/Logic/SkipView.cs
+++ b/ZigbeeApp/Shared/Phone/Device/Logic/SkipView.cs
@@ -13,12 +13,13 @@
         /// <summary>
         /// 鍏跺畠鐣岄潰璺宠繘鏉ョ殑鍏ュ彛
         /// </summary>
-        public static void SkipAddLogic(int intvalue,DoorLock doorLock=null,UserCenter.MemberInfoRes accountObj = null)
+        public static void SkipAddLogic(int intvalue, DoorLock doorLock = null, UserCenter.MemberInfoRes accountObj = null)
         {
             /// 0.姝e父鑷姩鍖�;1.闂ㄩ攣鑷姩鍖�;2.闂ㄩ攣甯稿紑.鍏�;
             switch (intvalue)
             {
-                case 0: {
+                case 0:
+                    {
                         //new涓�涓柊閫昏緫瀵硅薄锛�
                         //鏂板姝e父鑷姩鍖栧叆鍙�
                         Common.Logic.CurrentLogic = new Common.Logic();
@@ -29,15 +30,17 @@
                         UserView.HomePage.Instance.AddChidren(addLogicPage);
                         UserView.HomePage.Instance.PageIndex += 1;
                         addLogicPage.Show();
-                    } break;
-                case 1: {
+                    }
+                    break;
+                case 1:
+                    {
                         //杩涘叆闂ㄩ攣鑱斿姩浜嬩欢鍏ュ彛
                         Send.UserMemberInfoRes = accountObj;
                         Send.CurrentDoorLock = doorLock;
                         if (accountObj == null)
                         {
                             ///闃叉鎶涘紓甯�
-                            Send.UserMemberInfoRes = new UserCenter.MemberInfoRes(); 
+                            Send.UserMemberInfoRes = new UserCenter.MemberInfoRes();
                         }
                         if (doorLock == null)
                         {
@@ -54,52 +57,49 @@
                         UserView.HomePage.Instance.AddChidren(doorLockLogicList);
                         UserView.HomePage.Instance.PageIndex += 1;
                         doorLockLogicList.Show();
-                    } break;
-                case 2: {
+                    }
+                    break;
+                case 2:
+                    {
                         Common.Logic.LogicDviceList.Clear();
                         if (Common.Logic.LogicDviceList.Count == 0)
                         {
                             Common.Logic.LogicDviceList.AddRange(LocalDevice.Current.listAllDevice.ToArray());
                         }
                         //璇诲彇绯荤粺褰撳墠鏃堕棿锛氭椂-鍒�
-                        int h =int.Parse(DateTime.Now.ToString("hh"));
-                        int m = int.Parse(DateTime.Now.ToString("mm"));
-                        //榛樿涓�涓椂闂存(寮�濮嬫椂闂翠负:绯荤粺褰撳墠锛岀粨鏉熸椂闂翠负:寮�濮嬫椂闂�+1涓椂闂�)
-                        Dictionary<string, string> timeDictionary = new Dictionary<string, string>();
-                        timeDictionary.Add("Type", "5");
-                        timeDictionary.Add("IsValid", "1");
-                        timeDictionary.Add("StartHour", h.ToString());
-                        timeDictionary.Add("StartMin", m.ToString());
-                        if (h + 1 == 24)
-                        {
-                            //缁撴潫鏃堕棿瓒呭嚭24灏忔椂澶勭悊鏂规硶;
-                            timeDictionary.Add("StopHour", h.ToString());
-                            timeDictionary.Add("StopMin", "59");
-                        }
-                        else
-                        {
-                            timeDictionary.Add("StopHour", (h + 1).ToString());
-                            timeDictionary.Add("StopMin", m.ToString());
-                        }
+                        //璇诲彇绯荤粺褰撳墠鏃堕棿锛氭椂-鍒�
+                        var h = DateTime.Now.ToString("HH");
+                        var m = DateTime.Now.ToString("mm");
+                        Dictionary<string, string> timeConditionsInfo = new Dictionary<string, string>();
+                        timeConditionsInfo.Add("Type", "0");
+                        timeConditionsInfo.Add("IsValid", "1");
+                        timeConditionsInfo.Add("DateType", "0");
+                        timeConditionsInfo.Add("RemindTime", "0");
+                        timeConditionsInfo.Add("EnDelay", "0");
+                        timeConditionsInfo.Add("DelayTime", "0");
+                        timeConditionsInfo.Add("DoorLockOpenDelayTime", "0");
+                        timeConditionsInfo.Add("StartHour", h);
+                        timeConditionsInfo.Add("StartMin", m);
                         Dictionary<string, object> actionsInfo = new Dictionary<string, object>();
                         actionsInfo.Add("LinkType", 8);
                         actionsInfo.Add("DeviceAddr", doorLock.DeviceAddr);
                         actionsInfo.Add("Epoint", doorLock.DeviceEpoint);
-                        actionsInfo.Add("PassData", "055704010112");//榛樿闂ㄩ攣甯稿紑
-                  
+                        actionsInfo.Add("PassData", "055704010113");//榛樿闂ㄩ攣甯稿叧
+
                         //new涓�涓柊閫昏緫瀵硅薄锛�
                         //鏂板闂ㄩ攣甯稿紑妯″紡鑷姩鍖栧叆鍙o紱
                         Common.Logic.CurrentLogic = new Common.Logic();
                         Common.Logic.CurrentLogic.IsEnable = 1;//榛樿涓哄紑
                         Common.Logic.CurrentLogic.LogicType = 2;//鏍囪閫昏緫绫诲瀷
                         Common.Logic.CurrentLogic.LogicName = Language.StringByID(MyInternationalizationString.openmode);
-                        Common.Logic.CurrentLogic.Conditions.Add(timeDictionary);//娣诲姞鏉′欢
+                        Common.Logic.CurrentLogic.Conditions.Add(timeConditionsInfo);//娣诲姞鏉′欢
                         Common.Logic.CurrentLogic.Actions.Add(actionsInfo);//娣诲姞鐩爣
                         var oneLogic = new OneLogic();
                         UserView.HomePage.Instance.AddChidren(oneLogic);
                         UserView.HomePage.Instance.PageIndex += 1;
                         oneLogic.Show(false);
-                    } break;
+                    }
+                    break;
             }
 
         }
@@ -180,8 +180,8 @@
                 X = Application.GetRealWidth(58),
                 Y = scenehorizontalScrol.Bottom,
             };
-            functionSceneAutoBodyView.AddChidren(logicScrolView);
-          
+            functionSceneAutoBodyView.AddChidren(logicScrolView);
+
             logicScrolView.SetCornerWithSameRadius(Application.GetRealHeight(58), HDLUtils.RectCornerTopLeft);
             bool no = false;
             //鏄剧ず榛樿妯℃澘鐨勭晫闈簨浠�
@@ -286,10 +286,10 @@
                 Read(logicScrolView, no);
                 //鍏抽棴鍒锋柊View锛�
                 logicScrolView.EndHeaderRefreshing();
-            };
-
-           //鑷姩鍖�
-           Read(logicScrolView, no);
+            };
+
+            //鑷姩鍖�
+            Read(logicScrolView, no);
 
         }
         /// <summary>
@@ -299,36 +299,43 @@
         private static async void Read(VerticalRefreshLayout logicScrolView, bool no)
         {
             CommonPage.Loading.Start();
-            if (Common.Logic.LogicList.Count == 0)
+            try
             {
-                var Idlist1 = await Send.GetLogicId(0);//
-                var Idlist2 = await Send.GetLogicId(2);//闂ㄩ攣甯稿紑妯″紡
-                if (Idlist1.Count != 0)
+                if (Common.Logic.LogicList.Count == 0)
                 {
-                    var listlogic1 = await Send.ReadList(Idlist1.Count, 0);
-                    for (int j = 0; j < listlogic1.Count; j++)
+                    var Idlist1 = await Send.GetLogicId(0);//
+                    var Idlist2 = await Send.GetLogicId(2);//闂ㄩ攣甯稿紑妯″紡
+                    if (Idlist1.Count != 0)
                     {
-                        var logic = listlogic1[j];
-                        if (logic.LogicType != 0)
+                        var listlogic1 = await Send.ReadList(Idlist1.Count, 0);
+                        for (int j = 0; j < listlogic1.Count; j++)
                         {
-                            continue;
+                            var logic = listlogic1[j];
+                            if (logic.LogicType != 0)
+                            {
+                                continue;
+                            }
+                            Common.Logic.LogicList.Add(logic);
                         }
-                        Common.Logic.LogicList.Add(logic);
+                    }
+                    if (Idlist2.Count != 0)
+                    {
+                        var listlogic2 = await Send.ReadList(Idlist2.Count, 2);
+                        for (int j = 0; j < listlogic2.Count; j++)
+                        {
+                            var logic = listlogic2[j];
+                            if (logic.LogicType != 2)
+                            {
+                                continue;
+                            }
+                            Common.Logic.LogicList.Add(logic);
+                        }
                     }
                 }
-                if (Idlist2.Count != 0)
-                {
-                    var listlogic2 = await Send.ReadList(Idlist2.Count, 2);
-                    for (int j = 0; j < listlogic2.Count; j++)
-                    {
-                        var logic = listlogic2[j];
-                        if (logic.LogicType != 2)
-                        {
-                            continue;
-                        }
-                        Common.Logic.LogicList.Add(logic);
-                    }
-                }
+            }
+            catch (Exception e)
+            {
+                var dd = e.Message;
             }
             //鑷姩鍖�
             Automationview(logicScrolView, no);
@@ -347,7 +354,7 @@
                 refresview.BackgroundColor = 0x00000000;
                 var noFrameLayout = new FrameLayout
                 {
-                    Height = Application.GetRealHeight(434 + 200 + 32 + 294-55),
+                    Height = Application.GetRealHeight(434 + 200 + 32 + 294 - 55),
                     //BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor,
                 };
                 refresview.AddChidren(noFrameLayout);
@@ -355,7 +362,7 @@
 
                 var noIconBtn = new Button
                 {
-                    Y = Application.GetRealHeight(294-55),
+                    Y = Application.GetRealHeight(294 - 55),
                     Width = Application.GetMinRealAverage(756),
                     Height = Application.GetMinRealAverage(434),
                     UnSelectedImagePath = "Item/NoFunction.png",
@@ -394,7 +401,7 @@
             int i = 1;//灞�閮ㄥ彉閲忥紝榛樿鏄涓�鏉¢�昏緫;
             foreach (var logic in Common.Logic.LogicList)
             {
-               
+
                 var fLayout = new FrameLayout
                 {
                     Height = Application.GetRealHeight(190 + 30),
@@ -402,7 +409,7 @@
                     BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor,
                 };
                 refresview.AddChidren(fLayout);
-            
+
                 var logicRowlayout = new RowLayout
                 {
                     Height = Application.GetRealHeight(190 + 30),
@@ -419,8 +426,8 @@
                     fLayout.SetCornerWithSameRadius(Application.GetRealHeight(58), HDLUtils.RectCornerTopLeft);
                     logicRowlayout.SetCornerWithSameRadius(Application.GetRealHeight(58), HDLUtils.RectCornerTopLeft);
                     i = 2;
-                }
-              
+                }
+
                 var logicnameBtn = new Button
                 {
                     Height = Application.GetRealHeight(58),
@@ -461,7 +468,7 @@
                         logic.IsEnable = 0;
                         StatusColor(logic, logicRowlayout, 0);
                     }
-                   Send.LogicControlSwitch(logic);
+                    Send.LogicControlSwitch(logic);
                     //Logic.Send.AddModifyLogic(logic);
                 };
                 if (logic.IsEnable == 1)
@@ -482,8 +489,9 @@
                     TextColor = ZigbeeColor.Current.LogicBtnSaveTextColor,
                 };
                 logicRowlayout.AddRightView(edit);
-                if (logic.LogicType==2) {
-                    edit.TextID=MyInternationalizationString.look;
+                if (logic.LogicType == 2)
+                {
+                    edit.TextID = MyInternationalizationString.look;
                 }
                 edit.MouseUpEventHandler += (sender, e) =>
                 {
@@ -534,7 +542,9 @@
                     Width = Application.GetRealWidth(1080 - 58),
                     BackgroundColor = ZigbeeColor.Current.LogicRowLayoutLineColor,
                 };
-                fLayout.AddChidren(line);
+                fLayout.AddChidren(line);
+
+
             }
 
         }
@@ -572,9 +582,9 @@
                 {
                     indexlist.Add(linkType);
                 }
-            }
-             //鎺掑垪鍥炬爣椤哄簭;
-            if (indexlist.Contains("0")|| indexlist.Contains("8"))
+            }
+            //鎺掑垪鍥炬爣椤哄簭;
+            if (indexlist.Contains("0") || indexlist.Contains("8"))
             {
                 iconIndexlist.Add("0");
             }
@@ -702,10 +712,10 @@
         /// <param name="timeVlaue">鏃堕棿鍊�</param>
         /// <param name="common">璁惧</param>
         /// <returns></returns>
-        public  static void LockAddModifyLogic(int timeVlaue, CommonDevice common)
+        public static async System.Threading.Tasks.Task<bool> LockAddModifyLogic(int timeVlaue, CommonDevice common)
         {
             //璇诲彇绯荤粺褰撳墠鏃堕棿锛氭椂-鍒�
-            var h = DateTime.Now.ToString("hh");
+            var h = DateTime.Now.ToString("HH");
             var m = DateTime.Now.ToString("mm");
             Dictionary<string, string> timeConditionsInfo = new Dictionary<string, string>();
             timeConditionsInfo.Add("Type", "0");
@@ -730,21 +740,29 @@
             currentLogic.LogicName = Language.StringByID(R.MyInternationalizationString.openmode);
             currentLogic.Conditions.Add(timeConditionsInfo);
             currentLogic.Actions.Add(actionsInfo);
-            Exist(3);//鏌ユ壘鏄惁瀛樺湪璁剧疆杩囧け鏁堟椂闂�(鏈夌殑璇濆垹闄わ紝鍐嶆坊鍔�)
-            Send.AddModifyLogic(currentLogic);
+            Exist(3);//鏌ユ壘鏄惁瀛樺湪璁剧疆杩囧け鏁堟椂闂�(鏈夌殑璇濆垹闄わ紝鍐嶆坊鍔�)
+            var logicIfon = await Send.AddModifyLogic(currentLogic);
+            if (logicIfon != null && logicIfon.LogicId != 0)
+            {
+                //娣诲姞闂ㄩ攣澶辨晥鏃堕棿鐨勫巻鍙茶褰�
+                UserCenter.HdlDeviceDoorLockLogic.Current.AddDoorHistoryLog((DoorLock)common, 9003, timeVlaue.ToString());
+                return true;//琛ㄧず娣诲姞鎴愬姛;
+            }
+            return false;//琛ㄧず娣诲姞澶辫触;
 
         }
 
         ///<summary>
         /// s-one闂ㄩ攣鏄惁瀛樺湪鑷姩鍖栫殑鏂规硶(true涓哄瓨鍦�)
         /// </summary>
-        public static async System.Threading.Tasks.Task<bool> Exist(int valueInt=2)
+        public static async System.Threading.Tasks.Task<bool> Exist(int valueInt = 2)
         {
             bool exist = false;
             var Idlist = await Send.GetLogicId(valueInt);
             if (Idlist.Count != 0)
             {
-                if (valueInt==3) {
+                if (valueInt == 3)
+                {
                     for (int i = 0; i < Idlist.Count; i++)
                     {
                         //valueInt=3涓�鏉$壒娈婄殑鑷姩鍖�(鐢ㄦ潵璁剧疆澶辨晥鏃堕棿)
@@ -762,8 +780,8 @@
         public static async void LockCloseLogic(CommonDevice common)
         {
             //璇诲彇绯荤粺褰撳墠鏃堕棿锛氭椂-鍒�
-            int h =int.Parse(DateTime.Now.ToString("hh"));
-            int m= int.Parse(DateTime.Now.ToString("mm"));
+            int h = int.Parse(DateTime.Now.ToString("HH"));
+            int m = int.Parse(DateTime.Now.ToString("mm"));
             //杞寲涓哄灏戝垎閽�;
             int s = h * 60 + m;
             var logicList = new List<Common.Logic>();
@@ -786,14 +804,14 @@
                             int stopHour = int.Parse(conditions["StopHour"]);
                             int s1 = startMin + startHour * 60;//寮�濮嬫椂闂村��
                             int s2 = stopMin + stopHour * 60;//缁撴潫鏃堕棿鍊�
-                            if (s >= s1&&s<=s2)
-                            {
-                                //鏌ユ壘绯荤粺鏃堕棿鍊兼槸鍚﹀睘浜庤繖涓寖鍥达紱
+                            if (s >= s1 && s <= s2)
+                            {
+                                //鏌ユ壘绯荤粺鏃堕棿鍊兼槸鍚﹀睘浜庤繖涓寖鍥达紱
                                 logicList.Add(logic);
                             }
                         }
-                    }
-                  
+                    }
+
                 }
             }
             foreach (var logic in logicList)

--
Gitblit v1.8.0