tzy
2021-03-29 9463fa981945f278a639a1303192272732415f22
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
using System;
using System.IO;
using System.Net;
 
namespace HDL_ON.UI.UI2.FuntionControlView.Video
{
    public class Send
    {
        public Send()
        {
        }
 
        ///// <summary>
        ///// 获取可视对讲列表
        ///// </summary>
        //static async System.Threading.Tasks.Task<List<VideoCalss>> GetVideoInfoList(CloudsVideo clouds)
        //{
        //    List<VideoCalss> eSVideoInfosList = new List<VideoCalss>();
        //    var jobject = new JObject();
        //    jobject.Add("cmtID", clouds.FLCommunityID);
        //    jobject.Add("unitno", clouds.FLBuildingID);
        //    jobject.Add("method", "getUUIDList");
        //    var url = "http://112.74.164.111:180/api.php/Device/getmonitorUUID";
        //    var str = await Send.HttpWebRequest(url, jobject.ToString(), "POST");
        //    if (string.IsNullOrEmpty(str))
        //    {
        //        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)
        //    {
        //        VideoCalss eSVideoInfo = new VideoCalss();
        //        eSVideoInfo.ESRoomID = int.Parse(clouds.FLRoomID);
        //        string str1 = clouds.FLBuildingID.Substring(0, 2).TrimStart('0');
        //        string str2 = clouds.FLBuildingID.Substring(2, 2).TrimStart('0');
        //        eSVideoInfo.RoomName = str1 + Language.StringByID(R.MyInternationalizationString.dong) + str2 + Language.StringByID(R.MyInternationalizationString.unit);
        //        eSVideoInfo.DeviceName = videoInfo["aliasName"];
        //        if (videoInfo["uuid"].Contains(","))
        //        {
        //            var uuid = videoInfo["uuid"].Split(',');
        //            eSVideoInfo.ESVideoUUID = uuid[0];
        //        }
        //        else
        //        {
        //            eSVideoInfo.ESVideoUUID = videoInfo["uuid"];
        //        }
        //        eSVideoInfosList.Add(eSVideoInfo);
        //    }
        //    return eSVideoInfosList;
        //}
 
        ///// <summary>
        /////  请求服务器的方法(支持请求方式为POST/GET)
        ///// </summary>
        ///// <param name="getUrl">请求的地址</param>
        ///// <param name="str">请求数据</param>
        ///// <param name="method">请求方式为POST/GET</param>
        ///// <param name="second">超时时间</param>
        ///// <returns></returns>
        //public static async System.Threading.Tasks.Task<string> HttpWebRequest(string getUrl, string str, string method, int second = 3, bool _bool = false)
        //{
        //    try
        //    {
        //        HttpWebRequest request = WebRequest.Create(getUrl) as HttpWebRequest; //创建请求
        //        request.Method = method; //请求方式为POST/GET
        //        request.ContentType = "application/json";
        //        request.Timeout = second * 1000;//超时时间
        //        if (_bool)
        //        {
        //            //用于高胜可视对讲接口
        //            request.Headers.Add("Authorization", Config.Instance.Token);
        //        }
        //        if (method == "POST")
        //        {
        //            byte[] jsonbyte = System.Text.Encoding.UTF8.GetBytes(str);
        //            request.ContentLength = jsonbyte.Length;
        //            Stream postStream = request.GetRequestStream();
        //            postStream.Write(jsonbyte, 0, jsonbyte.Length);
        //            postStream.Close();
        //        }
        //        //发送请求并获取相应回应数据       
        //        HttpWebResponse res;
        //        try
        //        {
        //            res = (HttpWebResponse)request.GetResponse();
        //        }
        //        catch (WebException ex)
        //        {
        //            res = (HttpWebResponse)ex.Response;
        //        }
        //        StreamReader sr = new StreamReader(res.GetResponseStream(), System.Text.Encoding.UTF8);
        //        string content = sr.ReadToEnd(); //获得响应字符串
        //        return content;
        //    }
        //    catch
        //    {
        //        return null;
        //    }
       // }
 
    }
}