void sendNextRequest(string sessionId) { string[] files = { "samplebatchdata000.txt", "samplebatchdata001.txt", "samplebatchdata002.txt", "samplebatchdata003.txt", "samplebatchdata004.txt", "samplebatchdata005.txt" }; Random rnd = new Random(); int idx = rnd.Next(0, 6); HttpClient client = new HttpClient(); HttpRequestMessage msg = new HttpRequestMessage(HttpMethod.Post, String.Format(ConfigurationManager.AppSettings["HeavyCalcApi"], "startheavycalc")); StartHeavyCalcRequest hcReq = new StartHeavyCalcRequest() { SessionId = sessionId, FileName = files[idx] }; string sContent = JsonConvert.SerializeObject(hcReq); msg.Content = new StringContent(sContent, Encoding.UTF8, "application/json"); HttpResponseMessage resp = client.SendAsync(msg).Result; }
public IActionResult StartHeavyCalc(StartHeavyCalcRequest request) { IActionResult response = null; logger.LogInformation($"Call to heavycalc for {request.FileName}"); validateStrParam("sessionid", request.SessionId); validateStrParam("filename", request.FileName); if (!isValidSession(request.SessionId)) { logger.LogError($"Invalid session tocken {request.SessionId}"); throw new ArgumentException(string.Format("Invalid session toekn: {0}", request.SessionId)); } logger.LogInformation($"Sending message for {request.FileName}"); sendStartMessage(request.FileName); StartHeavyCalcResponse respContent = new StartHeavyCalcResponse() { IsStarted = true, StartedDt = DateTime.UtcNow }; response = Ok(JsonConvert.SerializeObject(respContent, Formatting.Indented)); return(response); }
public HttpResponseMessage StartHeavyCalc(StartHeavyCalcRequest request) { HttpResponseMessage response = new HttpResponseMessage(); validateStrParam("sessionid", request.SessionId); validateStrParam("filename", request.FileName); if (!isValidSession(request.SessionId)) { throw new ArgumentException(string.Format("Invalid session toekn: {0}", request.SessionId)); } sendStartMessage(request.FileName); StartHeavyCalcResponse respContent = new StartHeavyCalcResponse() { IsStarted = true, StartedDt = DateTime.UtcNow }; response.Content = new StringContent(JsonConvert.SerializeObject(respContent)); return(response); }