黄学彪
2020-11-19 9ef48d7b2da7c408b53f73be0f6eef3cbac1c84a
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
using System;
using System.Text;
using System.Text.RegularExpressions;
using Shared.Common;
 
namespace Shared.Phone.Login
{
    public class AccountLogic
    {
        #region ◆ 变量____________________________
        /// <summary>
        /// _instance
        /// </summary>
        private static AccountLogic _instance;
        /// <summary>
        /// Instance
        /// </summary>
        public static AccountLogic Instance
        {
            get
            {
                if(_instance==null)
                {
                    _instance = new AccountLogic();
                }
                return _instance;
            }
        }
 
        #endregion
 
        #region ◆ 邮箱____________________________
 
        /// <summary>
        /// 检查邮箱合法性
        /// </summary>
        /// <param name="email"></param>
        /// <returns></returns>
        public bool CheckEmail(string email)
        {
            var regex= new  Regex(CommonPage.EmailRegexStr);
            return regex.IsMatch(email);
        }
 
 
 
        #endregion
 
        #region ◆ 手机____________________________
 
        /// <summary>
        /// 检查手机号合法性
        /// </summary>
        /// <param name="phone"></param>
        /// <returns></returns>
        public bool CheckPhone(string phone)
        {
            var regex = new Regex(CommonPage.PhoneForForeignRegexStr);
            return regex.IsMatch(phone);
        }
 
        /// <summary>
        /// 检查手机号合法性、区分区号
        /// </summary>
        /// <param name="phone">手机号</param>
        /// <param name="zoneCode">区号</param>
        /// <returns></returns>
        public bool CheckPhoneWithZone(string phone, string zoneCode)
        {
            if (zoneCode == "86")
            {
                var regex = new Regex(CommonPage.PhoneRegexStr);
                return regex.IsMatch(phone);
            }
            else
            {
                var regex = new Regex(CommonPage.PhoneForForeignRegexStr);
                return regex.IsMatch(phone);
            }
        }
 
        #endregion
 
        #region ◆ 密码____________________________
 
        /// <summary>
        /// 检查密码长度合法性
        /// </summary>
        /// <param name="password"></param>
        /// <returns></returns>
        public bool CheckPwdLength(string password)
        {
            if (password.Trim().Length >= 6 && password.Trim().Length <= 13)
            {
                return true;
            }
            return false;
        }
 
        #endregion
 
        #region ◆ 经纬度__________________________
        /// <summary>
        /// ReceiveAppLatAndLon
        /// </summary>
        /// <param name="lat"></param>
        /// <param name="lon"></param>
        public async void ReceiveAppLatAndLon(string lon, string lat)
        {
            try
            {
                var requestObj = new SendDataToServer.ReceiveAppLatAndLonObj
                {
                    Longitude = lon,
                    Latitude = lat
                };
                var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(requestObj);
                var revertObj = RequestHttpsZigbeeAsync("ProcessRange/ReceiveAppLatAndLon", System.Text.Encoding.UTF8.GetBytes(requestJson));
 
                if (UserCenter.UserCenterResourse.HideOption.WriteGpsPoint == 1)
                {
                    string flage = revertObj == null ? "false" : revertObj.StateCode;
                    string txtvalue = "lon:" + lon + " lat:" + lat + " " + flage;
                    HdlMessageLogic.Current.ShowMassage(ShowMsgType.Tip, txtvalue);
                    UserCenter.HdlLogLogic.Current.WriteLog(-1, "经纬度上报  " + txtvalue);
                }
            }
            catch { }
        }
 
        /// <summary>
        /// 请求服务器方法
        /// 指定一个Url,和请求方法,数据,Cookie,得到响应的数据
        /// </summary>
        /// <param name="requestUrl">请求Url</param>
        /// <param name="byteData">请求的的数据</param>
        /// <returns>得到响应的数据</returns>
        public Shared.Common.ResponseEntity.ResponsePack RequestHttpsZigbeeAsync(string requestUrl, byte[] byteData)
        {
            string result = RequestHttpsZigbeeResultAsync(requestUrl, byteData);
            if (result != null)
            {
                try
                {
                    var data = Newtonsoft.Json.JsonConvert.DeserializeObject<Shared.Common.ResponseEntity.ResponsePack>(result);
                    return data;
                }
                catch (Exception ex)
                {
                    System.Console.WriteLine(ex.Message);
                }
            }
            return null;
        }
 
        /// <summary>
        /// 请求服务器方法
        /// 指定一个Url,和请求方法,数据,Cookie,得到响应的数据
        /// </summary>
        /// <param name="requestUrl">请求Url</param>
        /// <param name="byteData">请求的的数据</param>
        /// <returns>得到响应的数据</returns>
        public string RequestHttpsZigbeeResultAsync(string requestUrl, byte[] byteData)
        {
            var result = RequestHttpsZigbeeBytesResultAsync(requestUrl, byteData);
            if (result != null)
            {
                return Encoding.UTF8.GetString(result);
            }
            return null;
        }
 
        /// <summary>
        /// 请求服务器方法
        /// 指定一个Url,和请求方法,数据,Cookie,得到响应的数据
        /// </summary>
        /// <param name="requestUrl">请求Url</param>
        /// <param name="byteData">请求的的数据</param>
        /// <param name="requestMethod">POST 或者 GET 等等</param>
        /// <returns>得到响应的数据</returns>
        public byte[] RequestHttpsZigbeeBytesResultAsync(string requestUrl, byte[] byteData, string requestMethod = "POST")
        {
            //请求Url的完成路径
            var requestHost = "https://global.hdlcontrol.com/GeofenceService";
            var fullUrl = $"{requestHost}/{requestUrl}";
            return CommonPage.Instance.DoRequestZigbeeHttpsInterface(fullUrl, byteData, Config.Instance.Token, requestMethod);
        }
 
        #endregion
    }
}