/// <summary> /// Generates the company inventory booking reports. /// </summary> /// <param name="companyId">The company identifier.</param> /// <param name="userId">The user identifier.</param> /// <param name="bookingPath">The booking path.</param> private void GenerateCompanyInventoryBookingReports(int companyId, int userId, string bookingPath) { string fileName = "Booking List"; InventoryManageBookingListReportParameters parametersBookingList = new InventoryManageBookingListReportParameters { BookingStatus = null, CompanyId = companyId, CreatedByUserId = userId, IsInventoryManagerMode = true, SearchText = string.Empty, ShowArchived = false, SortExpression = string.Empty, UserId = userId }; string fileNameExtension; string encoding; string mimeType; List <Task> asyncTaskList = new List <Task>(); byte[] reportBytes = UserWebReportHandler.GenerateInventoryManageBookingListReport(parametersBookingList, ReportTypes.Excel, out fileNameExtension, out encoding, out mimeType); asyncTaskList.Add(FileHandler.SaveFileToDisk(reportBytes, string.Format("{0}.{1}", fileName, fileNameExtension), bookingPath)); InventoryBL inventoryBL = new InventoryBL(DataContext); var bookings = inventoryBL.GetBookingInfo(companyId, null, string.Empty, null, false); foreach (BookingInfo booking in bookings) { asyncTaskList.Add(SaveBookingDetailsReport(booking, companyId, userId, bookingPath)); } Task.WaitAll(asyncTaskList.ToArray()); }
/// <summary> /// Exports the report. /// </summary> /// <param name="exportType">Type of the export.</param> private void ExportReport(ReportTypes exportType) { string fileName = string.Empty; InventoryManageBookingListReportParameters parameters = new InventoryManageBookingListReportParameters { BookingStatus = this.BookingStatus, CompanyId = this.CompanyId, CreatedByUserId = this.CreatedByUserId, IsInventoryManagerMode = this.DisplayMode == ViewMode.InventoryManager, SearchText = cboSearch.Text, ShowArchived = this.ShowArchived, SortExpression = gvBookings.MasterTableView.SortExpressions.GetSortString(), UserId = this.UserID }; if (this.DisplayMode == ViewMode.InventoryManager) { Data.Company company = GetBL <CompanyBL>().GetCompany(this.CompanyId.Value); if (company != null) { fileName = string.Format("{0}'s_Bookings", company.CompanyName); } } else if (this.DisplayMode == ViewMode.MyBookings) { Data.User user = GetBL <PersonalBL>().GetUser(this.CreatedByUserId.Value); if (user != null) { fileName = string.Format("{0}'s_Bookings", user.FirstName); } } string fileNameExtension; string encoding; string mimeType; byte[] reportBytes = UserWebReportHandler.GenerateInventoryManageBookingListReport(parameters, exportType, out fileNameExtension, out encoding, out mimeType); Utils.ExportReport(reportBytes, mimeType, fileNameExtension, fileName); }