public void ProcessPendingServiceRequests(string templateFilePath) { try { string emailTemplateContent = FilesHandler.GetFileContent(templateFilePath); List <ServiceRequestDto> requests = requestService.GetAllEmailPendingRequests(); string emailClientIP = settingsService.GetSystemSettingValue("Email Proxy Server"); string ownerEmailID = settingsService.GetSystemSettingValue("Contractor Request Email Owner"); string bccEmailID = settingsService.GetSystemSettingValue("Contractor Request Email BCC Email IDs"); string outlookPwd = settingsService.GetSystemSettingValue("Owner's Outlook EMAIL Password"); string emailSubject = "New Contractor Request for Agilisium"; EmailHandler emailHandler = new EmailHandler(ownerEmailID, outlookPwd); foreach (var request in requests) { try { StringBuilder vendorEmail = new StringBuilder(emailTemplateContent); vendorEmail.Replace("__EMAIL_BODY__", request.EmailMessage); emailHandler.SendEmail(emailClientIP, request.VendorEmailID, emailSubject, vendorEmail.ToString(), bccEmailID); requestService.UpdateEmailSentStatus(request.ServiceRequestID); } catch (Exception) {} } } catch (Exception) { } }
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()); }
private string GenerateEmailBody(string templateFilePath, int podID, string podName, string managerName, int reportingDay) { logger.Info("Generating email body"); string emailTemplateContent = FilesHandler.GetFileContent(templateFilePath); StringBuilder emailBody = new StringBuilder(emailTemplateContent); emailBody.Replace("__POD__", podName); emailBody.Replace("__MANAGER_NAME__", managerName); emailBody.Replace("__DAY__", reportingDay.ToString()); CultureInfo ci = Thread.CurrentThread.CurrentCulture; string monthName = ci.DateTimeFormat.GetMonthName(DateTime.Today.Month); emailBody.Replace("__MONTH_NAME__", monthName); return(emailBody.ToString()); }
private string GenerateEmailBody(string templateFilePath) { logger.Info("Generating email body"); List <BillabilityWiseAllocationSummaryDto> allocationSummary = allocationService.GetBillabilityWiseAllocationSummary().ToList(); ResourceCountDto dto = empService.GetEmployeesCountSummary(); string emailTemplateContent = FilesHandler.GetFileContent(templateFilePath); StringBuilder emailBody = new StringBuilder(emailTemplateContent); emailBody.Replace("__TODAY__", DateTime.Today.Year.ToString() + "/" + DateTime.Today.Month + "/" + DateTime.Today.Day); emailBody.Replace("__TOTAL_COUNT__", dto.TotalCount.ToString()); emailBody.Replace("__DELIVERY_COUNT__", dto.DeliveryCount.ToString()); emailBody.Replace("__BD_COUNT__", dto.BdCount.ToString()); emailBody.Replace("__BO_COUNT__", dto.BoCount.ToString()); emailBody.Replace("__BILLABLE__", allocationSummary.FirstOrDefault(e => e.AllocationType == "Billable")?.NumberOfEmployees.ToString()); emailBody.Replace("__COMMITED_BUFFER__", allocationSummary.FirstOrDefault(e => e.AllocationType == "Committed Buffer")?.NumberOfEmployees.ToString()); emailBody.Replace("__NON_COMMITED_BUFFER__", allocationSummary.FirstOrDefault(e => e.AllocationType == "Non-Committed Buffer")?.NumberOfEmployees.ToString()); emailBody.Replace("__NOT_ALLOCATED_YET_DELIVERY__", allocationSummary.FirstOrDefault(e => e.AllocationType == "Not Allocated - Delivery")?.NumberOfEmployees.ToString()); emailBody.Replace("__NOT_ALLOCATED_YET_OTHERS__", allocationSummary.FirstOrDefault(e => e.AllocationType == "BD & BO")?.NumberOfEmployees.ToString()); emailBody.Replace("__BENCH_AVAILABLE__", allocationSummary.FirstOrDefault(e => e.AllocationType == "Bench (Available)")?.NumberOfEmployees.ToString()); emailBody.Replace("__BENCH_EARMARKED__", allocationSummary.FirstOrDefault(e => e.AllocationType == "Bench (Earmarked)")?.NumberOfEmployees.ToString()); return(emailBody.ToString()); }