Esempio n. 1
0
        // Token: 0x06000088 RID: 136 RVA: 0x000029E4 File Offset: 0x00000BE4
        public SDKCommonResp Cancel(string taskUri)
        {
            SDKCommonResp sdkcommonResp = new SDKCommonResp();
            string        text          = RestClientUtil.sendRequest("POST", taskUri + "/cancel", null, this.bean, "Cancel");

            TaskResource.log.Info("Cancel result : " + text);
            return(JsonConvert.DeserializeObject <SDKCommonResp>(text));
        }
Esempio n. 2
0
        // Token: 0x06000390 RID: 912 RVA: 0x00007930 File Offset: 0x00005B30
        public SDKCommonResp ResetPassword(ResetPasswordReq req)
        {
            SDKCommonResp sdkcommonResp = new SDKCommonResp();
            string        text          = RestClientUtil.sendRequest("POST", "/service/users/password/reset", req, this.bean, "ResetPassword");

            UserResource.log.Info("ResetPassword result : " + text);
            return(JsonConvert.DeserializeObject <SDKCommonResp>(text));
        }
        // Token: 0x0600030C RID: 780 RVA: 0x00006C00 File Offset: 0x00004E00
        public SDKCommonResp Logout()
        {
            SDKCommonResp sdkcommonResp = new SDKCommonResp();
            string        text          = RestClientUtil.sendRequest("DELETE", "/service/session", null, this.bean, "Logout");

            AuthenticateResource.log.Info("Logout result : " + text);
            return(JsonConvert.DeserializeObject <SDKCommonResp>(text));
        }
Esempio n. 4
0
        // Token: 0x0600038E RID: 910 RVA: 0x0000787C File Offset: 0x00005A7C
        public SDKCommonResp SetUserRoles(string userId, SetUserRolesReq req)
        {
            SDKCommonResp sdkcommonResp = new SDKCommonResp();
            string        text          = RestClientUtil.sendRequest("POST", "/service/users/" + userId + "/setRoles", req, this.bean, "SetUserRoles");

            UserResource.log.Info("SetUserRoles result : " + text);
            return(JsonConvert.DeserializeObject <SDKCommonResp>(text));
        }
Esempio n. 5
0
        // Token: 0x06000394 RID: 916 RVA: 0x00007AEC File Offset: 0x00005CEC
        public SDKCommonResp ModifyRole(ModifyRoleReq req)
        {
            SDKCommonResp sdkcommonResp = new SDKCommonResp();
            string        text          = RestClientUtil.sendRequest("POST", "/service/roles/mod", req, this.bean, "ModifyRole");

            UserResource.log.Info("ModifyRole result : " + text);
            return(JsonConvert.DeserializeObject <SDKCommonResp>(text));
        }
Esempio n. 6
0
        // Token: 0x06000391 RID: 913 RVA: 0x00007984 File Offset: 0x00005B84
        public SDKCommonResp RemoveUser(string userId)
        {
            SDKCommonResp sdkcommonResp = new SDKCommonResp();
            string        text          = RestClientUtil.sendRequest("DELETE", "/service/users/" + userId, null, this.bean, "RemoveUser");

            UserResource.log.Info("RemoveUser result : " + text);
            return(JsonConvert.DeserializeObject <SDKCommonResp>(text));
        }
Esempio n. 7
0
        // Token: 0x06000395 RID: 917 RVA: 0x00007B40 File Offset: 0x00005D40
        public SDKCommonResp RemoveRole(string roleName)
        {
            SDKCommonResp sdkcommonResp = new SDKCommonResp();
            string        text          = RestClientUtil.sendRequest("POST", "/service/roles/rmv", new RemoveRoleReq
            {
                roleName = roleName
            }, this.bean, "RemoveRole");

            UserResource.log.Info("RemoveRole result : " + text);
            return(JsonConvert.DeserializeObject <SDKCommonResp>(text));
        }
Esempio n. 8
0
        // Token: 0x060001DB RID: 475 RVA: 0x00005224 File Offset: 0x00003424
        public static string sendRequest(string methodType, string uri, object requestBody, ClientProviderBean bean, string methodName)
        {
            string result;

            if (!RestClientUtil.CheckParam(bean))
            {
                result = JsonConvert.SerializeObject(new SDKCommonResp
                {
                    errorCode = "2130000404"
                });
            }
            else
            {
                Uri uri2 = null;
                try
                {
                    uri2 = new Uri(bean.serverUrl + uri);
                    RestClientUtil.log.Info(methodName + " request Url :" + uri2);
                }
                catch (Exception ex)
                {
                    return(JsonConvert.SerializeObject(new SDKCommonResp
                    {
                        errorCode = "2130000404"
                    }));
                }
                if (bean.serverUrl.StartsWith("https"))
                {
                    ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(RestClientUtil.CheckValidationResult);
                }
                HttpWebRequest httpWebRequest = WebRequest.Create(uri2) as HttpWebRequest;
                httpWebRequest.Proxy       = null;
                httpWebRequest.Timeout     = 10000;
                httpWebRequest.Method      = methodType;
                httpWebRequest.ContentType = "application/json;charset=UTF-8";
                httpWebRequest.Accept      = "application/json;version=6.3;charset=UTF-8";
                httpWebRequest.Headers.Add("Accept-Language", "zh_CN");
                string taken = ClientCacheBean.getAuthToken(bean);

                httpWebRequest.Headers.Add("X-Auth-Token", taken);
                if ("POST".Equals(methodType) || "PUT".Equals(methodType))
                {
                    string text = JsonUtil.JsonSerializer(requestBody);
                    RestClientUtil.log.Info(methodName + " request Body :" + LogUtil.ReplayLog(text));
                    byte[] bytes = Encoding.UTF8.GetBytes(text);
                    try
                    {
                        using (Stream requestStream = httpWebRequest.GetRequestStream())
                        {
                            requestStream.Write(bytes, 0, bytes.Length);
                            requestStream.Flush();
                            requestStream.Close();
                        }
                    }
                    catch (Exception ex)
                    {
                        LogUtil.WriteLog(RestClientUtil.log, "error", string.Format("connect server exception, {0}", ex.ToString()));
                        return(JsonConvert.SerializeObject(new SDKCommonResp
                        {
                            errorCode = "2130000404"
                        }));
                    }
                }
                HttpWebResponse httpWebResponse = null;
                try
                {
                    httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse();
                }
                catch (WebException ex2)
                {
                    httpWebResponse = (HttpWebResponse)ex2.Response;
                }
                if (httpWebResponse == null || httpWebResponse.StatusCode == HttpStatusCode.NotFound)
                {
                    result = JsonConvert.SerializeObject(new SDKCommonResp
                    {
                        errorCode = "2130000404"
                    });
                }
                else
                {
                    string text2 = "";
                    using (StreamReader streamReader = new StreamReader(httpWebResponse.GetResponseStream(), Encoding.GetEncoding("UTF-8")))
                    {
                        text2 = streamReader.ReadToEnd();
                        streamReader.Close();
                    }
                    if (httpWebResponse.StatusCode == HttpStatusCode.OK && (string.IsNullOrEmpty(text2) || "{}".Equals(text2)))
                    {
                        SDKCommonResp sdkcommonResp = new SDKCommonResp();
                        text2 = JsonConvert.SerializeObject(sdkcommonResp);
                    }
                    result = text2;
                }
            }
            return(result);
        }