Exemple #1
0
        /// <summary>
        /// Saves the booking details report.
        /// </summary>
        /// <param name="booking">The booking.</param>
        /// <param name="companyId">The company identifier.</param>
        /// <param name="userId">The user identifier.</param>
        /// <param name="bookingPath">The booking path.</param>
        private Task SaveBookingDetailsReport(BookingInfo booking, int companyId, int userId, string bookingPath)
        {
            InventoryBL inventoryBL            = new InventoryBL(DataContext);
            string      bookingDetailsFileName = string.Format("{0} {1} details", booking.BookingNumber, Utils.Ellipsize(booking.BookingName, 50));
            BookingDetailsReportParameters parametersBookingDetails = new BookingDetailsReportParameters
            {
                BookingId      = booking.BookingId,
                BookingName    = booking.BookingName,
                CompanyId      = companyId,
                ContactPerson  = null,
                DisplayMode    = "Admin",
                ItemTypeId     = 0,
                RelatedTable   = booking.RelatedTable,
                SortExpression = string.Empty,
                UserId         = userId
            };

            string fileNameExtension;
            string encoding;
            string mimeType;

            byte[] reportBytes = UserWebReportHandler.GenerateBookingDetailsReport(parametersBookingDetails, ReportTypes.Excel,
                                                                                   out fileNameExtension, out encoding, out mimeType, true);
            return(FileHandler.SaveFileToDisk(reportBytes, string.Format("{0}.{1}", bookingDetailsFileName, fileNameExtension), bookingPath));
        }
Exemple #2
0
        /// <summary>
        /// Exports the report.
        /// </summary>
        /// <param name="exportType">Type of the export.</param>
        private void ExportReport(ReportTypes exportType)
        {
            int itemTypeId;

            int.TryParse(ddItemTypes.SelectedValue, out itemTypeId);
            string fileName = string.Empty;

            Data.Company company = GetBL <CompanyBL>().GetCompany(ViewingCompanyId);
            fileName = string.Format("{0}'s_Bookings", company.CompanyName);

            BookingDetailsReportParameters parameters = new BookingDetailsReportParameters
            {
                BookingId          = this.BookingId,
                BookingName        = GetBookingName(),
                CompanyId          = ViewingCompanyId,
                ContactPerson      = GetContactedPerson(),
                DisplayMode        = DisplayMode.ToString(),
                ItemTypeId         = itemTypeId,
                RelatedTable       = this.RelatedTableName,
                SortExpression     = gvBookingDetails.MasterTableView.SortExpressions.GetSortString(),
                UserId             = this.UserID,
                ShowMyBookingsOnly = chkMyBookingsOnly.Checked
            };

            string fileNameExtension;
            string encoding;
            string mimeType;

            byte[] reportBytes = UserWebReportHandler.GenerateBookingDetailsReport(parameters, exportType,
                                                                                   out fileNameExtension, out encoding, out mimeType, true);
            Utils.ExportReport(reportBytes, mimeType, fileNameExtension, fileName);
        }