/// <summary> /// 执行请求并返回结果 /// </summary> /// <returns></returns> public async Task <OssResult <TResult> > ExecuteAsync() { try { ServiceRequest request = BuildRequest(); //加入dateheader request.Headers[HttpHeaders.Date] = DateUtils.FormatRfc822Date(DateTime.UtcNow); if (RequestContext.OssCredential.UseToken) { request.Headers[HttpHeaders.SecurityToken] = RequestContext.OssCredential.SecurityToken; } // 发送请求 var caller = new ServiceCaller(RequestContext); HttpResponseMessage response = await caller.CallServiceAsync(request); // 解析结果 return(await ProcessResponseInternal(response)); } catch (Exception ex) { return(new OssResult <TResult>() { IsSuccess = false, InnerException = ex, ErrorMessage = ex.Message }); } }
public void ExecuteApiServiceCallForAgents() { var stringListOfAgents = ServiceCaller.CallFreshServiceAgents(_freshServiceAgentsTask); var jsonDeserialisedAgents = JsonConvert.DeserializeObject <FreshServiceAgentsModel[]>(stringListOfAgents); CacheHelper.SaveToCache(Constants.AgentsCacheKey, jsonDeserialisedAgents, DateTime.Now.AddHours(Constants.CacheExpirationTimeInHours)); }
private static void Main(string[] args) { ServiceCaller caller = new ServiceCaller(); int capacity = 0; while (capacity < 10) { Console.WriteLine(); Console.WriteLine("Select Car type"); Console.WriteLine("1:Hatchback"); Console.WriteLine("2:Seden"); Console.WriteLine("3:MiniTruck"); int type = Convert.ToInt32(Console.ReadLine()); string vehicleType = GetVehicleType(type); Console.WriteLine("Enter Model"); string model = Console.ReadLine(); Console.WriteLine("Enter vehicle number"); string vehiclenumber = Console.ReadLine(); Console.WriteLine(); var parkingDetails = caller.Park(vehicleType, model, vehiclenumber); Console.WriteLine(parkingDetails); Console.WriteLine(); capacity++; } Console.ReadLine(); }
public Task <ServiceStandardResponse <bool> > UpdateTemplateAsync(string templateName, string templateBody) { return(ServiceCaller.PostAsync <bool>(EndPoints.UpdateTemplate, new HttpTemplateUpdateCommand() { TemplateBody = templateBody, TemplateName = templateName }).ContinueWith(x => new ServiceStandardResponse <bool>(x.Result))); }
public Task <ServiceStandardResponse <EmailTemplateServiceProcessResult> > SendEmailAsync(string templateName, List <EmailMergeModelData> emailMergeModelData, TemplateEmailSenderInformation request) { return(ServiceCaller.PostAsync <EmailTemplateServiceProcessResult>(EndPoints.SendEmail, new HttpSendEmailCommand { EmailMergeModelData = emailMergeModelData, Request = request, TemplateName = templateName }).ContinueWith(x => new ServiceStandardResponse <EmailTemplateServiceProcessResult>(x.Result))); }
public void ExecuteApiServiceCallForTickets() { var cachedRequesterData = CacheHelper.GetFromCache <FreshServiceRequesterModel[]>(Constants.RequestersCacheKey); var cachedDepartmentData = CacheHelper.GetFromCache <FreshServiceDepartmentModel[]>(Constants.DepartmentsCacheKey); var cachedAgentsData = CacheHelper.GetFromCache <FreshServiceAgentsModel[]>(Constants.AgentsCacheKey); var stringListOfTickets = ServiceCaller.CallFreshServiceApi(_freshServiceApiTask); var jsonDeserializedTickets = JsonConvert.DeserializeObject <FreshServiceTicketModel[]>(stringListOfTickets); var ticketDomainObjects = PopulateModelWithTicketObjects(jsonDeserializedTickets, cachedRequesterData, cachedDepartmentData, cachedAgentsData); SaveTickets(ticketDomainObjects); }
public async Task LoadSponsorsAsync() { IsBusy = true; var data = await ServiceCaller.CallService(service.GetAllSponsors); if (data.IsSuccess) { Sponsors = new ObservableCollection <Sponsor>(data.Value); } IsBusy = false; }
private async Task LoadEventsAsync() { IsBusy = true; var data = await ServiceCaller.CallService(service.GetAllEvents); if (data.IsSuccess) { Events = new ObservableCollection <Event>(data.Value); } IsBusy = false; Refreshing = false; }
private async Task LoadInfoAsync() { IsBusy = true; var data = await ServiceCaller.CallService(service.GetInfo); if (data.IsSuccess) { Info = data.Value; } IsBusy = false; Refreshing = false; }
public async Task LoadSessionsAsync() { IsBusy = true; var data = await ServiceCaller.CallService(service.GetAllSessions); if (data.IsSuccess) { Sessions = new ObservableCollection <Session>(data.Value); allSessions = new List <Session>(Sessions.ToList()); } IsBusy = false; Refreshing = false; }
public LoginResponse Login(Request <UserProfile> loginRequest) { var serviceCaller = new ServiceCaller(); try { var response = serviceCaller.MakeLoginRequestPost <UserProfile, LoginResponse>(loginRequest); return(response); } catch (Exception ex) { throw ex; } }
public IActionResult Update([FromRoute] string model, [FromRoute] long id, [FromBody] object content) { IActionResult response = null; object values = GetObjectsFromJson(model, content.ToString()); var exceptions = ValidateModels(values); if (exceptions.Count() > 0) { response = BadRequest(exceptions); } else { ServiceCaller.Call(context, GlobalEnums.Api.Update, model, values); response = Ok(); } return(response); }
public Books() { serviceCaller = new ServiceCaller(); }
public async Task <ServiceStandardResponse <bool> > TemplateExists(string templateName) { var result = await ServiceCaller.GetAsync <bool>(EndPoints.TemplateExists + getAppendtemplate(templateName)); return(new ServiceStandardResponse <bool>(result)); }
public async Task <ServiceStandardResponse <bool> > DeleteTemplateAsync(string templateName) { await ServiceCaller.DeleteAsync(EndPoints.DeleteTemplate + getAppendtemplate(templateName)); return(new ServiceStandardResponse <bool>(true)); }
public Task <ServiceStandardResponse <bool> > UnPublishTemplateAsync(string templateName) { return(ServiceCaller.PostAsync <bool>(EndPoints.UnPublishTemplate + getAppendtemplate(templateName), new { }).ContinueWith(x => new ServiceStandardResponse <bool>(true))); }
public Task <ServiceStandardResponse <EmailTemplateInformation> > GetTemplateAsync(string templateName) { return(ServiceCaller.GetAsync <EmailTemplateInformation>(EndPoints.GetTemplate + getAppendtemplate(templateName)).ContinueWith(x => new ServiceStandardResponse <EmailTemplateInformation>(x.Result))); }
public IActionResult Get([FromRoute] string model, long?id) { return(Json(ServiceCaller.Call(context, GlobalEnums.Api.Get, model, id))); }
public IActionResult Delete([FromRoute] string model, long id) { ServiceCaller.Call(context, GlobalEnums.Api.Delete, model, id); return(Ok()); }
public Task <ServiceStandardResponse <List <EmailTemplateInformation> > > GetAllTemplatesAsync() { return(ServiceCaller.GetAsync <List <EmailTemplateInformation> >(EndPoints.GetAllTemplates).ContinueWith(x => new ServiceStandardResponse <List <EmailTemplateInformation> >(x.Result))); }