public void GenerateResourceAllocationReport(string appTempDirectory) { logger.Info("Reading system settings"); string emailClientIP = ProcessorHelper.GetSettingsValue(ProcessorHelper.EMAIL_PROXY_SERVER); string ownerEmailID = ProcessorHelper.GetSettingsValue(ProcessorHelper.CONTRACTOR_REQ_EMAIL_OWNER); string templateFilePath = ProcessorHelper.GetSettingsValue(ProcessorHelper.TEMPLATE_FOLDER_PATH) + "\\ResourceAllocationReportTemplate.html"; string toEmailID = ProcessorHelper.GetSettingsValue(ProcessorHelper.MANAGERS_EMAIL_GROUP); string outlookPwd = ProcessorHelper.GetSettingsValue(ProcessorHelper.EMAIL_OWNERS_PASSWORD); string emailSubject = "Agilisium - Resource Allocation Report"; string bccEmailIDs = ProcessorHelper.GetSettingsValue(ProcessorHelper.CONTRACTOR_REQ_BCC_RECEIPIENTS); EmailHandler emailHandler = new EmailHandler(ownerEmailID, outlookPwd); string emailContent = GenerateEmailBody(templateFilePath); string attachmentFilePath = GenerateAllocationReportAsCsvFile(appTempDirectory); logger.Info("Sending email with attachment"); emailHandler.SendEmail(emailClientIP, toEmailID, emailSubject, emailContent, bccEmailIDs, attachmentFilePath); WindowsServiceSettingsDto windowsService = new WindowsServiceSettingsDto { ExecutionInterval = "Weekly", ServiceID = (int)WindowsServices.WeeklyAllocationsMailer, ServiceName = WindowsServices.WeeklyAllocationsMailer.ToString(), }; settingRepository.UpdateWindowsServiceStatus(windowsService); }
public void GenerateManagementNotifications(string appTempDirectory, int reportingDay) { logger.Info("Reading system settings"); string emailClientIP = ProcessorHelper.GetSettingsValue(ProcessorHelper.EMAIL_PROXY_SERVER); string ownerEmailID = ProcessorHelper.GetSettingsValue(ProcessorHelper.CONTRACTOR_REQ_EMAIL_OWNER); string templateFilePath = ProcessorHelper.GetSettingsValue(ProcessorHelper.TEMPLATE_FOLDER_PATH) + "\\PODWiseEmployees.html"; string toEmailID = null; string outlookPwd = ProcessorHelper.GetSettingsValue(ProcessorHelper.EMAIL_OWNERS_PASSWORD); string emailSubject = "RMT Alert - Please Confirm, Employees Under your POD"; try { logger.Info("Deleting old files"); FilesHandler.RemoveAllFilesFromDirectory(appTempDirectory); } catch (Exception exp) { logger.Error(exp); } List <PracticeDto> pods = practiceRepository.GetAll().ToList(); logger.Info($"There are {pods.Count} PODs"); foreach (PracticeDto pod in pods) { logger.Info("Generating CSV file"); string attachmentFilePath = CreateFileAttachment(appTempDirectory, pod.PracticeID); logger.Info("Generating email content"); string emailContent = GenerateEmailBody(templateFilePath, pod.PracticeID, pod.PracticeName, pod.ManagerName, reportingDay); string managerEmailID = null; if (pod.ManagerID.HasValue) { managerEmailID = empService.GetByID(pod.ManagerID.Value)?.EmailID; } if (string.IsNullOrWhiteSpace(managerEmailID)) { managerEmailID = dmEmailID; } toEmailID = managerEmailID; logger.Info("Sending email with attachment to " + pod.ManagerName); EmailHandler emailHandler = new EmailHandler(ownerEmailID, outlookPwd); emailHandler.SendEmail(emailClientIP, toEmailID, emailSubject, emailContent, dmEmailID, attachmentFilePath, System.Net.Mail.MailPriority.High); WindowsServiceSettingsDto windowsService = new WindowsServiceSettingsDto { ExecutionInterval = "Monthly", ServiceID = (int)WindowsServices.ManagementNotifications, ServiceName = WindowsServices.ManagementNotifications.ToString(), }; settingRepository.UpdateWindowsServiceStatus(windowsService); } }
private string GenerateAllocationFailureEmailContent(ProjectAllocationDto allocation) { string templateFilePath = ProcessorHelper.GetSettingsValue(ProcessorHelper.TEMPLATE_FOLDER_PATH) + "\\AllocationFailureEmailTemplate.html"; string emailTemplateContent = FilesHandler.GetFileContent(templateFilePath); StringBuilder emailBody = new StringBuilder(emailTemplateContent); CultureInfo ci = Thread.CurrentThread.CurrentUICulture; emailBody.Replace("__START_DATE__", $"{allocation.AllocationStartDate.Day}/{ci.DateTimeFormat.GetAbbreviatedMonthName(allocation.AllocationStartDate.Month)}/{allocation.AllocationStartDate.Year}"); emailBody.Replace("__END_DATE__", $"{allocation.AllocationEndDate.Day}/{ci.DateTimeFormat.GetAbbreviatedMonthName(allocation.AllocationEndDate.Month)}/{allocation.AllocationEndDate.Year}"); emailBody.Replace("__RESOURCE_NAME__", allocation.EmployeeName); emailBody.Replace("__PROJECT_NAME__", allocation.ProjectName); emailBody.Replace("__RESOURCE_ID__", allocation.EmployeeID.ToString()); return(emailBody.ToString()); }
private string GenerateNewAllocationEmailContent(ProjectDto benchProject, EmployeeDto employee) { string templateFilePath = ProcessorHelper.GetSettingsValue(ProcessorHelper.TEMPLATE_FOLDER_PATH) + "\\NewAllocationEmailTemplate.html"; string emailTemplateContent = FilesHandler.GetFileContent(templateFilePath); StringBuilder emailBody = new StringBuilder(emailTemplateContent); CultureInfo ci = Thread.CurrentThread.CurrentUICulture; emailBody.Replace("__START_DATE__", $"{DateTime.Today.Day}/{ci.DateTimeFormat.GetAbbreviatedMonthName(DateTime.Today.Month)}/{DateTime.Today.Year}"); emailBody.Replace("__END_DATE__", $"{benchProject.EndDate.Day}/{ci.DateTimeFormat.GetAbbreviatedMonthName(benchProject.EndDate.Month)}/{benchProject.EndDate.Year}"); emailBody.Replace("__RESOURCE_NAME__", $"{employee.FirstName} {employee.LastName}"); emailBody.Replace("__PROJECT_NAME__", benchProject.ProjectName); emailBody.Replace("__RESOURCE_ID__", employee.EmployeeID.ToString()); return(emailBody.ToString()); }
public AllocationsUpdaterServiceProcessor() { logger = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); log4net.Config.XmlConfigurator.Configure(); allocationRepo = new AllocationRepository(); employeeRepo = new EmployeeRepository(); projectRepo = new ProjectRepository(); trackerRepo = new NotificationsTrackerRepository(); practiceRepository = new PracticeRepository(); settingRepository = new SystemSettingRepository(); emailClientIP = ProcessorHelper.GetSettingsValue(ProcessorHelper.EMAIL_PROXY_SERVER); ownerEmailID = ProcessorHelper.GetSettingsValue(ProcessorHelper.CONTRACTOR_REQ_EMAIL_OWNER); outlookPwd = ProcessorHelper.GetSettingsValue(ProcessorHelper.EMAIL_OWNERS_PASSWORD); }