From ccdff82fac4bcc1067ec806ade5ae897f1214f4d Mon Sep 17 00:00:00 2001 From: wei <kaede@kaededeMacBook-Air.local> Date: 星期四, 01 四月 2021 14:41:53 +0800 Subject: [PATCH] 异常捕获 --- HDL_ON/UI/UI2/FuntionControlView/Video/VideoSend.cs | 150 ++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 115 insertions(+), 35 deletions(-) diff --git a/HDL_ON/UI/UI2/FuntionControlView/Video/VideoSend.cs b/HDL_ON/UI/UI2/FuntionControlView/Video/VideoSend.cs index 5e2a6c0..e4d944d 100644 --- a/HDL_ON/UI/UI2/FuntionControlView/Video/VideoSend.cs +++ b/HDL_ON/UI/UI2/FuntionControlView/Video/VideoSend.cs @@ -6,7 +6,6 @@ using HDL_ON.UI.UI2.PersonalCenter.PirDevice; using Newtonsoft.Json.Linq; using Shared; -using static HDL_ON.UI.UI2.FuntionControlView.Video.VideoMethod; namespace HDL_ON.UI.UI2.FuntionControlView.Video { @@ -32,57 +31,130 @@ /// <returns></returns> public static ResponsePackNew GetCall(string flBindId) { - var jObject = new JObject { { "homeId", PirSend.HomeId }, { "flBindId", flBindId }, { "pageSize", int.MaxValue } }; + var jObject = new JObject { { "homeId", PirSend.HomeId }, { "flBindId", flBindId }, { "pageSize", 100 } }; var responsePackNew = RequestServerhomeId(jObject, NewAPI.API_POST_FL_GetCallList); return responsePackNew; } /// <summary> /// 鑾峰彇闂ㄥ彛鏈哄垪琛�(1瀹ゅ唴鏈�,2瀹ゅ鏈猴紝3鍥村鏈猴紝4绠$悊鏈�,5浜屾纭鏈�) /// </summary> - public static List<ESVideoInfo> GetVideoInfoList(VideoObj video) + public static List<VideoMethod.FlVideo> GetVideoInfoList(VideoMethod.VideoClouds video) { - List<ESVideoInfo> eSVideoInfosList = new List<ESVideoInfo>(); + List<VideoMethod.FlVideo> eSVideoInfosList = new List<VideoMethod.FlVideo>(); var jobject = new JObject(); - jobject.Add("cmtID",video.flCmtId); + jobject.Add("cmtID", video.flCmtId); jobject.Add("unitno", video.flBuildingId); jobject.Add("method", "getUUIDList"); - var str = HttpWebRequest(NewAPI.API_POST_FL_List, jobject.ToString(), "POST"); - if (string.IsNullOrEmpty(str)) + try { - return eSVideoInfosList; - } - var json = JObject.Parse(str); - if (json == null) - { - return eSVideoInfosList; - } - if (json["resCode"].ToString() != "0") - { - return eSVideoInfosList; - } - var list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Dictionary<string, string>>>(json["list"].ToString()); - if (list.Count == 0) - { - return eSVideoInfosList; - } - foreach (var videoInfo in list) - { - ESVideoInfo eSVideoInfo = new ESVideoInfo(); - eSVideoInfo.DeviceName = videoInfo["aliasName"]; - if (videoInfo["uuid"].Contains(",")) + var str = HttpWebRequest(NewAPI.API_POST_FL_List, jobject.ToString(), "POST"); + if (string.IsNullOrEmpty(str)) { - var uuid = videoInfo["uuid"].Split(','); - eSVideoInfo.ESVideoUUID = uuid[0]; + return eSVideoInfosList; } - else + var json = JObject.Parse(str); + if (json == null) { - eSVideoInfo.ESVideoUUID = videoInfo["uuid"]; + return eSVideoInfosList; } - eSVideoInfo.uuid = videoInfo["uuid"]; - eSVideoInfo.roomno = video.flRoomId; - eSVideoInfosList.Add(eSVideoInfo); + if (json["resCode"].ToString() != "0") + { + return eSVideoInfosList; + } + eSVideoInfosList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<VideoMethod.FlVideo>>(json["list"].ToString()); + } + catch { } return eSVideoInfosList; + } + + /// <summary> + /// 闅忔満瀵嗙爜6浣� + /// </summary> + /// <returns></returns> public static string getCode() { Random rand = new Random(); string code = ""; for (int ctr = 0; ctr < 6; ctr++) { code += rand.Next(10).ToString(); } return code; } + + + /// <summary> + /// 涓婃姤鍔ㄦ�佸紑閿佸瘑鐮�(娉ㄦ剰锛氬瘑鐮佹湁鍙兘寤舵椂1鍒嗛挓鐢熸晥) + /// </summary> + public static void GetQRcode(FrameLayout frame, VideoMethod.VideoClouds video, Action<bool, string> action) + { + System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1)); // 褰撳湴鏃跺尯 + var timeStamp = ((long)(DateTime.Now - startTime).TotalSeconds).ToString(); // 鐩稿樊绉掓暟 + var timeStamp2 = ((long)(DateTime.Now.AddDays(1) - startTime).TotalSeconds).ToString(); // 鐩稿樊绉掓暟 + + ///鏍囪鏄惁鎴愬姛 + bool if_bool = false; + //涓存椂瀵嗙爜 + string pwd = getCode(); + var jobject = new JObject(); jobject.Add("communityID", video.flCmtId);//绀惧尯ID + jobject.Add("fromTime", timeStamp);//寮�濮嬫椂闂� + jobject.Add("validTime", timeStamp2);//鏈夋晥鏃堕棿 + jobject.Add("unitno", video.flBuildingId);//鍗曞厓鍙� + jobject.Add("roomno", video.flRoomId);//鎴块棿鍙� + jobject.Add("code", pwd); jobject.Add("userKey", video.id); jobject.Add("timestamp", timeStamp); jobject.Add("secretKey", video.flSecretKey); jobject.Add("method", "setdynamicpwd"); jobject.Add("numTimes", "5"); + //鍔犺浇log + Loading loading = new Loading(); + frame.AddChidren(loading); + loading.Start(); + new System.Threading.Thread(() => + { + try + { + var str = HttpWebRequest(NewAPI.API_POST_FL_QRcode, jobject.ToString(), "POST"); + if (!string.IsNullOrEmpty(str)) + { + var json = JObject.Parse(str); + if (json != null) + { + var stateCode = json["status"].ToString(); + if (stateCode == "0") + { + if_bool = true; + } + } + } + } + catch { } + finally + { + Application.RunOnMainThread(() => + { + loading.Hide(); + action(if_bool, pwd); + + }); + } + + }) + { IsBackground = true }.Start(); + } + /// <summary> + /// 涓嬭浇鍥剧墖 + /// </summary> + public static void GetIcon(FrameLayout frame,string url) + { + Loading loading = new Loading(); + frame.AddChidren(loading); + loading.Start(); + new System.Threading.Thread(() => + { + try + { + var responsePackNew = RequestServerhomeId(null, url); + } + catch { } + finally + { + Application.RunOnMainThread(() => + { + loading.Hide(); + + }); + } + + }) + { IsBackground = true }.Start(); } /// <summary> /// 璇锋眰鏈嶅姟鍣ㄧ殑鏂规硶(鏀寔璇锋眰鏂瑰紡涓篜OST/GET) @@ -137,5 +209,13 @@ return HttpUtil.RequestHttpsPostFroHome(api_Url, requestJson, mTimeout); } + + + } + class FlResponsePackNew + {// + public string status = string.Empty; + public string desc = string.Empty; + } } -- Gitblit v1.8.0