// // GET: /Report/ public ActionResult Index(string application, [FromUri] ReportRequest request) { // this is necessary for opening the report in a new window if (request.ReportName == null) { return(View("Index")); } if (request.SearchDTO == null) { request.SearchDTO = new PaginatedSearchRequestDto(); } request.SearchDTO.ShouldPaginate = false; request.Key.Mode = SchemaMode.input; request.Key.Platform = ClientPlatform.Web; var dataResponse = _dataController.Get(application, request); var data = new DataTable(); if (dataResponse is ApplicationListResult) { var listData = ((ApplicationListResult)dataResponse).ResultObject; var schema = ((ApplicationListResult)dataResponse).Schema; data = ReportUtil.ConvertMapListToTable( listData.Select(f => f.Attributes).ToList(), schema ); } else if (dataResponse is ApplicationDetailResult) { var detailData = ((ApplicationDetailResult)dataResponse).ResultObject; var schema = ((ApplicationDetailResult)dataResponse).Schema; data = ReportUtil.ConvertMapListToTable( new List <IDictionary <string, object> >() { detailData.Attributes }, schema ); } var rdlc = ReportUtil.GetDescriptorPath(request.ReportName); var dsName = ReportUtil.GetDataSetName(request.ReportName); var parameters = new Dictionary <string, string>(); if (request.SearchDTO != null && !String.IsNullOrEmpty(request.SearchDTO.SearchParams) && !String.IsNullOrEmpty(request.SearchDTO.SearchValues)) { parameters = (Dictionary <string, string>) PopulateReportParamters(request.SearchDTO.SearchParams, request.SearchDTO.SearchValues); } //Adding SCIM to parameters for IncidentPerLocationSCIMReport string scimMatch = "SCIM"; Regex regex = new Regex(scimMatch, RegexOptions.IgnoreCase); if (regex.IsMatch(request.ReportName) && parameters.ContainsKey("commodities_description_header")) { string[] arrTemp = parameters["commodities_description_header"].Split('-'); parameters.Add("system_header", arrTemp[0] + '-' + arrTemp[1]); parameters.Add("component_header", (arrTemp.Length > 2) ? arrTemp[2] : MISSING); parameters.Add("item_header", (arrTemp.Length > 3) ? arrTemp[3] : MISSING); parameters.Add("module_header", (arrTemp.Length > 4) ? ModuleFieldValue(arrTemp) : MISSING); } else if (request.ReportName.Equals("ITCReport") && parameters.ContainsKey("persongroup_description_header")) { var strbld = new StringBuilder(); foreach (var location in parameters["persongroup_description_header"].Split(',')) { var siteAndCostCenter = location.Split('-'); strbld.Append("HLAG-"); strbld.Append(siteAndCostCenter[0]); strbld.Append(" - "); strbld.Append(siteAndCostCenter[1]); strbld.Append(", "); } if (strbld.Length > 2) { strbld.Remove(strbld.Length - 2, 2); } parameters["persongroup_description_header"] = strbld.ToString(); var user = SecurityFacade.CurrentUser(); parameters["requestor"] = user.FirstName + " " + user.LastName; } return(View("Index", new ReportModel(rdlc, dsName, data, parameters))); }