using System; using HDL_ON.DAL.Server; using HDL_ON.UI.UI2.PersonalCenter.PirDevice; using System.Collections.Generic; using Shared; namespace HDL_ON.UI.UI2.FuntionControlView.Video { public class VideoMethod { /// /// 程序主入口 /// /// log父控件 /// 可视对讲对象 public void MianView(FrameLayout frameLayout, VideoClouds video) { //加载log Loading loading = new Loading(); frameLayout.AddChidren(loading); loading.Start(); List listESVideoInfo = new List(); List listCall = new List(); new System.Threading.Thread(() => { try { listESVideoInfo = VideoSend.GetVideoInfoList(video); listCall = getCall(video.id); } catch { } finally { Application.RunOnMainThread(() => { loading.Hide(); var mainView = new MainView(); MainPage.BasePageView.AddChidren(mainView); mainView.Show(listESVideoInfo, listCall, video); MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; }); } }) { IsBackground = true }.Start(); } /// /// 获取可视对讲 /// /// 回调函数 /// log父控件 public void getVideo(Action action, FrameLayout frame, bool tag) { ThreadSend(null, (responsePackNew) => { try { var str = responsePackNew.Data.ToString(); var videoObj = Newtonsoft.Json.JsonConvert.DeserializeObject(str); action(videoObj); } catch { } }, "获取可视对讲", "fram", frame, null, tag); } /// /// 获取历史通话记录 /// /// public List getCall(string id) { List callViewList = new List(); try { List listCall = new List(); var responsePackNew = VideoSend.GetCall(id); if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "") { var jobject = Newtonsoft.Json.Linq.JObject.Parse(responsePackNew.Data.ToString()); string list = jobject["list"].ToString(); listCall = Newtonsoft.Json.JsonConvert.DeserializeObject>(list); } List strYear = new List(); //查询年份 for (int i = 0; i < listCall.Count; i++) { var call = listCall[i]; if (string.IsNullOrEmpty(call.callTime)) { continue; } var dd = Convert.ToDateTime(call.callTime); var year = dd.ToString("yyyy"); if (null == strYear.Find((c) => c == year)) { strYear.Add(year); } } //重新存储 for (int j = 0; j < strYear.Count; j++) { var year = strYear[j]; CallView callView = new CallView(); callView.year = year; for (int i = 0; i < listCall.Count; i++) { var call = listCall[i]; if (string.IsNullOrEmpty(call.callTime)) { continue; } var dd = Convert.ToDateTime(call.callTime); var y = dd.ToString("yyyy"); if (y == year) { callView.callList.Add(call); } } callViewList.Add(callView); } } catch { } return callViewList; } /// /// 发送命令线程 /// /// 数据对象 /// 回调函数 /// 判断字符 /// 判断log父控件 /// log父控件 /// log父控件 /// 是否要显示log public static void ThreadSend(VideoClouds videoObj, Action action, string str, string view, FrameLayout frame, Dialog dialog, bool tag = true) { //加载log Loading loading = new Loading(); if (view == "dialog") { dialog.AddChidren(loading); } else { frame.AddChidren(loading); } if (tag) { loading.Start(); } ResponsePackNew responsePackNew = null; new System.Threading.Thread(() => { try { if (str == "获取可视对讲") { responsePackNew = VideoSend.GetVideo(); } else if (str == "获取通话记录") { responsePackNew = VideoSend.GetCall(videoObj.id); } } catch { } finally { Application.RunOnMainThread(() => { if (tag) { loading.Hide(); } if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "") { action(responsePackNew); } else { Method method = new Method(); //自定义错误提示文本 string eorroText = ""; if (str == "获取可视对讲") { } method.ErrorShow(responsePackNew, eorroText); } }); } }) { IsBackground = true }.Start(); } /// /// 随机密码6位 /// /// public static string getCode() { Random rand = new Random(); string code = ""; for (int ctr = 0; ctr < 6; ctr++) { code += rand.Next(10).ToString(); } return code; } /// /// 获取当前时间戳 /// /// public static string GetCurrentTimeStamp() { TimeSpan ts = DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0); return Convert.ToInt64(ts.TotalSeconds).ToString(); } /// /// 获取当前时间戳 /// /// public static string GetTomorrowTimeStamp() { //当前时间的后一天 TimeSpan ts = DateTime.Now.AddDays(1) - new DateTime(1970, 1, 1, 0, 0, 0, 0); return Convert.ToInt64(ts.TotalSeconds).ToString(); } [Serializable] public class VideoClouds { /// /// 丰林绑定id(flBindId) /// public string id = string.Empty; /// /// 住宅id /// public string homeId = string.Empty; /// /// 虚拟手机号 /// public string phone = string.Empty; /// /// 虚拟身份证号码 /// public string idCard = string.Empty; /// /// 社区主键Id /// public string communtiyId = string.Empty; /// /// 丰林楼栋号 /// public string flBuildingId = string.Empty; /// /// 丰林楼栋名称 /// public string flBuildingName = string.Empty; /// /// 丰林房间名称 /// public string flRoomId = string.Empty; /// /// 丰林安全密钥 /// public string flSecretKey = string.Empty; /// /// 丰林的小区Id /// public string flCmtId = string.Empty; } [Serializable] public class Call { /// ///记录主键Id /// public string id = string.Empty; /// /// 住宅id /// public string homeId = string.Empty; /// /// 呼叫时间 /// public string callTime = string.Empty; /// /// 通话时长 /// public string callDuration = string.Empty; /// /// 呼叫状态(0:未接;1:已接;2:拒接) /// public string callStatus = string.Empty; /// /// 是否开锁 /// public bool isUnlock; /// /// 截图地址 /// public string screenshotUrl = string.Empty; /// ///丰林绑定主键id(门口机主键Id) /// public string flBindId = string.Empty; } [Serializable] public class CallView { /// ///年 /// public string year = string.Empty; public List callList = new List(); } [Serializable] public class FlVideo { /// /// 设备名称 /// public string aliasName = string.Empty; /// /// 设备类型:(1室内机,2室外机,3围墙机,4管理机,5二次确认机) /// public string devType = string.Empty; public string uuid = string.Empty; } } }