| | |
| | | /// <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.正常自动化;1.门锁自动化;2.门锁常开.关; |
| | | switch (intvalue) |
| | | { |
| | | case 0: { |
| | | case 0:
|
| | | { |
| | | //new一个新逻辑对象; |
| | | //新增正常自动化入口 |
| | | Common.Logic.CurrentLogic = new Common.Logic(); |
| | |
| | | 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)
|
| | | {
|
| | |
| | | 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一个新逻辑对象; |
| | | //新增门锁常开模式自动化入口; |
| | | 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; |
| | | } |
| | | |
| | | } |
| | |
| | | X = Application.GetRealWidth(58), |
| | | Y = scenehorizontalScrol.Bottom, |
| | | }; |
| | | functionSceneAutoBodyView.AddChidren(logicScrolView); |
| | | |
| | | functionSceneAutoBodyView.AddChidren(logicScrolView);
|
| | |
|
| | | logicScrolView.SetCornerWithSameRadius(Application.GetRealHeight(58), HDLUtils.RectCornerTopLeft); |
| | | bool no = false; |
| | | //显示默认模板的界面事件 |
| | |
| | | Read(logicScrolView, no); |
| | | //关闭刷新View; |
| | | logicScrolView.EndHeaderRefreshing(); |
| | | }; |
| | | |
| | | //自动化 |
| | | Read(logicScrolView, no); |
| | | };
|
| | |
|
| | | //自动化
|
| | | Read(logicScrolView, no); |
| | | |
| | | } |
| | | /// <summary> |
| | |
| | | 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); |
| | |
| | | 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); |
| | |
| | | |
| | | 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", |
| | |
| | | int i = 1;//局部变量,默认是第一条逻辑; |
| | | foreach (var logic in Common.Logic.LogicList) |
| | | { |
| | | |
| | | |
| | | var fLayout = new FrameLayout |
| | | { |
| | | Height = Application.GetRealHeight(190 + 30), |
| | |
| | | BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor, |
| | | }; |
| | | refresview.AddChidren(fLayout); |
| | | |
| | | |
| | | var logicRowlayout = new RowLayout |
| | | { |
| | | Height = Application.GetRealHeight(190 + 30), |
| | |
| | | fLayout.SetCornerWithSameRadius(Application.GetRealHeight(58), HDLUtils.RectCornerTopLeft); |
| | | logicRowlayout.SetCornerWithSameRadius(Application.GetRealHeight(58), HDLUtils.RectCornerTopLeft); |
| | | i = 2; |
| | | } |
| | | |
| | | }
|
| | |
|
| | | var logicnameBtn = new Button |
| | | { |
| | | Height = Application.GetRealHeight(58), |
| | |
| | | logic.IsEnable = 0; |
| | | StatusColor(logic, logicRowlayout, 0); |
| | | } |
| | | Send.LogicControlSwitch(logic); |
| | | Send.LogicControlSwitch(logic); |
| | | //Logic.Send.AddModifyLogic(logic); |
| | | }; |
| | | if (logic.IsEnable == 1) |
| | |
| | | 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) => |
| | | { |
| | |
| | | Width = Application.GetRealWidth(1080 - 58), |
| | | BackgroundColor = ZigbeeColor.Current.LogicRowLayoutLineColor, |
| | | }; |
| | | fLayout.AddChidren(line); |
| | | fLayout.AddChidren(line);
|
| | |
|
| | |
|
| | | } |
| | | |
| | | } |
| | |
| | | { |
| | | indexlist.Add(linkType); |
| | | } |
| | | } |
| | | //排列图标顺序; |
| | | if (indexlist.Contains("0")|| indexlist.Contains("8")) |
| | | }
|
| | | //排列图标顺序;
|
| | | if (indexlist.Contains("0") || indexlist.Contains("8")) |
| | | { |
| | | iconIndexlist.Add("0"); |
| | | } |
| | |
| | | /// <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"); |
| | |
| | | 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一条特殊的自动化(用来设置失效时间) |
| | |
| | | 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>(); |
| | |
| | | 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) |