// formats a single row private ImmutableList <string> formatRow(R report, int rowIdx, ReportOutputFormat format) { ImmutableList.Builder <string> tableRow = ImmutableList.builder(); for (int colIdx = 0; colIdx < report.ColumnCount; colIdx++) { tableRow.add(formatData(report, rowIdx, colIdx, format)); } return(tableRow.build()); }
//------------------------------------------------------------------------- /// <summary> /// Formats a value into a string. /// </summary> /// <param name="value"> the value </param> /// <param name="format"> the format that controls how the value is formatted </param> /// <returns> the formatted value </returns> //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") protected String formatValue(Object value, ReportOutputFormat format) protected internal virtual string formatValue(object value, ReportOutputFormat format) { //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: Object formatValue = value instanceof java.util.Optional ? ((java.util.Optional<?>) value).orElse(null) : value; object formatValue = value is Optional ? ((Optional <object>)value).orElse(null) : value; if (formatValue == null) { return(""); } FormatSettings <object> formatSettings = formatSettingsProvider.settings(formatValue.GetType(), defaultSettings); ValueFormatter <object> formatter = formatSettings.Formatter; return(format == ReportOutputFormat.CSV ? formatter.formatForCsv(formatValue) : formatter.formatForDisplay(formatValue)); }
protected internal override string formatData(TradeReport report, int rowIdx, int colIdx, ReportOutputFormat format) { TradeReportColumn templateColumn = report.Columns.get(colIdx); //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: com.opengamma.strata.collect.result.Result<?> result = report.getData().get(rowIdx, colIdx); Result <object> result = report.Data.get(rowIdx, colIdx); if (result.Failure) { return(templateColumn.IgnoreFailures ? "" : Messages.format("FAIL: {}", result.Failure.Message)); } object value = result.Value; return(formatValue(value, format)); }
/// <summary> /// 產生大型報表需要的XML檔案 /// </summary> /// <param name="ModuleName">模組名稱</param> /// <param name="CodeName">目前檔案aspx名稱</param> /// <param name="ReportCode">報表代號需要增加代號請通知系統人員調整Windows服務程式</param> /// <param name="ReportCodeFilePath">報表檔(.RPT)存放位置</param> /// <param name="RPTParameters">抓取DB所需要的變數</param> /// <param name="CryRPTParameters">報表檔(.RPT)所需要的變數,無變數輸入null</param> /// <param name="ROF">報表格式(EXCEL,PDF,CSV)</param> /// <param name="DownLoadFileName">下載的檔案名稱,無預設檔名輸入空白(系統將以程式編號命名)</param> /// <param name="MoniterLogFileName">WEB需要監控處理進度的檔名</param> public void GenerReportConfigXML(string ModuleName, string CodeName, string ReportCode, string ReportCodeFilePath, ReportParameter[] RPTParameters, ReportParameter[] CryRPTParameters, ReportOutputFormat ROF, string DownLoadFileName, ref string MoniterLogFileName ) { if (IsLogin()) { //開始處理時間 DateTime StartTime = DateTime.Now; string ProcessFileName = string.Format("{0}{1}{2}{3}{4}{5}{6}_T{7}_{8}.XML", DateTime.Now.Year.ToString(), DateTime.Now.Month.ToString().PadLeft(2, '0'), DateTime.Now.Day.ToString().PadLeft(2, '0'), DateTime.Now.Hour.ToString().PadLeft(2, '0'), DateTime.Now.Minute.ToString().PadLeft(2, '0'), DateTime.Now.Second.ToString().PadLeft(2, '0'), DateTime.Now.Millisecond.ToString(), Thread.CurrentThread.ManagedThreadId.ToString(), Session["UID"].ToString() ); XmlTextWriter XTW = new XmlTextWriter(string.Format("{0}\\ProcessReportQueue\\{1}", ReportWebPath, ProcessFileName ), Encoding.UTF8 ); XTW.Formatting = Formatting.Indented; XTW.WriteStartElement("Report"); XTW.WriteElementString("User", Session["UID"].ToString()); XTW.WriteElementString("StartTime", StartTime.ToString()); XTW.WriteElementString("Module", ModuleName); XTW.WriteElementString("CodeName", CodeName); XTW.WriteElementString("ReportCode", ReportCode); XTW.WriteElementString("ReportCodeFilePath", ReportCodeFilePath); XTW.WriteStartElement("InputParameters"); for (int i = 0; i < RPTParameters.Length; i++) { XTW.WriteStartElement("Parameter"); XTW.WriteAttributeString("key", RPTParameters[i].ParameterName); XTW.WriteString(RPTParameters[i].ParameterValue); XTW.WriteEndElement(); } XTW.WriteEndElement(); XTW.WriteStartElement("RoportParameters"); if (CryRPTParameters != null) //報表輸入參數存在 { for (int j = 0; j < CryRPTParameters.Length; j++) { XTW.WriteStartElement("Parameter"); XTW.WriteAttributeString("key", CryRPTParameters[j].ParameterName); XTW.WriteString(CryRPTParameters[j].ParameterValue); XTW.WriteEndElement(); } } XTW.WriteEndElement(); switch (ROF) { case ReportOutputFormat.EXCEL: XTW.WriteElementString("ReportOutputFormat", "EXCEL"); break; case ReportOutputFormat.PDF: XTW.WriteElementString("ReportOutputFormat", "PDF"); break; case ReportOutputFormat.CSV: XTW.WriteElementString("ReportOutputFormat", "CSV"); break; default: break; } XTW.WriteElementString("CustomerFileName", (DownLoadFileName.Trim().Length != 0) ? DownLoadFileName : CodeName); XTW.WriteElementString("ProcessState", "Start"); XTW.WriteElementString("EndTime", ""); MoniterLogFileName = string.Format("{0}{1}{2}{3}{4}{5}_{6}_{7}.log", StartTime.Year.ToString(), StartTime.Month.ToString().PadLeft(2, '0'), StartTime.Day.ToString().PadLeft(2, '0'), StartTime.Hour.ToString().PadLeft(2, '0'), StartTime.Minute.ToString().PadLeft(2, '0'), StartTime.Second.ToString().PadLeft(2, '0'), ReportCode, Session["UID"].ToString() ); XTW.WriteElementString("WebMonitorFile",MoniterLogFileName); XTW.WriteElementString("DownLoadFile", ""); XTW.WriteEndElement(); XTW.Close(); } }
protected internal override string formatData(CashFlowReport report, int rowIdx, int colIdx, ReportOutputFormat format) { object value = report.Data.get(rowIdx, colIdx); return(formatValue(value, format)); }
/// <summary> /// Formats a piece of data for display. /// </summary> /// <param name="report"> the report containing the data </param> /// <param name="rowIdx"> the row index of the data </param> /// <param name="colIdx"> the column index of the data </param> /// <param name="format"> the report output format </param> /// <returns> the formatted data </returns> protected internal abstract string formatData(R report, int rowIdx, int colIdx, ReportOutputFormat format);