public async Task <IActionResult> HouseKeeping() { Console.WriteLine( $"[{AWSXRayRecorder.Instance.TraceContext.GetEntity().RootSegment.TraceId}][{AWSXRayRecorder.Instance.GetEntity().TraceId}] - In Housekeeping, trying to reset the app."); var result = await GetPetDetails(null, null, null); var Pets = JsonSerializer.Deserialize <List <Pet> >(result); var searchParams = new SearchParams(); //string updateadoptionstatusurl = _configuration["updateadoptionstatusurl"]; string updateadoptionstatusurl = SystemsManagerConfigurationProviderWithReloadExtensions.GetConfiguration(_configuration, "updateadoptionstatusurl"); foreach (var pet in Pets.Where(item => item.availability == "no")) { searchParams.pettype = pet.pettype; searchParams.petid = pet.petid; searchParams.petavailability = "yes"; StringContent putData = new StringContent(JsonSerializer.Serialize(searchParams)); await _httpClient.PutAsync(updateadoptionstatusurl, putData); } //string cleanupadoptionsurl = _configuration["cleanupadoptionsurl"]; string cleanupadoptionsurl = SystemsManagerConfigurationProviderWithReloadExtensions.GetConfiguration(_configuration, "cleanupadoptionsurl"); await _httpClient.PostAsync(cleanupadoptionsurl, null); return(View()); }
private async Task <StartExecutionResponse> StartStepFunctionExecution(string petId, string petType) { /* * * // Code to invoke StepFunction through API Gateway * var stepFunctionInputModel = new StepFunctionInputModel() * { * input = JsonSerializer.Serialize(new SearchParams() {petid = petId, pettype = petType}), * name = $"{petType}-{petId}-{Guid.NewGuid()}", * stateMachineArn = SystemsManagerConfigurationProviderWithReloadExtensions.GetConfiguration(_configuration,"petadoptionsstepfnarn") * }; * * var content = new StringContent( * JsonSerializer.Serialize(stepFunctionInputModel), * Encoding.UTF8, * "application/json"); * * return await _httpClient.PostAsync(SystemsManagerConfigurationProviderWithReloadExtensions.GetConfiguration(_configuration,"petadoptionsstepfnurl"), content); * */ // Console.WriteLine($"STEPLOG -ARN - {SystemsManagerConfigurationProviderWithReloadExtensions.GetConfiguration(_configuration,"petadoptionsstepfnarn")}"); //Console.WriteLine($"STEPLOG - SERIALIZE - {JsonSerializer.Serialize(new SearchParams() {petid = petId, pettype = petType})}"); AWSSDKHandler.RegisterXRay <IAmazonStepFunctions>(); return(await new AmazonStepFunctionsClient().StartExecutionAsync(new StartExecutionRequest() { Input = JsonSerializer.Serialize(new SearchParams() { petid = petId, pettype = petType }), Name = $"{petType}-{petId}-{Guid.NewGuid()}", StateMachineArn = SystemsManagerConfigurationProviderWithReloadExtensions.GetConfiguration(_configuration, "petadoptionsstepfnarn") })); }
// GET public async Task <IActionResult> Index() { AWSXRayRecorder.Instance.BeginSubsegment("Calling PetListAdoptions"); Console.WriteLine($"[{AWSXRayRecorder.Instance.GetEntity().TraceId}][{AWSXRayRecorder.Instance.TraceContext.GetEntity().RootSegment.TraceId}] - Calling PetListAdoptions API"); string result; List <Pet> Pets = new List <Pet>(); try { //string petlistadoptionsurl = _configuration["petlistadoptionsurl"]; string petlistadoptionsurl = SystemsManagerConfigurationProviderWithReloadExtensions.GetConfiguration(_configuration, "petlistadoptionsurl"); result = await _httpClient.GetStringAsync($"{petlistadoptionsurl}"); Pets = JsonSerializer.Deserialize <List <Pet> >(result); } catch (Exception e) { AWSXRayRecorder.Instance.AddException(e); throw e; } finally { AWSXRayRecorder.Instance.EndSubsegment(); } return(View(Pets)); }
public AdoptionController(IConfiguration configuration) { _configuration = configuration; //_searchApiurl = _configuration["searchapiurl"]; _searchApiurl = SystemsManagerConfigurationProviderWithReloadExtensions.GetConfiguration(_configuration, "searchapiurl"); AWSSDKHandler.RegisterXRayForAllServices(); }
private async Task <SendMessageResponse> PostMessageToSqs(string petId, string petType) { AWSSDKHandler.RegisterXRay <IAmazonSQS>(); return(await _sqsClient.SendMessageAsync(new SendMessageRequest() { MessageBody = JsonSerializer.Serialize($"{petId}-{petType}"), QueueUrl = SystemsManagerConfigurationProviderWithReloadExtensions.GetConfiguration(_configuration, "queueurl") })); }
private async Task <string> GetPetDetails(string pettype, string petcolor, string petid) { string searchUri = string.Empty; if (!String.IsNullOrEmpty(pettype) && pettype != "all") { searchUri = $"pettype={pettype}"; } if (!String.IsNullOrEmpty(petcolor) && petcolor != "all") { searchUri = $"&{searchUri}&petcolor={petcolor}"; } if (!String.IsNullOrEmpty(petid) && petid != "all") { searchUri = $"&{searchUri}&petid={petid}"; } switch (pettype) { case "puppy": PuppySearchCount.Inc(); PetSearchCount.Inc(); break; case "kitten": KittenSearchCount.Inc(); PetSearchCount.Inc(); break; case "bunny": BunnySearchCount.Inc(); PetSearchCount.Inc(); break; } //string searchapiurl = _configuration["searchapiurl"]; string searchapiurl = SystemsManagerConfigurationProviderWithReloadExtensions.GetConfiguration(_configuration, "searchapiurl"); return(await _httpClient.GetStringAsync($"{searchapiurl}{searchUri}")); }
private async Task <HttpResponseMessage> PostTransaction(string petId, string pettype) { return(await _httpClient.PostAsync($"{SystemsManagerConfigurationProviderWithReloadExtensions.GetConfiguration(_configuration,"paymentapiurl")}?petId={petId}&petType={pettype}", null)); }