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 || 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); } }
// 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; } }
// 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); } }