old mode 100755
new mode 100644
| | |
| | | using System.Linq; |
| | | using System.Net; |
| | | using System.Text; |
| | | using Shared.Phone.UserCenter.Abount; |
| | | |
| | | namespace Shared.Common |
| | | { |
| | | public class CommonPage : UIDrawerLayout |
| | |
| | | public static Loading Loading = new Loading(); |
| | | public void Show() |
| | | { |
| | | //if (Application.IsPad) |
| | | //{ |
| | | // Application.DesignWidth = 2048; |
| | | // Application.DesignHeight = 1536; |
| | | // Pad.MainPage.Instance .Show(); |
| | | // } |
| | | //else |
| | | //{ |
| | | Application.DesignWidth = 1080; |
| | | Application.DesignHeight = 1920; |
| | | Application.MainPage.AddChidren(this); |
| | | AddChidren(Phone.UserView.HomePage.Instance); |
| | | Application.MainPage.AddChidren(Loading); |
| | | //} |
| | | Phone.UserView.HomePage.Instance.InitPage(); |
| | | |
| | | Phone.UserView.HomePage.Instance.InitPage();
|
| | |
|
| | | //设置顶部状态栏文字为黑色
|
| | | Application.SetStatusBarTextBlack(true); |
| | | } |
| | | |
| | | public static string SoftTitle = "ZigBee"; |
| | | /// <summary> |
| | | /// 短信模板编号 |
| | | /// </summary> |
| | | public static int SoftSmsType = 0; |
| | | public static string LogoString = @"Logo/Logo.png"; |
| | | public static string RegisterLogoString = @"Logo/Register_logo.png"; |
| | | //public static string RequestHttpsHost = "https://global.hdlcontrol.com/HangZhouHdlCloudApi"; |
| | | public static string RequestHttpsHost = "https://global.hdlcontrol.com/ProposedProductionApi"; |
| | | /// <summary> |
| | | /// 版本号 |
| | | /// </summary> |
| | | public static string CodeIDString = "1.0.20041501"; |
| | | //public static string CodeIDString = "1.1.0121070801"; |
| | | public static string CodeIDString = "1.2.1"; |
| | | /// <summary> |
| | | /// 注册来源(0:HDL On 1:Zigbee) |
| | | /// </summary> |
| | | public static int RegisterSoruceFromZIGBEE = 0; |
| | | public static string Source = "ZIGBEE"; |
| | | /// <summary> |
| | | /// Company 用户公司用于公司App定制版 默认0 |
| | | /// </summary> |
| | |
| | | /// </summary> |
| | | public static int XLeft = 58; |
| | | /// <summary> |
| | | /// button高度--110 |
| | | /// </summary> |
| | | public static int ButtonHeight = 110; |
| | | /// <summary> |
| | | /// 使用的语言 |
| | | /// </summary> |
| | | public static string ZigBeeLanguage |
| | |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// 大控件圆角 --- 10。不是不半圆那种。 |
| | | /// </summary> |
| | | public static uint BigFormRadius = 10; |
| | | /// <summary> |
| | | /// 默认手机区号为86中国大陆 |
| | | /// </summary> |
| | | public static string PhoneZoneStr = "86"; |
| | | /// <summary> |
| | | /// 手机区名称 |
| | | /// </summary> |
| | | public static string ZoneNameStr = "中国大陆"; |
| | | /// <summary> |
| | | /// 距离顶端高度--80 状态栏高度 |
| | | /// </summary> |
| | | public static int NavigationTitle_Y = 80; |
| | | /// <summary> |
| | | /// 行高--180 |
| | | /// </summary> |
| | | public static int RowHeight = 180; |
| | | /// <summary> |
| | | /// APP宽度 -- 1080 |
| | | /// </summary> |
| | | public static int AppRealWidth = 1080; |
| | | /// <summary> |
| | | /// APP高度 -- 1920 |
| | | /// </summary> |
| | | public static int AppRealHeight = 1920; |
| | | /// <summary> |
| | | /// 返回键距离左边的距离 30 |
| | | /// </summary> |
| | | public static int Navigation_X = 30; |
| | | /// <summary> |
| | | /// 导航栏高度-220 |
| | | /// </summary> |
| | | public static int Navigation_Height = 220; |
| | | /// <summary> |
| | | /// 底边栏高度 |
| | | /// </summary> |
| | | public const int TabbarHeight = 141; |
| | | /// <summary> |
| | | /// 线条的高度--实际像素3 |
| | | /// </summary> |
| | | public static int LineHeight = 3; |
| | | /// <summary> |
| | | /// 整个场景延时时间--60秒 |
| | | /// </summary> |
| | | public static int SceneDelayTime = 60; |
| | | |
| | | /// <summary> |
| | | /// 间隔多长时间读取设备状态 单位 秒 --默认30 |
| | | /// </summary> |
| | | public static int ReadDeviceStatuSpan = 30; |
| | | /// <summary> |
| | | /// 读取多少页--999 |
| | | /// </summary> |
| | | public static int PageSize = 999; |
| | | |
| | | /// <summary> |
| | | /// 用于中国大陆验证手机号正则表达式 |
| | |
| | | /// 用于验证邮箱正则表达式 |
| | | /// </summary> |
| | | public static string EmailRegexStr = "^\\s*([A-Za-z0-9_-]+(\\.\\w+)*@(\\w+\\.)+\\w{2,5})\\s*$"; |
| | | |
| | | |
| | | //public static Encoding EncodingUTF8 = Encoding.UTF8; |
| | | //public static Encoding EncodingGB2312 = Encoding.GetEncoding("gb2312"); |
| | | public static bool IsRemote = false; |
| | | public static bool FindGateway = false; |
| | | /// <summary> |
| | | /// 当前网络连接的模式 0:没有网络 1:远程连接,也叫3G,4G 2:WIFI |
| | | /// </summary> |
| | | public static int nowNetworkMode = 0; |
| | | /// <summary> |
| | | /// 占位字体大小 |
| | | /// 11 |
| | | /// </summary> |
| | | public static int PlaceHolderTextSize = 11; |
| | | /// <summary>
|
| | | /// 安卓的系统返回按键能否按下(比如在备份还原时,不能按下返回键)
|
| | | /// </summary> |
| | |
| | | /// </summary> |
| | | /// <param name="requestUrl">请求Url</param> |
| | | /// <param name="byteData">请求的的数据</param> |
| | | /// <param name="timeout">超时,默认5秒</param> |
| | | /// <returns>得到响应的数据</returns> |
| | | public async System.Threading.Tasks.Task<Shared.Common.ResponseEntity.ResponsePack> RequestHttpsZigbeeAsync(string requestUrl, byte[] byteData) |
| | | public ResponseEntity.ResponsePack RequestHttpsZigbeeAsync(string requestUrl, byte[] byteData, int timeout = 5) |
| | | { |
| | | string result = await this.RequestHttpsZigbeeResultAsync(requestUrl, byteData); |
| | | string result = this.RequestHttpsZigbeeResultAsync(requestUrl, byteData, timeout); |
| | | if (result != null) |
| | | { |
| | | try |
| | |
| | | /// </summary> |
| | | /// <param name="requestUrl">请求Url</param> |
| | | /// <param name="byteData">请求的的数据</param> |
| | | /// <param name="timeout">超时,默认5秒</param> |
| | | /// <returns>得到响应的数据</returns> |
| | | public async System.Threading.Tasks.Task<string> RequestHttpsZigbeeResultAsync(string requestUrl, byte[] byteData) |
| | | public string RequestHttpsZigbeeResultAsync(string requestUrl, byte[] byteData, int timeout = 5) |
| | | { |
| | | var result = await RequestHttpsZigbeeBytesResultAsync(requestUrl, byteData); |
| | | var result = RequestHttpsZigbeeBytesResultAsync(requestUrl, byteData, "POST", timeout); |
| | | if (result != null)
|
| | | {
|
| | | return Encoding.UTF8.GetString(result);
|
| | |
| | | /// <param name="requestUrl">请求Url</param> |
| | | /// <param name="byteData">请求的的数据</param> |
| | | /// <param name="requestMethod">POST 或者 GET 等等</param> |
| | | /// <param name="timeout">超时,默认5秒</param> |
| | | /// <returns>得到响应的数据</returns> |
| | | public async System.Threading.Tasks.Task<byte[]> RequestHttpsZigbeeBytesResultAsync(string requestUrl, byte[] byteData, string requestMethod = "POST") |
| | | public byte[] RequestHttpsZigbeeBytesResultAsync(string requestUrl, byte[] byteData, string requestMethod = "POST", int timeout = 5) |
| | | { |
| | | //请求Url的完成路径 |
| | | var fullUrl = $"{RequestHttpsHost}/{requestUrl}"; |
| | | return await this.DoRequestZigbeeHttpsInterface(fullUrl, byteData, Config.Instance.Token, requestMethod); |
| | | return this.DoRequestZigbeeHttpsInterface(fullUrl, byteData, Config.Instance.Token, requestMethod, timeout); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <param name="requestUrl">请求Url</param> |
| | | /// <param name="byteData">请求的的数据</param> |
| | | /// <param name="requestMethod">POST 或者 GET 等等</param> |
| | | /// <param name="timeout">超时,默认5秒</param> |
| | | /// <returns>得到响应的数据</returns> |
| | | public async System.Threading.Tasks.Task<byte[]> RequestZigbeeHttpsByAdmin(string requestUrl, byte[] byteData, string requestMethod = "POST") |
| | | public byte[] RequestZigbeeHttpsByAdmin(string requestUrl, byte[] byteData, string requestMethod = "POST", int timeout = 5) |
| | | {
|
| | | //请求Url的完成路径 |
| | | var fullUrl = $"{Config.Instance.AdminRequestBaseUrl}/{requestUrl}";
|
| | | return await this.DoRequestZigbeeHttpsInterface(fullUrl, byteData, Config.Instance.AdminRequestToken, requestMethod); |
| | | } |
| | | return this.DoRequestZigbeeHttpsInterface(fullUrl, byteData, Config.Instance.AdminRequestToken, requestMethod, timeout); |
| | | }
|
| | |
|
| | | /// <summary> |
| | | /// 请求服务器方法 |
| | |
| | | /// <param name="byteData">请求的的数据</param> |
| | | /// <param name="token">token</param> |
| | | /// <param name="requestMethod">POST 或者 GET 等等</param> |
| | | /// <param name="timeout">超时,默认5秒</param> |
| | | /// <returns>得到响应的数据</returns> |
| | | public async System.Threading.Tasks.Task<byte[]> DoRequestZigbeeHttpsInterface(string requestFullUrl, byte[] byteData, string token, string requestMethod = "POST") |
| | | public byte[] DoRequestZigbeeHttpsInterface(string requestFullUrl, byte[] byteData, string token, string requestMethod = "POST", int timeout = 5) |
| | | {
|
| | | try |
| | | { |
| | |
| | | |
| | | //2. 初始化HttpWebRequest对象 |
| | | webRequest.Method = requestMethod; |
| | | webRequest.Timeout = 10 * 1000; |
| | | webRequest.Timeout = timeout * 1000; |
| | | //取消使用代理访问 |
| | | webRequest.Proxy = null; |
| | | webRequest.UseDefaultCredentials = false; |
| | | if (token != null)
|
| | | {
|
| | | //对应微信网址
|
| | |
| | | return ms.ToArray(); |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | catch (WebException e) |
| | | {
|
| | | #if DEBUG |
| | | System.Console.WriteLine(e.Message);
|
| | | #endif |
| | | if (e.Status == WebExceptionStatus.ConnectFailure//由有网络切换到无网络时触发
|
| | | || e.Status == WebExceptionStatus.Timeout//超时
|
| | | || e.Status == WebExceptionStatus.NameResolutionFailure)//本身就是无网络时启动时触发
|
| | | {
|
| | | Phone.UserCenter.HdlWifiLogic.Current.CanAccessHttp = false;
|
| | | }
|
| | | return null;
|
| | | } |
| | | catch (Exception e) |
| | | { |
| | | return null; |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | //清除角标数值 |
| | | public void clearBadgeNum()
|
| | | { |
| | | try
|
| | | { |
| | | //this.RequestHttpsZigbeeResultAsync("ZigbeeUsers/CornerClear", null, 10); |
| | | this.RequestHttpsZigbeeBytesResultAsync("ZigbeeUsers/CornerClear", null, "GET", 10); |
| | | } |
| | | catch { }
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | try
|
| | | {
|
| | | Application.RunOnMainThread(() =>
|
| | | {
|
| | | //设定一个时间
|
| | | { |
| | | #if iOS
|
| | | //全视通退出登录 |
| | | Shared.IOS.HDLFVSDK.Video.Logout(); |
| | | #endif |
| | | //设定一个时间 |
| | | Config.Instance.LoginDateTime = new DateTime(1970, 1, 1);
|
| | | Config.Instance.Save();
|
| | | CommonPage.Instance.RemoveAll();
|
| | | CommonPage.Instance.Show();
|
| | | var login = new Phone.Login.AccountLogin();
|
| | | var login = new Phone.Login.AccountLoginForm();
|
| | | CommonPage.Instance.AddChidren(login);
|
| | | login.Show();
|
| | | login.ShowForm();
|
| | | });
|
| | | }
|
| | | catch { }
|
| | |
| | | /// 登录成功后上报设备id等相关信息给后端 |
| | | /// </summary> |
| | | /// <returns>返回状态码</returns> |
| | | public async System.Threading.Tasks.Task<string> PushRegID() |
| | | public string PushRegID() |
| | | { |
| | | //#if DEBUG |
| | | // //调试不需要发送这个东西 |
| | | // return null; |
| | | //#endif |
| | | try |
| | | { |
| | | string deviceAlias; |
| | |
| | | deviceType = "iphone"; |
| | | #elif Android |
| | | deviceAlias = Android.OS.Build.Manufacturer; |
| | | deviceType = "android"; |
| | | #endif |
| | | deviceType = "android";
|
| | | #endif
|
| | | |
| | | var RegIDObj = new SendDataToServer.SignZigbeeNeedPushRegIDObj() |
| | | { |
| | | RegID = Shared.Common.Config.Instance.RegistrationID, |
| | |
| | | DeviceType = deviceType |
| | | }; |
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(RegIDObj); |
| | | var reverObj = await CommonPage.Instance.RequestHttpsZigbeeAsync("ZigbeeUsers/SignZigbeeNeedPushRegID", System.Text.Encoding.UTF8.GetBytes(requestJson)); |
| | | Console.WriteLine(requestJson); |
| | | var reverObj = CommonPage.Instance.RequestHttpsZigbeeAsync("ZigbeeUsers/SignZigbeeNeedPushRegID", System.Text.Encoding.UTF8.GetBytes(requestJson), 4); |
| | | if (reverObj == null) |
| | | { |
| | | {
|
| | | //调试:记录极光ID
|
| | | Phone.UserCenter.HdlLogLogic.Current.WriteOtherText(Shared.Phone.UserCenter.DirNameResourse.JiguangFile, "send:" + RegIDObj.RegID + " fail,receive obj is null", false, true); |
| | | return null; |
| | | } |
| | | }
|
| | | //调试:记录极光ID
|
| | | Phone.UserCenter.HdlLogLogic.Current.WriteOtherText(Shared.Phone.UserCenter.DirNameResourse.JiguangFile, "send:" + RegIDObj.RegID + " result:" + reverObj.StateCode, false, true); |
| | | |
| | | return reverObj.StateCode; |
| | | } |
| | | catch |