黄学彪
2020-04-13 3793a9a38ac6c4c4111c2bba3a35a71c30601e82
ZigbeeApp/Shared/Phone/Device/Logic/SkipView.cs
@@ -18,7 +18,8 @@
            /// 0.正常自动化;1.门锁自动化;2.门锁常开.关;
            switch (intvalue)
            {
                case 0: {
                case 0:
                    {
                        //new一个新逻辑对象;
                        //新增正常自动化入口
                        Common.Logic.CurrentLogic = new Common.Logic();
@@ -29,8 +30,10 @@
                        UserView.HomePage.Instance.AddChidren(addLogicPage);
                        UserView.HomePage.Instance.PageIndex += 1;
                        addLogicPage.Show();
                    } break;
                case 1: {
                    }
                    break;
                case 1:
                    {
                        //进入门锁联动事件入口
                        Send.UserMemberInfoRes = accountObj;
                        Send.CurrentDoorLock = doorLock;
@@ -54,38 +57,34 @@
                        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一个新逻辑对象;
                        //新增门锁常开模式自动化入口;
@@ -93,13 +92,14 @@
                        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;
            }
        }
@@ -299,6 +299,8 @@
        private static async void Read(VerticalRefreshLayout logicScrolView, bool no)
        {
            CommonPage.Loading.Start();
            try
            {
            if (Common.Logic.LogicList.Count == 0)
            {
                var Idlist1 = await Send.GetLogicId(0);//
@@ -329,6 +331,11 @@
                        Common.Logic.LogicList.Add(logic);
                    }
                }
                }
            }
            catch (Exception e)
            {
                var dd = e.Message;
            }
            //自动化
            Automationview(logicScrolView, no);
@@ -482,7 +489,8 @@
                    TextColor = ZigbeeColor.Current.LogicBtnSaveTextColor,
                };
                logicRowlayout.AddRightView(edit);
                if (logic.LogicType==2) {
                if (logic.LogicType == 2)
                {
                    edit.TextID=MyInternationalizationString.look;
                }
                edit.MouseUpEventHandler += (sender, e) =>
@@ -535,6 +543,8 @@
                    BackgroundColor = ZigbeeColor.Current.LogicRowLayoutLineColor,
                };
                fLayout.AddChidren(line);
            }
        }
@@ -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");
@@ -731,7 +741,14 @@
            currentLogic.Conditions.Add(timeConditionsInfo);
            currentLogic.Actions.Add(actionsInfo);
            Exist(3);//查找是否存在设置过失效时间(有的话删除,再添加)
            Send.AddModifyLogic(currentLogic);
            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;//表示添加失败;
        }
@@ -744,7 +761,8 @@
            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,7 +780,7 @@
        public static async void LockCloseLogic(CommonDevice common)
        {
            //读取系统当前时间:时-分
            int h =int.Parse(DateTime.Now.ToString("hh"));
            int h = int.Parse(DateTime.Now.ToString("HH"));
            int m= int.Parse(DateTime.Now.ToString("mm"));
            //转化为多少分钟;
            int s = h * 60 + m;