From c7698e163e43cea9e7f8ee45f8e3f91c9265cca4 Mon Sep 17 00:00:00 2001 From: 黄学彪 <hxb@hdlchina.com.cn> Date: 星期一, 04 十一月 2019 19:11:41 +0800 Subject: [PATCH] 合并了全部的代码 --- ZigbeeApp/Shared/Phone/ZigBee/Device/Safeguard.cs | 134 +++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 131 insertions(+), 3 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/ZigBee/Device/Safeguard.cs b/ZigbeeApp/Shared/Phone/ZigBee/Device/Safeguard.cs index 5068bba..2e92268 100755 --- a/ZigbeeApp/Shared/Phone/ZigBee/Device/Safeguard.cs +++ b/ZigbeeApp/Shared/Phone/ZigBee/Device/Safeguard.cs @@ -877,7 +877,10 @@ /// 鏈�灏�4涓瓧绗︼紝鏈�澶�32涓瓧绗� /// </summary> public string Password; - + /// <summary> + /// 鐢ㄦ埛瀵嗙爜鎻愮ず璇� + /// </summary> + public string PassWordTips = string.Empty; } #endregion @@ -886,10 +889,11 @@ /// *鏂板鎴栭噸璁剧敤鎴峰瘑鐮侊紙闇�瑕佺鐞嗗憳鏉冮檺锛� /// <para>userId:鐢ㄦ埛id 濡傛灉鐢ㄦ埛id瀛樺湪锛屽垯淇敼瀵嗙爜銆傚鏋滅敤鎴穒d涓嶅瓨鍦紝鍒欎负璇d鏂板瀵嗙爜 /// 涓�0鏃讹紝鑷姩鍒嗛厤鏂扮殑鐢ㄦ埛id銆備负5鏃讹紝鍒欎慨鏀硅儊杩瘑鐮併�傚彇鍊艰寖鍥�0-5銆�</para> - /// <para>password:鏂扮鐞嗗憳瀵嗙爜</para> + /// <para>password:鏂扮鐞嗗憳瀵嗙爜</para> + /// <para>passWordTips:瀵嗙爜鎻愮ず</para> /// <para>loginToken:鐧婚檰鏍囪瘑锛屾渶澶�32涓瓧绗︺�傜敱app鑷姩鐢熸垚鐨勫敮涓�鏍囪瘑銆備笌绠$悊鍛樼櫥闄嗘寚浠ょ殑鈥淟oginToken鈥濅竴鑷达紝鍚﹀垯灏嗚繑鍥炩�淪ecurity/Error_Respon鈥濋敊璇��</para> /// </summary> - public static async System.Threading.Tasks.Task<SetUserPasswordResponseAllData> SetUserPasswordAsync(int userId, string password,string loginToken) + public static async System.Threading.Tasks.Task<SetUserPasswordResponseAllData> SetUserPasswordAsync(int userId, string password, string passWordTips, string loginToken) { return await System.Threading.Tasks.Task.Run(async () => { @@ -980,6 +984,7 @@ { { "UserId", userId }, { "Password", password}, + { "PassWordTips", passWordTips}, { "LoginToken", loginToken} }; jObject.Add("Data", data); @@ -1005,6 +1010,129 @@ return d; }); + } + + /// <summary> + /// *鏂板鎴栭噸璁剧敤鎴峰瘑鐮侊紙闇�瑕佺鐞嗗憳鏉冮檺锛� + /// <para>userId:鐢ㄦ埛id 濡傛灉鐢ㄦ埛id瀛樺湪锛屽垯淇敼瀵嗙爜銆傚鏋滅敤鎴穒d涓嶅瓨鍦紝鍒欎负璇d鏂板瀵嗙爜 + /// 涓�0鏃讹紝鑷姩鍒嗛厤鏂扮殑鐢ㄦ埛id銆備负5鏃讹紝鍒欎慨鏀硅儊杩瘑鐮併�傚彇鍊艰寖鍥�0-5銆�</para> + /// <para>password:鏂扮鐞嗗憳瀵嗙爜</para> + /// <para>passWordTips:瀵嗙爜鎻愮ず</para> + /// <para>loginToken:鐧婚檰鏍囪瘑锛屾渶澶�32涓瓧绗︺�傜敱app鑷姩鐢熸垚鐨勫敮涓�鏍囪瘑銆備笌绠$悊鍛樼櫥闄嗘寚浠ょ殑鈥淟oginToken鈥濅竴鑷达紝鍚﹀垯灏嗚繑鍥炩�淪ecurity/Error_Respon鈥濋敊璇��</para> + /// </summary> + public static async System.Threading.Tasks.Task<SetUserPasswordResponseAllData> SetPassWordTipsAsync(int userId, string password, string passWordTips, string loginToken) + { + return await System.Threading.Tasks.Task.Run(async () => + { + SetUserPasswordResponseAllData d = null; + var mainGateway = ZbGateway.MainGateWay; + if (mainGateway == null) + { + d = new SetUserPasswordResponseAllData { errorMessageBase = "褰撳墠娌℃湁涓荤綉鍏�" }; + return d; + } + + Action<string, string> action = (topic, message) => + { + var gatewayID = topic.Split('/')[0]; + var jobject = Newtonsoft.Json.Linq.JObject.Parse(message); + + if (topic == gatewayID + "/" + "Error_Respon") + { + var gatewayTemp = new ZbGateway() { Time = jobject.Value<int>("Time"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = mainGateway.getGatewayBaseInfo.gwID }; + var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<ErrorResponData>(jobject["Data"].ToString()); + + if (temp == null) + { + d = new SetUserPasswordResponseAllData { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" }; + } + else + { + d = new SetUserPasswordResponseAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) }; + } + } + + if (topic == gatewayID + "/" + "Security/Error_Respon") + { + var securityTemp = new Safeguard() { Time = jobject.Value<int>("Time"), DataID = jobject.Value<int>("Data_ID"), GateWayId = mainGateway.getGatewayBaseInfo.gwID }; + var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<ErrorResponData>(jobject["Data"].ToString()); + d = new SetUserPasswordResponseAllData { }; + if (temp == null) + { + d.errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖"; + } + else + { + if (temp.Error == 1) + { + d.errorMessageBase = "缃戝叧涓嶆槸涓荤綉鍏筹紝鏃犳硶杩涜璇ユ搷浣溿��"; + } + else if (temp.Error == 2) + { + d.errorMessageBase = "璇ユ搷浣滈渶瑕佸畨闃茬鐞嗗憳鏉冮檺锛岄渶鍏堜互绠$悊鍛樿韩浠借繘琛岀櫥闄嗐��"; + } + d.errorResponData = temp; + } + } + + if (topic == gatewayID + "/" + "Security/AddPassWordTips_Respon") + { + var security = new Safeguard() { DataID = jobject.Value<int>("Data_ID"), GateWayId = mainGateway.CurrentGateWayId }; + var result = Newtonsoft.Json.JsonConvert.DeserializeObject<int>(jobject["Data"]["Result"].ToString()); + if (result == 0) + { + security.setUserPasswordResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<SetUserPasswordResponseData>(jobject["Data"].ToString()); + if (security.setUserPasswordResponseData != null) + { + d = new SetUserPasswordResponseAllData { setUserPasswordResponseData = security.setUserPasswordResponseData }; + } + } + else + { + d = new SetUserPasswordResponseAllData { }; + var r = new SetUserPasswordResponseData(); + r.Result = result; + d.setUserPasswordResponseData = r; + } + } + }; + mainGateway.Actions += action; + try + { + var jObject = new Newtonsoft.Json.Linq.JObject() { + { "Cluster_ID", 0 }, + { "Command", 4037} + }; + var data = new JObject + { + { "UserId", userId }, + { "Password", password}, + { "PassWordTips", passWordTips}, + { "LoginToken", loginToken} + }; + jObject.Add("Data", data); + mainGateway.Send("Security/AddPassWordTips", jObject.ToString()); + } + catch + { + } + var dateTime = DateTime.Now; + while ((DateTime.Now - dateTime).TotalMilliseconds < WaitReceiveDataTime) + { + await System.Threading.Tasks.Task.Delay(10); + if (d != null) + { + break; + } + } + if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime) + { + d = new SetUserPasswordResponseAllData { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" }; + } + mainGateway.Actions -= action; + + return d; + }); } /// <summary> -- Gitblit v1.8.0