| | |
| | | /// 获取Logic的方法 |
| | | /// </summary> |
| | | /// <returns>The logic identifier.</returns> |
| | | public static async System.Threading.Tasks.Task<Common.Logic> GetLogic(int LogicId,int LogicType) |
| | | public static async System.Threading.Tasks.Task<Common.Logic> GetLogic(int LogicId, int LogicType) |
| | | { |
| | | return await System.Threading.Tasks.Task.Run(async () => |
| | | { |
| | |
| | | } |
| | | } |
| | | var accounts = new JArray(); |
| | | foreach (var dictionary in logic.Accounts) { |
| | | foreach (var dictionary in logic.Accounts) |
| | | { |
| | | var Type = int.Parse(dictionary["Type"]); |
| | | switch (Type) |
| | | { |
| | | case 1: { |
| | | case 1: |
| | | { |
| | | /// |
| | | } break; |
| | | if (logic.LogicType == 1) |
| | | { |
| | | var accounts1 = new JObject |
| | | { |
| | | ["Type"] = int.Parse(dictionary["Type"]), |
| | | ["Account"] = dictionary["Account"], |
| | | |
| | | }; |
| | | accounts.Add(accounts1); |
| | | } |
| | | } |
| | | break; |
| | | case 7: |
| | | { |
| | | var location = new JObject |
| | |
| | | { "IsEnable", logic.IsEnable} , |
| | | { "LogicName", logic.LogicName}, |
| | | { "Relationship",logic.Relationship} , |
| | | { "LogicType",logic.LogicType} , |
| | | { "LogicCustomPushText",logic.LogicCustomPushText} , |
| | | { "TimeAttribute", timeAttribute} , |
| | | { "Conditions", conditions }, |
| | |
| | | /// 获取Logic列表的方法 |
| | | /// </summary> |
| | | /// <returns>The logic identifier.</returns> |
| | | public static async System.Threading.Tasks.Task<List<Common.Logic>> ReadList(int sum,int LogicType) |
| | | public static async System.Threading.Tasks.Task<List<Common.Logic>> ReadList(int sum, int LogicType) |
| | | { |
| | | return await System.Threading.Tasks.Task.Run(async () => |
| | | { |
| | | |
| | | var listLogic = new List<Common.Logic>(); |
| | | // bool @bool = false; |
| | | var listLogic = new List<Common.Logic>();
|
| | | // bool @bool = false;
|
| | | Action<string, string> action = (topic, data) => |
| | | { |
| | | var gatewayID = topic.Split('/')[0]; |
| | |
| | | System.Collections.Specialized.NameValueCollection postValues = new System.Collections.Specialized.NameValueCollection(); |
| | | postValues.Add("RequestVersion", CommonPage.RequestVersion); |
| | | postValues.Add("ReqDto.LoginAccessToken", Config.Instance.Token); |
| | | System.Threading.Tasks.Task.Run(() => |
| | | { |
| | | try |
| | | { |
| | | |
| | | byte[] responseArray = webClient.UploadValues(url, postValues); |
| | | var str = System.Text.Encoding.UTF8.GetString(responseArray); |
| | | var jObject = JObject.Parse(str); |
| | | if (jObject == null || jObject["StateCode"].ToString() != "Success") |
| | | { |
| | | return; |
| | | } |
| | | var pageData = jObject["ResponseData"]["PageData"].ToString(); |
| | | var datalist = JArray.Parse(pageData); |
| | | for (int i = 0; i < datalist.Count; i++) |
| | | { |
| | | var data = JObject.Parse(datalist[i].ToString()); |
| | | if (Config.Instance.HomeId == data["Id"].ToString()) |
| | | { |
| | | Residential residential = new Residential(); |
| | | |
| | | if (Convert.ToBoolean(data["IsOthreShare"].ToString())) |
| | | { |
| | | System.Threading.Tasks.Task.Run(() =>
|
| | | {
|
| | | try
|
| | | {
|
| | |
|
| | | byte[] responseArray = webClient.UploadValues(url, postValues);
|
| | | var str = System.Text.Encoding.UTF8.GetString(responseArray);
|
| | | var jObject = JObject.Parse(str);
|
| | | if (jObject == null || jObject["StateCode"].ToString() != "Success")
|
| | | {
|
| | | return;
|
| | | }
|
| | | var pageData = jObject["ResponseData"]["PageData"].ToString();
|
| | | var datalist = JArray.Parse(pageData);
|
| | | for (int i = 0; i < datalist.Count; i++)
|
| | | {
|
| | | var data = JObject.Parse(datalist[i].ToString());
|
| | | if (Config.Instance.HomeId == data["Id"].ToString())
|
| | | {
|
| | | Residential residential = new Residential();
|
| | |
|
| | | if (Convert.ToBoolean(data["IsOthreShare"].ToString()))
|
| | | { |
| | | //分享者ID |
| | | residential.Id = data["Id"].ToString(); |
| | | //是否是分享账号[true(是分享);false;(不是分享)]; |
| | | residential.IsOthreShare = Convert.ToBoolean(data["IsOthreShare"].ToString()); |
| | | //分享者住宅ID |
| | | residential.MainUserDistributedMark = data["MainUserDistributedMark"].ToString(); |
| | | residential.IsOtherAccountCtrl = true; |
| | | residential.doorlockmac = doorlockMac; |
| | | list = ReadToken(residential); |
| | | } |
| | | else |
| | | { |
| | | residential.Url = "https://global.hdlcontrol.com/HangZhouHdlCloudApi/DoorLock/GetDoorLockPager"; |
| | | residential.Token = Config.Instance.Token; |
| | | residential.Id = Config.Instance.HomeId; |
| | | residential.IsOtherAccountCtrl = false; |
| | | residential.doorlockmac = doorlockMac; |
| | | list = ReadDoorLock(residential); |
| | | |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | catch { } |
| | | }); |
| | | residential.MainUserDistributedMark = data["MainUserDistributedMark"].ToString();
|
| | | residential.IsOtherAccountCtrl = true;
|
| | | residential.doorlockmac = doorlockMac;
|
| | | list = ReadToken(residential);
|
| | | }
|
| | | else
|
| | | {
|
| | | residential.Url = "https://global.hdlcontrol.com/HangZhouHdlCloudApi/DoorLock/GetDoorLockPager";
|
| | | residential.Token = Config.Instance.Token;
|
| | | residential.Id = Config.Instance.HomeId;
|
| | | residential.IsOtherAccountCtrl = false;
|
| | | residential.doorlockmac = doorlockMac;
|
| | | list = ReadDoorLock(residential);
|
| | |
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | | }
|
| | | catch { }
|
| | | }); |
| | | var datetime = DateTime.Now; |
| | | while ((DateTime.Now - datetime).TotalMilliseconds < 3*1000) |
| | | while ((DateTime.Now - datetime).TotalMilliseconds < 3 * 1000) |
| | | { |
| | | if (list.Count != 0) |
| | | { |
| | |
| | | public static List<DoorLock> ReadDoorLock(Residential lockifon) |
| | | { |
| | | List<DoorLock> list = new List<DoorLock>(); |
| | | System.Net.WebClient webClient = new System.Net.WebClient(); |
| | | System.Net.WebClient webClient = new System.Net.WebClient();
|
| | | System.Collections.Specialized.NameValueCollection postValues = new System.Collections.Specialized.NameValueCollection(); |
| | | postValues.Add("RequestVersion", CommonPage.RequestVersion); |
| | | postValues.Add("LoginAccessToken", lockifon.Token); |
| | |
| | | public class MembershipIfon |
| | | { |
| | | public string MembershipId = string.Empty; |
| | | public List<string> UserIdMode=new List<string>(); |
| | | public List<string> UserIdMode = new List<string>(); |
| | | public string MembershipName = string.Empty; |
| | | } |
| | | |
| | | public static List<MembershipIfon> UserList = new List<MembershipIfon>(); |
| | | |
| | | |
| | | public static List<MembershipIfon> UserList = new List<MembershipIfon>();
|
| | |
|
| | |
|
| | | #endregion |
| | | } |
| | | } |