internal Result SuspendCompany(string externalId, SuspendCustomerParams data) { var loggerManager = new LoggerManager(); var operationGuid = Guid.NewGuid().ToString(); try { loggerManager.InsertLogoRecord(nameof(SuspendCompany), nameof(LogLevel.Info), null, data.TransactionId, JsonConvert.SerializeObject(data)); var orderDemandManager = new OrderDemandManager(); var suspendCompany = new SuspendCompanyData { ExternalId = externalId, OrderDemandGuid = operationGuid }; var validator = new CompanyValidator(); var valResults = validator.Validate(suspendCompany); var validationSucceeded = valResults.IsValid; if (!validationSucceeded) { var failures = valResults.Errors; var message = failures.Aggregate(string.Empty, (current, failure) => current + (failure.ErrorMessage + "<br />")); return(new Result { IsCompleted = false, Success = false, Message = message }); } orderDemandManager.SaveOrderDemand(null, operationGuid, 0, (int)ProvisionType.SuspendCustomer, (int)OrderDemandStates.Created, (int)OrderDemandType.Integrated, JsonConvert.SerializeObject(suspendCompany), data.TransactionId); return(new Result { IsCompleted = false, Success = true }); } catch (Exception ex) { loggerManager.InsertLogoRecord(nameof(SuspendCompany), nameof(LogLevel.Error), ex.Message + " " + ex.StackTrace, operationGuid, JsonConvert.SerializeObject(data)); return(new Result { IsCompleted = true, Success = false, Message = ex.Message }); } }
public override void DoJob(dynamic data) { var operationGuid = string.Empty; try { SuspendCompanyData json = JsonConvert.DeserializeObject <SuspendCompanyData>(data); operationGuid = json.OrderDemandGuid; _CompanyRepository.SuspendCompany(json.ExternalId); _orderDemandRepository.ChangeOrderDemandState(operationGuid, (int)OrderDemandStates.Finished); } catch (Exception ex) { _orderDemandRepository.ChangeOrderDemandState(operationGuid, (int)OrderDemandStates.FinishedError); _logRepository.InsertLogoRecord(nameof(Create), nameof(LogLevel.Error), ex.Message + " " + ex.StackTrace, operationGuid, data); } }