/// <summary> /// Get the information of all inspection reports in the service order /// </summary> /// <returns>ExportInspectionReportsModel</returns> public static ExportInspectionReportsModel SearchInspectionReportsByServiceOrder(ParameterSearchAllInspectionReport parameters) { ExportInspectionReportsModel result = new ExportInspectionReportsModel(); using (VestalisEntities context = new VestalisEntities()) { //Get the list of inspection reports by service order var inspectionReports = (from inspectionRep in context.InspectionReports join serviceOrd in context.ServiceOrders on inspectionRep.ServiceOrderId equals serviceOrd.ServiceOrderId where inspectionRep.IsDeleted == false && serviceOrd.IsDeleted == false && serviceOrd.ServiceOrderId == parameters.ServiceOrderId && parameters.SelectedReports.Contains(inspectionRep.FormName) orderby inspectionRep.FormOrder select new { inspectionRep.FormName, inspectionRep.FormOrder }).ToList(); bool isClient = Roles.IsUserInRole(parameters.UserName, "Client"); List<string> rolesForUser = Roles.GetRolesForUser(parameters.UserName).ToList(); foreach (var item in inspectionReports) { DynamicDataGrid gridColumns = InspectionReportBusiness.GetInspectionReportGridDefinition(parameters.BusinessApplicationId, isClient, item.FormName); //set the parameters ParameterSearchInspectionReport parameterSearchInspectionReport = new ParameterSearchInspectionReport { BusinessApplicationId = parameters.BusinessApplicationId, Collection = new FormCollection(), InspectionReportName = item.FormName, ServiceOrderId = parameters.ServiceOrderId, UserName = parameters.UserName, RolesForUser = rolesForUser, PageSize = 0, SelectedPage = 0, IsClient = isClient, IsExport = true, Captions = gridColumns.Captions }; //get the information of the current inspection report DynamicDataGrid model = InspectionReportBusiness.SearchInspectionReportList(parameterSearchInspectionReport); result.InspectionReports.Add(item.FormName, model); } result.ServiceOrderData = GetServiceOrderForm(parameters.BusinessApplicationId, parameters.ServiceOrderId); if (parameters.IsSelectedServiceOrder) { result.IsSelectedServiceOrder = true; result.ServiceOrderSheetName = parameters.ServiceOrderReportName; } } return result; }
/// <summary> /// Search all service orders for exporting to excel /// </summary> /// <param name="rowId">Id of service order</param> /// <param name="selectedReports">Report names selected for exporting to excel</param> public ActionResult ExecuteSearchAllInspectionReportsExport(Guid rowId, string selectedReports) { List<string> inspectionReports = selectedReports.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries).ToList(); if (inspectionReports.Count == 0) { return Json(Resources.ServiceOrder.GenerateReportMessage); } else { Guid businessApplicationId = new Guid(Convert.ToString(Session["BusinessAplicationId"])); ParameterSearchAllInspectionReport parameters = new ParameterSearchAllInspectionReport() { BusinessApplicationId = businessApplicationId, ServiceOrderId = rowId, UserName = UserName, SelectedReports = inspectionReports, IsSelectedServiceOrder = inspectionReports.Contains(Resources.ServiceOrder.ServiceOrderMenu), ServiceOrderReportName = Resources.ServiceOrder.ServiceOrderMenu }; ExportInspectionReportsModel result = ServiceOrderBusiness.SearchInspectionReportsByServiceOrder(parameters); result.BusinessApplicationName = _businessApplicationName; Session.Add("ResultSearchAllInspectionReports", result); return Json(""); } }