/// <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()); }