/// <summary> /// Gets report extended fields for report template. /// </summary> /// <param name="templatePath">Template file path.</param> /// <param name="extendedFields">Extended fields.</param> private void _GetReportExtendedFields(string templatePath, ref List <string> extendedFields) { Debug.Assert(!string.IsNullOrEmpty(templatePath)); Debug.Assert(null != extendedFields); ActiveReport3 rpt = null; try { rpt = _LoadReportStructure(templatePath); ICollection <string> declareExtendedFields = _exporter.ExtendedFields; // check in control's "DataField" _GetExtendedFieldsFromControl(declareExtendedFields, rpt.Sections, ref extendedFields); // check in script if (extendedFields.Count != declareExtendedFields.Count) { string script = rpt.Script; if (!string.IsNullOrEmpty(script)) { _GetExtendedFieldsFromScript(declareExtendedFields, script, ref extendedFields); } } } finally { _DisposeReport(ref rpt); } }
/// <summary> /// Disposes all report core resources. /// </summary> /// <param name="report">Active report object.</param> private void _DisposeReport(ref ActiveReport3 report) { Debug.Assert(null != report); // dispose subreports for (int sectionIndex = 0; sectionIndex < report.Sections.Count; ++sectionIndex) { // find and dispose all subReports - one by one (safely) try { Section section = report.Sections[sectionIndex]; for (int controlIndex = 0; controlIndex < section.Controls.Count; ++controlIndex) { var subReport = section.Controls[controlIndex] as SubReport; if (null != subReport) { ActiveReport3 subReportObj = subReport.Report; if (null != subReportObj) { _FreeReport(ref subReportObj); } } } } catch {} // do nothing } // dispose master report _FreeReport(ref report); }
/// <summary> /// Freeses all report core resources. /// </summary> /// <param name="report">Active report object.</param> private void _FreeReport(ref ActiveReport3 report) { Debug.Assert(null != report); report.Document.Dispose(); report.Dispose(); report = null; }
//生成案卷封底 public static void PrintFileBottom(string FileID, string OutFileName) { ActiveReport3 rpt = newCjRpt.get_CJNew_BKB_Rpt(Convert.ToInt32(FileID)); DataDynamics.ActiveReports.Export.Pdf.PdfExport p = new DataDynamics.ActiveReports.Export.Pdf.PdfExport(); rpt.SetLicense(Archives.InterFace.PdfMerger.Reports.License.GetLicense()); rpt.Run(); p.Export(rpt.Document, OutFileName); System.Windows.Forms.Application.DoEvents(); }
/// <summary> /// Disposes all report core resources. /// </summary> /// <param name="description">Created report description.</param> public void DisposeReport(ReportStateDescription description) { Debug.Assert(null != description); ActiveReport3 rpt = description.Report; if (null != rpt) { description.Report = null; _DisposeReport(ref rpt); GC.Collect(); GC.WaitForFullGCApproach(); } }
//private static ReportsYG.get_YG_Reports ygrpt = new ReportsYG.get_YG_Reports(); //生成案卷封面 public static void PrintFileFace(string FileID, string OutFileName) { ActiveReport3 rpt = null; switch (PdfMergerCommand.archivesType) { case ArchivesType.文书档案: rpt = wsrpt.get_WS_FM_Rpt(Convert.ToInt32(FileID)); break; case ArchivesType.科技档案_2000: rpt = kejirpt.get_KeJi_FM_Rpt(Convert.ToInt32(FileID)); break; case ArchivesType.公安业务档案: rpt = ywrpt.get_YW_FM_Rpt(Convert.ToInt32(FileID)); break; //case ArchivesType.城建档案旧: // rpt = oldCjRpt.get_CJOld_FM_Rpt(Convert.ToInt32(FileID)); // break; case ArchivesType.城建档案新: rpt = newCjRpt.get_CJNew_FM_Rpt(Convert.ToInt32(FileID)); break; case ArchivesType.社保业务档案: rpt = sbywrpt.get_SBYW_FM_Rpt(Convert.ToInt32(FileID)); break; case ArchivesType.编制档案: rpt = bzrpt.get_BZ_FM_Rpt(Convert.ToInt32(FileID)); break; //case ArchivesType.沿革档案: // rpt = ygrpt.get_YG_FM_Rpt(Convert.ToInt32(FileID)); // break; } if (rpt != null) { DataDynamics.ActiveReports.Export.Pdf.PdfExport p = new DataDynamics.ActiveReports.Export.Pdf.PdfExport(); rpt.SetLicense(License.GetLicense()); rpt.Run(); p.Export(rpt.Document, OutFileName); System.Windows.Forms.Application.DoEvents(); } }
public EndUserDesignerForm(string reportName, string reportTemplatePath) { System.Diagnostics.Debug.Assert(!string.IsNullOrEmpty(reportTemplatePath)); InitializeComponent(); // Create new report instance and assign to Report Explorer this.arDesigner.Toolbox = this.arToolbox; this.arDesigner.PropertyGrid = this.arPropertyGrid; // Add Menu and CommandBar to Form this.commandBarManager = this.arDesigner.CommandBarManager; // Edit CommandBar // NOTE: need check after each used version of ActiveReports - can be changed this.commandBarManager.CommandBars.RemoveAt(0); // NOTE: remove menu CommandBarItem item = this.commandBarManager.CommandBars[0].Items[2]; // NOTE: get SaveAs button this.commandBarManager.CommandBars[0].Items.Clear(); // NOTE: remove New, Open, SaveAs buttons this.commandBarManager.CommandBars[0].Items.AddButton(item.Image, item.Text, new CommandEventHandler(OnSaveNew), 0); // NOTE: set customize Save routine this.Controls.Add(this.commandBarManager); // Fill Toolbox LoadTools(this.arToolbox); // Activate default group on the toolbox this.arToolbox.SelectedCategory = "ActiveReports 3.0"; // Setup Status Bar this.arStatus.Panels.Add(new StatusBarPanel()); this.arStatus.Panels.Add(new StatusBarPanel()); this.arStatus.Panels[0].AutoSize = StatusBarPanelAutoSize.Spring; this.arStatus.Panels[1].AutoSize = StatusBarPanelAutoSize.Spring; this.arStatus.ShowPanels = true; ActiveReport3 rpt = new ActiveReport3(); rpt.LoadLayout(reportTemplatePath); arDesigner.Report = rpt; if (!string.IsNullOrEmpty(reportName)) { this.Text = reportName; } templatePath = reportTemplatePath; }
/// <summary> /// Loads report structure. /// </summary> /// <param name="templatePath">Report template path.</param> /// <returns>Created and inited report core.</returns> private ActiveReport3 _LoadReportStructure(string templatePath) { Debug.Assert(!string.IsNullOrEmpty(templatePath)); // load report structure var rpt = new ActiveReport3(); rpt.Document.CacheToDisk = true; rpt.Document.CacheToDiskLocation = GetTempFullFileName(); string filePath = ReportsGenerator.GetTemplateAbsolutelyPath(templatePath); using (var fs = new FileStream(filePath, FileMode.Open, FileAccess.Read)) rpt.LoadLayout(fs); return(rpt); }
/// <summary> /// Loads report structure. /// </summary> /// <param name="templatePath">Report template path.</param> /// <returns>Created and inited report core.</returns> private ActiveReport3 _LoadReportStructure(string templatePath) { Debug.Assert(!string.IsNullOrEmpty(templatePath)); // load report structure var rpt = new ActiveReport3(); rpt.Document.CacheToDisk = true; rpt.Document.CacheToDiskLocation = GetTempFullFileName(); string filePath = ReportsGenerator.GetTemplateAbsolutelyPath(templatePath); using (var fs = new FileStream(filePath, FileMode.Open, FileAccess.Read)) rpt.LoadLayout(fs); return rpt; }
/// <summary> /// Disposes all report core resources. /// </summary> /// <param name="report">Active report object.</param> private void _DisposeReport(ref ActiveReport3 report) { Debug.Assert(null != report); // dispose subreports for (int sectionIndex = 0; sectionIndex < report.Sections.Count; ++sectionIndex) { // find and dispose all subReports - one by one (safely) try { Section section = report.Sections[sectionIndex]; for (int controlIndex = 0; controlIndex < section.Controls.Count; ++controlIndex) { var subReport = section.Controls[controlIndex] as SubReport; if (null != subReport) { ActiveReport3 subReportObj = subReport.Report; if (null != subReportObj) _FreeReport(ref subReportObj); } } } catch {} // do nothing } // dispose master report _FreeReport(ref report); }
public EndUserDesignerForm(string reportName, string reportTemplatePath) { System.Diagnostics.Debug.Assert(!string.IsNullOrEmpty(reportTemplatePath)); InitializeComponent(); // Create new report instance and assign to Report Explorer this.arDesigner.Toolbox = this.arToolbox; this.arDesigner.PropertyGrid = this.arPropertyGrid; // Add Menu and CommandBar to Form this.commandBarManager = this.arDesigner.CommandBarManager; // Edit CommandBar // NOTE: need check after each used version of ActiveReports - can be changed this.commandBarManager.CommandBars.RemoveAt(0); // NOTE: remove menu CommandBarItem item = this.commandBarManager.CommandBars[0].Items[2]; // NOTE: get SaveAs button this.commandBarManager.CommandBars[0].Items.Clear(); // NOTE: remove New, Open, SaveAs buttons this.commandBarManager.CommandBars[0].Items.AddButton(item.Image, item.Text, new CommandEventHandler(OnSaveNew), 0); // NOTE: set customize Save routine this.Controls.Add(this.commandBarManager); // Fill Toolbox LoadTools(this.arToolbox); // Activate default group on the toolbox this.arToolbox.SelectedCategory = "ActiveReports 3.0"; // Setup Status Bar this.arStatus.Panels.Add(new StatusBarPanel()); this.arStatus.Panels.Add(new StatusBarPanel()); this.arStatus.Panels[0].AutoSize = StatusBarPanelAutoSize.Spring; this.arStatus.Panels[1].AutoSize = StatusBarPanelAutoSize.Spring; this.arStatus.ShowPanels = true; ActiveReport3 rpt = new ActiveReport3(); rpt.LoadLayout(reportTemplatePath); arDesigner.Report = rpt; if (!string.IsNullOrEmpty(reportName)) this.Text = reportName; templatePath = reportTemplatePath; }