public override void writeToCsv(CsvStreamWriter writer)
        {
            if (writer == null || sections == null || !needToWrite())
            {
                return;
            }

            PressureLossReportHelper helper = PressureLossReportHelper.instance;

            if (helper == null)
            {
                return;
            }

            writer.addTitleRow(ReportResource.fittingDetailInfo);

            //fitting title
            List <string> strFittingFields = new List <string>();

            getFields(strFittingFields);
            DataTable tbTitle = new DataTable();

            helper.getTableTitle(tbTitle, strFittingFields);
            writer.AddData(tbTitle, 1);

            foreach (MEPSection section in sections)
            {
                DataTable tb = new DataTable();
                if (getFittingInfo(section, tb))
                {
                    writer.AddData(tb, 1);
                }
            }
        }
        public override void writeToCsv(CsvStreamWriter writer)
        {
            if (writer == null || system == null)
            {
                return;
            }

            //system name
            string sysName = system.Name;

            if (sysName.Length > 0)
            {
                writer.addTitleRow(sysName);
                writer.addOneEmptyRow();
            }

            if (needToWrite())
            {
                writer.addTitleRow(ReportResource.systemInformation);
                DataTable tb = new DataTable();
                getInfoDataTable(tb);
                writer.AddData(tb, 1);
            }
        }
        public override void writeToCsv(CsvStreamWriter writer)
        {
            if (writer == null || sections == null)
            {
                return;
            }

            PressureLossReportHelper helper = PressureLossReportHelper.instance;

            if (helper == null)
            {
                return;
            }

            writer.addTitleRow(ReportResource.sectionTitle);


            //section title
            List <string> strSectionFields = new List <string>();

            getFields(strSectionFields);
            DataTable tbTitle = new DataTable();

            helper.getTableTitle(tbTitle, strSectionFields, false, true);
            writer.AddData(tbTitle, 1);

            //each section
            foreach (MEPSection section in sections)
            {
                DataTable tb = new DataTable();
                if (getSectionInfo(section, tb))
                {
                    writer.AddData(tb, 1);
                }
            }
        }
        public override void writeToCsv(CsvStreamWriter writer)
        {
            if (writer == null || system == null)
            return;

             //system name
             string sysName = system.Name;
             if (sysName.Length > 0)
             {
            writer.addTitleRow(sysName);
            writer.addOneEmptyRow();
             }

             if (needToWrite())
             {
            writer.addTitleRow(ReportResource.systemInformation);
            DataTable tb = new DataTable();
            getInfoDataTable(tb);
            writer.AddData(tb, 1);
             }
        }
        public override void writeToCsv(CsvStreamWriter writer)
        {
            if (writer == null || sections == null || !needToWrite())
            return;

             PressureLossReportHelper helper = PressureLossReportHelper.instance;
             if (helper == null)
            return;

             writer.addTitleRow(ReportResource.segmentDetailInfo);

             //segment title
             List<string> strSegmentFields = new List<string>();
             getFields(strSegmentFields);
             DataTable tbTitle = new DataTable();
             helper.getTableTitle(tbTitle, strSegmentFields);
             writer.AddData(tbTitle, 1);

             foreach (MEPSection section in sections)
             {
            DataTable tb = new DataTable();
            if (getSegmentInfo(section, tb))
               writer.AddData(tb, 1);
             }
        }
Exemplo n.º 6
0
        // TODO
        public override bool save(string fileName, PressureLossReportData reportData)
        {
            try
             {
            PressureLossReportHelper helper = PressureLossReportHelper.instance;
            CsvStreamWriter writer = new CsvStreamWriter();

            //title
            string strTitle = ReportResource.reportName;
            if (helper.Domain == ReportResource.pipeDomain)
               strTitle = ReportResource.pipeReportName;
            else
               strTitle = ReportResource.ductReportName;

            DataTable titleTB = new DataTable();
            titleTB.Columns.Add();
            titleTB.Rows.Add(strTitle);
            writer.AddData(titleTB, 1);
            writer.addOneEmptyRow();

            DataTable tbTitle = new DataTable();
            DataTable tb = new DataTable();

            //Project info
            ReportProjectInfo proInfo = new ReportProjectInfo();
            proInfo.writeToCsv(writer);

            writer.addOneEmptyRow();

            //each system
            List<MEPSystem> systems = helper.getSortedSystems();
            if (systems == null || systems.Count < 1)
               return false;
            foreach (MEPSystem sysElem in systems)
            {
               if (sysElem == null)
                  continue;

               //system name and info
               MEPSystemInfo systemInfo = new MEPSystemInfo(sysElem);
               systemInfo.writeToCsv(writer);

               if (systemInfo.needToWrite())
                  writer.addOneEmptyRow();

               List<MEPSection> sections = new List<MEPSection>();
               MEPSystemInfo.getSectionsFromSystem(sysElem, sections);

               //sections: title and info
               SectionsInfo sectionInfo = new SectionsInfo(sections);
               sectionInfo.writeToCsv(writer);

               if (reportData.DisplayCriticalPath)
               {
                  string criticalInfo = ReportResource.criticalPath + " : " + MEPSystemInfo.getCriticalPath(sysElem);
                  criticalInfo += " ; " + ReportResource.totalPressureLoss + " : " + MEPSystemInfo.getCriticalPathPressureLoss(sysElem);

                  writer.addTitleRow(criticalInfo);
               }

               writer.addOneEmptyRow();

               //segments: title and info
               SegmentsInfo segmentsInfo = new SegmentsInfo(sections);
               segmentsInfo.writeToCsv(writer);
               if (segmentsInfo.needToWrite())
                  writer.addOneEmptyRow();

               //fittings: title and info
               FittingsInfo fittingsInfo = new FittingsInfo(sections);
               fittingsInfo.writeToCsv(writer);
               if (fittingsInfo.needToWrite())
                  writer.addOneEmptyRow();
            }

            writer.Save(fileName);
            return true;
             }
             catch(Exception e)
             {
            if (e.Message == ReportConstants.failed_to_delete)
            {
               string subMsg = ReportResource.csvSubMsg.Replace("%FULLPATH%", fileName);
               UIHelperFunctions.postWarning(ReportResource.csvGenerateTitle, ReportResource.csvMsg, subMsg);
            }
            else
               UIHelperFunctions.postWarning(ReportResource.csvGenerateTitle, ReportResource.csvMsg);
            return false;
             }
        }
Exemplo n.º 7
0
        // TODO
        public override bool save(string fileName, PressureLossReportData reportData)
        {
            try
            {
                PressureLossReportHelper helper = PressureLossReportHelper.instance;
                CsvStreamWriter          writer = new CsvStreamWriter();

                //title
                string strTitle = ReportResource.reportName;
                if (helper.Domain == ReportResource.pipeDomain)
                {
                    strTitle = ReportResource.pipeReportName;
                }
                else
                {
                    strTitle = ReportResource.ductReportName;
                }

                DataTable titleTB = new DataTable();
                titleTB.Columns.Add();
                titleTB.Rows.Add(strTitle);
                writer.AddData(titleTB, 1);
                writer.addOneEmptyRow();

                DataTable tbTitle = new DataTable();
                DataTable tb      = new DataTable();

                //Project info
                ReportProjectInfo proInfo = new ReportProjectInfo();
                proInfo.writeToCsv(writer);

                writer.addOneEmptyRow();

                //each system
                List <MEPSystem> systems = helper.getSortedSystems();
                if (systems == null || systems.Count < 1)
                {
                    return(false);
                }
                foreach (MEPSystem sysElem in systems)
                {
                    if (sysElem == null)
                    {
                        continue;
                    }

                    //system name and info
                    MEPSystemInfo systemInfo = new MEPSystemInfo(sysElem);
                    systemInfo.writeToCsv(writer);

                    if (systemInfo.needToWrite())
                    {
                        writer.addOneEmptyRow();
                    }

                    List <MEPSection> sections = new List <MEPSection>();
                    MEPSystemInfo.getSectionsFromSystem(sysElem, sections);

                    //sections: title and info
                    SectionsInfo sectionInfo = new SectionsInfo(sections);
                    sectionInfo.writeToCsv(writer);

                    if (reportData.DisplayCriticalPath)
                    {
                        string criticalInfo = ReportResource.criticalPath + " : " + MEPSystemInfo.getCriticalPath(sysElem);
                        criticalInfo += " ; " + ReportResource.totalPressureLoss + " : " + MEPSystemInfo.getCriticalPathPressureLoss(sysElem);

                        writer.addTitleRow(criticalInfo);
                    }

                    writer.addOneEmptyRow();

                    //segments: title and info
                    SegmentsInfo segmentsInfo = new SegmentsInfo(sections);
                    segmentsInfo.writeToCsv(writer);
                    if (segmentsInfo.needToWrite())
                    {
                        writer.addOneEmptyRow();
                    }

                    //fittings: title and info
                    FittingsInfo fittingsInfo = new FittingsInfo(sections);
                    fittingsInfo.writeToCsv(writer);
                    if (fittingsInfo.needToWrite())
                    {
                        writer.addOneEmptyRow();
                    }
                }

                writer.Save(fileName);
                return(true);
            }
            catch (Exception e)
            {
                if (e.Message == ReportConstants.failed_to_delete)
                {
                    string subMsg = ReportResource.csvSubMsg.Replace("%FULLPATH%", fileName);
                    UIHelperFunctions.postWarning(ReportResource.csvGenerateTitle, ReportResource.csvMsg, subMsg);
                }
                else
                {
                    UIHelperFunctions.postWarning(ReportResource.csvGenerateTitle, ReportResource.csvMsg);
                }
                return(false);
            }
        }