Inheritance: IDisposable
Ejemplo n.º 1
0
        public bool openDocument(String fileName)
        {
            cMouseWait mouse = new cMouseWait();
            try
            {
                if (!m_report.loadSilent(fileName))
                {
                    return false;
                }

                m_report.getLaunchInfo().setStrConnect(m_database);

                Application.DoEvents();
                
                return true;
            }
            catch (Exception ex)
            {
                return false;
            }
            finally
            {
                mouse.Dispose();
            }
        }
Ejemplo n.º 2
0
        public void showProperties() {
            if (m_keyFocus == "") { return; }

            cMouseWait mouse = new cMouseWait();

            if (m_paint.paintObjIsSection(m_keyFocus)) {
                showSectionProperties();
            } 
            else {
                m_keyObj = m_keyFocus;
                pShowCtrlProperties();
            }

            refreshAll();
        }
Ejemplo n.º 3
0
        public bool openDocument(String fileName) {
            cMouseWait mouse = new cMouseWait();
            try {

                // to avoid reentrancy
                m_opening = true;

                if (fileName == "") {

                    pSetInitDir();

                    // TODO: the original version of this function
                    //       made a very dirty use of the return of m_report.load
                    //
                    //       the code creates a new document when m_report.load(...)
                    //       return false and m_report.getName != ""
                    //
                    //       when m_report.load is translated we will
                    //       need to rewrite this function
                    //
                    //       in the original function there was a goto to
                    //       a 'done' label 
                    if (!m_report.load(m_fmain.openFileDialog)) {

                        if (m_report.getName() == "")  
                            return false;

                        // here the original function has a goto
                        // 'goto done'
                    }

                } 
                else {

                    if (!m_report.loadSilent(fileName)) {
                        return false;
                    }
                }

                reLoadReport();

                // here the original function has a 'done' label
                // 
                /*
                 * 
                Done:
                   With m_fmain.cmDialog
                        Dim FileEx As CSKernelFile.cFileEx
                        Set FileEx = New CSKernelFile.cFileEx
                        .InitDir = FileEx.FileGetPath(.FileName)
                   End With

                 * I don't know wath this code is suposed to do
                 * but it is clear that is very dirty so we
                 * will need to rewrite all this lines
                 */ 

                Application.DoEvents();

				cGlobals.setDocActive(this);

                m_opening = false;

                return true;
            }
            catch (Exception ex) {
                return false;
            }
            finally {
                mouse.Dispose();
            }            
        }
Ejemplo n.º 4
0
        public bool saveDocument(bool saveAs) {
            cMouseWait mouse = new cMouseWait(); 
            try {
                bool isNew = false;

                isNew = m_report.getName() == "";

                if (isNew) {
					m_report.setName(m_name);
                }

                if (saveAs) {
                    isNew = true;
                }

                setZOrder();

                pValidateSectionAspect();

                if (!m_report.save(m_fmain.saveFileDialog, isNew))
                reLoadReport();
                return true;

            } catch (Exception ex) {
                cError.mngError(ex, "saveDocument", C_MODULE, "");
                return false;
            }
            finally {
                mouse.Dispose();
            }
        }
Ejemplo n.º 5
0
        private void launchReport() {
            cMouseWait mouse = new cMouseWait(); 
            try {
                setZOrder();
                showProgressDlg();

                m_report.getLaunchInfo().getPrinter().setPaperInfo(m_report.getPaperInfo());
                m_report.getLaunchInfo().setObjPaint(new CSReportPaint.cReportPrint());
				// TODO: remove this
				m_report.getLaunchInfo().setHwnd(0);
                m_report.getLaunchInfo().setShowPrintersDialog(true);
                m_report.launch();

            } catch (Exception ex) {
                cError.mngError(ex, "launchReport", C_MODULE, "");
            }
            finally {
                mouse.Dispose();
                closeProgressDlg();
            }
        }
Ejemplo n.º 6
0
        public bool openDocument(String fileName) {
            cMouseWait mouse = new cMouseWait();
            try {

                // to avoid reentrancy
                m_opening = true;

                if (fileName == "") {

                    pSetInitDir();

                    if (!m_report.load(m_fmain.openFileDialog)) {

                        if (m_report.getName() == "")
                            return false;
                    }

                }
                else {

                    if (!m_report.loadSilent(fileName)) {
                        return false;
                    }
                }

                reLoadReport();

                Application.DoEvents();

                cMainEditor.setDocActive(this);

                m_opening = false;

                // Testing
                //

                //m_paint.initGrid(m_picReport.CreateGraphics(), m_typeGrid);

                //var bmp = m_paint.getBitmap();
/*
                var g = Graphics.FromImage(bmp);
                var graph = m_picReport.CreateGraphics();

                System.Drawing.Rectangle rect = new System.Drawing.Rectangle(0, 0, (int)graph.VisibleClipBounds.Width, (int)graph.VisibleClipBounds.Height + 56); // TODO check why 56 ???
                Brush brush = new SolidBrush(Color.Red);
                g.FillRectangle(brush, rect);
                brush.Dispose();

                var b = new SolidBrush(Color.Black);
                g.FillRectangle(b, new RectangleF(0,0,10,10));
                g.FillRectangle(b, new RectangleF(100,100, 10, 10));

                Brush bg = new System.Drawing.Drawing2D.HatchBrush(
                                            System.Drawing.Drawing2D.HatchStyle.DottedGrid,
                                            Color.FromArgb(0xC0C0C0),
                                            Color.White);

                g.FillRectangle(bg, new RectangleF(200, 100, 100, 100));



                b.Dispose();
                bg.Dispose();
                graph.Dispose();
                g.Dispose();
 */
                //m_picReport.Image = bmp;

                return true;
            }
            catch (Exception ex) {
                return false;
            }
            finally {
                mouse.Dispose();
            }
        }
Ejemplo n.º 7
0
        public bool saveData(object commDialog, bool withDialog)
        { // TODO: Use of ByRef founded Public Function SaveData(ByRef CommDialog As Object, Optional ByVal WithDialog As Boolean = True) As Boolean
            CSXml.cXml docXml = null;
            docXml = new CSXml.cXml();

            docXml.init(commDialog);
            docXml.setFilter(C_FILEDATAEX);
            docXml.setName(getFileName(m_name) + "-data.csd");
            docXml.setPath(m_path);

            if (withDialog)
            {
                if (!docXml.newXmlWithDialog())
                {
                    return false;
                }
            }
            else
            {
                if (!docXml.newXml())
                {
                    return false;
                }
            }

            Application.DoEvents();

            cMouseWait mouse = new cMouseWait();
            String dataName = "";
            String dataPath = "";

            dataName = docXml.getName();
            dataPath = docXml.getPath();

            CSXml.cXmlProperty xProperty = null;
            xProperty = new CSXml.cXmlProperty();

            xProperty.setName("RptName");
            xProperty.setValue(eTypes.eText, dataName);
            docXml.addProperty(xProperty);

            // Configuracion de paginas
            XmlNode nodeObj = null;
            XmlNode nodeObjAux = null;

            // Paginas
            cReportPage page = null;

            xProperty.setName(C_NODERPTPAGES);
            xProperty.setValue(eTypes.eText, "");
            nodeObj = docXml.addNode(xProperty);

            for (int _i = 0; _i < m_pages.count(); _i++)
            {
                page = m_pages.item(_i);
                page.save(docXml, nodeObj);
                if (!saveDataForWeb(page, dataName, dataPath))
                {
                    return false;
                }
            }

            if (!docXml.save())
            {
                return false;
            }

            if (!docXml.openXml())
            {
                return false;
            }

            if (!nLoadData(docXml))
            {
                return false;
            }

            mouse.Dispose();

            return true;
        }
Ejemplo n.º 8
0
        private void launchReport()
        {
            cMouseWait mouse = new cMouseWait();
            try
            {
                showProgressDlg();

                var li = m_report.getLaunchInfo();

                li.getPrinter().setPaperInfo(m_report.getPaperInfo());

                m_fPrint = new cReportPrint();
                m_fPrint.setHidePreviewWindow(true);
                li.setObjPaint(m_fPrint);

                // TODO: remove this
                li.setHwnd(0);
                li.setShowPrintersDialog(true);

                m_report.launch();

            }
            catch (Exception ex)
            {
                cError.mngError(ex, "launchReport", C_MODULE, "");
            }
            finally
            {
                mouse.Dispose();
                closeProgressDlg();
            }
        }
Ejemplo n.º 9
0
        private bool make()
        {
            float detailHeight = 0;
            float lineHeight = 0;

            CSReportDll.cReportPageFields fields = null;
            CSReportDll.cReportPageField field = null;
            CSReportDll.cReportPageFields detail = null;

            csRptGetLineResult rslt;
            csRptNewPageResult rsltNewPage;
            float top = 0;
            float topSection = 0;
            float heightSection = 0;
            int secLnIndex = -1;
            float[] offsetTop = null;
            float[] vdummy = null;

            cMouseWait mouse = new cMouseWait();

            printerSetSizeAndOrient(
                m_report.getLaunchInfo().getPrinter().getDeviceName(),
                m_report.getPaperInfo().getPaperSize(),
                m_report.getPaperInfo().getOrientation());

            m_currPage = -1;

            // we create the first page
            //
            rsltNewPage = m_report.newPage();

            // if it has failed
            //
            if (rsltNewPage == csRptNewPageResult.CSRPTNPERROR)
            {
                return false;
            }

            // if there is no data
            //
            if (rsltNewPage == csRptNewPageResult.CSRPTNPEND)
            {
                return m_report.endPage() != csRptEndPageResult.CSRPTEPERROR;
            }

            // we are goin to evaluate the detail's first line
            // or group header's first line only if there are not
            // groups
            //
            if (m_report.getGroups().count() == 0)
            {
                m_report.evalPreGroupHeader();
                m_report.evalPre();
            }

            // get details dimensions
            //
            detailHeight = getDetailHeight(m_report.getPages().item(m_report.getPages().count()-1), ref top);

            // add the height of the images for controls which can grow and are in the header
            //
            getLineHeight(m_report.getPages().item(m_report.getPages().count()-1).getHeader(), ref vdummy);

            do
            {
                // get the line
                //
                rslt = m_report.getLine(ref fields);

                // if we have finished
                //
                if (rslt == csRptGetLineResult.CSRPTGLEND)
                {
                    break;
                }

                // if the row is virtual we need to call the engine
                // to give it a chance to evalute formulas in the
                // header which are marked to be compiled before printing
                //
                if (rslt == csRptGetLineResult.CSRPTGLVIRTUALH)
                {

                    m_report.evalPreGroupHeader();

                    // idem for footers
                    //
                }
                else if (rslt == csRptGetLineResult.CSRPTGLVIRTUALF)
                {

                    m_report.evalPreGroupFooter();

                    // if the engine responded that we need to create a new page
                    //
                }
                else if (rslt == csRptGetLineResult.CSRPTGLNEWPAGE)
                {
                    // get the new page
                    //
                    if (!pNewPage(ref top, ref detailHeight))
                    {
                        return false;
                    }
                }
                else
                {
                    // get the line's height
                    //
                    lineHeight = getLineHeight(fields, ref offsetTop);

                    // if it can fit we create a new page
                    //
                    if (lineHeight > detailHeight)
                    {

                        // get the new page
                        //
                        if (!pNewPage(ref top, ref detailHeight))
                        {
                            return false;
                        }
                    }
                    else
                    {
                        heightSection = 0;
                        topSection = 0;
                        secLnIndex = -1;

                        //---------------------------------------------------------------------------------
                        // this code is here and not in a function because we want to improve the
                        // speed when run the report
                        //
                        // add the line to the page
                        //
                        detail = m_report.getPages().item(m_report.getPages().count()-1).getDetail();

                        for (int _i = 0; _i < fields.count(); _i++)
                        {
                            field = fields.item(_i);

                            // get the field's top
                            //
                            CSReportDll.cReportSectionLine w_sectionLine = field.getInfo().getSectionLine();

                            // one time for section
                            //
                            if (secLnIndex != w_sectionLine.getIndex())
                            {
                                secLnIndex = w_sectionLine.getIndex();
                                CSReportDll.cReportAspect w_aspect = w_sectionLine.getAspect();
                                topSection = topSection + (w_aspect.getTop() - (topSection + heightSection));
                                heightSection = heightSection + w_aspect.getHeight();
                            }

                            field.setTop(top
                                            + offsetTop[secLnIndex]
                                            + (field.getInfo().getAspect().getTop()
                                            - topSection));

                            detail.add(field);
                        }
                        //---------------------------------------------------------------------------------

                        // get the detail's height
                        //
                        top = top + lineHeight;
                        detailHeight = detailHeight - lineHeight;

                        // notify the engine about the groups' staste
                        //
                        if (rslt == csRptGetLineResult.CSRPTGLGROUPHEADER)
                        {
                            m_report.markGroupHeaderPrinted();

                            // evaluate every function which are mark 
                            // to be printed after printing
                            //
                            m_report.evalPostGroupHeader();

                        }
                        else if (rslt == csRptGetLineResult.CSRPTGLGROUPFOOTER)
                        {
                            m_report.markGroupFooterPrinted();

                            // evaluate every function which are mark 
                            // to be printed after printing
                            //
                            m_report.evalPostGroupFooter();

                        }
                        else if (rslt == csRptGetLineResult.CSRPTGLDETAIL)
                        {
                            m_report.evalPost();
                            m_report.moveToNext();
                        }
                        if (m_report.getLineType() == csRptGetLineResult.CSRPTGLDETAIL)
                        {
                            m_report.evalPre();
                        }
                    }
                }
            } while (true);

            return m_report.endPage() != csRptEndPageResult.CSRPTEPERROR;
        }
Ejemplo n.º 10
0
        public void printPage(int nPage, bool inPrinter)
        {
            CSReportDll.cReportPage page = null;

            cMouseWait mouse = new cMouseWait();

            m_rePaintObject = true;

            if (nPage > 1)
            {
                m_currPage = nPage-1;
            }
            else
            {
                switch (nPage)
                {
                    case (int)csEMoveTo.C_FIRSTPAGE:
                        m_currPage = 0;
                        break;
                    case (int)csEMoveTo.C_LASTPAGE:
                        m_currPage = m_report.getPages().count()-1;
                        break;
                    case (int)csEMoveTo.C_NEXTPAGE:
                        if (m_currPage + 1 < m_report.getPages().count())
                        {
                            m_currPage = m_currPage + 1;
                        }
                        else
                        {
                            m_currPage = m_report.getPages().count()-1;
                        }
                        break;
                    case (int)csEMoveTo.C_PREVIOUSPAGE:
                        if (m_currPage - 1 >= 0)
                        {
                            m_currPage = m_currPage - 1;
                        }
                        else
                        {
                            m_currPage = 0;
                        }
                        break;
                }
            }
            if (m_currPage == -1 || m_currPage > m_report.getPages().count()-1) { return; }

            page = m_report.getPages().item(m_currPage);

            // we need to clear the print object
            //
            m_paint.getPaintObjects().clear();

            createPaintObjects(page.getHeader(), C_OFFSETHEADER);
            createPaintObjects(page.getDetail(), C_OFFSETDETAIL);
            createPaintObjects(page.getFooter(), C_OFFSETFOOTER);

            if (!inPrinter)
            {
                // set the current page in the preview window
                //
                m_rpwPrint.setCurrPage(m_currPage);

                m_rpwPrint.getBody().Refresh();
            }
        }
Ejemplo n.º 11
0
        private bool pExportPDF(ref String outputFile, bool bShowPDFWindow)
        {
            try
            {
                cMouseWait mouse = new cMouseWait();

                Application.DoEvents();

                CSReportExport.cReportPdf expPDF = null;
                expPDF = new CSReportExport.cReportPdf();

                expPDF.setFileName(cUtil.getValidPath(System.Environment.GetEnvironmentVariable("TEMP")) + pGetExportFileName());
                expPDF.setExportEmailAddress(m_report.getExportEmailAddress());

                return expPDF.exportEx(m_report, this, outputFile, bShowPDFWindow);

            }
            catch (Exception ex)
            {
                cError.mngError(ex, "pExportPDF", C_MODULE, "");
                return false;
            }
        }
Ejemplo n.º 12
0
 public bool initDbEx(string nameDb,
                      string server,
                      string user,
                      string password,
                      string connect,
                      bool useOleDb)
 {
     cMouseWait mouseWait = new cMouseWait();
     try
     {
         closeDb();
         if (m_ocn == null)
         {
             m_ocn = createConnection();
         }
         m_originalStrConnect = connect;
         if (connect == "")
         {
             connect = string.Format("Data Source={0};User Id={1};Password={2};Integrated Security=no;",
                                     server,
                                     user,
                                     password);
             m_serverName = server;
             m_userName = user;
             m_password = password;
         }
         else
         {
             m_serverName = cUtil.getToken(connect, "Data Source=");
             m_userName = cUtil.getToken(connect, "User="******"Password="******"initDbEx", c_module, "");
         return false;
     }
     finally
     {
         mouseWait.Dispose();
     }
 }
Ejemplo n.º 13
0
        public bool getNewId(string table,
                             string fieldId,
                             out int id,
                             string function,
                             string module,
                             string title,
                             eErrorLevel level)
        {
            cMouseWait mouseWait = new cMouseWait();
            id = cConstants.C_NO_ID;
            try
            {
                if (pGetNewId(table, fieldId, out id, false,
                               function, module, title, level))
                {
                    return true;
                }
                else
                {
                    if (pReconnectTry())
                    {
                        return pGetNewId(table, fieldId, out id, true,
                                         function, module, title, level);
                    }
                    else return false;
                }
            }
            catch (Exception ex)
            {
                cError.mngError(ex, "getNewId for " + module + "." + function, c_module, "");
                return false;
            }
            finally
            {
                mouseWait.Dispose();
            }

        }