public void DeliveryConfirmationDoWork(object arg) { int miliSecondsTimeOut = Convert.ToInt32(ConfigurationManager.AppSettings["MilisecondsTimeOut"]); for (; ; ) { if (deliveryServiceStop.WaitOne(miliSecondsTimeOut)) return; try { using (EmailModel model = new EmailModel()) { model.DeliveryServiceWork(); } using (EmailModel model = new EmailModel()) { model.ReadServiceWork(); } } catch (Exception ex) { Logger.Write(string.Format("An error has ocurred while running the Delivery Confirmation Service!\n{0}\n{1}", ex.Message, ex.StackTrace)); } } }
public EmailViewModel(IEmailView view) { _view = view; _callLogModel = new CallLogModel(); _callCriteriaModel = new CallCriteriaModel(); _emailModel = new EmailModel(); }
public void Dispose() { _view = null; _callLogModel = null; _callCriteriaModel = null; _emailModel = null; }
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 TestIfModelIsUpdatingEmailStatus() { // Arrange CS_Email email = new CS_Email() { ID = 1, Active = true, Status = (short)Globals.EmailService.Status.Pending }; EmailModel model = new EmailModel(new FakeUnitOfWork()); CS_Email updatedEmail = null; // Act updatedEmail = model.UpdateStatusEmail(email, Globals.EmailService.Status.Sent); // Assert Assert.IsNotNull(updatedEmail); Assert.AreEqual((short)Globals.EmailService.Status.Sent, updatedEmail.Status, "Error on Status field"); }
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 TestIfModelIsReturningPendingEmails() { // Arrange FakeObjectSet<CS_Email> fakeEmailList = new FakeObjectSet<CS_Email>(); fakeEmailList.AddObject(new CS_Email() { ID = 1, Status = (short)Globals.EmailService.Status.Pending, Active = true }); fakeEmailList.AddObject(new CS_Email() { ID = 2, Status = (short)Globals.EmailService.Status.Pending, Active = true }); fakeEmailList.AddObject(new CS_Email() { ID = 3, Status = (short)Globals.EmailService.Status.Sent, Active = true }); fakeEmailList.AddObject(new CS_Email() { ID = 4, Status = (short)Globals.EmailService.Status.Error, Active = true }); Mock<IUnitOfWork> mockUnitOfWork = new Mock<IUnitOfWork>(); mockUnitOfWork.Setup(e => e.CreateObjectSet<CS_Email>()).Returns(fakeEmailList); EmailModel model = new EmailModel(mockUnitOfWork.Object); // Act IList<CS_Email> pendingEmails = model.ListAllPendingEmails(); // Assert Assert.IsNotNull(pendingEmails); Assert.AreEqual(2, pendingEmails.Count); }
/// <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); } }
/// <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); } } }
/// <summary> /// Sends the request Customer email /// </summary> /// <param name="emailBody">Email body</param> /// <param name="resend">Indicates if it's a new attempt of sending the request (TRUE) or it's the first attempt (FALSE)</param> /// <param name="cancel">Indicates if it's a new attempt of cancelling the request (TRUE) or it's the first attempt (FALSE)</param> /// <param name="customerNumber">If it's an update request, this field will have the Master Customer ID, if not it will be null</param> /// <param name="username">Username that made the request</param> private void SendCustomerRequestEmail(string emailBody, bool resend, bool cancel, string customerNumber, string username) { string subject = "New Company Request"; if (resend) subject += " (RESEND)"; if (cancel) subject += " (CANCEL)"; if (!string.IsNullOrEmpty(customerNumber)) subject += " - Master ID: " + customerNumber; string[] receipts = null; SettingsModel settingsModel = new SettingsModel(_unitOfWork); string emails = settingsModel.GetCustomerRequestEmails(); if (!string.IsNullOrEmpty(emails)) receipts = emails.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); if (null != receipts) { EmailModel emailModel = new EmailModel(_unitOfWork); for (int i = 0; i < receipts.Length; i++) { emailModel.SaveEmail(receipts[i], subject, emailBody, username, null); } } }
/// <summary> /// Instance objects /// </summary> private void InstanceObjects() { _employeeRepository = new CachedRepository<CS_Employee>(); _employeeOffCallRepository = new EFRepository<CS_EmployeeOffCallHistory>(); _employeeCoverageRepository = new EFRepository<CS_EmployeeCoverage>(); _employeeInfoRepository = new EFRepository<CS_View_EmployeeInfo>(); _employeeCallLogInfoRepository = new EFRepository<CS_View_Employee_CallLogInfo>(); _divisionRepository = new EFRepository<CS_Division>(); _employeeEmergencyContactRepository = new EFRepository<CS_EmployeeEmergencyContact>(); _customerInfoRepository = new EFRepository<CS_CustomerInfo>(); _contactRepository = new EFRepository<CS_Contact>(); _callCriteriaRepository = new EFRepository<CS_CallCriteria>(); _callCriteriaValueRepository = new EFRepository<CS_CallCriteriaValue>(); _callLogRepository = new EFRepository<CS_CallLog>(); _callLogResourceRepository = new EFRepository<CS_CallLogResource>(); _resourceRepository = new EFRepository<CS_Resource>(); _phoneTypeRepository = new EFRepository<CS_PhoneType>(); _phoneNumberRepository = new EFRepository<CS_PhoneNumber>(); _managersLocationRepository = new EFRepository<CS_View_ManagersLocation>(); _employeeRepository.UnitOfWork = _unitOfWork; _employeeOffCallRepository.UnitOfWork = _unitOfWork; _employeeCoverageRepository.UnitOfWork = _unitOfWork; _employeeInfoRepository.UnitOfWork = _unitOfWork; _employeeCallLogInfoRepository.UnitOfWork = _unitOfWork; _divisionRepository.UnitOfWork = _unitOfWork; _employeeEmergencyContactRepository.UnitOfWork = _unitOfWork; _customerInfoRepository.UnitOfWork = _unitOfWork; _contactRepository.UnitOfWork = _unitOfWork; _callCriteriaRepository.UnitOfWork = _unitOfWork; _callCriteriaValueRepository.UnitOfWork = _unitOfWork; _callLogRepository.UnitOfWork = _unitOfWork; _callLogResourceRepository.UnitOfWork = _unitOfWork; _resourceRepository.UnitOfWork = _unitOfWork; _phoneTypeRepository.UnitOfWork = _unitOfWork; _phoneNumberRepository.UnitOfWork = _unitOfWork; _managersLocationRepository.UnitOfWork = _unitOfWork; _callCriteriaModel = new CallCriteriaModel(_unitOfWork); _settingsModel = new SettingsModel(_unitOfWork); _emailModel = new EmailModel(_unitOfWork); _callLogModel = new CallLogModel(_unitOfWork); }
/// <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; }
/// <summary> /// Dispose all objects that are no longer needed /// </summary> public void Dispose() { _equipmentInfoRepository = null; _equipmentRepository = null; _equipmentTypeRepository = null; _viewReserveEquipmentRepository = null; _conflictedCombosRepository = null; _equipmentPermitEmailRepository = null; _resourceRepository = null; if (null != _settingsModel) { _settingsModel.Dispose(); _settingsModel = null; } if (null != _locationModel) { _locationModel.Dispose(); _locationModel = null; } if (null != _emailModel) { _emailModel.Dispose(); _emailModel = null; } if (null != _callLogModel) { _callLogModel.Dispose(); _callLogModel = null; } _unitOfWork.Dispose(); _unitOfWork = null; }
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); } } }
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"); }
private void InstanceObjects() { _jobRepository = new CachedRepository<CS_Job>(); _jobRepository.UnitOfWork = _unitOfWork; _jobStatusRepository = new CachedRepository<CS_JobStatus>(); _jobStatusRepository.UnitOfWork = _unitOfWork; _jobDivisionRepository = new EFRepository<CS_JobDivision>(); _jobDivisionRepository.UnitOfWork = _unitOfWork; _priceTypeRepository = new CachedRepository<CS_PriceType>(); _priceTypeRepository.UnitOfWork = _unitOfWork; _jobCategoryRepository = new CachedRepository<CS_JobCategory>(); _jobCategoryRepository.UnitOfWork = _unitOfWork; _jobTypeRepository = new CachedRepository<CS_JobType>(); _jobTypeRepository.UnitOfWork = _unitOfWork; _jobActionRepository = new CachedRepository<CS_JobAction>(); _jobActionRepository.UnitOfWork = _unitOfWork; _lostJobReasonRepository = new CachedRepository<CS_LostJobReason>(); _lostJobReasonRepository.UnitOfWork = _unitOfWork; _competitorRepository = new EFRepository<CS_Competitor>(); _competitorRepository.UnitOfWork = _unitOfWork; _frequencyRepository = new CachedRepository<CS_Frequency>(); _frequencyRepository.UnitOfWork = _unitOfWork; _customerInfoRepository = new EFRepository<CS_CustomerInfo>(); _customerInfoRepository.UnitOfWork = _unitOfWork; _jobDescriptionRepository = new EFRepository<CS_JobDescription>(); _jobDescriptionRepository.UnitOfWork = _unitOfWork; _scopeOfWorkRepository = new EFRepository<CS_ScopeOfWork>(); _scopeOfWorkRepository.UnitOfWork = _unitOfWork; _locationInfoRepository = new EFRepository<CS_LocationInfo>(); _locationInfoRepository.UnitOfWork = _unitOfWork; _jobPhotoReportRepository = new EFRepository<CS_JobPhotoReport>(); _jobPhotoReportRepository.UnitOfWork = _unitOfWork; _presetInfoRepository = new EFRepository<CS_PresetInfo>(); _presetInfoRepository.UnitOfWork = _unitOfWork; _lostJobInfoRepository = new EFRepository<CS_LostJobInfo>(); _lostJobInfoRepository.UnitOfWork = _unitOfWork; _specialPricingRepository = new EFRepository<CS_SpecialPricing>(); _specialPricingRepository.UnitOfWork = _unitOfWork; _jobInfoRepository = new EFRepository<CS_JobInfo>(); _jobInfoRepository.UnitOfWork = _unitOfWork; _jobStatusHistoryRepository = new EFRepository<CS_Job_JobStatus>(); _jobStatusHistoryRepository.UnitOfWork = _unitOfWork; _jobPermitRepository = new EFRepository<CS_JobPermit>(); _jobPermitRepository.UnitOfWork = _unitOfWork; _divisionRepository = new EFRepository<CS_Division>(); _divisionRepository.UnitOfWork = _unitOfWork; _employeeRepository = new EFRepository<CS_Employee>(); _employeeRepository.UnitOfWork = _unitOfWork; _customerRepository = new EFRepository<CS_Customer>(); _customerRepository.UnitOfWork = _unitOfWork; _cityRepository = new EFRepository<CS_City>(); _cityRepository.UnitOfWork = _unitOfWork; _stateRepository = new EFRepository<CS_State>(); _stateRepository.UnitOfWork = _unitOfWork; _countryRepository = new EFRepository<CS_Country>(); _countryRepository.UnitOfWork = _unitOfWork; _zipCodeRepository = new EFRepository<CS_ZipCode>(); _zipCodeRepository.UnitOfWork = _unitOfWork; _contactRepository = new EFRepository<CS_Contact>(); _contactRepository.UnitOfWork = _unitOfWork; _callLogRepository = new EFRepository<CS_CallLog>(); _callLogRepository.UnitOfWork = _unitOfWork; _jobPermitTypeRepository = new CachedRepository<CS_JobPermitType>(); _jobPermitTypeRepository.UnitOfWork = _unitOfWork; _jobSummaryRepository = new EFRepository<CS_View_JobSummary>(); _jobSummaryRepository.UnitOfWork = _unitOfWork; _callLogResourceRepository = new EFRepository<CS_CallLogResource>(); _callLogResourceRepository.UnitOfWork = _unitOfWork; _callLogCallCriteriaEmailRepository = new EFRepository<CS_CallLogCallCriteriaEmail>(); _callLogCallCriteriaEmailRepository.UnitOfWork = _unitOfWork; _turnoverActiveReportRepository = new EFRepository<CS_View_TurnoverActiveReport>(); _turnoverActiveReportRepository.UnitOfWork = _unitOfWork; _turnoverNonActiveReportRepository = new EFRepository<CS_View_TurnoverNonActiveReport>(); _turnoverNonActiveReportRepository.UnitOfWork = _unitOfWork; _jobLocalEquipmentTypeRepository = new EFRepository<CS_Job_LocalEquipmentType>(); _jobLocalEquipmentTypeRepository.UnitOfWork = _unitOfWork; _settingsModel = new SettingsModel(_unitOfWork); _emailModel = new EmailModel(_unitOfWork); _callCriteriaModel = new CallCriteriaModel(_unitOfWork); _mailList = new List<CS_ScopeOfWork>(); _divisionList = new List<CS_JobDivision>(); _mailScope = new StringBuilder(); _mailBillingBuilder = new StringBuilder(); _jobDataRepository = new EFRepository<CS_View_GetJobData>(); _jobDataRepository.UnitOfWork = _unitOfWork; _jobLocalEquipmentTypeRepository = new EFRepository<CS_Job_LocalEquipmentType>(); _jobLocalEquipmentTypeRepository.UnitOfWork = _unitOfWork; _projectCalendarAllocationRepository = new EFRepository<CS_View_ProjectCalendar_Allocation>(); _projectCalendarAllocationRepository.UnitOfWork = _unitOfWork; _projectCalendarReservedRepository = new EFRepository<CS_View_ProjectCalendar_Reserved>(); _projectCalendarReservedRepository.UnitOfWork = _unitOfWork; _projectCalendarCallLogRepository = new EFRepository<CS_View_ProjectCalendar_CallLog>(); _projectCalendarCallLogRepository.UnitOfWork = _unitOfWork; }
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); } }