Ejemplo n.º 1
0
        public ActionResult <string> GetSTSToken()
        {
            HttpResultModel ret = new HttpResultModel();

            ret.result = Result.SUCCESS;
            try
            {
                string content = HelperProvider.GetRequestContent(HttpContext);
                if (String.IsNullOrEmpty(content))
                {
                    ret.result    = Result.ERROR;
                    ret.errorCode = MainErrorModels.PARAMETER_ERROR;
                    ret.message   = "The request body is empty.";

                    Log.WriteErrorLog("v2:MainController::GetSTSToken", "请求参数为空。{0}", HelperProvider.GetHeader(HttpContext));
                    return(JsonConvert.SerializeObject(ret));
                }
                var requestBody = JsonConvert.DeserializeObject <STSTokenRequestBody>(content);

                ret.data = HelperProvider.GetToken(requestBody.userId, requestBody.region);
            }
            catch (Exception ex)
            {
                ret.result    = Result.ERROR;
                ret.errorCode = MainErrorModels.LOGIC_ERROR;
                ret.message   = Convert.ToString(MainErrorModels.LOGIC_ERROR);

                Log.WriteErrorLog("v2::MainController::GetSTSToken", "异常:{0}", ex.Message);
            }
            return(JsonConvert.SerializeObject(ret));
        }
Ejemplo n.º 2
0
        public ActionResult <string> GetSTSTokenV2(int userId, string region)
        {
            HttpResultModel ret = new HttpResultModel();

            ret.result = Result.SUCCESS;
            try
            {
                ret.data = HelperProvider.GetToken(userId, region);
            }
            catch (Exception ex)
            {
                ret.result    = Result.ERROR;
                ret.errorCode = MainErrorModels.LOGIC_ERROR;
                ret.message   = Convert.ToString(MainErrorModels.LOGIC_ERROR);

                Log.WriteErrorLog("MainController::GetSTSToken", "异常:{0}", ex.Message);
            }
            return(JsonConvert.SerializeObject(ret));
        }