public FileStreamResult ExportExcelCategories(Guid? businessAppId) { PaginatedList<CatalogueModel> model = Session["SearchCatalogueCategoriesExcel"] as PaginatedList<CatalogueModel>; Session.Remove("SearchCatalogueCategoriesExcel"); string logoPath = Server.MapPath("~/Images/logo.png"); MemoryStream report = ExcelBusiness.GenerateCatalogueReport(model.Collection, logoPath); report.Position = 0; string currentDateTime = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"); MicrosoftExcelStreamResult result = new MicrosoftExcelStreamResult(report, "CatalogueReport" + currentDateTime + ".xlsx"); return result; }
public FileStreamResult ExportExcelValues() { CatalogueValueSearchModel model = Session["SearchCatalogueValuesExcel"] as CatalogueValueSearchModel; Session.Remove("SearchCatalogueValuesExcel"); string logoPath = Server.MapPath("~/Images/logo.png"); MemoryStream report = ExcelBusiness.GenerateCatalogueValueReport(model, logoPath); report.Position = 0; string currentDateTime = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"); MicrosoftExcelStreamResult result = new MicrosoftExcelStreamResult(report, "CatalogueValue" + currentDateTime + ".xlsx"); return result; }
/// <summary> /// Perform the creation of the excel file with the information of the service orders /// </summary> /// <param name="collection">Form collection</param> /// <returns>Json result</returns> public ActionResult ExecuteSeachServiceOrders(FormCollection collection) { bool resultMethod; try { bool isClient = User.IsInRole("Client"); Guid businessApplicationId = new Guid(Convert.ToString(Session["BusinessAplicationId"])); //if the logged user is client, the system will add a new key in the collection with the id of the client DynamicDataGrid model = GetModelExcelExport(isClient, collection, businessApplicationId); model.Captions = _captions; model.BusinessApplicationName = _businessApplicationName; model.FormName = _formName; string logoPath = Server.MapPath("~/Images/logo.png"); //generate the report MemoryStream report = ExcelBusiness.GenerateReportDinamically(model, logoPath); report.Position = 0; string currentDateTime = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"); //download the report MicrosoftExcelStreamResult result = new MicrosoftExcelStreamResult(report, "ServiceOrderReport" + currentDateTime + ".xlsx"); resultMethod = true; Session.Add("ResultSearchServiceOrders", result); } catch (Exception ex) { resultMethod = false; ExceptionManager.HandleException(ex, "AllExceptionsPolicy"); } return Json(resultMethod); }
/// <summary> /// Build the excel file /// </summary> /// <returns>JSON</returns> public ActionResult GenerateExcelAllInspectionReports() { bool resultMethod; try { ExportInspectionReportsModel result = Session["ResultSearchAllInspectionReports"] as ExportInspectionReportsModel; Session.Remove("ResultSearchAllInspectionReports"); Guid businessApplicationId = new Guid(Convert.ToString(Session["BusinessAplicationId"])); result.InspectionReports.Values.ToList().ForEach(value => { value.BusinessApplicationName = _businessApplicationName; }); string currentDateTime = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"); string orderNumber = result.ServiceOrderData.OrderIdentifier == null || String.IsNullOrEmpty(result.ServiceOrderData.OrderIdentifier.FieldValue) ? Resources.Common.ServiceOrderUndefined : result.ServiceOrderData.OrderIdentifier.FieldValue; string logoPath = Server.MapPath("~/Images/logo.png"); MemoryStream ms = ExcelBusiness.GenerateAllInspectionReports(result, logoPath); ms.Position = 0; MicrosoftExcelStreamResult report = new MicrosoftExcelStreamResult(ms, "InspectionReports_SO_" + orderNumber + "_" + currentDateTime + ".xlsx"); resultMethod = true; Session.Add("AllInspectionReports", report); } catch (Exception ex) { resultMethod = false; ExceptionManager.HandleException(ex, "AllExceptionsPolicy"); } return Json(resultMethod); }
public ActionResult SearchInfoInspectionReport(FormCollection collection) { bool resultMethod; try { Guid businessApplicationId = new Guid(Convert.ToString(Session["BusinessAplicationId"])); Guid serviceOrderReportId = new Guid(Session["serviceOrderReportId"].ToString()); //get the data DynamicDataGrid model = GetModelExportExcel(collection, businessApplicationId, serviceOrderReportId); string businessApplicationName = Session["businessApplicationName"].ToString(); model.FormName = _inspectionReportId; model.BusinessApplicationName = businessApplicationName; string reportName = _inspectionReportId.Replace(" ", ""); string logoPath = Server.MapPath("~/Images/logo.png"); //generate the report MemoryStream report = ExcelBusiness.GenerateReportDinamically(model,logoPath); report.Position = 0; string currentDateTime = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"); MicrosoftExcelStreamResult result = new MicrosoftExcelStreamResult(report, reportName + "Report" + currentDateTime + ".xlsx"); resultMethod = true; Session.Add("ResultInspectionReportSearch", result); } catch (Exception ex) { resultMethod = false; ExceptionManager.HandleException(ex, "AllExceptionsPolicy"); } return Json(resultMethod); }
public FileStreamResult ExportExcelUsers() { PaginatedList<UserGridModel> model = Session["ResultSearchUsers"] as PaginatedList<UserGridModel>; Session.Remove("ResultSearchUsers"); string logoPath = Server.MapPath("~/Images/logo.png"); MemoryStream report = ExcelBusiness.GenerateUserReport(model.Collection, logoPath); report.Position = 0; string currentDateTime = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"); //download the report MicrosoftExcelStreamResult result = new MicrosoftExcelStreamResult(report, "UserReport" + currentDateTime + ".xlsx"); return result; }
/// <summary> /// Generate permission report /// </summary> /// <returns></returns> public FileStreamResult ExportExcelPermissions() { string userNameAccess = Session["userNameAccess"].ToString(); int userType = int.Parse(Session["userTypeAccess"].ToString()); string userTypeName = UserTypes.First(data => data.Key == userType).Value; PaginatedList<PermissionGridModel> model = Session["SearchPermissionExcel"] as PaginatedList<PermissionGridModel>; Session.Remove("SearchPermissionExcel"); string logoPath = Server.MapPath("~/Images/logo.png"); MemoryStream report = ExcelBusiness.GeneratePermissionReport(model.Collection, userNameAccess, userTypeName, logoPath); report.Position = 0; string currentDateTime = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"); //download the report MicrosoftExcelStreamResult result = new MicrosoftExcelStreamResult(report, "PermissionReport" + currentDateTime + ".xlsx"); return result; }