Hi,
How to use
- [HttpPost]
- [ValidateAntiForgeryToken]
- public ActionResult ReRunFailedSelectedBilling(List
FailedGroups) - {
- if (_logger.IsInfoEnabled)
- _logger.LogInfo(string.Format("Entering ReRunFailedSelectedBilling"));
- List
CGs = FailedGroups.Where(x => x.ReRunFlag).ToList(); - // Re-using code to get something working for GPSI. This should actually remove all the CGs and then process a single WFR. For now, we'll process one WFR for each CG...
- foreach (BillingFailedViewModel group in CGs)
- {
- using (var dbContextScope = _dbContextScopeFactory.Create())
- {
- ReRunModel run = new ReRunModel((int)group.Id, DbConnection, ServerURL);
- var login = HttpContext.User.Identity.Name;
- run.Reject(login);
- if (run._Status.Success == false)
- {
- TempData["Failure"] = "Error in rejection. Failed to reject.";
- }
- else
- {
- // Create a new workflow request and re-run
- var wfr = run.SetWorkflowRequest();
- dbContextScope.SaveChanges();
- run.WorkflowRequestId = wfr.Id;
- run.Run(run.RunSychronousService(), login); Question : How to use Asynch instead of synchcronous
- }
- }
- }
- }
Asynch Method available in class - startrunmodel.cs
- public async Task RunAsync(string login)
- {
- logger.LogInfo(string.Format("PERF RunAsync starting"));
- // Kick off the server job
- string customer = wfRepo.GetCurrentUserCustomer(_User.WindowsUserName).Customer.Code;
- ServiceStatus status = new ServiceStatus { Success = false, Message = "Run failed." };
- Task[] wfrTasks = new Task[WorkflowRequests.Count()];
- int idx = 0;
- foreach (var wfr in WorkflowRequests)
- {
- WorkflowRequest request = new WorkflowRequest()
- {
- WorkflowRequestId = wfr.Id.ToString(),
- CustomerCode = customer,
- UserName = _User.WindowsUserName,
- LoginName = login
- };
- try
- {
- logger.LogInfo(string.Format("PERF RequestBillingAsync {0} called", wfr.Id.ToString()));
- wfrTasks[idx++] = _Service.RequestBillingAsync(request);
- }
- catch (Exception e)
- {
- logger.LogError("RequestBilling failed ", e);
- }
- logger.LogInfo(string.Format("PERF RequestBillingAsync {0} returned", wfr.Id.ToString()));
- //_Status.Add(status);
- }
- //await Task.WhenAll(wfrTasks);
- await Task.Yield();
- logger.LogInfo(string.Format("PERF RunAsync ending "));
- // return status;
- }

Jenith ThakkarPosted Jul 13, 2020, 3:35 AM
Okay try in this way
Make this method
run.Run(run.RunSychronousService(), login); Convert this line to
await run.Run(run.RunSychronousService(), login);
Praveen KumarPosted Jul 13, 2020, 3:05 AM
Jenith ThakkarPosted Jul 13, 2020, 1:34 AM