| | |
| | | |
| | | namespace Shared.Phone.Device.Logic |
| | | { |
| | | public class SkipView |
| | | public class SkipView:FrameLayout |
| | | { |
| | | |
| | | /// <summary> |
| | | /// 其它界面跳进来的入口 |
| | | /// </summary> |
| | | public static void SkipAddLogic(int intvalue, DoorLock doorLock = null, UserCenter.MemberInfoRes accountObj = null) |
| | | public async static void SkipAddLogic(int intvalue, DoorLock doorLock = null, MemberInfoRes accountObj = null) |
| | | { |
| | | /// 0.正常自动化;1.门锁自动化;2.门锁常开.关; |
| | | /// 0.正常自动化;1.门锁自动化;2.Sone门锁; |
| | | switch (intvalue) |
| | | { |
| | | case 0:
|
| | | case 0: |
| | | { |
| | | //new一个新逻辑对象; |
| | | //新增正常自动化入口 |
| | |
| | | UserView.HomePage.Instance.AddChidren(addLogicPage); |
| | | UserView.HomePage.Instance.PageIndex += 1; |
| | | addLogicPage.Show(); |
| | | }
|
| | | } |
| | | break; |
| | | case 1:
|
| | | case 1: |
| | | { |
| | | //进入门锁联动事件入口 |
| | | Send.UserMemberInfoRes = accountObj;
|
| | | Send.CurrentDoorLock = doorLock;
|
| | | if (accountObj == null)
|
| | | {
|
| | | ///防止抛异常
|
| | | Send.UserMemberInfoRes = new UserCenter.MemberInfoRes();
|
| | | }
|
| | | if (doorLock == null)
|
| | | {
|
| | | ///防止抛异常
|
| | | Send.CurrentDoorLock = new DoorLock();
|
| | | }
|
| | | ///进来刷新一次设备列表;
|
| | | Common.Logic.LogicDviceList.Clear();
|
| | | if (Common.Logic.LogicDviceList.Count == 0)
|
| | | {
|
| | | Common.Logic.LogicDviceList.AddRange(LocalDevice.Current.listAllDevice.ToArray());
|
| | | }
|
| | | var doorLockLogicList = new DoorLockLogic.LockLogicList();
|
| | | UserView.HomePage.Instance.AddChidren(doorLockLogicList);
|
| | | UserView.HomePage.Instance.PageIndex += 1;
|
| | | doorLockLogicList.Show(); |
| | | }
|
| | | break; |
| | | case 2:
|
| | | { |
| | | Send.UserMemberInfoRes = accountObj; |
| | | Send.CurrentDoorLock = doorLock; |
| | | if (accountObj == null) |
| | | { |
| | | ///防止抛异常 |
| | | Send.UserMemberInfoRes = new MemberInfoRes(); |
| | | } |
| | | if (doorLock == null) |
| | | { |
| | | ///防止抛异常 |
| | | Send.CurrentDoorLock = new DoorLock(); |
| | | } |
| | | ///进来刷新一次设备列表; |
| | | Common.Logic.LogicDviceList.Clear(); |
| | | if (Common.Logic.LogicDviceList.Count == 0) |
| | | { |
| | | Common.Logic.LogicDviceList.AddRange(LocalDevice.Current.listAllDevice.ToArray()); |
| | | Common.Logic.LogicDviceList.AddRange(HdlDeviceCommonLogic.Current.listAllDevice.ToArray()); |
| | | } |
| | | //读取系统当前时间:时-分 |
| | | //读取系统当前时间:时-分 |
| | | 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", "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(timeConditionsInfo);//添加条件 |
| | | Common.Logic.CurrentLogic.Actions.Add(actionsInfo);//添加目标 |
| | | var oneLogic = new OneLogic(); |
| | | UserView.HomePage.Instance.AddChidren(oneLogic); |
| | | var doorLockLogicList = new DoorLockLogic.LockLogicList(); |
| | | UserView.HomePage.Instance.AddChidren(doorLockLogicList); |
| | | UserView.HomePage.Instance.PageIndex += 1; |
| | | oneLogic.Show(false); |
| | | }
|
| | | doorLockLogicList.Show(); |
| | | } |
| | | break; |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | #region ◆ 自动化__________________________ |
| | | |
| | | public static bool If_once = true;//进来只读一次标识; |
| | | /// <summary> |
| | | /// 自动化功能代码入口 |
| | | /// </summary> |
| | | public static void ShowAutotionView(FrameLayout functionSceneAutoBodyView) |
| | | { |
| | | // functionSceneAutoBodyView.BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor; |
| | | //functionSceneAutoBodyView.BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor; |
| | | #region ---推荐模板的组件 |
| | | //推荐模板背景控件 |
| | | |
| | | |
| | | var bjFrameLayout1 = new FrameLayout |
| | | { |
| | | Width = Application.GetRealWidth(1080 - 58), |
| | | Height = Application.GetRealHeight(50), |
| | | BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor, |
| | | X = Application.GetRealWidth(58), |
| | | //Radius = (uint)Application.GetRealHeight(50), |
| | | Y = Application.GetRealHeight(30), |
| | | |
| | | }; |
| | | functionSceneAutoBodyView.AddChidren(bjFrameLayout1); |
| | | var bjFrameLayout = new FrameLayout |
| | | { |
| | | Width = Application.GetRealWidth(1080 - 58), |
| | |
| | | X = Application.GetRealWidth(58), |
| | | //Radius = (uint)Application.GetRealHeight(50), |
| | | Y = Application.GetRealHeight(30), |
| | | |
| | | }; |
| | | functionSceneAutoBodyView.AddChidren(bjFrameLayout); |
| | | bjFrameLayout.SetCornerWithSameRadius(Application.GetRealHeight(58), HDLUtils.RectCornerBottomLeft); |
| | | bjFrameLayout1.SetCornerWithSameRadius(Application.GetRealHeight(17), HDLUtils.RectCornerTopLeft); |
| | | bjFrameLayout.SetCornerWithSameRadius(Application.GetRealHeight(58), HDLUtils.RectCornerTopLeft|HDLUtils.RectCornerBottomLeft); |
| | | //图标控件 |
| | | var sigBtn = new Button |
| | | { |
| | |
| | | X = Application.GetRealWidth(58), |
| | | Y = scenehorizontalScrol.Bottom, |
| | | }; |
| | | functionSceneAutoBodyView.AddChidren(logicScrolView);
|
| | |
|
| | | functionSceneAutoBodyView.AddChidren(logicScrolView); |
| | | |
| | | logicScrolView.SetCornerWithSameRadius(Application.GetRealHeight(58), HDLUtils.RectCornerTopLeft); |
| | | bool no = false; |
| | | //显示默认模板的界面事件 |
| | |
| | | //下拉刷新自动化列表的事件 |
| | | logicScrolView.BeginHeaderRefreshingAction += () => |
| | | { |
| | | //重新刷新logic列表 |
| | | Common.Logic.LogicList.Clear(); |
| | | Read(logicScrolView, no); |
| | | if (!Config.Instance.Home.IsVirtually) |
| | | {//虚拟的不获取网关逻辑列表 |
| | | //重新刷新logic列表 |
| | | If_once = true; |
| | | Common.Logic.LogicList.Clear(); |
| | | Read(logicScrolView, no); |
| | | } |
| | | //关闭刷新View; |
| | | logicScrolView.EndHeaderRefreshing(); |
| | | };
|
| | |
|
| | | //自动化
|
| | | }; |
| | | |
| | | //自动化 |
| | | Read(logicScrolView, no); |
| | | |
| | | } |
| | |
| | | /// <param name="logicScrolView"></param> |
| | | private static async void Read(VerticalRefreshLayout logicScrolView, bool no) |
| | | { |
| | | //if (Config.Instance.HomeId != UserCenter.UserCenterResourse.AccountOption.OldHomeStringId) |
| | | //{ |
| | | // //切换住宅清除之前缓存数据; |
| | | // Common.Logic.LogicList.Clear(); |
| | | // Common.Logic.LockLogicList.Clear(); |
| | | // Common.Logic.SoneLogicList.Clear(); |
| | | //} |
| | | |
| | | CommonPage.Loading.Start(); |
| | | try |
| | | { |
| | | if (Common.Logic.LogicList.Count == 0) |
| | | if (!Config.Instance.Home.IsVirtually)//虚拟的不获取网关逻辑列表 |
| | | { |
| | | var Idlist1 = await Send.GetLogicId(0);// |
| | | var Idlist2 = await Send.GetLogicId(2);//门锁常开模式 |
| | | if (Idlist1.Count != 0) |
| | | if (If_once) |
| | | { |
| | | var listlogic1 = await Send.ReadList(Idlist1.Count, 0); |
| | | for (int j = 0; j < listlogic1.Count; j++) |
| | | if (Common.Logic.LogicList.Count == 0) |
| | | { |
| | | var logic = listlogic1[j]; |
| | | if (logic.LogicType != 0) |
| | | If_once = false; |
| | | var Idlist1 = await Send.GetLogicId(0);// |
| | | var Idlist2 = await Send.GetLogicId(2);//门锁常开模式 |
| | | if (Idlist1.Count != 0) |
| | | { |
| | | continue; |
| | | var listlogic1 = await Send.ReadList(Idlist1.Count, 0); |
| | | for (int j = 0; j < listlogic1.Count; j++) |
| | | { |
| | | 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) |
| | | if (Idlist2.Count != 0) |
| | | { |
| | | continue; |
| | | 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); |
| | | } |
| | | } |
| | | Common.Logic.LogicList.Add(logic); |
| | | |
| | | } |
| | | } |
| | | } |
| | |
| | | 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(); |
| | | if (Common.Logic.LogicList.Count == 0 && no == false) |
| | | { |
| | |
| | | fLayout.SetCornerWithSameRadius(Application.GetRealHeight(58), HDLUtils.RectCornerTopLeft); |
| | | logicRowlayout.SetCornerWithSameRadius(Application.GetRealHeight(58), HDLUtils.RectCornerTopLeft); |
| | | |
| | | }
|
| | | i++;
|
| | | } |
| | | i++; |
| | | var logicnameBtn = new Button |
| | | { |
| | | Height = Application.GetRealHeight(58), |
| | |
| | | logic.IsEnable = 0; |
| | | StatusColor(logic, logicRowlayout, 0); |
| | | } |
| | | Send.LogicControlSwitch(logic); |
| | | if (!Config.Instance.Home.IsVirtually) |
| | | { |
| | | Send.LogicControlSwitch(logic); |
| | | } |
| | | //Logic.Send.AddModifyLogic(logic); |
| | | }; |
| | | if (logic.IsEnable == 1) |
| | |
| | | logicRowlayout.AddRightView(del); |
| | | del.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | var alert = new UserCenter.ShowMsgControl(UserCenter.ShowMsgType.Confirm, |
| | | var alert = new ShowMsgControl(ShowMsgType.Confirm, |
| | | Language.StringByID(MyInternationalizationString.doyouwanttodelete), |
| | | Language.StringByID(MyInternationalizationString.confrim));
|
| | | alert.Show();
|
| | | alert.ConfirmClickEvent += () =>
|
| | | Language.StringByID(MyInternationalizationString.confrim)); |
| | | alert.Show(); |
| | | alert.ConfirmClickEvent += () => |
| | | { |
| | | Common.Logic.LogicList.Remove(logic); |
| | | Automationview(refresview, no); |
| | | Send.DelLogic(logic.LogicId);
|
| | | if (!Config.Instance.Home.IsVirtually) |
| | | { |
| | | Send.DelLogic(logic.LogicId); |
| | | } |
| | | }; |
| | | |
| | | }; |
| | |
| | | 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")) |
| | | { |
| | | iconIndexlist.Add("0"); |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | /// <summary> |
| | | /// 门锁取消设置用的方法(相当一个关闭常开模式按钮,分类-自动化-不需要显示该自动化) |
| | | /// 门锁失效设置用的方法(相当一个关闭常开模式按钮,分类-自动化-不需要显示该自动化) |
| | | /// </summary> |
| | | /// <param name="timeVlaue">时间值</param> |
| | | /// <param name="common">设备</param> |
| | | /// <returns></returns> |
| | | public static async System.Threading.Tasks.Task<bool> LockAddModifyLogic(int timeVlaue, CommonDevice common) |
| | | public static async System.Threading.Tasks.Task<int> LockAddModifyLogic(int timeVlaue, CommonDevice common) |
| | | { |
| | | //读取系统当前时间:时-分 |
| | | var h = DateTime.Now.ToString("HH"); |
| | |
| | | timeConditionsInfo.Add("DelayTime", "0"); |
| | | timeConditionsInfo.Add("StartHour", h); |
| | | timeConditionsInfo.Add("StartMin", m); |
| | | timeConditionsInfo.Add("DoorLockOpenDelayTime", timeVlaue.ToString()); |
| | | if (HdlUserCenterResourse.HideOption.DoorLockNomallyOpenTimeMode == 1) |
| | | { |
| | | //强制变更时间模式为分钟 |
| | | timeConditionsInfo.Add("DoorLockOpenDelayTime", (timeVlaue * 60).ToString()); |
| | | } |
| | | else |
| | | { |
| | | timeConditionsInfo.Add("DoorLockOpenDelayTime", (timeVlaue * 3600).ToString()); |
| | | } |
| | | Dictionary<string, object> actionsInfo = new Dictionary<string, object>(); |
| | | actionsInfo.Add("LinkType", 8); |
| | | actionsInfo.Add("DeviceAddr", common.DeviceAddr); |
| | | actionsInfo.Add("Epoint", common.DeviceEpoint); |
| | | actionsInfo.Add("Epoint", "200"); |
| | | actionsInfo.Add("PassData", "055704010113");//默认门锁常关 |
| | | |
| | | Dictionary<string, string> accounts = new Dictionary<string, string>(); |
| | | accounts.Add("Type", "8"); |
| | | accounts.Add("Option4", common.DeviceAddr.ToString());//用于判断识别是哪个门锁; |
| | | accounts.Add("Option2", common.DeviceEpoint.ToString()); |
| | | |
| | | Common.Logic currentLogic = new Common.Logic(); |
| | | currentLogic.IsEnable = 1;//默认为开 |
| | |
| | | currentLogic.LogicName = Language.StringByID(R.MyInternationalizationString.openmode); |
| | | currentLogic.Conditions.Add(timeConditionsInfo); |
| | | currentLogic.Actions.Add(actionsInfo); |
| | | Exist(3);//查找是否存在设置过失效时间(有的话删除,再添加)
|
| | | currentLogic.Accounts.Add(accounts); |
| | | var logicIfon = await Send.AddModifyLogic(currentLogic); |
| | | if (logicIfon != null && logicIfon.LogicId != 0)
|
| | | {
|
| | | //添加门锁失效时间的历史记录
|
| | | UserCenter.HdlDeviceDoorLockLogic.Current.AddDoorHistoryLog((DoorLock)common, 9003, timeVlaue.ToString());
|
| | | return true;//表示添加成功; |
| | | if (logicIfon != null && logicIfon.LogicId != 0) |
| | | { |
| | | //添加门锁失效时间的历史记录 |
| | | HdlDeviceDoorLockLogic.Current.AddDoorHistoryLog((DoorLock)common, 9003, timeVlaue.ToString()); |
| | | return logicIfon.LogicId;//表示添加成功; |
| | | } |
| | | return false;//表示添加失败; |
| | | return 0;//表示添加失败; |
| | | |
| | | }
|
| | |
|
| | | ///<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)
|
| | | {
|
| | | int exist = 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;
|
| | | } |
| | | |
| | | } |
| | | } |
| | | exist = 1;
|
| | | ///<summary> |
| | | /// s-one门锁是否存在自动化的方法; |
| | | /// 注意(参数:2-常开自动化;3-失效时间自动化); |
| | | /// 返回值:0不存在;其它值都存在; |
| | | /// </summary> |
| | | public static async System.Threading.Tasks.Task<int> Exist(int valueInt, ZigBee.Device.DoorLock doorLock) |
| | | { |
| | | |
| | | int exist = 0; |
| | | var IdList = await Send.GetLogicId(valueInt); |
| | | if (IdList.Count != 0) |
| | | { |
| | | for (int i = 0; i < IdList.Count; i++) |
| | | { |
| | | var id = IdList[i]; |
| | | var logic = await Send.GetLogic(id, valueInt); |
| | | if (logic != null) |
| | | { |
| | | if (ExistLogic(logic, doorLock)) |
| | | { |
| | | exist = id; |
| | | ///找到退出 |
| | | break; |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | return exist; |
| | | } |
| | | |
| | | |
| | | ///<summary> |
| | | ///获取门锁时效性逻辑信息 |
| | | /// 返回值:null不存在;其它值都存在; |
| | | /// </summary> |
| | | public static async System.Threading.Tasks.Task<Common.Logic> GetLogicIfon(ZigBee.Device.DoorLock doorLock) |
| | | { |
| | | 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); |
| | | if (!ExistLogic(logic, doorLock)) |
| | | { |
| | | logic = null; |
| | | } |
| | | } |
| | | return logic; |
| | | } |
| | | |
| | | ///<summary> |
| | | ///删除该门锁所有时效性自动化 |
| | | /// 返回值:true成功;false失败; |
| | | /// </summary> |
| | | public static async System.Threading.Tasks.Task<bool> DelAllLogic(ZigBee.Device.DoorLock doorLock) |
| | | { |
| | | bool _if = false; |
| | | var Idlist = await Send.GetLogicId(3); |
| | | if (Idlist.Count != 0) |
| | | { |
| | | for (int i = 0; i < Idlist.Count; i++) |
| | | { |
| | | int id = Idlist[i]; |
| | | var logic = await Send.GetLogic(id, 3); |
| | | if (logic != null) |
| | | { |
| | | if (ExistLogic(logic, doorLock)) |
| | | { |
| | | //本来只有一条时效性自动化, |
| | | //防止特殊情况,找到就删除掉; |
| | | //var valueInt = await Send.DelLogic(id); |
| | | //if (valueInt == 0) |
| | | //{ |
| | | // _if = true; |
| | | //} |
| | | //(考虑性能默认删除成功,直接返回成功结果true) |
| | | _if = true; |
| | | Send.DelLogic(id); |
| | | |
| | | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return _if; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 查找这一条自动化是否属于该门锁 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public static bool ExistLogic(Common.Logic logic, ZigBee.Device.DoorLock doorLock) |
| | | { |
| | | for (int j = 0; j < logic.Accounts.Count; j++) |
| | | { |
| | | //Option4是设备mac; |
| | | if (logic.Accounts[j]["Option4"].ToString() == doorLock.DeviceAddr) |
| | | { |
| | | //查找是否是那个门锁; |
| | | //如果不是该门锁联动事件不显示出来; |
| | | return true; |
| | | } |
| | | |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | | } |
| | | |