| | |
| | | |
| | | //public static Button LogoButton = new Button (); |
| | | |
| | | public static string RequestVersion = "20200108"; |
| | | public static string RequestVersion = "20200110"; |
| | | public static UserInfo LoginUser; |
| | | /// <summary> |
| | | /// 是否是管理员权限(变更了,成员的时候,这个也为ture。为什么会声明这样变量,因为有些接口必须使用原来的Token) |
| | | /// </summary> |
| | | public static bool IsAdministrator = false; |
| | | public static bool IsAdministrator { |
| | | get { |
| | | if (UserConfig.Instance == null || UserConfig.Instance.CurrentRegion == null) { |
| | | return false; |
| | | } else { |
| | | return UserConfig.Instance.CurrentRegion.IsOthreShare; |
| | | } |
| | | } |
| | | } |
| | | |
| | | public static string SoftPadTitle = "Crabtree"; |
| | | public static string SoftTitle = "Crabtree"; |
| | |
| | | /// <param name="methodType">请求方法.</param> |
| | | /// <param name="dataStringJson">请求的参数.</param> |
| | | /// <param name="needHeaders">是否需要包头.</param> |
| | | public static ResponsePack RequestHttps (string methodType, string dataStringJson, bool needHeaders = false, bool needTip2 = true, string urlHead = "") |
| | | public static ResponsePack RequestHttps (string methodType, string dataStringJson, string urlHead = "") |
| | | { |
| | | ResponsePack revertObj = null; |
| | | try { |
| | | if (!SystemRemote.checeInternet ()) { |
| | | Application.RunOnMainThread (() => { |
| | | MainPage.WiFiStatus = "CrabtreeAdd/WiFiUnlink.png"; |
| | | MainPage.Loading.Hide (); |
| | | }); |
| | | } |
| | | //2020-01-08 屏蔽 |
| | | //if (!SystemRemote.checeInternet ()) { |
| | | // Application.RunOnMainThread (() => { |
| | | // MainPage.WiFiStatus = "CrabtreeAdd/WiFiUnlink.png"; |
| | | // MainPage.Loading.Hide (); |
| | | // }); |
| | | //} |
| | | //new System.Threading.Thread (() => { |
| | | // requesTime = DateTime.Now; |
| | | // isShowLoading = true; |
| | |
| | | //} |
| | | webClient.Headers.Add ("CONTENT-TYPE", "application/json"); |
| | | string url = urlHead + methodType; |
| | | if (needHeaders && LoginUser != null) {/* 如果不需要验证Token可以不用传入 */ |
| | | if (LoginUser != null) {/* 如果不需要验证Token可以不用传入 */ |
| | | webClient.Headers.Add ("Authorization", LoginUser.LoginTokenString); |
| | | } |
| | | byte [] bytes = null; |
| | |
| | | } catch (System.Net.WebException webEx) { |
| | | Application.RunOnMainThread (() => { |
| | | MainPage.Loading.Hide (); |
| | | revertObj = new ResponsePack () { StateCode = ErrorCode.NetworkError }; |
| | | //new Alert ( "","Network abnormal, unable to connect to the Internet", Language.StringByID (R.MyInternationalizationString.Close)).Show (); |
| | | return; |
| | | }); |
| | | return new ResponsePack () { StateCode = ErrorCode.NetworkError }; |
| | | } |
| | | string responseString = null; |
| | | if (bytes != null) { |
| | | responseString = Encoding.UTF8.GetString (bytes); |
| | | string responseString = Encoding.UTF8.GetString (bytes); |
| | | //var DD = Newtonsoft.Json.Linq.JObject .Parse("GFGFDG");DD["ResponseData"]["PageData"] |
| | | } |
| | | |
| | | //var request = (HttpWebRequest)WebRequest.Create (url); |
| | | //var data = Encoding.UTF8.GetBytes (dataStringJson); |
| | |
| | | //var response = (HttpWebResponse)request.GetResponse (); |
| | | //var responseString = new StreamReader (response.GetResponseStream ()).ReadToEnd (); |
| | | |
| | | if (responseString != null) { |
| | | try { |
| | | revertObj = Newtonsoft.Json.JsonConvert.DeserializeObject<ResponsePack> (responseString); |
| | | //if (revertObj.StateCode.ToUpper() != "SUCCESS") { |
| | | // if (methodType == API.IsExistingAccount) { |
| | | |
| | | // } else if (needTip) { |
| | | // Application.RunOnMainThread (() => { |
| | | // new Alert ("", revertObj.ErrorInfo, Language.StringByID (R.MyInternationalizationString.Close)).Show (); |
| | | // }); |
| | | // } |
| | | //} |
| | | return Newtonsoft.Json.JsonConvert.DeserializeObject<ResponsePack> (responseString); |
| | | } catch (Exception ex) { |
| | | Console.WriteLine (ex.ToString ()); |
| | | revertObj = new ResponsePack () { StateCode = "Data exception" }; |
| | | return new ResponsePack () { StateCode = "Data exception" }; |
| | | } |
| | | } |
| | | else { |
| | | revertObj = new ResponsePack () { StateCode = ErrorCode.NetworkError }; |
| | | //if (methodType == API.Login && needTip) { |
| | | // Application.RunOnMainThread (() => { |
| | | // new Alert ("", Language.StringByID (R.MyInternationalizationString.FailureToDataBase), |
| | | // Language.StringByID (R.MyInternationalizationString.Close)).Show (); |
| | | // }); |
| | | //} else { |
| | | // if (needTip) |
| | | // FailureToServer (); |
| | | //} |
| | | } |
| | | return revertObj; |
| | | #endregion |
| | | } catch (Exception ex) { |
| | | Console.WriteLine (ex.Message); |
| | | return revertObj; |
| | | } finally { |
| | | //requesTime = requesTime.AddDays(1); |
| | | } |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <param name="methodType">请求方法.</param> |
| | | /// <param name="dataStringJson">请求的参数.</param> |
| | | /// <param name="needHeaders">是否需要包头.</param> |
| | | public static byte [] RequestHttpsReturnByte (string methodType, string dataStringJson, bool needHeaders = false, bool needTip2 = true, string urlHead = "") |
| | | public static byte [] RequestHttpsReturnByte (string methodType, string dataStringJson, bool needHeaders = false, string urlHead = "") |
| | | { |
| | | ResponsePack revertObj = null; |
| | | try { |
| | | if (!SystemRemote.checeInternet ()) { |
| | | Application.RunOnMainThread (() => { |
| | | MainPage.WiFiStatus = "CrabtreeAdd/WiFiUnlink.png"; |
| | | MainPage.Loading.Hide (); |
| | | }); |
| | | } |
| | | |
| | | |
| | | |
| | | |