Example #1
0
        /// <summary>
        /// Exports the report.
        /// </summary>
        /// <param name="exportType">Type of the export.</param>
        private void ExportReport(ReportTypes exportType)
        {
            var project = GetBL <ProjectBL>().GetProject(this.ProjectId);

            if (project != null)
            {
                ItemisedPurchaseReportParameters parameters = new ItemisedPurchaseReportParameters
                {
                    CultureName    = this.CultureName,
                    ItemTypeId     = projectItemTypes.SelectedItemTypeId,
                    ProjectId      = this.ProjectId,
                    SortExpression = rgvItemisedPurchase.MasterTableView.SortExpressions.GetSortString(),
                    UserId         = this.UserID
                };

                string fileName = string.Format("{0}_ItemisedPurchaseReport", project.ProjectName);
                string fileNameExtension;
                string encoding;
                string mimeType;

                byte[] reportBytes = UserWebReportHandler.GenerateItemisedPurchaseReport(parameters, exportType,
                                                                                         out fileNameExtension, out encoding, out mimeType);
                Utils.ExportReport(reportBytes, mimeType, fileNameExtension, fileName);
            }
        }
Example #2
0
        /// <summary>
        /// Generates the itemised purchase report.
        /// </summary>
        /// <param name="project">The project.</param>
        /// <param name="itemTypeName">Name of the item type.</param>
        /// <param name="itemTypeId">The item type identifier.</param>
        /// <param name="userId">The user identifier.</param>
        /// <param name="folderPath">The folder path.</param>
        private void GenerateItemisedPurchaseReport(Project project, string itemTypeName, int itemTypeId, int userId, string folderPath)
        {
            ItemisedPurchaseReportParameters parameters = new ItemisedPurchaseReportParameters
            {
                CultureName    = Utils.GetCultureName(project.Country.CountryCode),
                ItemTypeId     = itemTypeId,
                ProjectId      = project.ProjectId,
                SortExpression = string.Empty,
                UserId         = userId
            };

            string fileName = string.Format("{0} - Itemised Purchase Report", itemTypeName);
            string fileNameExtension;
            string encoding;
            string mimeType;

            byte[] reportBytes = UserWebReportHandler.GenerateItemisedPurchaseReport(parameters, ReportTypes.Excel,
                                                                                     out fileNameExtension, out encoding, out mimeType);
            FileHandler.SaveFileToDisk(reportBytes, string.Format("{0}.{1}", fileName, fileNameExtension), folderPath).Wait();
        }