public ActionResult PrintRatingReportPerBusinessUnit(List <SurveyStatus> Survey_ForList, bool includeRaters, string businessUnit) { if (Survey_ForList.Count() == 0) { return(Redirect("PrintRatingReport")); } List <string> itemRow = new List <string>(); RatingReport reportObject = new RatingReport(); DataTable dt = new DataTable(); SurveyForList surveyReportPParameterObject = new SurveyForList(); surveyReportPParameterObject.Type = "Annually"; surveyReportPParameterObject.Period = "2016"; //var tempDirectoryPath = ConfigurationManager.AppSettings["BusinessUnitReportLocation"] + @"" + businessUnit; //var files = Directory.GetFiles(tempDirectoryPath, "*.xlsx"); //if (Directory.Exists(tempDirectoryPath)) //{ // foreach (var item in files) // { // System.IO.File.Delete(item); // } // Directory.Delete(tempDirectoryPath); //} foreach (var ratee in Survey_ForList) { surveyReportPParameterObject.Survey_For = ratee.Survey_For; List <SurveyStatus> list = new List <SurveyStatus>(); list.Add(new SurveyStatus() { Survey_For = ratee.Survey_For }); var raterList = new List <string>(); if (!string.IsNullOrWhiteSpace(ratee.Survey_For)) { dt = new DataTable(); var report = new Surveys().getSurveyForReport(surveyReportPParameterObject); if (report.Count() > 0) { ViewBag.ReportList = report; dt = reportObject.GetColumns(dt, report); reportObject.AddHeadings(dt, ratee.Survey_For, report.First().Period); reportObject.AddQuestionHeadings(dt, report); reportObject.AddQuestionAverallMinRating(dt, report); reportObject.AddQuestionAverallMaxRating(dt, report); reportObject.AddQuestionAverageRating(dt, report); dt.Rows.Add(new List <string>().ToArray()); //if (includeRaters) //{ itemRow.Add("INDIVIDUAL RATER SCORES AND COMMENTS"); dt.Rows.Add(itemRow.ToArray()); var raters = report.Select(c => c.Rater).AsQueryable().Distinct().ToList(); var questionsPerRater = report.Select(c => c.Rater_Comment).AsQueryable().Distinct().ToList(); //for (int i = 0; i < report.Select(c => c.Question_ID).AsQueryable().Distinct().ToList().Count; i++) // { foreach (var item in raters) { var record = report.Where(c => c.Rater == item).ToList(); reportObject.AddIndividualRaterComment(dt, record, includeRaters, item, report); reportObject.AddIndividualRating(dt, record, includeRaters, item, report); } // } //} } } if (!string.IsNullOrWhiteSpace(ratee.Survey_For) && dt.Rows.Count > 0) { GenerateRatingReportExcelFilePerBusinessUnit(dt, list, includeRaters, businessUnit); } } return(Redirect("PrintRatingReport")); }
//[AccessDeniedAuthorize(Roles = @"FUTUREGROWTH\FG-APP-PAS-ADMIN")] public ActionResult PrintRatingReport(string Survey_For) { var generateBulkReport = false; List <SurveyStatus> employeePerBusinessUnit = new List <SurveyStatus>(); var surveyFor = Request.Form["Survey_For"]; var includeRaters = Convert.ToBoolean(Request.Form["IncludeRaters"]); //Generate report per business unit var employeeForList = GetEmployeeList(); var teamList = new Surveys().getSurveyTeams(); if (surveyFor == "Performance and Attribution") { surveyFor = surveyFor.Replace("and", "&"); } var employeeSurveyListPerTeam = teamList.Where(c => c.Team == surveyFor); //if this is true then, generate bulk report if (employeeSurveyListPerTeam.Count() > 0) { generateBulkReport = true; if (generateBulkReport) { employeePerBusinessUnit = employeeForList.Where(c => c.Team_Desc == surveyFor).ToList(); } PrintRatingReportPerBusinessUnit(employeePerBusinessUnit, includeRaters, surveyFor); } else { if (string.IsNullOrWhiteSpace(surveyFor)) { return(View()); } List <string> itemRow = new List <string>(); RatingReport reportObject = new RatingReport(); DataTable dt = new DataTable(); SurveyForList surveyReportPParameterObject = new SurveyForList(); surveyReportPParameterObject.Type = "Annually"; surveyReportPParameterObject.Period = "2016"; surveyReportPParameterObject.Survey_For = surveyFor; var raterList = new List <string>(); if (!string.IsNullOrWhiteSpace(surveyFor)) { var report = new Surveys().getSurveyForReport(surveyReportPParameterObject); if (report.Count > 0) { ViewBag.ReportList = report; dt = reportObject.GetColumns(dt, report); reportObject.AddHeadings(dt, surveyFor, report.First().Period); reportObject.AddQuestionHeadings(dt, report); reportObject.AddQuestionAverallMinRating(dt, report); reportObject.AddQuestionAverallMaxRating(dt, report); reportObject.AddQuestionAverageRating(dt, report); dt.Rows.Add(new List <string>().ToArray()); //if (includeRaters) //{ itemRow.Add("INDIVIDUAL RATER SCORES AND COMMENTS"); dt.Rows.Add(itemRow.ToArray()); var raters = report.Select(c => c.Rater).AsQueryable().Distinct().ToList(); var questionsPerRater = report.Select(c => c.Rater_Comment).AsQueryable().Distinct().ToList(); // for (int i = 0; i < report.Select(c => c.Question_ID).AsQueryable().Distinct().ToList().Count; i++) // { foreach (var item in raters) { var record = report.Where(c => c.Rater == item).ToList(); reportObject.AddIndividualRaterComment(dt, record, includeRaters, item, report); reportObject.AddIndividualRating(dt, record, includeRaters, item, report); } // } //} } } if (!string.IsNullOrWhiteSpace(surveyFor) && dt.Rows.Count > 0) { GenerateRatingReportExcelFile(dt, surveyFor, includeRaters); } } return(RedirectToAction("PrintRatingReport")); }