| | |
| | | { |
| | | public class Send |
| | | { |
| | | #region ----获取Logic |
| | | #region ----Logic所有发送命令 |
| | | /// <summary> |
| | | /// 获取LogicId的方法 |
| | | /// </summary> |
| | |
| | | ["Type"] = int.Parse(dictionary["Type"]), |
| | | ["IsValid"] = int.Parse(dictionary["IsValid"]), |
| | | ["AtHome"] = int.Parse(dictionary["AtHome"]), |
| | | ["WhoSiteUId"] =dictionary["WhoSiteUId"], |
| | | ["WhoSiteUId"] = dictionary["WhoSiteUId"], |
| | | }; |
| | | conditions.Add(diliInfo); |
| | | break; |
| | |
| | | { |
| | | ["Type"] = int.Parse(dictionary["Type"]), |
| | | ["Account"] = dictionary["Account"], |
| | | ["AccountName"] = dictionary["AccountName"], |
| | | ["UserId"] = dictionary["UserId"], |
| | | |
| | | }; |
| | |
| | | logic.LogicName = Logicifon["LogicName"].ToString(); |
| | | logic.LogicType = int.Parse(Logicifon["LogicType"].ToString()); |
| | | logic.Relationship = int.Parse(Logicifon["Relationship"].ToString()); |
| | | logic.LogicCustomPushText =Logicifon["LogicCustomPushText"].ToString(); |
| | | logic.LogicCustomPushText = Logicifon["LogicCustomPushText"].ToString(); |
| | | logic.LogicIsCustomPushText = int.Parse(Logicifon["LogicIsCustomPushText"].ToString()); |
| | | logic.TimeAttribute = Newtonsoft.Json.JsonConvert.DeserializeObject<Common.TimeAttributeObj>(Logicifon["TimeAttribute"].ToString()); |
| | | logic.Conditions = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Dictionary<string, string>>>(Logicifon["Conditions"].ToString()); |
| | |
| | | return listLogic; |
| | | }); |
| | | } |
| | | // <summary> |
| | | /// 通过设备找到区域(房间)名称 |
| | | /// </summary> |
| | | /// <param name="btnregionname">Btnregionname.</param> |
| | | /// <param name="device">Device.</param> |
| | | public static void RoomNmae(Button btnregionname, CommonDevice device) |
| | | { |
| | | var room = new Common.Room(); |
| | | btnregionname.Text = UserCenter.HdlRoomLogic.Current.GetRoomNameByDevice(device); |
| | | } |
| | | /// <summary> |
| | | /// 找出楼层所有房间 |
| | | /// </summary> |
| | | /// <param name="floorId">楼层ID</param> |
| | | /// <returns></returns> |
| | | public static List<Common.Room> GetRoomList(string floorId) |
| | | { |
| | | return UserCenter.HdlRoomLogic.Current.GetAllListRooms().FindAll((obj) => obj.FloorId == floorId); |
| | | //var list1 = new List<Common.Room>(); |
| | | /////找到某楼层房间列表; |
| | | //var list = Common.Room.Lists.FindAll((obj) => obj.FloorId == floorId); |
| | | //for (int i = 0; i < list.Count; i++) |
| | | //{ |
| | | // if (str == "device") |
| | | // { |
| | | // if (list[i].DeviceUIList.Count != 0) |
| | | // { ///过滤掉没有设备的房间 |
| | | // list1.Add(list[i]); |
| | | // } |
| | | // } |
| | | // else |
| | | // { |
| | | // if (list[i].SceneUIList.Count != 0) |
| | | // { ///过滤掉没有场景的房间 |
| | | // list1.Add(list[i]); |
| | | // } |
| | | // } |
| | | //} |
| | | /////返回房间列表; |
| | | //return list1; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取场景信息的方法 |
| | | /// </summary> |
| | |
| | | sceneui = new SceneUI(); |
| | | sceneui.Name = jObjectdata["Data"]["ScenesName"].ToString(); |
| | | sceneui.Id = int.Parse(jObjectdata["Data"]["ScenesId"].ToString()); |
| | | |
| | | |
| | | } |
| | | }; |
| | | var mainGateWay = ZbGateway.MainGateWay; |
| | |
| | | while ((DateTime.Now - dateTime).TotalMilliseconds < 3 * 1000) |
| | | { |
| | | await System.Threading.Tasks.Task.Delay(100); |
| | | if (sceneui!=null) |
| | | if (sceneui != null) |
| | | { |
| | | break; |
| | | } |
| | |
| | | #endregion |
| | | |
| | | #region ----获取门锁 |
| | |
|
| | | |
| | | /// <summary> |
| | | /// 获取自己+其他成员信息 |
| | | /// </summary> |
| | |
| | | if (UserCenter.UserCenterResourse.UserInfo.AuthorityNo != 3) |
| | | { |
| | | var pra = new UserCenter.MemberListInfoPra(); |
| | | string result = await UserCenter.UserCenterLogic.GetResponseDataByRequestHttps("ZigbeeUsers/GetSubAccountByDistributedMark", false, pra); |
| | | string result = ""; |
| | | if (AllUserIfon.Count != 0) |
| | | { |
| | | //服务返回来没有门锁成员信息,没有必要再去请求成员列表, |
| | | //原因:节约时间,体验效果好; |
| | | result = await UserCenter.UserCenterLogic.GetResponseDataByRequestHttps("ZigbeeUsers/GetSubAccountByDistributedMark", false, pra); |
| | | } |
| | | var listInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<List<UserCenter.MemberInfoRes>>(result); |
| | | for (int i = 0; i < listInfo.Count; i++) |
| | | { |
| | |
| | | { |
| | | string s = null; |
| | | var str = await WebClientAsync(0, CommonPage.RequestHttpsHost + "/App/GetHomePager");//不同区域域名前缀不一样 |
| | | // var str = await WebClientAsync(0, "https://global.hdlcontrol.com/HangZhouHdlCloudApi/App/GetHomePager"); |
| | | // var str = await WebClientAsync(0, "https://global.hdlcontrol.com/HangZhouHdlCloudApi/App/GetHomePager"); |
| | | var jObject = JObject.Parse(str); |
| | | if (jObject == null || jObject["StateCode"].ToString() != "Success") |
| | | { |
| | |
| | | lockifon.doorlockmac = residential.doorlockmac; |
| | | return await WebClientAsync(2, lockifon.Url, lockifon); |
| | | } |
| | | #region 定义解析门锁的对象 |
| | | |
| | | public class Residential |
| | | { |
| | | /// <summary> |
| | |
| | | public bool IsFreezeUser; |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 门锁列表 |
| | | /// </summary> |
| | |
| | | /// </summary> |
| | | public static UserCenter.MemberInfoRes UserMemberInfoRes = null; |
| | | #endregion |
| | | #endregion |
| | | |
| | | /// <summary> |
| | | /// 自己用 |
| | | /// 自己用的发送的方法 |
| | | /// </summary> |
| | | /// <param name="tag">标记是那条命令</param> |
| | | /// <param name="logic">逻辑对象</param> |
| | | public static void Zj(bool tag, Common.Logic logic) |
| | | { |
| | | new System.Threading.Thread(() => |
| | |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | } |
| | | |
| | | #region 请求服务器方法--- |
| | | /// <summary> |
| | | /// 请求数据的封装方法 |
| | |
| | | jObject.Add("LogicID", Common.Logic.CurrentLogic.LogicId); |
| | | } |
| | | break; |
| | | case "读取云端门锁数据": |
| | | { |
| | | jObject.Add("RequestVersion", CommonPage.RequestVersion); |
| | | jObject.Add("HomeId", Config.Instance.HomeId); |
| | | jObject.Add("DoorLockId", obj.ToString());//门锁Mac+端口 |
| | | jObject.Add("PageSetting.PageSize", Int32.MaxValue.ToString()); |
| | | } |
| | | break; |
| | | |
| | | } |
| | | return await HttpWebRequest(getUrl, jObject.ToString(), method); |
| | | } |
| | |
| | | /// <param name="method">请求方式为POST/GET</param> |
| | | /// <param name="second">超时时间</param> |
| | | /// <returns></returns> |
| | | public static async System.Threading.Tasks.Task<string>HttpWebRequest(string getUrl, string str, string method,int second= 3) |
| | | public static async System.Threading.Tasks.Task<string> HttpWebRequest(string getUrl, string str, string method, int second = 3) |
| | | { |
| | | HttpWebRequest request = WebRequest.Create(getUrl) as HttpWebRequest; //创建请求 |
| | | request.Method = method; //请求方式为POST/GET |
| | |
| | | postValues.Add("LoginAccessToken", Config.Instance.Token); |
| | | postValues.Add("MainAccountId", residential.MainUserDistributedMark); |
| | | postValues.Add("SharedHid", residential.Id); |
| | | |
| | | } |
| | | break; |
| | | case 2: |
| | |
| | | return System.Text.Encoding.UTF8.GetString(varByte);
|
| | | } |
| | | #endregion |
| | | |
| | | /// <summary> |
| | | /// 判断字典是否存在的方法 |
| | | /// </summary> |
| | | /// <param name="deviceConditionsInfo"></param> |
| | | /// <param name="Key"></param> |
| | | /// <param name="Value"></param> |
| | | public static void dictionary(Dictionary<string, string> deviceConditionsInfo, string Key, string Value) |
| | | { |
| | | if (deviceConditionsInfo.ContainsKey(Key)) |
| | | { |
| | | deviceConditionsInfo.Remove(Key); |
| | | } |
| | | deviceConditionsInfo.Add(Key, Value); |
| | | } |
| | | |
| | | |
| | | } |
| | | } |