コード例 #1
0
        public static List<string> CreatePdfPerAccount(XtraReportDefaultTemplate xreport, ReportDataSet dSet, string pReportsPath)
        {
            List<string> _PdfFiles = new List<string>();
            foreach (DataRow row in dSet.account.Rows) {
                if (row.RowState == DataRowState.Deleted)
                    continue;

                var dSetClone = (ReportDataSet)dSet.Copy();
                var dset = dSetClone.account.Select(String.Format("NOT(account_id={0})", row["account_id"]));
                foreach (var rowD in dset)
                    rowD.Delete();

                dSetClone.AcceptChanges();
                string fileName = String.Format(@"{0}\{1}_{2}_{3}.pdf",
                    pReportsPath,
                    row["company_name"].ToString().Replace(" ", "_").Replace(":", "_").Replace("/", "").Replace(@"\", ""),
                    DateTime.Now.ToString("yyyy-MM-dd"),
                    Guid.NewGuid().ToString()
                );

                var report = xreport.CloneReport() as XtraReportDefaultTemplate;
                report.ReportHeader.Controls.Clear();
                PdfExportOptions pdfOptions = report.ExportOptions.Pdf;
                pdfOptions.Compressed = true;
                pdfOptions.ImageQuality = PdfJpegImageQuality.Low;
                report.DataSource = dSetClone;
                report.ExportToPdf(fileName);
                _PdfFiles.Add(fileName);
            }

            return _PdfFiles;
        }
コード例 #2
0
        public static string GetReportLayout(XtraReportDefaultTemplate pTemplate)
        {
            var ms = new MemoryStream();
            //xreport.SaveLayoutToXml(ms);
            pTemplate.SaveLayout(ms);
            ms.Position = 0;

            var sr = new StreamReader(ms, Encoding.Default);
            string _reportTemplate = sr.ReadToEnd();
            return _reportTemplate;
        }
コード例 #3
0
        public static string SavePDF(XtraReportDefaultTemplate xreport, ReportDataSet dSet, string pReportsPath, bool pIsWebPortalCall = false)
        {
            // Set PDF-specific export options.
            //string reportPath = Directory.GetCurrentDirectory();

            //string reportPath = ConfigurationManager.AppSettings["PdfReportsPath"].ToString(); // for debugging purposes only
            //if (pIsWebPortalCall)
            //string reportPath = ConfigManager.AppSettings["PdfReportsPath"].ToString();

            if (!pIsWebPortalCall) {
                if (!Directory.Exists(@"C:\BrightVision"))
                    Directory.CreateDirectory(@"C:\BrightVision");

                if (!Directory.Exists(@"C:\BrightVision\PdfReports"))
                    Directory.CreateDirectory(@"C:\BrightVision\PdfReports");
            }

            string fileName = "";
            ReportDataSet dSetClone = new ReportDataSet();
            foreach (DataRow row in dSet.account.Rows) {
                if (row.RowState == DataRowState.Deleted)
                    continue;

                dSetClone = (ReportDataSet)dSet.Copy();
                var dset = dSetClone.account.Select(String.Format("NOT(account_id={0})", row["account_id"]));
                foreach (var rowD in dset)
                    rowD.Delete();

                dSetClone.AcceptChanges();
                fileName = String.Format(@"{0}\{1}_{2}_{3}.pdf",
                    pReportsPath,
                    row["company_name"].ToString().Replace(" ", "_").Replace(":", "_").Replace("/", "").Replace(@"\", ""),
                    DateTime.Now.ToString("yyyy-MM-dd"),
                    Guid.NewGuid().ToString()
                );
            }

            var report = xreport.CloneReport() as XtraReportDefaultTemplate;
            report.ReportHeader.Controls.Clear();
            PdfExportOptions pdfOptions = report.ExportOptions.Pdf;
            pdfOptions.Compressed = true;
            pdfOptions.ImageQuality = PdfJpegImageQuality.Low;
            report.DataSource = dSetClone;
            report.ExportToPdf(fileName);

            return fileName;
        }
コード例 #4
0
 public ReportUserDesigner(ReportDataSet dataset)
 {
     InitializeComponent();
     xreport = XtraReportDefault.CreateXtraReportDefaultTemplate(dataset);
     additional_data_report_templates _item = m_efDbModel.additional_data_report_templates.FirstOrDefault(i => i.is_default == true);
     if (_item != null) {
         if (!string.IsNullOrEmpty(_item.layout_config)) {
             MemoryStream _stream = new MemoryStream();
             StreamWriter _writer = new StreamWriter(_stream, Encoding.Default);
             _writer.Write(_item.layout_config);
             _writer.Flush();
             _stream.Position = 0;
             xreport.LoadLayout(_stream);
         }
     }
     this.LoadDefault();
 }
コード例 #5
0
        public static XtraReportDefaultTemplate CreateXtraReportDefaultTemplate(ReportDataSet reportDataset)
        {
            XtraReportDefaultTemplate rdt = new XtraReportDefaultTemplate();

            rdt.DataSource = reportDataset;
            return rdt;
        }
コード例 #6
0
        public static void SavePDFPerAccount(XtraReportDefaultTemplate xreport, ReportDataSet dSet)
        {
            FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog();
            string reportPath = string.Empty;
            if (folderBrowserDialog.ShowDialog() == DialogResult.OK) {
                foreach (DataRow row in dSet.account.Rows) {
                    if (row.RowState == DataRowState.Deleted)
                        continue;

                    var dSetClone = (ReportDataSet)dSet.Copy();
                    var dset = dSetClone.account.Select(String.Format("NOT(account_id={0})", row["account_id"]));
                    foreach (var rowD in dset)
                        rowD.Delete();

                    dSetClone.AcceptChanges();
                    reportPath = folderBrowserDialog.SelectedPath;
                    string fileName = String.Format(@"{0}\{1}_{2}_{3}.pdf",
                        reportPath,
                        row["company_name"].ToString().Replace(" ", "_").Replace(":", "_").Replace("/", "").Replace(@"\", ""),
                        DateTime.Now.ToString("yyyy-MM-dd"),
                        Guid.NewGuid().ToString()
                    );

                    //string fileName = String.Format("{0}\\{1}_{2}.pdf", reportPath, row["company_name"].ToString().Replace(" ", "_").Replace(":", "_"), DateTime.Now.ToString("yyyy-MM-dd_HH_mm_ss"));

                    var report = xreport.CloneReport() as XtraReportDefaultTemplate;
                    report.ReportHeader.Controls.Clear();
                    PdfExportOptions pdfOptions = report.ExportOptions.Pdf;
                    pdfOptions.Compressed = true;
                    pdfOptions.ImageQuality = PdfJpegImageQuality.Low;
                    report.DataSource = dSetClone;
                    report.ExportToPdf(fileName);
                }
                DialogResult _dlg = MessageBox.Show(
                    string.Format("Successfully generated reports.{0}Would you like to open the folder where the reports are saved?", Environment.NewLine),
                    "Brightvision Reports",
                    MessageBoxButtons.YesNo,
                    MessageBoxIcon.Question
                );
                if (_dlg == DialogResult.Yes)
                    System.Diagnostics.Process.Start(folderBrowserDialog.SelectedPath);
            }
        }
コード例 #7
0
            private string ShowReportPagePreview(ReportDataSet pReportDataSet, bool pCreateFile = false)
            {
                m_ReportPageTemplateProperty.StatisticsDataSource = new DataTable();
                if (m_CallingEnvironment != eCallingEnvironment.BrightSales_SendEmail)
                    m_ReportPageTemplateProperty.StatisticsDataSource = this.GetFilteredData();

                string template = m_eftConfigData.report_layout_config;
                if (string.IsNullOrEmpty(template))
                    template = BrightVision.Reporting.Business.FacadeReportTemplate.GetDefaultReportLayout();

                XtraReportDefaultTemplate _report = new XtraReportDefaultTemplate(template, m_ReportPageTemplateProperty) {
                    DataSource = pReportDataSet
                };

                /**
                 * return the file name created if has any,
                 * else just show report and return empty string.
                 */
                if (pCreateFile) {
                    string _FileName = String.Format(@"{0}\Report_{1}_{2}.pdf",
                        m_ReportsPath,
                        DateTime.Now.ToString("yyyy-MM-dd"),
                        Guid.NewGuid().ToString()
                    );

                    XtraReportDefaultTemplate _TemplatePdf = _report;
                    PdfExportOptions pdfOptions = _TemplatePdf.ExportOptions.Pdf;
                    pdfOptions.Compressed = true;
                    pdfOptions.ImageQuality = PdfJpegImageQuality.Low;
                    _TemplatePdf.DataSource = pReportDataSet;
                    _TemplatePdf.ExportToPdf(_FileName);

                    return _FileName;
                }
                else
                    _report.ShowPreview();

                return string.Empty;
            }
コード例 #8
0
            private string GenerateReports()
            {
                string _PdfFileName = string.Empty;

                try {
                    this.GetReportPageBaseData();
                    XtraReportDefaultTemplate _report = new XtraReportDefaultTemplate();
                    var result = m_ReportPageTemplateProperty.DynamicProperty.Where(q => q.Type == TemplateDynamicType.Statistics);
                    if (m_ReportPageTemplateProperty.DynamicProperty != null && m_ReportPageTemplateProperty.DynamicProperty.Count > 0)
                        m_ReportPageTemplateProperty.DynamicProperty.RemoveAll(param => param.Type == TemplateDynamicType.Statistics);

                    string template = m_eftConfigData.report_layout_config;
                    if (template == null)
                        template = BrightVision.Reporting.Business.FacadeReportTemplate.GetDefaultReportLayout();

                    _report = new XtraReportDefaultTemplate(template);
                    if (m_IsWebPortalCall) {
                        if (m_CallingEnvironment == eCallingEnvironment.BrightManager_ViewDisplay ||
                            m_CallingEnvironment == eCallingEnvironment.BrightSales_ViewDisplay ||
                            m_CallingEnvironment == eCallingEnvironment.BrightSales_SendEmail) {

                            /**
                             * create report for a specific account only
                             * with no report headers.
                             */
                            if (m_AccountId > 0)
                                _PdfFileName = XtraReportDefaultTemplate.SavePDF(_report, m_ReportPageDataSet, m_ReportsPath, m_IsWebPortalCall);

                            /**
                             * create a report containing all accounts and contacts
                             * with report headers.
                             */
                            else
                                _PdfFileName = this.ShowReportPagePreview(m_ReportPageDataSet, true);
                        }
                        else if (m_CallingEnvironment == eCallingEnvironment.BrightManager_SaveAccountPerPdf ||
                                 m_CallingEnvironment == eCallingEnvironment.BrightSales_SaveAccountPerPdf) {

                            m_lstPdfFiles = new List<string>();
                            m_lstPdfFiles = XtraReportDefaultTemplate.CreatePdfPerAccount(_report, m_ReportPageDataSet, m_ReportsPath);
                        }
                    }

                    /**
                     * this means that the call was made by the application.
                     * Bright Manager or Bright Sales. (for sending emails)
                     */
                    else {
                        if (m_AccountId > 0 && m_CallingEnvironment == eCallingEnvironment.BrightSales_SendEmail)
                            _PdfFileName = XtraReportDefaultTemplate.SavePDF(_report, m_ReportPageDataSet, m_ReportsPath, m_IsWebPortalCall);
                    }

                    //if (m_CallingEnvironment == eCallingEnvironment.BrightSales_SendEmail || m_IsWebPortalCall) {
                    //    /**
                    //     * create report for a specific account only
                    //     * with no report headers.
                    //     */
                    //    if (m_AccountId > 0)
                    //        _PdfFileName = XtraReportDefaultTemplate.SavePDF(_report, m_ReportPageDataSet, m_ReportsPath, m_IsWebPortalCall);

                    //    /**
                    //     * create a report containing all accounts and contacts
                    //     * with report headers.
                    //     */
                    //    else
                    //        _PdfFileName = this.ShowReportPagePreview(m_ReportPageDataSet, true);
                    //}
                    //else
                    //    XtraReportDefaultTemplate.SavePDFPerAccount(_report, m_ReportPageDataSet);
                }
                catch (Exception e) {
                    if (m_IsWebPortalCall)
                        throw e;

                    BrightVision.Common.UI.NotificationDialog.Error("Reports", e.Message);
                }

                return _PdfFileName;
            }
コード例 #9
0
        private void btnShowReport_Click(object sender, EventArgs e)
        {
            /**
             * ready to use vars
             * ViewConfigId
             * SubCampaignId
             * m_efeExportViewTemplate -> object handle for export_view_report_templates
             */

            WaitDialog.Show(ParentForm, "Loading report...");
            if (StaticDatasource.Rows.Count == 0)
            {
                WaitDialog.Close();
                return;
            }

            // current report template selected row
            XtraReportDefaultTemplate _report;
            var _efDbModel = new BrightPlatformEntities(UserSession.EntityConnection) { CommandTimeout = 0 };
            var _ReportTemplate = gvReportTemplate.GetFocusedRow() as CTAdditionalDataReportTemplate;
            var _efeReportTemplate = m_efDbModel.additional_data_report_templates.FirstOrDefault(i => i.id == _ReportTemplate.id);
            templateData.StatisticsDataSource = this.StaticDatasource;
            string template = _efeReportTemplate.layout_config;
            if (template == null)
                template = ToString(new XtraReportDefaultTemplate());

            _report = new XtraReportDefaultTemplate(template, templateData);
            _report.DataSource = this.ReportDatasetTemp;
            WaitDialog.Close();
            _report.ShowPreviewDialog();
        }