private string GenerateAllocationReportAsCsvFile(string appTempDirectory) { logger.Info("Generate CSV file for the attachment"); string filePath = ""; StringBuilder recordString = new StringBuilder($"Employee ID,Employee Name,Primary Skills,Secondary Skills,Business Unit,Project Name,Account Name,Allocation Type,Allocation Start Date,Allocation End Date,Project Manager,Comments{Environment.NewLine}"); try { List <BillabilityWiseAllocationDetailDto> detailsDtos = allocationService.GetBillabilityWiseAllocationDetail("all", "all").ToList(); foreach (BillabilityWiseAllocationDetailDto dto in detailsDtos) { recordString.Append($"{dto.EmployeeID},"); recordString.Append($"{dto.EmployeeName},"); recordString.Append($"{dto.PrimarySkills?.Replace(",", "")},"); recordString.Append($"{dto.SecondarySkills?.Replace(",", "")},"); recordString.Append($"{dto.BusinessUnit},"); recordString.Append($"{dto.ProjectName},"); recordString.Append($"{dto.AccountName},"); recordString.Append($"{dto.AllocationType},"); recordString.Append($"{dto.AllocationStartDate?.ToString("dd/MMM/yyyy")},"); recordString.Append($"{dto.AllocationEndDate?.ToString("dd/MMM/yyyy")},"); recordString.Append($"{dto.ProjectManager},"); recordString.Append($"{dto.Comments}{Environment.NewLine}"); } string fileName = $"ResourceAllocationReport-AsOn-{DateTime.Today.Year}-{DateTime.Today.Month}-{DateTime.Today.Day}.csv"; filePath = FilesHandler.CreateFile(appTempDirectory, fileName, recordString.ToString()); } catch (Exception exp) { logger.Error("Error while generating CSV file", exp); } return(filePath); }