private void ImportJobSendMail(JobTaskResponse result) { try { _mailSender = CSMMailSender.GetCSMMailSender(); if (result.JobTaskResults != null && result.JobTaskResults.Count > 0) { foreach (var task in result.JobTaskResults.Where(x => x.StatusResponse.Status == Constants.StatusResponse.Failed)) { if (task.NumFailedDelete == 0) { _mailSender.NotifySyncEmailFailed(WebConfig.GetTaskEmailToAddress(), result.SchedDateTime, task.StatusResponse.Description); } else { _mailSender.NotifySyncEmailSuccess(WebConfig.GetTaskEmailToAddress(), result.SchedDateTime, task); } } } else { _logger.InfoFormat("O:--Unable to Send Email Notification--:Total Results/{0}", 0); } } catch (Exception ex) { _logger.Error("Exception occur:\n", ex); } }
private bool ExportDataToTOT(string executeTime, ExportFileResponse response) { var now = DateTime.Now; _doNotCallFacade = new DoNotCallFacade(); List <DoNotCallUpdatePhoneNoModel> newDataList = _doNotCallFacade.GetDoNotCallPhoneNoListByExecuteTime(executeTime); int itemCount = newDataList.Count; if (itemCount > 0) { // Generate file byte[] fileByte = _doNotCallFacade.GenerateDoNotCallPhoneListAttachment(newDataList); // Send email _mailSender = CSMMailSender.GetCSMMailSender(); int activeCount = newDataList.Count(x => x.Status == Constants.DNC.Block); int inactiveCount = newDataList.Count(x => x.Status == Constants.DNC.Unblock); string fileName = now.FormatDateTime(Constants.DateTimeFormat.ExportDateTime); string attachmentFileName = $"{fileName}.csv"; bool success = _mailSender.ExpportUpdatePhoneStatusToTOT(now, executeTime, activeCount, inactiveCount, fileByte, attachmentFileName); // generate file _doNotCallFacade.GenerateDoNotCallPhoneListFile(fileByte, fileName, success); response.ExportDataCount = success ? itemCount : 0; return(success); } return(true); }
public ExportFileResponse ExportFile(ExportFileRequest request) { string methodName = $"{nameof(DoNotCallBatchProcess)}.{nameof(ExportFile)}"; var response = new ExportFileResponse(); DateTime startTime = DateTime.Now; response.StartTime = startTime; try { if (request == null || request.Header == null) { throw new NullReferenceException($"{methodName}: Request/Header is null!"); } var requestHeader = request.Header; response.Header = GetResponseHeader(requestHeader, methodName); // Set batch process status if (AppLog.BatchProcessStart(Constants.BatchProcessCode.ExportDoNotCallUpdateFile, startTime) == false) { return(SetUnprocessResponse(response, methodName)); } // Authenticate user if (!ValidateServiceRequest(request.Header)) { return(SetInvalidLoginResponse(response)); } _logger.DebugFormat("-- XMLRequest --\n{0}", request.SerializeObject()); // Export ExportUpdateData(response); return(SetSuccessResponse(response)); } catch (Exception ex) { DateTime errorTime = DateTime.Now; response = SetErrorResponse(response, ex); _mailSender = CSMMailSender.GetCSMMailSender(); _mailSender.NotifyFailExportDoNotCall(response.StartTime, errorTime, response.ElapsedTime, response.Error, response.ExportDataCount); return(response); } finally { UpdateBatchProcessStatus(response); //Insert Audit Log bool success = response.ResultStatus == Constants.StatusResponse.Success; string detail = !string.IsNullOrWhiteSpace(response.Error) ? response.Error : response.Description; InsertAuditLog(methodName, success, detail ?? response.ResultStatus); } }
private void ReSubmitActivityToCBSHPSendMail(ReSubmitActivityToCBSHPSystemTaskResponse result) { try { _mailSender = CSMMailSender.GetCSMMailSender(); if (result.NumOfError > 0) { _mailSender.NotifyReSubmitActivityToCBSHPSystemSuccess(WebConfig.GetTaskEmailToAddress(), result); } else if (Constants.StatusResponse.Failed.Equals(result.StatusResponse.Status)) { _mailSender.NotifyReSubmitActivityToCBSHPSystemFailed(WebConfig.GetTaskEmailToAddress(), result.SchedDateTime, result.StatusResponse.ErrorCode); } } catch (Exception ex) { _logger.Error("Exception occur:\n", ex); } }
private void CreateSRActivitySendMail(CreateSrFromReplyEmailTaskResponse result) { try { _mailSender = CSMMailSender.GetCSMMailSender(); if (result.NumOfError > 0) { _mailSender.NotifyCreateSrFromReplyEmailSuccess(WebConfig.GetTaskEmailToAddress(), result); } else if (Constants.StatusResponse.Failed.Equals(result.StatusResponse.Status)) { _mailSender.NotifyCreateSrFromReplyEmailFailed(WebConfig.GetTaskEmailToAddress(), result.SchedDateTime, result.StatusResponse.ErrorCode); } } catch (Exception ex) { _logger.Error("Exception occur:\n", ex); } }