From d2666457d16f6171785596a8a9cb2fb9fb35f84b Mon Sep 17 00:00:00 2001
From: JLChen <551775569@qq.com>
Date: 星期五, 16 四月 2021 18:03:54 +0800
Subject: [PATCH] 2021-4-16-1

---
 HDL_ON/UI/UI2/FuntionControlView/Video/VideoMethod.cs |  224 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 224 insertions(+), 0 deletions(-)

diff --git a/HDL_ON/UI/UI2/FuntionControlView/Video/VideoMethod.cs b/HDL_ON/UI/UI2/FuntionControlView/Video/VideoMethod.cs
new file mode 100644
index 0000000..b08335b
--- /dev/null
+++ b/HDL_ON/UI/UI2/FuntionControlView/Video/VideoMethod.cs
@@ -0,0 +1,224 @@
+锘縰sing 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
+    {
+        /// <summary>
+        /// 绋嬪簭涓诲叆鍙�
+        /// </summary>
+        /// <param name="frameLayout">log鐖舵帶浠�</param>
+        /// <param name="video">鍙瀵硅瀵硅薄</param>
+        public void MianView(FrameLayout frameLayout, VideoClouds video)
+        {
+            //鍔犺浇log
+            Loading loading = new Loading();
+            frameLayout.AddChidren(loading);
+            loading.Start();
+            List<FlVideo> listESVideoInfo = new List<FlVideo>();
+            List<CallView> listCall = new List<CallView>();
+            new System.Threading.Thread(() =>
+            {
+                try
+                {
+                    listESVideoInfo = VideoSend.GetVideoInfoList(video);
+                    listCall = GetCall(video.id);
+                }
+                catch
+                {
+
+                }
+                finally
+                {
+                    Application.RunOnMainThread(() =>
+                    {
+                        loading.Hide();
+                        var mainView = new VideoMainView();
+                        MainPage.BasePageView.AddChidren(mainView);
+                        mainView.Show(listESVideoInfo, listCall, video);
+                        MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
+                    });
+                }
+            })
+            { IsBackground = true }.Start();
+        }
+        /// <summary>
+        /// 鑾峰彇鍙瀵硅
+        /// </summary>
+        /// <param name="action">鍥炶皟鍑芥暟</param>
+        /// <param name="frame">log鐖舵帶浠�</param>
+        /// <param name="tag">鏄惁瑕佹樉绀簂og(榛樿鏄剧ずtag=true)</param>
+        public void GetVideo(Action<VideoClouds> action, FrameLayout frame, bool tag) 
+        {
+            VideoClouds videoObj =null;
+            ThreadSend(null, (responsePackNew) =>
+             {
+                 try
+                 {
+                     var str = responsePackNew.Data.ToString();
+                     videoObj = Newtonsoft.Json.JsonConvert.DeserializeObject<VideoClouds>(str);
+                     action(videoObj);
+                 }
+                 catch {
+                     action(videoObj);
+                 }
+             }, "鑾峰彇鍙瀵硅", "fram", frame, null, tag);
+        } 
+        /// <summary>
+        /// 鑾峰彇鍘嗗彶閫氳瘽璁板綍
+        /// </summary>
+        /// <param name="id"></param>
+        public List<CallView> GetCall(string id)
+        {
+            List<CallView> callViewList = new List<CallView>();
+            try
+            {
+                
+                List<Call> listCall = new List<Call>();
+                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<Call>>(list);
+
+                }
+                List<string> strYear = new List<string>();
+                //鏌ヨ骞翠唤
+                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;
+        } 
+        /// <summary>
+        /// 鍙戦�佸懡浠ょ嚎绋�
+        /// </summary>
+        /// <param name="videoObj">鏁版嵁瀵硅薄</param>
+        /// <param name="action">鍥炶皟鍑芥暟</param>
+        /// <param name="str">鍒ゆ柇瀛楃</param>
+        /// <param name="view">鍒ゆ柇log鐖舵帶浠�</param>
+        /// <param name="frame">log鐖舵帶浠�</param>
+        /// <param name="dialog">log鐖舵帶浠�</param>
+        /// <param name="tag">鏄惁瑕佹樉绀簂og</param>
+        public static void ThreadSend(VideoClouds videoObj, Action<ResponsePackNew> 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();
+
+
+        }
+        /// <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>
        /// 鑾峰彇褰撳墠鏃堕棿鎴�
        /// </summary>
        /// <returns></returns>
        public static string GetCurrentTimeStamp()
        {
            //TimeSpan ts = DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0);
            //return Convert.ToInt64(ts.TotalSeconds).ToString();

            System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1)); // 褰撳湴鏃跺尯
+          
+            return ((long)(DateTime.Now - startTime).TotalSeconds).ToString(); // 鐩稿樊绉掓暟
+            
        }
+        /// <summary>
        /// 鑾峰彇褰撳墠鏃堕棿鎴�
        /// </summary>
        /// <returns></returns>
        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();
+            System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1)); // 褰撳湴鏃跺尯
+            return ((long)(DateTime.Now.AddDays(1) - startTime).TotalSeconds).ToString(); // 鐩稿樊绉掓暟
+        }
+     
+
+    }
+}

--
Gitblit v1.8.0