public static void SendEmail(WorkshopSettings workshopSettings, MailSettings mailSettings, Document document, string attachmentPath) { if (workshopSettings == null) { throw new ArgumentNullException(nameof(workshopSettings)); } if (mailSettings == null) { throw new ArgumentNullException(nameof(mailSettings)); } if (document == null) { return; } string recipient = GetRecipientEmailAddresses(workshopSettings, mailSettings, document.CustomerContact); if (string.IsNullOrEmpty(recipient)) { return; } recipient.Split(';').ForEach(c => { CreateEmailTask(mailSettings, attachmentPath, c); }); }
private static string GetRecipientEmailAddresses(WorkshopSettings workshopSettings, MailSettings mailSettings, string customerContact) { string recipients = string.Empty; if (mailSettings == null || mailSettings.DontSendEmails || workshopSettings.DoNotSend) { return(recipients); } if (workshopSettings.SendToOffice) { recipients = AppendRecipient(recipients, workshopSettings.MainEmailAddress); recipients = AppendRecipient(recipients, workshopSettings.SecondaryEmailAddress); } if (workshopSettings.SendToCustomer && !string.IsNullOrEmpty(customerContact)) { var repository = ContainerBootstrapper.Resolve <IRepository <CustomerContact> >(); CustomerContact customer = repository.FirstOrDefault(contact => string.Equals(customerContact, contact.Name, StringComparison.CurrentCultureIgnoreCase)); if (customer != null) { if (IsValidEmail(customer.Email)) { recipients = AppendRecipient(recipients, customer.Email); } if (IsValidEmail(customer.SecondaryEmail)) { recipients = AppendRecipient(recipients, customer.SecondaryEmail); } } } return(recipients); }
public static void Email(this PDFDocumentResult pdfDocumentResult, WorkshopSettings workshopSettings, MailSettings mailSettings) { if (pdfDocumentResult.Document == null) { return; } EmailHelper.SendEmail(workshopSettings, mailSettings, pdfDocumentResult.Document, pdfDocumentResult.FilePath); }
public static void Create(PDFDocument document, LetterForDecommissioningDocument letterForDecommissioningDocument) { var settingsRepository = ContainerBootstrapper.Resolve <ISettingsRepository <WorkshopSettings> >(); WorkshopSettings settings = settingsRepository.GetWorkshopSettings(); var repository = ContainerBootstrapper.Resolve <IRepository <CustomerContact> >(); var customerContact = repository.FirstOrDefault(contact => string.Equals(letterForDecommissioningDocument.CustomerContact, contact.Name, StringComparison.CurrentCultureIgnoreCase)); if (customerContact != null) { AbsolutePositionText(document, customerContact.Name, 61, 740, 500, 50, document.GetLargeFont(true), Element.ALIGN_LEFT); AbsolutePositionText(document, customerContact.Address, 61, 720, 500, 50, document.GetLargerFont(false), Element.ALIGN_LEFT); AbsolutePositionText(document, $"{customerContact.Town}, {customerContact.PostCode}", 61, 705, 500, 50, document.GetLargerFont(false), Element.ALIGN_LEFT); } if (letterForDecommissioningDocument.InspectionDate != null) { AbsolutePositionText(document, letterForDecommissioningDocument.InspectionDate.Value.ToString("dd.MM.yyyy"), 61, 660, 200, 20, document.GetLargerFont(false), Element.ALIGN_LEFT); } string line1 = GetParagraph1Text(letterForDecommissioningDocument.TachographMake, letterForDecommissioningDocument.TachographModel, letterForDecommissioningDocument.SerialNumber, letterForDecommissioningDocument.RegistrationNumber); AbsolutePositionText(document, line1, 61, 620, 550, 50, document.GetLargerFont(false), Element.ALIGN_LEFT); string line2 = GetParagraph2Text(); AbsolutePositionText(document, line2, 61, 575, 550, 50, document.GetLargerFont(false), Element.ALIGN_LEFT); string line3 = GetParagraph3Text(); AbsolutePositionText(document, line3, 61, 518, 550, 100, document.GetLargerFont(false), Element.ALIGN_LEFT); string line4 = GetParagraph4Text(); AbsolutePositionText(document, line4, 61, 455, 550, 100, document.GetLargerFont(false), Element.ALIGN_LEFT); string regardsText = GetRegardsText(letterForDecommissioningDocument.Technician); AbsolutePositionText(document, regardsText, 61, 395, 550, 100, document.GetLargerFont(false), Element.ALIGN_LEFT); AbsolutePositionText(document, Resources.TXT_SIGNATURE, 61, 350, 550, 100, document.GetSmallerFont(), Element.ALIGN_LEFT); document.DrawLine(110, 320, 350, 320); TryAddSignature(document, letterForDecommissioningDocument, 140, 310); AbsolutePositionText(document, settings.WorkshopName, 61, 200, 500, 100, document.GetLargerFont(false), Element.ALIGN_LEFT); string address1 = $"{settings.Address1}, {settings.Address2}"; AbsolutePositionText(document, address1, 61, 185, 500, 100, document.GetLargerFont(false), Element.ALIGN_LEFT); string address2 = $"{settings.Town}, {settings.PostCode}"; AbsolutePositionText(document, address2, 61, 170, 500, 100, document.GetLargerFont(false), Element.ALIGN_LEFT); }
public StatusReportViewModel(List <Technician> technicians, WorkshopSettings workshopSettings, List <StatusReportUserViewModel> users) { Users = users; if (technicians == null || technicians.Count == 0 || workshopSettings == null) { return; } TachoCentreLastCheck = workshopSettings.CentreQuarterlyCheckDate; TachoCentreNextCheck = workshopSettings.CentreQuarterlyCheckDate == null ? (DateTime?)null : workshopSettings.CentreQuarterlyCheckDate.GetValueOrDefault().AddMonths(3).Date; GV212LastCheck = workshopSettings.MonthlyGV212Date; ColorStart = ColorStop = GetColorForScore(technicians); Score = CalculateScore(technicians); }
public static void Create(PDFDocument document, UndownloadabilityDocument undownloadabilityDocument) { var settingsRepository = ContainerBootstrapper.Resolve <ISettingsRepository <WorkshopSettings> >(); WorkshopSettings settings = settingsRepository.GetWorkshopSettings(); var rawData = ImageHelper.LoadFromResourcesAsByteArray("UndownloadHeader"); document.AddImage(rawData, 390, 290, 59, document.Height - 350); AbsolutePositionText(document, settings.WorkshopName, 61, 710, 500, 50, document.GetLargeFont(true), Element.ALIGN_LEFT); AbsolutePositionText(document, settings.Address1, 61, 680, 500, 50, document.GetRegularFont(false), Element.ALIGN_LEFT); AbsolutePositionText(document, $"{settings.Town} {settings.PostCode}", 61, 645, 500, 50, document.GetRegularFont(false), Element.ALIGN_LEFT); AbsolutePositionText(document, undownloadabilityDocument.TachographMake, 61, 585, 500, 50, document.GetRegularFont(false), Element.ALIGN_LEFT); AbsolutePositionText(document, undownloadabilityDocument.TachographModel, 61, 548, 500, 50, document.GetRegularFont(false), Element.ALIGN_LEFT); AbsolutePositionText(document, undownloadabilityDocument.SerialNumber, 61, 510, 500, 50, document.GetRegularFont(false), Element.ALIGN_LEFT); string line1 = GetLine1Text(undownloadabilityDocument.TachographMake, undownloadabilityDocument.TachographModel, undownloadabilityDocument.SerialNumber, undownloadabilityDocument.RegistrationNumber); AbsolutePositionText(document, line1, 61, 450, 550, 50, document.GetLargerFont(false), Element.ALIGN_LEFT); string line2 = GetLine2Text(); AbsolutePositionText(document, line2, 61, 405, 550, 50, document.GetLargerFont(false), Element.ALIGN_LEFT); string line3 = GetLine3Text(); AbsolutePositionText(document, line3, 61, 375, 550, 100, document.GetLargerFont(false), Element.ALIGN_LEFT); string line4 = GetLine4Text(); AbsolutePositionText(document, line4, 61, 310, 550, 100, document.GetLargerFont(false), Element.ALIGN_LEFT); document.DrawLine(50, 219, 545, 219); document.DrawLine(50, 147, 545, 147); document.DrawLine(125, 172, 238, 172); document.DrawLine(322, 172, 484, 172); if (undownloadabilityDocument.InspectionDate != null) { AbsolutePositionText(document, undownloadabilityDocument.InspectionDate.Value.ToString("dd.MM.yyyy"), 125, 195, 200, 20, document.GetSmallerFont(), Element.ALIGN_LEFT); } AbsolutePositionText(document, Resources.TXT_DATE, 125, 175, 200, 20, document.GetSmallerFont(), Element.ALIGN_LEFT); TryAddSignature(document, undownloadabilityDocument, 310, 158); AbsolutePositionText(document, string.Format(Resources.TXT_UNDOWNLOADABILITY_SIGNATURE, undownloadabilityDocument.Technician), 322, 175, 522, 20, document.GetSmallerFont(), Element.ALIGN_LEFT); }
public void UploadWorkshopSettings(WorkshopSettings workshopSettings) { using (var context = new ConnectContext()) { workshopSettings.Id = 0; workshopSettings.UserId = GetUserId(); workshopSettings.Uploaded = DateTime.Now; if (workshopSettings.Created == default(DateTime) || workshopSettings.Created == _sqlDefaultDateTime) { workshopSettings.Created = DateTime.Now; } context.Set <WorkshopSettings>().Add(workshopSettings); context.SaveChanges(); } }
public static void BackupIfRequired(WorkshopSettings workshopSettings) { if (workshopSettings == null) { throw new ArgumentNullException(nameof(workshopSettings)); } if (workshopSettings.BackupFilePath == null) { return; } if (workshopSettings.BackupFilePath.Length < 3 || workshopSettings.BackupFilePath == Resources.TXT_NO_PATH_SPECIFIED || workshopSettings.AutoBackup == false || workshopSettings.CustomDayOfWeeks == null || workshopSettings.CustomDayOfWeeks.Count == 0) { return; } if (workshopSettings.CustomDayOfWeeks.Any(d => CustomDayOfWeek.Parse(d.DayOfWeek) == DateTime.Now.DayOfWeek)) { AutoBackup(workshopSettings.BackupFilePath); } }
public static void Email(this GV212Report gv212Report, WorkshopSettings workshopSettings, MailSettings mailSettings) { ReCreateGV212(gv212Report).Email(workshopSettings, mailSettings); }