陈嘉乐
2020-04-27 18b93d511dc764b469d7c4a7e755f7274f89cdb4
ZigbeeApp/Shared/Phone/Device/Logic/SkipView.cs
@@ -18,21 +18,31 @@
            /// 0.正常自动化;1.门锁自动化;2.门锁常开.关;
            switch (intvalue)
            {
                case 0:
                case 0:
                    {
                        //new一个新逻辑对象;
                        //新增正常自动化入口
                        Common.Logic.CurrentLogic = new Common.Logic();
                        Common.Logic.CurrentLogic.IsEnable = 1;//默认为开
                        Common.Logic.CurrentLogic.LogicType = 0;//标记逻辑类型
                        Common.Logic.CurrentLogic.LogicName = Language.StringByID(MyInternationalizationString.automation1);
                        var addLogicPage = new AddLogicPage();
                        //Common.Logic.CurrentLogic = new Common.Logic();
                        //Common.Logic.CurrentLogic.IsEnable = 1;//默认为开
                        //Common.Logic.CurrentLogic.LogicType = 0;//标记逻辑类型
                        //Common.Logic.CurrentLogic.LogicName = Language.StringByID(MyInternationalizationString.automation1);
                        //var addLogicPage = new AddLogicPage();
                        //UserView.HomePage.Instance.AddChidren(addLogicPage);
                        //UserView.HomePage.Instance.PageIndex += 1;
                        //addLogicPage.Show();
                        var addLogicPage = new SoneLogicList();
                        UserView.HomePage.Instance.AddChidren(addLogicPage);
                        UserView.HomePage.Instance.PageIndex += 1;
                        addLogicPage.Show();
                    }
                    }
                    break;
                case 1:
                case 1:
                    {
                        //进入门锁联动事件入口
                        Send.UserMemberInfoRes = accountObj;
@@ -40,7 +50,7 @@
                        if (accountObj == null)
                        {
                            ///防止抛异常
                            Send.UserMemberInfoRes = new UserCenter.MemberInfoRes();
                            Send.UserMemberInfoRes = new UserCenter.MemberInfoRes();
                        }
                        if (doorLock == null)
                        {
@@ -57,10 +67,17 @@
                        UserView.HomePage.Instance.AddChidren(doorLockLogicList);
                        UserView.HomePage.Instance.PageIndex += 1;
                        doorLockLogicList.Show();
                    }
                    }
                    break;
                case 2:
                    {
                case 2:
                    {
                        if (doorLock == null)
                        {
                            ///防止抛异常
                            doorLock = new DoorLock();
                        }
                        Send.CurrentDoorLock = doorLock;
                        Common.Logic.LogicDviceList.Clear();
                        if (Common.Logic.LogicDviceList.Count == 0)
                        {
@@ -83,7 +100,7 @@
                        Dictionary<string, object> actionsInfo = new Dictionary<string, object>();
                        actionsInfo.Add("LinkType", 8);
                        actionsInfo.Add("DeviceAddr", doorLock.DeviceAddr);
                        actionsInfo.Add("Epoint", doorLock.DeviceEpoint);
                        actionsInfo.Add("Epoint", "200");
                        actionsInfo.Add("PassData", "055704010113");//默认门锁常关
                        //new一个新逻辑对象;
@@ -98,7 +115,7 @@
                        UserView.HomePage.Instance.AddChidren(oneLogic);
                        UserView.HomePage.Instance.PageIndex += 1;
                        oneLogic.Show(false);
                    }
                    }
                    break;
            }
@@ -180,8 +197,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,9 +303,9 @@
                Read(logicScrolView, no);
                //关闭刷新View;
                logicScrolView.EndHeaderRefreshing();
            };
            //自动化
            };
            //自动化
            Read(logicScrolView, no);
        }
@@ -341,13 +358,11 @@
            Automationview(logicScrolView, no);
            CommonPage.Loading.Hide();
        }
        static RowLayout selectedRow = new RowLayout() { Tag = "0" };//记录左滑状态
        /// <summary>
        /// 加载自动化列表界面
        /// </summary>
        /// <param name="refresview">Refresview.</param>
        static  RowLayout selectedRow = new RowLayout() { Tag="0"};//记录左滑状态
        private static async void Automationview(VerticalRefreshLayout refresview, bool no)
        {
            refresview.RemoveAll();
@@ -439,8 +454,8 @@
                    fLayout.SetCornerWithSameRadius(Application.GetRealHeight(58), HDLUtils.RectCornerTopLeft);
                    logicRowlayout.SetCornerWithSameRadius(Application.GetRealHeight(58), HDLUtils.RectCornerTopLeft);
                   
                }
                i++;
                }
                i++;
                var logicnameBtn = new Button
                {
                    Height = Application.GetRealHeight(58),
@@ -555,9 +570,9 @@
                    Width = Application.GetRealWidth(1080 - 58),
                    BackgroundColor = ZigbeeColor.Current.LogicRowLayoutLineColor,
                };
                fLayout.AddChidren(line);
                fLayout.AddChidren(line);
            }
        }
@@ -595,8 +610,8 @@
                {
                    indexlist.Add(linkType);
                }
            }
            //排列图标顺序;
            }
            //排列图标顺序;
            if (indexlist.Contains("0") || indexlist.Contains("8"))
            {
                iconIndexlist.Add("0");
@@ -744,7 +759,7 @@
            actionsInfo.Add("LinkType", 8);
            actionsInfo.Add("DeviceAddr", common.DeviceAddr);
            actionsInfo.Add("Epoint", common.DeviceEpoint);
            actionsInfo.Add("PassData", "055704010113");//默认门锁常关
            actionsInfo.Add("PassData", "055704010113");//默认门锁常关e
            Common.Logic currentLogic = new Common.Logic();
            currentLogic.IsEnable = 1;//默认为开
@@ -753,52 +768,51 @@
            currentLogic.LogicName = Language.StringByID(R.MyInternationalizationString.openmode);
            currentLogic.Conditions.Add(timeConditionsInfo);
            currentLogic.Actions.Add(actionsInfo);
            Exist(3);//查找是否存在设置过失效时间(有的话删除,再添加)
            var logicIfon = await Send.AddModifyLogic(currentLogic);
            if (logicIfon != null && logicIfon.LogicId != 0)
            {
                return true;
            if (logicIfon != null && logicIfon.LogicId != 0)
            {
                //添加门锁失效时间的历史记录
                UserCenter.HdlDeviceDoorLockLogic.Current.AddDoorHistoryLog((DoorLock)common, 9003, timeVlaue.ToString());
                return true;//表示添加成功;
            }
            return false;
            return false;//表示添加失败;
        }
      ///<summary>
      /// s-one门锁是否存在自动化的方法;
      /// 注意(参数2;3):valueInt=3是删除设置失效时间自动化;valueInt=2判断是否存在自动化;
      /// 返回值:0不存在;1存在;2删除成功;3删除失败;
      /// </summary>
      public static async System.Threading.Tasks.Task<int> Exist(int valueInt = 2)
        {
        ///<summary>
        /// s-one门锁是否存在自动化的方法;
        /// 注意(参数:2-自动化;3-失效时间自动化);
        /// 返回值:0不存在;其它值都存在;
        /// </summary>
        public static async System.Threading.Tasks.Task<int> Exist(int valueInt=2)
        {
            int exist = 0;
            var Idlist = await Send.GetLogicId(valueInt);
            if (Idlist.Count != 0)
            var Idlist = await Send.GetLogicId(valueInt);
            if (Idlist.Count != 0)
            {
                if (valueInt == 3)
                {
                    for (int i = 0; i < Idlist.Count; i++)
                    {
                        //valueInt=3一条特殊的自动化(用来设置失效时间)
                        var d=await Send.DelLogic(Idlist[i]);
                  if (d != 0)
                  {
                     //删除成功
                     exist = 2;
                  }
                  else
                  {
                     //删除失败
                     exist = 3;
                  }
                  return exist;
                //默认取第一个逻辑ID
                exist = Idlist[0];
               }
            }
                exist = 1;
            }
            return exist;
        }
        ///<summary>
        ///获取逻辑信息
        /// 返回值:null不存在;其它值都存在;
        /// </summary>
        public static async System.Threading.Tasks.Task<Common.Logic> GetLogicIfon()
        {
            Common.Logic logic = null;
            var Idlist = await Send.GetLogicId(3);
            if (Idlist.Count != 0)
            {
                //默认取第一个逻辑ID(时效性只有一条逻辑)
                int exist = Idlist[0];
                logic = await Send.GetLogic(exist, 3);
            }
            return logic;
        }
    }
}