/// <summary> /// Service logic method /// </summary> /// <param name="arg"></param> private void DoWork(object arg) { for (; ; ) { if (iVantageImportStop.WaitOne(10000)) return; try { EmployeeModel employeeModel = new EmployeeModel(); employeeModel.ServiceWork(); } catch (Exception ex) { Logger.Write(string.Format("An error has ocurred while running the IVantage Import Service!\n{0}\n{1}", ex.Message, ex.StackTrace)); SettingsModel settings = new SettingsModel(); EmailModel emailModel = new EmailModel(); StringBuilder mailError = new StringBuilder(); mailError.AppendLine(string.Format("An error has ocurred while running the IVantage Import Service!\n{0}\n{1}", ex.Message, ex.StackTrace)); //MailUtility.SendMail(settings.GetITEmailOnError(), "", "", mailError.ToString(), "IVantage Import Service - Error occured on Employee Information", false, null); emailModel.SaveEmailList(settings.GetITEmailOnError(), "IVantage Import Service - Error occured on Employee Information", mailError.ToString(), "System", (int)Globals.Security.SystemEmployeeID); } } }
public void TestIfModelIsSavingEmailList() { // Arrange EmailModel model = new EmailModel(new FakeUnitOfWork()); string receipts = "[email protected];[email protected];[email protected]"; string subject = "testing email save"; string body = "this is a test"; string username = "******"; int employeeId = 1; IList<CS_Email> savedEmail = null; // Act savedEmail = model.SaveEmailList(receipts, subject, body, username, employeeId); // Assert Assert.IsNotNull(savedEmail); Assert.AreEqual(savedEmail.Count, 3); Assert.AreEqual("*****@*****.**", savedEmail[0].Receipts, "Error on Receipts field"); Assert.AreEqual("*****@*****.**", savedEmail[1].Receipts, "Error on Receipts field"); Assert.AreEqual("*****@*****.**", savedEmail[2].Receipts, "Error on Receipts field"); Assert.AreEqual(subject, savedEmail[0].Subject, "Error on Subject field"); Assert.AreEqual(body, savedEmail[0].Body, "Error on Body field"); Assert.AreEqual(username, savedEmail[0].CreatedBy, "Error on CreatedBy field"); Assert.AreEqual(employeeId, savedEmail[0].CreationID, "Error on CreationID field"); Assert.AreEqual((short)Globals.EmailService.Status.Pending, savedEmail[0].Status, "Error on Status Field"); }
public void SendMail() { _jobModel = new JobModel(); string[] receipts = _view.ReceiptsString.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); using (_emailModel = new EmailModel()) { if (_view.JobID.HasValue) { CS_Job job = _jobModel.GetJobById(_view.JobID.Value); _emailModel.SaveEmailList(string.Join(";", receipts), _view.EmailSubject, _view.EmailBody, _view.UserName, _view.CreationId); _jobModel.SaveCallCriteriaInitialAdviseCallCriteriaEmailResources(_callLogModel.GetCallLogById(job.CS_CallLog.FirstOrDefault(e => e.CallTypeID == (int)Globals.CallEntry.CallType.InitialLog).ID)); } else { _emailModel.SaveEmailList(receipts, _view.ReceiptsIds, _view.EmailSubject, _view.EmailBody, _view.UserName, _view.CreationId); } } }
public void SendNotificationForInvoicingTeamTest() { //Arrange EmailModel model = new EmailModel(new FakeUnitOfWork()); #region Body StringBuilder sb = new StringBuilder(); sb.Append("<div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Job#:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" 243"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Customer:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" American Test"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Initial Customer Contact:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" danilo"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Bill to:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" cecilia, danilo"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Initial Call date:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" 14/02/2011 00:00:00"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Initial Call time:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" 10:11:59"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Price Type:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" description test"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Job Action:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" Environmental Work, General - Undefined Scope of Work"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Job Category:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" B"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Job Type:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" A"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Division:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" 005"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Interim Bill:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" Yes"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Requested By:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" Dcecilia, Test"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Frequency:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" D"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Country:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" USA"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("State:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" Texas"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("City:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" Dalton"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Number Engines:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" 1"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Number Loads:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" 2"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Number Empties:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" 1"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Scope Of Work:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append("xxcxcxc"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Job start date:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" 14/02/2011 00:00:00"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Job end date:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" 14/02/2011 00:00:00"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("</div>"); #endregion string receipts = "[email protected];[email protected]"; string subject = "Status Changed - Cancel => Active"; string username = "******"; int employeeId = 1; IList<CS_Email> savedEmail = null; //Act savedEmail = model.SaveEmailList(receipts, subject, sb.ToString(), username, employeeId); //Assert Assert.IsNotNull(savedEmail); Assert.AreEqual(savedEmail.Count, 2); Assert.AreEqual("*****@*****.**", savedEmail[0].Receipts, "Error on Receipts field"); Assert.AreEqual("*****@*****.**", savedEmail[1].Receipts, "Error on Receipts field"); Assert.AreEqual(subject, savedEmail[0].Subject, "Error on Subject field"); Assert.AreEqual(sb.ToString(), savedEmail[0].Body, "Error on Body field"); Assert.AreEqual(username, savedEmail[0].CreatedBy, "Error on CreatedBy field"); Assert.AreEqual(employeeId, savedEmail[0].CreationID, "Error on CreationID field"); Assert.AreEqual((short)Globals.EmailService.Status.Pending, savedEmail[0].Status, "Error on Status Field"); }
public void SendNotificationForEstimationTeamTest() { //Arrange EmailModel model = new EmailModel(new FakeUnitOfWork()); #region Body StringBuilder sb = new StringBuilder(); sb.Append("<div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Non-job#:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" 000000025INT"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Division:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" 005"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("JobType:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" A"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("JobAction:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" Environmental Work, General - Undefined Scope of Work"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Scope Of Work:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append("xxcxcxc"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Job start date:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append("14/02/2011 00:00:00"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Employee:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" Dcecilia, Test"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Number Engines:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" 1"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Number Loads:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" 2"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Number Empties:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" 1"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("</div>"); #endregion string receipts = "[email protected];[email protected]"; string subject = "Status Changed - Bid => Active"; string username = "******"; int employeeId = 1; IList<CS_Email> savedEmail = null; //Act savedEmail = model.SaveEmailList(receipts, subject, sb.ToString(), username, employeeId); //Assert Assert.IsNotNull(savedEmail); Assert.AreEqual(savedEmail.Count, 2); Assert.AreEqual("*****@*****.**", savedEmail[0].Receipts, "Error on Receipts field"); Assert.AreEqual("*****@*****.**", savedEmail[1].Receipts, "Error on Receipts field"); Assert.AreEqual(subject, savedEmail[0].Subject, "Error on Subject field"); Assert.AreEqual(sb.ToString(), savedEmail[0].Body, "Error on Body field"); Assert.AreEqual(username, savedEmail[0].CreatedBy, "Error on CreatedBy field"); Assert.AreEqual(employeeId, savedEmail[0].CreationID, "Error on CreationID field"); Assert.AreEqual((short)Globals.EmailService.Status.Pending, savedEmail[0].Status, "Error on Status Field"); }
/// <summary> /// Service Method that will start the import process of IVantage data /// </summary> /// <returns>True if process ran OK, False if there was an error</returns> public bool ServiceWork() { SettingsModel settings = new SettingsModel(); EmailModel emailModel = new EmailModel(); try { UpdateDivisions(); } catch (Exception ex) { Logger.Write(string.Format("An error has ocurred while trying to import the Division information!\n{0}\n{1}", ex.InnerException, ex.StackTrace)); StringBuilder mailError = new StringBuilder(); mailError.AppendLine(string.Format("An Error Ocurred when importing the Division Information!\n{0}\n{1}", ex.InnerException, ex.StackTrace)); //MailUtility.SendMail(settings.GetITEmailOnError(), "", "", mailError.ToString(), "IVantage Import Service - Error occured on Division Information", false, null); emailModel.SaveEmailList(settings.GetITEmailOnError(), "IVantage Import Service - Error occured on Division Information", mailError.ToString(), "System", (int)Globals.Security.SystemEmployeeID); return false; } try { UpdateEmployees(); } catch (Exception ex) { Logger.Write(string.Format("An error has ocurred while trying to import the Employee information!\n{0}\n{1}", ex.InnerException, ex.StackTrace)); StringBuilder mailError = new StringBuilder(); mailError.AppendLine(string.Format("An Error Ocurred when importing the Employee Information!\n{0}\n{1}", ex.InnerException, ex.StackTrace)); //MailUtility.SendMail(settings.GetITEmailOnError(), "", "", mailError.ToString(), "IVantage Import Service - Error occured on Employee Information", false, null); emailModel.SaveEmailList(settings.GetITEmailOnError(), "IVantage Import Service - Error occured on Employee Information", mailError.ToString(), "System", (int)Globals.Security.SystemEmployeeID); return false; } try { UpdateEmergencyContacts(); } catch (Exception ex) { Logger.Write(string.Format("An error has ocurred while trying to import the Emergency Contact information!\n{0}\n{1}", ex.InnerException, ex.StackTrace)); StringBuilder mailError = new StringBuilder(); mailError.AppendLine(string.Format("An Error Ocurred when importing the Emergency Contact Information!\n{0}\n{1}", ex.InnerException, ex.StackTrace)); //MailUtility.SendMail(settings.GetITEmailOnError(), "", "", mailError.ToString(), "IVantage Import Service - Error occured on Emergency Contact Information", false, null); emailModel.SaveEmailList(settings.GetITEmailOnError(), "IVantage Import Service - Error occured on Emergency Contact Information", mailError.ToString(), "System", (int)Globals.Security.SystemEmployeeID); return false; } return true; }
public void SendNotificationWhiteLight(CS_CallLog callentry, CS_CallLogResource resource) { _emailModel = new EmailModel(); IList<CS_Email> emails = new List<CS_Email>(); string receipts = string.Empty; //List receipts IList<EmailVO> receiptsEmail = _callCriteriaModel.ListReceiptsByCallLog(callentry.CallTypeID.ToString(), callentry.JobID, callentry); if (receiptsEmail.Count > 0) { for (int i = 0; i < receiptsEmail.Count; i++) receipts += (i == 0) ? receiptsEmail[i].Email : string.Format(";{0}", receiptsEmail[i].Email); //Body string body = GenerateEmailBodyForWhiteLight(resource); //Subject string subject = GenerateEmailSubjectForWhiteLight(callentry, resource); emails = _emailModel.SaveEmailList(receipts, subject, body, "System", Globals.Security.SystemEmployeeID); _callCriteriaModel.SendCallLogCriteriaEmails(callentry); } }
public void SendNotificationForTransportationTeam(IList<CS_EquipmentPermit> permitList) { _settingsModel = new SettingsModel(); _emailModel = new EmailModel(); for (int i = 0; i < permitList.Count; i++) { CS_EquipmentPermit permit = permitList[i]; IList<CS_Email> emails = new List<CS_Email>(); //Body string body = GenerateEmailBodyForTransportationTeam(permit); //List receipts string receipts = _settingsModel.GetTransportationTeamEmails(); //Subject string subject = GenerateEmailSubjectTransportationTeam(permit); if (!string.IsNullOrEmpty(receipts)) { emails = _emailModel.SaveEmailList(receipts, subject, body, "System", Globals.Security.SystemEmployeeID); } } }
/// <summary> /// Sends the email notification for the permit team /// </summary> /// <param name="equipmentPermitId">job id</param> public IList<CS_EquipmentPermitEmail> SendNotificationForPermitTeam(IList<CS_EquipmentPermit> expiredPermits) { _settingsModel = new SettingsModel(); try { IList<CS_EquipmentPermit> expiredLicenses = expiredPermits.Distinct(new Globals.EmailService.CS_EquipmentPermit_Comparer()).ToList(); IList<CS_State> states = new List<CS_State>(); using (_locationModel = new LocationModel()) { states = _locationModel.ListAllStates(); } IList<CS_EquipmentPermitEmail> returnList = new List<CS_EquipmentPermitEmail>(); for (int i = 0; i < expiredLicenses.Count; i++) { CS_EquipmentPermit license = expiredLicenses[i]; IList<CS_EquipmentPermit> expiredEquipments = expiredPermits.Where(e => e.LicenseNumber == license.LicenseNumber && e.Code == license.Code).ToList(); IList<CS_Email> emails = new List<CS_Email>(); //Body string body = GenerateEmailBodyForPermitTeam(license, expiredEquipments, states); //List receipts string receipts = _settingsModel.GetPermitTeamEmails(); //Subject string subject = GenerateEmailSubjectEstimationTeam(license, states); if (!string.IsNullOrEmpty(receipts)) { using (_emailModel = new EmailModel()) { emails = _emailModel.SaveEmailList(receipts, subject, body, "System", Globals.Security.SystemEmployeeID); } } for (int j = 0; j < expiredEquipments.Count; j++) { CS_EquipmentPermit equipmentPermit = expiredEquipments[j]; for (int h = 0; h < emails.Count; h++) { CS_Email email = emails[h]; returnList.Add ( new CS_EquipmentPermitEmail() { EmailID = email.ID, EquipmentPermitID = equipmentPermit.Id, CreatedBy = "System", CreationDate = email.CreationDate, CreationID = Globals.Security.SystemEmployeeID, ModifiedBy = "System", ModificationDate = email.CreationDate, ModificationID = Globals.Security.SystemEmployeeID, Active = true } ); } } } return returnList; } catch (Exception ex) { throw new Exception("There was an error sending the email notification for the Permit Team.", ex); } }
public void SendCallLogNotificationReservedEmails(CS_CallLog callLogEntry, List<CS_Reserve> resources) { try { EmailModel emailModel = new EmailModel(_unitOfWork); IList<CS_Email> emails = new List<CS_Email>(); string receipts = string.Empty; //List receipts IList<EmailVO> receiptsEmail = _callCriteriaModel.ListReceiptsByCallLog(callLogEntry.CallTypeID.ToString(), callLogEntry.JobID, callLogEntry); if (receiptsEmail.Count > 0) { for (int i = 0; i < receiptsEmail.Count; i++) receipts += (i == 0) ? receiptsEmail[i].Email : string.Format(";{0}", receiptsEmail[i].Email); //Body string body = GenerateEmailBodyForReservedResources(callLogEntry, resources); //Subject string subject = GenerateEmailSubjectForReservedResources(callLogEntry); //Save Email emailModel.SaveEmailList(receipts, subject, body, "System", Globals.Security.SystemEmployeeID); //Save Call Citeria _callCriteriaModel.SendCallLogCriteriaEmails(callLogEntry); } } catch (Exception e) { throw new Exception("There was an error while trying to send added resources notification!", e); } }