public ActionResult <string> GetUserDebitAttention(int userId) { HttpResultModel ret = new HttpResultModel(); ret.result = Result.SUCCESS; try { ///逻辑 DataProviderResultModel result = DebitProvider.GetUserDebitAttention(userId); if (result.result == Result.SUCCESS) { ret.data = result.data; } else { ret.result = result.result; ret.message = result.message; } } catch (Exception ex) { ret.result = Result.ERROR; ret.errorCode = MainErrorModels.LOGIC_ERROR; ret.message = Convert.ToString(MainErrorModels.LOGIC_ERROR); Log.WriteErrorLog("MainController::GetUserDebitAttention", "异常:{0}", ex.Message); } return(JsonConvert.SerializeObject(ret)); }
/// <summary> /// 获取某条贷款记录 /// </summary> /// <param name="debitId"></param> /// <returns></returns> public ActionResult <string> GetUserExtendInfo(int debitId) { HttpResultModel ret = new HttpResultModel(); ret.result = Result.SUCCESS; try { ///逻辑 DataProviderResultModel result = DebitProvider.GetUserExtendRecord(debitId); if (result.result == Result.SUCCESS) { ret.data = result.data; } else { ret.result = result.result; ret.message = result.message; } } catch (Exception ex) { ret.result = Result.ERROR; ret.errorCode = MainErrorModels.LOGIC_ERROR; ret.message = "The program logic error from the DebitController::GetUserDebitRecord function."; Log.WriteErrorLog("DebitController::GetUserDebitRecord", "异常:{0}", ex.Message); } return(JsonConvert.SerializeObject(ret)); }
/// <summary> /// 获取用户凭证 /// </summary> /// <param name="userId">用户ID</param> /// <param name="certType">凭证类型</param> /// <param name="objId">相关id</param> /// <returns></returns> public ActionResult <string> PostCertificate(int userId, int certType, int objId, string url) { HttpResultModel ret = new HttpResultModel(); ret.result = Result.SUCCESS; try { ///逻辑 List <string> list = new List <string>(); list.Add("http://storage.baomihua.com/h5/apptg/timg.jpg"); list.Add("http://storage.baomihua.com/h5/apptg/timg.jpg"); list.Add("http://storage.baomihua.com/h5/apptg/timg.jpg"); list.Add("http://storage.baomihua.com/h5/apptg/timg.jpg"); ret.data = list; } catch (Exception ex) { ret.result = Result.ERROR; ret.errorCode = MainErrorModels.LOGIC_ERROR; ret.message = Convert.ToString(MainErrorModels.LOGIC_ERROR); Log.WriteErrorLog("MainController::PostCertificate", "异常:{0}", ex.Message); } return(JsonConvert.SerializeObject(ret)); }
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)); }
public ActionResult <string> GetNotices() { HttpResultModel ret = new HttpResultModel(); ret.result = Result.SUCCESS; try { DataProviderResultModel result = MainInfoProvider.GetNotices(); if (result.result == Result.SUCCESS) { ret.data = result.data; } else { ret.result = result.result; ret.message = result.message; } } catch (Exception ex) { ret.result = Result.ERROR; ret.errorCode = MainErrorModels.LOGIC_ERROR; ret.message = Convert.ToString(MainErrorModels.LOGIC_ERROR); Log.WriteErrorLog("v2::MainController::GetNotice", "异常:{0}", ex.Message); } return(JsonConvert.SerializeObject(ret)); }
public async Task <HttpResultModel <CommandsModel> > PerformResponseUptime(CommandsReadModel commandsReadModel) { var resultCommandResponse = new HttpResultModel <CommandsModel>(); var resultStreamInfo = await GetStreamInformations(); if (resultStreamInfo.Result && resultStreamInfo.Model.Stream != null) { var stream = resultStreamInfo.Model.Stream; var nowEuw = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTime.Now, TZConvert.WindowsToIana("Romance Standard Time")); var createdAtEuw = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(Convert.ToDateTime(stream.Created_at), TZConvert.WindowsToIana("Romance Standard Time")); var timeStampDiff = nowEuw - createdAtEuw; var message = $"{timeStampDiff.Hours}h:{timeStampDiff.Minutes}m:{timeStampDiff.Seconds}s"; var model = new CommandsModel() { Response = commandsReadModel.Response.Replace("{uptime}", message) }; resultCommandResponse.PerformResult(true, "", _localizer["Uptime calculé."], model); return(resultCommandResponse); } else { resultCommandResponse.PerformResult(false, _localizer["Impossible de calculer l'uptime."], "", null); return(resultCommandResponse); } }
/// <summary> /// 获取贷款种类 /// </summary> /// <returns></returns> public ActionResult <string> GetInitDebitStyle() { HttpResultModel ret = new HttpResultModel(); ret.result = Result.SUCCESS; try { ret.data = new { debitStyle = new List <float> { 2000000.00f }, debitPeriod = new List <int> { 7 } }; } catch (Exception ex) { ret.result = Result.ERROR; ret.errorCode = MainErrorModels.LOGIC_ERROR; ret.message = Convert.ToString(MainErrorModels.LOGIC_ERROR); Log.WriteErrorLog("MainController::GetInitDebitStyle", "异常:{0}", ex.Message); } return(JsonConvert.SerializeObject(ret)); }
public async Task <ActionResult <HttpResultModel> > GetAll() { HttpResultModel httpResult = new HttpResultModel(); try { VRTSoapService.vrtserviceRD3SoapClient service = new VRTSoapService.vrtserviceRD3SoapClient(); ChannelFactory <VRTSoapService.vrtserviceRD3Soap> channelFactory = service.ChannelFactory; VRTSoapService.vrtserviceRD3Soap channel = channelFactory.CreateChannel(); VRTSoapService.ServiceRequest serviceRequest = new VRTSoapService.ServiceRequest { Body = new VRTSoapService.ServiceRequestBody { username = soapUsername, password = soapPassword, ShopName = "", BusinessTypeCode = "", ProvinceCode = 0, StreetCode = 0 } }; VRTSoapService.ServiceResponse responseMessage = await channel.ServiceAsync(serviceRequest); VRTSoapService.vrt soapResult = responseMessage?.Body?.ServiceResult; List <VRT> listVRT = new List <VRT>(); if (soapResult != null) { int countRecord = soapResult.vShopName.Count(); for (int index = 0; index < countRecord; index++) { VRT vrtModel = new VRT { vShopName = soapResult.vShopName[index]?.ToString(), vBusinessTypeName = soapResult.vBusinessTypeName[index]?.ToString(), vBusinessName = soapResult.vBusinessName[index]?.ToString(), vHouseNumber = soapResult.vHouseNumber[index]?.ToString(), vStreetName = soapResult.vStreetName[index]?.ToString(), vThambolName = soapResult.vThambolName[index]?.ToString(), vAmphurName = soapResult.vAmphurName[index]?.ToString(), vProvinceName = soapResult.vProvinceName[index]?.ToString(), vPostCode = soapResult.vPostCode[index]?.ToString(), vmsgerr = soapResult.vmsgerr.Count() > 0 ? soapResult.vmsgerr[index]?.ToString() : null, }; listVRT.Add(vrtModel); } } httpResult.SetPropertyHttpResult(httpResult, true, "", "", StatusCodes.Status200OK, listVRT); } catch (Exception ex) { httpResult.SetPropertyHttpResult(httpResult, false, "", ex.Message, StatusCodes.Status500InternalServerError); } return(httpResult); }
public ActionResult <string> GetUserDebitRecordDetail() { HttpResultModel ret = new HttpResultModel(); ret.result = Result.SUCCESS; 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:DebitController::SubmitDebitRequest", "请求参数为空。{0}", HelperProvider.GetHeader(HttpContext)); return(JsonConvert.SerializeObject(ret)); } try { var requestBody = JsonConvert.DeserializeObject <DebitInfoRequestBody>(content); DebitRecordLogResponse response = new DebitRecordLogResponse(); DataProviderResultModel result = DebitProvider.GetUserDebitRecord(requestBody.debitId); if (result.result == Result.SUCCESS) { response.debitInfo = result.data as DebitInfoModel; result = DebitProvider.GetUserDebitRecordLogs(requestBody.debitId); if (result.result == Result.SUCCESS) { response.logs = result.data as List <DebitRecordLogModel>; ret.data = response; ret.result = Result.SUCCESS; } else { ret.result = result.result; ret.message = result.message; } } else { ret.result = result.result; ret.message = result.message; } } catch (Exception ex) { ret.result = Result.ERROR; ret.errorCode = MainErrorModels.LOGIC_ERROR; ret.message = "The program logic error from the DebitController::GetUserDebitRecordDetail function."; Log.WriteErrorLog("v2::DebitController::GetUserDebitRecordDetail", "异常:{0}", ex.Message); } return(JsonConvert.SerializeObject(ret)); }
public override async Task OnAuthorizationAsync(AuthorizationFilterContext filterContext) { string path = filterContext.HttpContext.Request.QueryString.ToString(); var list = filterContext.ActionDescriptor.FilterDescriptors.Where(p => ((FilterDescriptor)p).Filter.GetType() == typeof(AllowAnonymousFilter)); if (list.Count() == 1 || path.ToLower().IndexOf("isdebug") > -1) { return; } string token = filterContext.HttpContext.Request.Headers["token"]; string userId = filterContext.HttpContext.Request.Headers["userId"]; string qudao = filterContext.HttpContext.Request.Headers["qudao"]; string version = filterContext.HttpContext.Request.Headers["version"]; string pkgName = filterContext.HttpContext.Request.Headers["pkgName"]; if (String.IsNullOrEmpty(token)) { HttpResultModel ret = new HttpResultModel { result = MainErrorModels.THE_TOKEN_VALIDATION_FAILED, message = "Token validation failed." }; //var response = new System.Net.Http.HttpResponseMessage(System.Net.HttpStatusCode.OK); var content = new ContentResult(); content.Content = JsonConvert.SerializeObject(ret); content.StatusCode = 200; filterContext.Result = content; Log.WriteWarning("CustomActionFilter::OnActionExecuting", "{0} {1} {2} {3} version:{4}", token, userId, qudao, ret.message, version); } else { Redis redis = HelperProvider.GetRedis(); string guid = redis.StringGet(String.Format("user_guid_{0}", userId)); string ctoken = HelperProvider.MD5Encrypt32(String.Format("{0}{1}", userId, guid)); if (ctoken != token) { HttpResultModel ret = new HttpResultModel { result = MainErrorModels.THE_TOKEN_VALIDATION_FAILED, message = "Token validation failed." }; var content = new ContentResult(); content.Content = JsonConvert.SerializeObject(ret); content.StatusCode = 200; filterContext.Result = content; Log.WriteDebugLog("CustomActionFilter::OnActionExecuting", "{0} {1} {2} {3} version:{4}", token, userId, qudao, ctoken, version); } } //await base.OnAuthorizationAsync(filterContext); }
public async Task <ActionResult <HttpResultModel> > GetById(string tIN) { HttpResultModel httpResult = new HttpResultModel(); try { if (!string.IsNullOrEmpty(tIN)) { TINSoapService.checktinpinserviceSoapClient service = new TINSoapService.checktinpinserviceSoapClient(); ChannelFactory <TINSoapService.checktinpinserviceSoap> channelFactory = service.ChannelFactory; TINSoapService.checktinpinserviceSoap channel = channelFactory.CreateChannel(); TINSoapService.ServiceTINRequest serviceRequest = new TINSoapService.ServiceTINRequest { Body = new TINSoapService.ServiceTINRequestBody { username = soapUsername, password = soapPassword, TIN = tIN, } }; TINSoapService.ServiceTINResponse responseMessage = await channel.ServiceTINAsync(serviceRequest); object soapResult = responseMessage?.Body?.ServiceTINResult; JObject jObject = JObject.Parse(soapResult?.ToString()); TINResult tINResult = new TINResult { ID = ((JValue)((JContainer)jObject[nameof(TINResult.ID)]).First)?.Value?.ToString(), MessageErr = ((JValue)((JContainer)jObject[nameof(TINResult.MessageErr)]).First)?.Value?.ToString(), DigitOk = ((JValue)((JContainer)jObject[nameof(TINResult.DigitOk)]).First)?.Value?.ToString(), IsExist = ((JValue)((JContainer)jObject[nameof(TINResult.IsExist)]).First)?.Value?.ToString(), vID = ((JValue)((JContainer)jObject[nameof(TINResult.vID)]).First)?.Value?.ToString(), vMessageErr = ((JValue)((JContainer)jObject[nameof(TINResult.vMessageErr)]).First)?.Value?.ToString(), vDigitOk = ((JValue)((JContainer)jObject[nameof(TINResult.vDigitOk)]).First)?.Value?.ToString(), vIsExist = ((JValue)((JContainer)jObject[nameof(TINResult.vIsExist)]).First)?.Value?.ToString() }; httpResult.SetPropertyHttpResult(httpResult, true, "", "", StatusCodes.Status200OK, tINResult); } else { httpResult.SetPropertyHttpResult(httpResult, true, "", "", StatusCodes.Status400BadRequest); } } catch (Exception ex) { httpResult.SetPropertyHttpResult(httpResult, false, "", ex.Message, StatusCodes.Status500InternalServerError); } return(httpResult); }
private HttpResultModel <CommandsModel> PerformResponseModel(CommandsReadModel commandsReadModel) { var resultCommandResponse = new HttpResultModel <CommandsModel>(); var commandsModel = new CommandsModel() { Response = commandsReadModel.Response }; resultCommandResponse.PerformResult(true, "", _localizer["Réponse trouvée."], commandsModel); return(resultCommandResponse); }
public async Task <ActionResult <HttpResultModel> > GetById(string tIN) { HttpResultModel httpResult = new HttpResultModel(); try { if (!string.IsNullOrWhiteSpace(tIN)) { VATSoapService.vatserviceRD3SoapClient service = new VATSoapService.vatserviceRD3SoapClient(); ChannelFactory <VATSoapService.vatserviceRD3Soap> channelFactory = service.ChannelFactory; // Must set certificates before CreateChannel() //string certificatepath1 = @"C:\Users\Me\source\repos\RevenueService\RevenueService.Api\Resources\adhq1.cer"; //string certificatepath2 = @"C:\Users\Me\source\repos\RevenueService\RevenueService.Api\Resources\ADHQ5.cer"; //X509Certificate2 certificate1 = new X509Certificate2(System.IO.File.ReadAllBytes(certificatepath1)); //X509Certificate2 certificate2 = new X509Certificate2(System.IO.File.ReadAllBytes(certificatepath2)); //channelFactory.Credentials.ClientCertificate.Certificate = certificate1; //channelFactory.Credentials.ServiceCertificate.DefaultCertificate = certificate2; VATSoapService.vatserviceRD3Soap channel = channelFactory.CreateChannel(); VATSoapService.ServiceRequest serviceRequest = new VATSoapService.ServiceRequest { Body = new VATSoapService.ServiceRequestBody { username = soapUsername, password = soapPassword, TIN = tIN, Name = "", ProvinceCode = 0, BranchNumber = 0, AmphurCode = 0, } }; VATSoapService.ServiceResponse responseMessage = await channel.ServiceAsync(serviceRequest); VATSoapService.vat soapResult = responseMessage?.Body.ServiceResult; Model.VAT vat = new Model.VAT(soapResult); httpResult.SetPropertyHttpResult(httpResult, true, "", "", StatusCodes.Status200OK, vat); } else { httpResult.SetPropertyHttpResult(httpResult, true, "", "", StatusCodes.Status400BadRequest); } } catch (Exception ex) { httpResult.SetPropertyHttpResult(httpResult, false, "", ex.Message, StatusCodes.Status500InternalServerError); } return(httpResult); }
public async Task <HttpResultModel> PostAsync() { HandleConfig(); HttpContent httpContent = null; if (ParamsType == ParamsType.Json) { httpContent = new StringContent(JsonConvert.SerializeObject(Data), Encoding.UTF8, "application/json"); if (!string.IsNullOrEmpty(JsonStr)) { httpContent = new StringContent(JsonStr, Encoding.UTF8, "application/json"); } } else if (ParamsType == ParamsType.FormData) { var data = new MultipartFormDataContent(); //表单数据 if (Data != null && Data.Count > 0) { foreach (var item in Data) { data.Add(new StringContent(item.Value), item.Key); } } //文件数据 if (Files != null && Files.Count > 0) { foreach (var item in Files) { var fileInfo = new FileInfo(item.Value); data.Add(new ByteArrayContent(File.ReadAllBytes(item.Value)), item.Key, fileInfo.Name); } } httpContent = data; } var response = await httpClient.PostAsync(Url, httpContent); var contentBytes = await response.Content.ReadAsByteArrayAsync(); var content = Encoding.Default.GetString(contentBytes, 0, contentBytes.Length); //var content = await response.Content.ReadAsStringAsync(); var result = new HttpResultModel() { IsSuccess = true, Content = content, StatusCode = (int)response.StatusCode }; return(result); }
/// <summary> /// 发送一个GET请求并获取返回内容 /// </summary> /// <returns></returns> public async Task <HttpResultModel> GetAsync() { HandleConfig(); var response = await httpClient.GetAsync(Url); //var content = await response.Content.ReadAsStringAsync(); var contentBytes = await response.Content.ReadAsByteArrayAsync(); var content = Encoding.Default.GetString(contentBytes, 0, contentBytes.Length - 1); var result = new HttpResultModel() { IsSuccess = true, Content = content, StatusCode = (int)response.StatusCode }; return(result); }
/// <summary> /// 获取用户的贷款记录 /// </summary> /// <param name="userId"></param> /// <returns></returns> public ActionResult <string> GetUserDebitRecords() { HttpResultModel ret = new HttpResultModel(); ret.result = Result.SUCCESS; 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:DebitController::SubmitDebitRequest", "请求参数为空。{0}", HelperProvider.GetHeader(HttpContext)); return(JsonConvert.SerializeObject(ret)); } try { var requestBody = JsonConvert.DeserializeObject <DebitRecordsRequestBody>(content); ///逻辑 DataProviderResultModel result = DebitProvider.GetUserDebitRecords(requestBody); if (result.result == Result.SUCCESS) { ret.data = result.data; } else { ret.result = result.result; ret.message = result.message; } } catch (Exception ex) { ret.result = Result.ERROR; ret.errorCode = MainErrorModels.LOGIC_ERROR; ret.message = "The program logic error from the DebitController::GetUserDebitRecords function."; Log.WriteErrorLog("v2::DebitController::GetUserDebitRecords", "UserId:{0},异常:{1}", content, ex.Message); } return(JsonConvert.SerializeObject(ret)); }
public ActionResult <string> GetUserDebitAttention() { 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::GetUserDebitAttention", "请求参数为空。{0}", HelperProvider.GetHeader(HttpContext)); return(JsonConvert.SerializeObject(ret)); } var requestBody = JsonConvert.DeserializeObject <UserInfoRequestBody>(content); int iUserId = 0; int.TryParse(requestBody.userId, out iUserId); ///逻辑 DataProviderResultModel result = DebitProvider.GetUserDebitAttention(iUserId); if (result.result == Result.SUCCESS) { ret.data = result.data; } else { ret.result = result.result; ret.message = result.message; } } catch (Exception ex) { ret.result = Result.ERROR; ret.errorCode = MainErrorModels.LOGIC_ERROR; ret.message = Convert.ToString(MainErrorModels.LOGIC_ERROR); Log.WriteErrorLog("v2::MainController::GetUserDebitAttention", "异常:{0}", ex.Message); } return(JsonConvert.SerializeObject(ret)); }
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)); }
/// <summary> /// 获取贷款种类 /// </summary> /// <returns></returns> public ActionResult <string> GetBankCodes() { HttpResultModel ret = new HttpResultModel(); ret.result = Result.SUCCESS; try { Redis redis = HelperProvider.GetRedis(); string key = "BankCodes"; string retJson = redis.StringGet(key); if (String.IsNullOrEmpty(retJson)) { DataProviderResultModel result = MainInfoProvider.GetBankCodes(); if (result.result == Result.SUCCESS) { ret.data = result.data; } else { ret.result = Result.ERROR; ret.errorCode = result.result; ret.message = result.message; } redis.StringSet(key, JsonConvert.SerializeObject(ret), 300); } else { return(retJson); } } catch (Exception ex) { ret.result = Result.ERROR; ret.errorCode = MainErrorModels.LOGIC_ERROR; ret.message = Convert.ToString(MainErrorModels.LOGIC_ERROR); Log.WriteErrorLog("MainController::GetBankCodes", "异常:{0}", ex.Message); } return(JsonConvert.SerializeObject(ret)); }
public ActionResult <string> GetNotices() { HttpResultModel ret = new HttpResultModel(); ret.result = Result.SUCCESS; try { string pkgName = HttpContext.Request.Headers["pkgName"]; if (String.IsNullOrEmpty(pkgName)) { List <NoticeModel> infos = new List <NoticeModel>(); NoticeModel info = new NoticeModel(); info.title = "Warning"; info.content = "Anda masih menggunakan aplikasi versi lama, silahkan klik https://play.google.com/store/apps/details?id=com.danapinjam.vip untuk mengunduh versi terbaru."; infos.Add(info); ret.data = infos; } else { ///逻辑 DataProviderResultModel result = MainInfoProvider.GetNotices(); if (result.result == Result.SUCCESS) { ret.data = result.data; } else { ret.result = result.result; ret.message = result.message; } } } catch (Exception ex) { ret.result = Result.ERROR; ret.errorCode = MainErrorModels.LOGIC_ERROR; ret.message = Convert.ToString(MainErrorModels.LOGIC_ERROR); Log.WriteErrorLog("MainController::GetNotice", "异常:{0}", ex.Message); } return(JsonConvert.SerializeObject(ret)); }
public ActionResult <string> GetSelection() { List <SelectionModel> list = new List <SelectionModel>(); HttpResultModel ret = new HttpResultModel(); ret.result = Result.SUCCESS; try { ret.data = MainInfoProvider.GetSelection(); } catch (Exception ex) { ret.result = Result.ERROR; ret.errorCode = MainErrorModels.LOGIC_ERROR; ret.message = Convert.ToString(MainErrorModels.LOGIC_ERROR); Log.WriteErrorLog("MainController::GetSelection", "异常:{0}", ex.Message); } return(JsonConvert.SerializeObject(ret)); }
/// <summary> /// /// </summary> /// <param name="userId"></param> /// <param name="debitId"></param> /// <param name="payBackDebitMoney"></param> /// <param name="certificateUrl"></param> /// <returns></returns> public ActionResult <string> SubmitExtendDebitRequest(int userId, int debitId, float payBackDebitMoney, string certificateUrl = "") { HttpResultModel ret = new HttpResultModel(); ret.result = Result.SUCCESS; Redis redis = HelperProvider.GetRedis(); try { string lockKey = "submitExtend"; if (redis.LockTake(lockKey, userId)) { ///逻辑 DataProviderResultModel result = DebitProvider.ExtendDebitRequest(userId, debitId, payBackDebitMoney, certificateUrl); ret.result = result.result; if (result.result != Result.SUCCESS) { ret.result = Result.ERROR; ret.errorCode = result.result; ret.message = result.message; } redis.LockRelease(lockKey, userId); } else { ret.result = Result.ERROR; ret.errorCode = MainErrorModels.ALREADY_SUBMIT_REQUEST; ret.message = "already submit request."; } } catch (Exception ex) { ret.result = Result.ERROR; ret.errorCode = MainErrorModels.LOGIC_ERROR; ret.message = Convert.ToString(MainErrorModels.LOGIC_ERROR); Log.WriteErrorLog("DebitController::SubmitExtendDebitRequest", "异常:{0}", ex.Message); } return(JsonConvert.SerializeObject(ret)); }
public async Task <HttpResultModel <CommandsModel> > PerformResponseSpotify(CommandsReadModel commandsReadModel, int spotifyType) { var resultCommandResponse = new HttpResultModel <CommandsModel>(); var resultSpotifyCurrentlyPlaying = await SpotifyCurrentlyPlaing(); if (resultSpotifyCurrentlyPlaying.Result) { var model = new CommandsModel(); if (resultSpotifyCurrentlyPlaying.Model != null && resultSpotifyCurrentlyPlaying.Model.IsPlaying) { if (spotifyType == (int)SpotifyTypeEnum.MUSIC) { model.Response = commandsReadModel.Response.Replace("{music}", resultSpotifyCurrentlyPlaying.Model.Item.Name).Replace("{artist}", resultSpotifyCurrentlyPlaying.Model.Item.Artists[0].Name); } else if (spotifyType == (int)SpotifyTypeEnum.PLAYLIST) { if (resultSpotifyCurrentlyPlaying.Model.Context != null && resultSpotifyCurrentlyPlaying.Model.Context.ExternalUrls.Spotify != string.Empty) { model.Response = commandsReadModel.Response.Replace("{playlist}", resultSpotifyCurrentlyPlaying.Model.Context.ExternalUrls.Spotify); } else { model.Response = _localizer["Pas de playlist associée au titre en cours."]; } } } else { model.Response = _localizer["Pas d'écoute Spotify en cours."]; } resultCommandResponse.PerformResult(true, "", _localizer["Commande music récupérée."], model); return(resultCommandResponse); } else { resultCommandResponse.PerformResult(false, _localizer["Impossible de récupérer les infos de la musique Spotify."], "", null); return(resultCommandResponse); } }
public ActionResult <string> GetUserCertificate(int objectId, int userId, int certificateType) { HttpResultModel ret = new HttpResultModel(); ret.result = Result.SUCCESS; try { ///逻辑 ret.data = UserProvider.GetUserCertificate(objectId, userId); } catch (Exception ex) { ret.result = Result.ERROR; ret.errorCode = MainErrorModels.LOGIC_ERROR; ret.message = Convert.ToString(MainErrorModels.LOGIC_ERROR); Log.WriteErrorLog("DebitController::GetUserCertificate", "异常:{0}", ex.Message); } return(JsonConvert.SerializeObject(ret)); }
public async Task <HttpResultModel> ExecuteHttp(HttpServiceOptions httpServiceOptions) { var successCodes = httpServiceOptions.HttpSuccessCode.Split(";").Select(a => int.Parse(a)); var httpResult = new HttpResultModel(); HttpResponseMessage response = null; switch (httpServiceOptions.HttpMethod) { case "Get": response = await _httpClient.GetAsync(httpServiceOptions.HttpServiceUrl); break; case "Post": using (var stringContent = new StringContent(httpServiceOptions.JsonBody, Encoding.UTF8)) { response = await _httpClient.PostAsync(httpServiceOptions.HttpServiceUrl, stringContent); } break; case "Put": using (var stringContent = new StringContent(httpServiceOptions.JsonBody, Encoding.UTF8)) { response = await _httpClient.PutAsync(httpServiceOptions.HttpServiceUrl, stringContent); } break; case "Delete": response = await _httpClient.DeleteAsync(httpServiceOptions.HttpServiceUrl); break; } if (successCodes.Any(a => a == (int)response.StatusCode)) { httpResult.IsSuccess = true; httpResult.Result = await response.Content.ReadAsJsonAsync <dynamic>(); } return(httpResult); }
public ActionResult <string> PublishVersion(int version, int isMust) { HttpResultModel ret = new HttpResultModel(); ret.result = Result.SUCCESS; try { Redis redis = HelperProvider.GetRedis(); string result = Convert.ToString(redis.StringSet("appVersion", version)); result += Convert.ToString(redis.StringSet("updateIsMust", isMust)); ret.data = result; } catch (Exception ex) { ret.result = Result.ERROR; ret.errorCode = MainErrorModels.LOGIC_ERROR; ret.message = Convert.ToString(MainErrorModels.LOGIC_ERROR); Log.WriteErrorLog("MainController::GetCertificate", "异常:{0}", ex.Message); } return(JsonConvert.SerializeObject(ret)); }
public async Task <HttpResultModel <CommandsModel> > GetCommandResponse(CommandsReadModel commandsReadModel) { var result = new HttpResultModel <CommandsModel>(); _logger.LogInformation("Command type id : {0}", commandsReadModel.TypeId); switch (commandsReadModel.TypeId) { case (int)CommandsType.Automatic: case (int)CommandsType.Response: result = PerformResponseModel(commandsReadModel); break; case (int)CommandsType.Mystery: break; case (int)CommandsType.Playlist: result = await _spotifyBusiness.PerformResponseSpotify(commandsReadModel, (int)SpotifyTypeEnum.PLAYLIST); break; case (int)CommandsType.Spotify: result = await _spotifyBusiness.PerformResponseSpotify(commandsReadModel, (int)SpotifyTypeEnum.MUSIC); break; case (int)CommandsType.Uptime: result = await _uptimeBusiness.PerformResponseUptime(commandsReadModel); break; default: break; } return(result); }
public ActionResult <string> Test(string phone) { HttpResultModel ret = new HttpResultModel(); ret.data = new SubmitDebitRequestBody(); /* * //Redis redis = HelperProvider.GetRedis(); * ret.result = Result.SUCCESS; * try * { * WaveCellSMSSingleSender.Authorization = ConfigSettings.WaveCellSMSAuthorization; * WaveCellSMSSingleSender.SubAccountName = ConfigSettings.WaveCellSMSAccountName; * WaveCellSMSSingleSender waveCellSMSSender = new WaveCellSMSSingleSender(); * * //if (String.IsNullOrEmpty(redis.StringGet(String.Format("attention_{0}", phone)))) * { * phone = "+62" + phone; * string msg = "Anda masih menggunakan aplikasi versi lama, silahkan klik https://play.google.com/store/apps/details?id=com.danapinjam.vip untuk mengunduh versi terbaru."; * WaveCellSMSResponseModels sendRet = waveCellSMSSender.Send(phone, msg); * ret.data = sendRet; * // redis.StringSet(String.Format("attention_{0}", phone), "1"); * } * * } * catch (Exception ex) * { * ret.result = Result.ERROR; * ret.errorCode = MainErrorModels.LOGIC_ERROR; * ret.message = Convert.ToString(MainErrorModels.LOGIC_ERROR); * * Log.WriteErrorLog("MainController::Test", "异常:{0}", ex.Message); * } */ return(JsonConvert.SerializeObject(ret)); }
public async Task <ActionResult <HttpResultModel> > Get([FromBody] Model.GEM model) { HttpResultModel httpResult = new HttpResultModel(); try { GEMSoapService.gemserviceRD3SoapClient service = new GEMSoapService.gemserviceRD3SoapClient(); ChannelFactory <GEMSoapService.gemserviceRD3Soap> channelFactory = service.ChannelFactory; GEMSoapService.gemserviceRD3Soap channel = channelFactory.CreateChannel(); GEMSoapService.ServiceRequest serviceRequest = new GEMSoapService.ServiceRequest { Body = new GEMSoapService.ServiceRequestBody { username = soapUsername, password = soapPassword, TIN = model.vTaxPayerID, ProvinceCode = Convert.ToInt32(model.vProvinceCode), GuildName = model.vGuildName, VATTaxPayerName = model.vVATTaxPayerName } }; GEMSoapService.ServiceResponse responseMessage = await channel.ServiceAsync(serviceRequest); GEMSoapService.gems soapResult = responseMessage?.Body.ServiceResult; Model.GEM gemModel = new Model.GEM(soapResult); // TODO: ตรงนี้ไม่มีตัวอย่างข้อมูลสำหรับทดสอบ หากต้องการใช้งานจะต้องพัฒนาต่อเอง httpResult.SetPropertyHttpResult(httpResult, true, "", "", StatusCodes.Status200OK, gemModel); } catch (Exception ex) { httpResult.SetPropertyHttpResult(httpResult, false, "API Error", ex.Message, StatusCodes.Status500InternalServerError); } return(Ok(httpResult)); }
public async Task <ActionResult <HttpResultModel> > Get([FromBody] Model.VAT model) { HttpResultModel httpResult = new HttpResultModel(); try { VATSoapService.vatserviceRD3SoapClient service = new VATSoapService.vatserviceRD3SoapClient(); ChannelFactory <VATSoapService.vatserviceRD3Soap> channelFactory = service.ChannelFactory; VATSoapService.vatserviceRD3Soap channel = channelFactory.CreateChannel(); VATSoapService.ServiceRequest serviceRequest = new VATSoapService.ServiceRequest { Body = new VATSoapService.ServiceRequestBody { username = soapUsername, password = soapPassword, TIN = model.vtin, Name = model.vName, ProvinceCode = Convert.ToInt32(model.vProvince), BranchNumber = Convert.ToInt32(model.vBranchNumber), AmphurCode = Convert.ToInt32(model.vAmphur), } }; VATSoapService.ServiceResponse responseMessage = await channel.ServiceAsync(serviceRequest); VATSoapService.vat soapResult = responseMessage?.Body.ServiceResult; Model.VAT vatModel = new Model.VAT(soapResult); httpResult.SetPropertyHttpResult(httpResult, true, "", "", StatusCodes.Status200OK, vatModel); } catch (Exception ex) { httpResult.SetPropertyHttpResult(httpResult, false, "API Error", ex.Message, StatusCodes.Status500InternalServerError); } return(Ok(httpResult)); }
public HttpResultModel TestObject() { var result = new HttpResultModel(); result.Status = 0; result.Message = "success"; return result; }