// we modify the report data source so it uses the CSReportWebServer instead of a real sql engine (SqlServer, PostgreSQL or Oracle) // public void init(JObject request) { m_webReportId = request["message"]["webReportId"].ToString(); m_reportId = Guid.NewGuid().ToString(); m_database = Guid.NewGuid().ToString(); m_report = new cReport(); m_report.setDatabaseEngine(csDatabaseEngine.CSREPORT_WEB); m_report.Progress += reportProgress; m_report.ReportDone += reportDone; cReportLaunchInfo oLaunchInfo = new cReportLaunchInfo(); oLaunchInfo.setPrinter(cPrintAPI.getcPrinterFromDefaultPrinter(null)); registerDataSource(request); if (!m_report.init(oLaunchInfo)) { return; } m_report.setPathDefault(Application.StartupPath); }
/* TODO: implement me private void form_QueryUnload(int cancel, int unloadMode) { cancel = !saveChanges(); if (cancel) { cGlobals.setDocActive(this); } } */ /* TODO: implement me private void form_Unload(int cancel) { if (m_fmain.getReportCopySource() == this) { m_fmain.setReportCopySource(null); } if (fSearch.fSearch.getFReport() == this) { fSearch.fSearch.setFReport(null); } m_report = null; m_paint = null; m_fToolBox = null; m_fControls = null; m_fTreeCtrls = null; m_fConnectsAux = null; m_fProperties = null; m_fFormula = null; m_fGroup = null; m_fProgress.Hide(); m_fProgress = null; cGlobals.setDocInacActive(this); G.redim(ref m_vSelectedKeys, 0); G.redim(ref m_vCopyKeys, 0); } */ public void init() { m_showingProperties = false; cReportLaunchInfo oLaunchInfo = null; m_report = new cReport(); // TODO: event handler for // /* m_report_Done(); m_report_Progress(task, page, currRecord, recordCount, cancel,); m_report_FindFileAccess(answer, commDialog, file,); */ oLaunchInfo = new cReportLaunchInfo(); m_report.getPaperInfo().setPaperSize(m_fmain.getPaperSize()); m_report.getPaperInfo().setOrientation(m_fmain.getOrientation()); oLaunchInfo.setPrinter(cPrintAPI.getcPrinterFromDefaultPrinter()); oLaunchInfo.setObjPaint(new CSReportPaint.cReportPrint()); if (!m_report.init(oLaunchInfo)) { return; } CSKernelFile.cFile file = new CSKernelFile.cFile(); m_report.setPathDefault(Application.StartupPath); m_picReport.Top = C_TOPBODY; m_picRule.Left = 0; m_picReport.Left = pGetLeftBody(); m_keyMoving = ""; m_keySizing = ""; m_keyObj = ""; m_keyFocus = ""; m_nextNameCtrl = 0; m_paint = new CSReportPaint.cReportPaint(); Rectangle tR = null; cReportPaperInfo w_paperInfo = m_report.getPaperInfo(); tR = new Rectangle(CSReportPaint.cGlobals.getRectFromPaperSize( m_report.getPaperInfo(), w_paperInfo.getPaperSize(), w_paperInfo.getOrientation())); cGlobals.createStandarSections(m_report, tR); m_paint.setGridHeight(pSetSizePics(tR.height)); m_paint.initGrid(m_picReport.CreateGraphics(), m_typeGrid); paintStandarSections(); m_dataHasChanged = false; }
/* TODO: implement me private void form_QueryUnload(int cancel, int unloadMode) { cancel = !saveChanges(); if (cancel) { cGlobals.setDocActive(this); } } */ /* TODO: implement me private void form_Unload(int cancel) { if (m_fmain.getReportCopySource() == this) { m_fmain.setReportCopySource(null); } if (fSearch.fSearch.getFReport() == this) { fSearch.fSearch.setFReport(null); } m_report = null; m_paint = null; m_fToolBox = null; m_fControls = null; m_fTreeCtrls = null; m_fConnectsAux = null; m_fProperties = null; m_fFormula = null; m_fGroup = null; m_fProgress.Hide(); m_fProgress = null; cGlobals.setDocInacActive(this); G.redim(ref m_vSelectedKeys, 0); G.redim(ref m_vCopyKeys, 0); } */ public void init() { m_showingProperties = false; cReportLaunchInfo oLaunchInfo = null; m_report = new cReport(); // TODO: event handler for // /* m_report_Done(); m_report_Progress(task, page, currRecord, recordCount, cancel,); m_report_FindFileAccess(answer, commDialog, file,); */ m_report.Progress += reportProgress; m_report.ReportDone += reportDone; oLaunchInfo = new cReportLaunchInfo(); m_report.getPaperInfo().setPaperSize(m_fmain.getPaperSize()); m_report.getPaperInfo().setOrientation(m_fmain.getOrientation()); oLaunchInfo.setPrinter(cPrintAPI.getcPrinterFromDefaultPrinter(m_fmain.printDialog)); oLaunchInfo.setObjPaint(new cReportPrint()); if (!m_report.init(oLaunchInfo)) { return; } m_report.setPathDefault(Application.StartupPath); m_picReport.Top = C_TOPBODY; m_picRule.Left = 0; m_picReport.Left = pGetLeftBody(); m_keyMoving = ""; m_keySizing = ""; m_keyObj = ""; m_keyFocus = ""; m_nextNameCtrl = 0; m_paint = new cReportPaint(); Rectangle tR = null; cReportPaperInfo w_paperInfo = m_report.getPaperInfo(); tR = new Rectangle(CSReportPaint.cGlobals.getRectFromPaperSize( m_report.getPaperInfo(), w_paperInfo.getPaperSize(), w_paperInfo.getOrientation())); cGlobals.createStandarSections(m_report, tR); reLoadReport(); }
// public functions public void Dispose() { m_rows = null; m_collRows = null; m_vRowsIndexAux = null; m_vGroups = null; m_vRowsIndex = null; m_lastRowIndex = -1; m_lastRowPreEvalued = null; m_lastRowPostEvalued = null; m_controls.clear(); m_controls = null; pDestroyCrossRef(m_headers); pDestroyCrossRef(m_details); pDestroyCrossRef(m_footers); pDestroyCrossRef(m_groups.getGroupsHeaders()); pDestroyCrossRef(m_groups.getGroupsFooters()); m_headers.clear(); m_details.clear(); m_footers.clear(); m_groupsHeaders.clear(); m_groupsFooters.clear(); m_details.setCopyColl(null); m_headers.setCopyColl(null); m_footers.setCopyColl(null); m_groupsHeaders.setCopyColl(null); m_groupsFooters.setCopyColl(null); m_headers = null; m_details = null; m_footers = null; m_groupsHeaders = null; m_groupsFooters = null; m_paperInfo = null; m_formulas.clear(); m_formulas = null; m_formulaTypes.clear(); m_formulaTypes = null; m_connect = null; m_pages.clear(); m_pages = null; m_pageSetting.clear(); m_pageSetting = null; m_compiler = null; m_launchInfo = null; m_connectsAux.clear(); m_connectsAux = null; pDestroyImages(); m_images = null; }
public void setLaunchInfo(cReportLaunchInfo oLaunchInfo) { m_launchInfo = new cReportLaunchInfo(); // copy from oLaunchInfo to m_LaunchInfo // m_launchInfo.setAction(oLaunchInfo.getAction()); m_launchInfo.setStrConnect(oLaunchInfo.getStrConnect()); m_launchInfo.setCopies(oLaunchInfo.getCopies()); m_launchInfo.setObjPaint(oLaunchInfo.getObjPaint()); m_launchInfo.setDataSource(oLaunchInfo.getDataSource()); m_launchInfo.setFile(oLaunchInfo.getFile()); m_launchInfo.setFileFormat(oLaunchInfo.getFileFormat()); m_launchInfo.setInternalPreview(oLaunchInfo.getInternalPreview()); m_launchInfo.setShowPrintersDialog(oLaunchInfo.getShowPrintersDialog()); m_launchInfo.setSilent(oLaunchInfo.getSilent()); m_launchInfo.setSqlstmt(oLaunchInfo.getSqlstmt()); m_launchInfo.setPrinter(oLaunchInfo.getPrinter()); // if the printer is not defined // if (m_launchInfo.getPrinter() == null) { // we use the default printer of the OS // m_launchInfo.setPrinter(cPrintAPI.getcPrinterFromDefaultPrinter(null)); } // if we have a reference to a printer // if (m_launchInfo.getPrinter() != null) { // TODO: check the values of paperType after calling // getcPrinterFromDefaultPrinter() because // the constants used by the OS could be differents // from the used by CSReport. in the original vb6 version // it was the case // // finaly we copy into m_PaperInfo the definicion found in LaunchInfo. // // when the report is called without define a printer // whe assign a defult printer and asign m_PaperInfo // to m_LaunchInfo.Printer.PaperInfo, so sometimes we // don't need to do that // if (!object.ReferenceEquals(m_paperInfo, m_launchInfo.getPrinter().getPaperInfo())) { m_paperInfo.setHeight(m_launchInfo.getPrinter().getPaperInfo().getHeight()); m_paperInfo.setWidth(m_launchInfo.getPrinter().getPaperInfo().getWidth()); } } }
public bool launch(cReportLaunchInfo oLaunchInfo) { try { List<object[]> recordsets = null; DataTable rs = null; m_compiler.setReport(this); m_compiler.initGlobalObject(); if (oLaunchInfo == null) { if (m_launchInfo == null) { throw new ReportLaunchInfoNoDefined( C_MODULE, cReportError.errGetDescript( csRptErrors.LAUNCH_INFO_UNDEFINED)); } } else { setLaunchInfo(oLaunchInfo); } if (m_launchInfo.getPrinter() == null) { throw new ReportLaunchInfoNoDefined( C_MODULE, cReportError.errGetDescript( csRptErrors.PRINTER_NOT_DEFINED)); } if (!OnProgress("Preparando el reporte")) { return false; } // we need to sort all controls using the zorder property // sortCollection(); if (!OnProgress("Compiling report ...")) { return false; } // compile report // if (!compileReport()) { return false; } // we need to sort all controls by his aspect.left property // pSortControlsByLeft(); if (!OnProgress("Querying database")) { return false; } recordsets = new List<object[]>(); m_collRows = new DataTable[1]; // get the main recordset // if (!pGetData(ref m_rows, ref rs, m_connect, true, recordsets)) { return false; } // the first element contains the main recordset // m_collRows[0] = m_rows; pInitImages(); // get additional recordsets // if (!pGetDataAux(recordsets)) { return false; } if (!initGroups(rs, pGetMainDataSource(recordsets))) { return false; } if (!OnProgress("Initializing report")) { return false; } if (!initControls(recordsets)) { return false; } // create the definition of this report // if (!createPageSetting()) { return false; } m_pages.clear(); m_lineIndex = 0; // globals initialization // m_bPrintFooter = false; m_bLastFootersWasPrinted = false; m_groupIndexChange = 0; m_iRow2 = 0; m_iRowFormula = 0; pSetGroupFormulaHeaders(); pSetGroupsInCtrlFormulaHide(); pSetIndexColInGroupFormulas(recordsets); pInitRowFormulas(); // check if there are groups which need to be reprinted when the page change // pExistsGroupToReprintInNP(); // to force the evaluate of the groups in the first page // m_bEvalPreGroups = true; m_bCloseFooter = false; m_bOpenHeader = false; cReportFormula formula = null; for (int _i = 0; _i < m_formulas.count(); _i++) { formula = m_formulas.item(_i); formula.setHaveToEval(true); } // launch the report // m_launchInfo.getObjPaint().setReport(this); if (!m_launchInfo.getObjPaint().makeReport()) { return false; } switch (m_launchInfo.getAction()) { case csRptLaunchAction.CSRPTLAUNCHPRINTER: if (!m_launchInfo.getObjPaint().printReport()) { return false; } break; case csRptLaunchAction.CSRPTLAUNCHFILE: if (!m_launchInfo.getObjPaint().makeXml()) { return false; } break; case csRptLaunchAction.CSRPTLAUNCHPREVIEW: if (!m_launchInfo.getObjPaint().previewReport()) { return false; } break; } return true; } catch (Exception ex) { m_compiler.setReport(null); // if we haven't printed to preview // we need to clear the references // between cReport and cReportLaunchInfo // if (m_launchInfo.getAction() != csRptLaunchAction.CSRPTLAUNCHPREVIEW) { m_launchInfo.getObjPaint().setReport(null); m_launchInfo.setObjPaint(null); } throw new ReportException(csRptErrors.ERROR_WHEN_RUNNING_REPORT, C_MODULE, "Error when running report.\n\n" + "Info: " + ex.Message + "\n" + "Source: " + ex.Source + "\n" + "Stack trace: " + ex.StackTrace + "\n" + "Description: " + ex.ToString() ); } }
public bool init(cReportLaunchInfo oLaunchInfo) { try { setLaunchInfo(oLaunchInfo); return true; } catch (Exception ex) { cError.mngError(ex, "Init", C_MODULE, ""); return false; } }