/// <summary> /// Render all data add and writes it to the specified writer /// </summary> /// <param name="model"> /// The model to render /// </param> /// <param name="os"> /// The output to write to /// </param> public override void RenderAllTables(IDataSetModel model, Stream os) { // TODO check the number of horizontal & vertical key values to determine the orientation of the page var doc = new Document(this._pageSize, 80, 50, 30, 65); // This doesn't seem to do anything... doc.AddHeader(Markup.HTML_ATTR_STYLESHEET, "style/pdf.css"); doc.AddCreationDate(); doc.AddCreator("NSI .NET Client"); try { PdfWriter.GetInstance(doc, os); doc.Open(); this.WriteTableModels(model, doc); } catch (DocumentException ex) { Trace.Write(ex.ToString()); LogError.Instance.OnLogErrorEvent(ex.ToString()); } catch (DbException ex) { Trace.Write(ex.ToString()); LogError.Instance.OnLogErrorEvent(ex.ToString()); } finally { if (doc.IsOpen()) { doc.Close(); } } }
/// <summary> /// Render all data add and writes it to the specified writer /// </summary> /// <param name="model"> /// The model to render /// </param> /// <param name="os"> /// The output to write to /// </param> public override void RenderAllTables(IDataSetModel model, TextWriter os) { string a = AssemblyDirectory; if (DecimalSeparator == ",") this.WriteEmbeddedHtml(os, "xls_start_comma.ftl"); else if (DecimalSeparator == ".") this.WriteEmbeddedHtml(os, "xls_start_dot.ftl"); this.WriteTableModels(model, os); this.WriteEmbeddedHtml(os, "xls_finish.ftl"); }
/// <summary> /// Render all data add and writes it to the specified writer /// </summary> /// <param name="model"> /// The model to render /// </param> /// <param name="os"> /// The output to write to /// </param> public override void RenderAllTables(IDataSetModel model, TextWriter os) { string a = AssemblyDirectory; if (DecimalSeparator == ",") { this.WriteEmbeddedHtml(os, "xls_start_comma.ftl"); } else if (DecimalSeparator == ".") { this.WriteEmbeddedHtml(os, "xls_start_dot.ftl"); } this.WriteTableModels(model, os); this.WriteEmbeddedHtml(os, "xls_finish.ftl"); }
/// <summary> /// Create and setup the titles for vertical dimensions /// </summary> /// <param name="model"> /// The DataSetModel to use /// </param> /// <returns> /// The row with the titles /// </returns> private TableRow CreateVerticalTitles(IDataSetModel model) { var verticalTitles = new TableRow(); verticalTitles.AddClass(HtmlClasses.VerticalKeys); foreach (string dim in model.VerticalKeys) { TableCell tableCell = this.CreateTitle(model.AllValidKeys[dim], dim, HtmlClasses.VerticalKeyTitle); // new TD(); verticalTitles.AddElement(tableCell); } return(verticalTitles); }
/// <summary> /// Clear data /// </summary> public void ClearData() { this.CloseSdmxMLDataSet(); this._dataSetModel = null; string fileName = ""; if (this._store != null) { fileName = (((ISTAT.WebClient.WidgetEngine.Model.DBData.DataSetStoreDB)(this._store))._dbInfo.Connection).DataSource; this._store.Dispose(); this._store = null; } for (int i = 0, j = this._dataDisposeList.Count; i < j; i++) { this._dataDisposeList[i].Dispose(); } this._dataDisposeList.Clear(); try { // close any files //FileInfo[] files = this._cacheFolder.GetFiles(this._sessionPrefix + "*.*"); FileInfo[] files = this._cacheFolder.GetFiles(fileName + ".sqlite"); foreach (FileInfo file in files) { file.Delete(); } } catch (IOException e) { Logger.Warn(e.Message, e); } catch (SecurityException e) { Logger.Warn(e.Message, e); } catch (UnauthorizedAccessException e) { Logger.Warn(e.Message, e); } }
/// <summary> /// Render to the specified writer the specified DataTable as a csv table /// </summary> /// <param name="model"> /// The model to render /// </param> /// <param name="os"> /// The output to write to /// </param> public void RenderAllTables(IDataSetModel model, TextWriter os) { IDataReader data = model.UnsortedReader; StringBuilder sb = new StringBuilder(); for (int i = 0, j = data.FieldCount; i < j; i++) { // TODO Check if the concept names should be returned instead if (_withQuotation) { sb.AppendFormat("\"{0}\"{1}", data.GetName(i), this._separator); } else { sb.AppendFormat("{0}{1}", data.GetName(i), this._separator); } } sb.Length--; sb.AppendLine(); os.Write(sb.ToString()); sb.Length = 0; while (data.Read()) { for (int i = 0, j = data.FieldCount; i < j; i++) { string val = data[i] as string; if (_withQuotation) { sb.AppendFormat("\"{0}\"{1}", val, this._separator); } else { sb.AppendFormat("{0}{1}", val, this._separator); } } sb.Length--; sb.AppendLine(); os.Write(sb.ToString()); sb.Length = 0; } data.Close(); }
/// <summary> /// Create and setup the titles for horizontal dimensions /// </summary> /// <param name="model"> /// The DataSetModel to use /// </param> /// <param name="horizontalRows"> /// The horizontal map to add the titles to /// </param> /// <param name="horizontalOrderedRows"> /// The list of rows /// </param> private void CreateHorizontalTitles( IDataSetModel model, IDictionary <string, TableRow> horizontalRows, ICollection <TableRow> horizontalOrderedRows) { foreach (string dim in model.HorizontalKeys) { var row = new TableRow(); row.AddClass(HtmlClasses.HorizontalKeys); // First cell is the title, which spawns over all columns used for vertical keys... TableCell tableCell = this.CreateTitle(model.AllValidKeys[dim], dim, "hkeytitle"); tableCell.SetColSpan(Math.Max(1, model.VerticalKeys.Count)); row.AddCell(tableCell); horizontalRows.Add(dim, row); horizontalOrderedRows.Add(row); } }
/// <summary> /// Add vertical key values to the specified output Row /// </summary> /// <param name="verticalPreviousValues"> /// A map of {key, previous value of key} /// </param> /// <param name="dimension"> /// The current key /// </param> /// <param name="outputRow"> /// The row to add the key values /// </param> /// <param name="currentValue"> /// The current value /// </param> /// <param name="model"> /// The dataset model /// </param> private void AddVerticalKeyValues2( IDictionary <string, TableCell> verticalPreviousValues, string dimension, TableRow outputRow, string currentValue, IDataSetModel model) { var tableCell = new TableCell { Text = currentValue }; tableCell.AddClass(HtmlClasses.VerticalKeyValue); string text = this.GetLocalizedName(dimension, currentValue); tableCell.SetupDisplayText( currentValue, text, dimension, model.GetDisplayMode(dimension, currentValue), this._enhancedOutput); outputRow.AddCell(tableCell); verticalPreviousValues[dimension] = tableCell; }
/// <summary> /// Write all data splitted in slices to the specified writer /// </summary> /// <param name="model"> /// The model to write /// </param> /// <param name="writer"> /// The writer to use /// </param> protected virtual void WriteTableModels(IDataSetModel model, TextWriter writer) { IDataReader allData = model.GetReader(false); Table containerTable = CreateContainerTable(); string oldKeySet = null; var s = new RendererState(model); while (allData.Read()) { s.InputRow = allData; string currentKeySet = MakeKey(model.SliceKeys, allData); if (!currentKeySet.Equals(oldKeySet)) { oldKeySet = currentKeySet; if (s.Table != null) { PopulateTable(s); containerTable.Write(writer); s.Reset(); } containerTable = CreateContainerTable(); Table sliceHeaderTable = this.CreateSliceHeaderTable(s); AddSliceHeading(containerTable, sliceHeaderTable); s.Table = CreateSliceTable(); AddSliceTable(containerTable, s.Table); this.InitTitles(s); } this.ParseDataRow(s); } allData.Close(); s.InputRow = null; if (s.Table != null) { PopulateTable(s); containerTable.Write(writer); s.Reset(); } }
/// <summary> /// Clear data /// </summary> public void ClearData() { this.CloseSdmxMLDataSet(); this._dataSetModel = null; if (this._store != null) { this._store.Dispose(); this._store = null; } for (int i = 0, j = this._dataDisposeList.Count; i < j; i++) { this._dataDisposeList[i].Dispose(); } this._dataDisposeList.Clear(); try { // close any files /*DA FARE FABIO NUOVO * _cacheFolder = new DirectoryInfo(Utils.GetAppPath()); * FileInfo[] files = this._cacheFolder.GetFiles(this._sessionPrefix + "*.*"); * foreach (FileInfo file in files) * { * file.Delete(); * }*/ } catch (IOException e) { Logger.Warn(e.Message, e); } catch (SecurityException e) { Logger.Warn(e.Message, e); } catch (UnauthorizedAccessException e) { Logger.Warn(e.Message, e); } }
/// <summary> /// Clear data /// </summary> public void ClearData() { this.CloseSdmxMLDataSet(); this._dataSetModel = null; if (this._store != null) { this._store.Dispose(); this._store = null; } for (int i = 0, j = this._dataDisposeList.Count; i < j; i++) { this._dataDisposeList[i].Dispose(); } this._dataDisposeList.Clear(); try { // close any files FileInfo[] files = this._cacheFolder.GetFiles(this._sessionPrefix + "*.*"); foreach (FileInfo file in files) { file.Delete(); } } catch (IOException e) { Logger.Warn(e.Message, e); } catch (SecurityException e) { Logger.Warn(e.Message, e); } catch (UnauthorizedAccessException e) { Logger.Warn(e.Message, e); } }
/// <summary> /// Add vertical key values to the specified output Row /// </summary> /// <param name="verticalPreviousValues"> /// A map of {key, previous value of key} /// </param> /// <param name="dimension"> /// The current key /// </param> /// <param name="outputRow"> /// The row to add the key values /// </param> /// <param name="currentValue"> /// The current value /// </param> /// <param name="model"> /// The dataset model /// </param> private void AddVerticalKeyValues( IDictionary<string, TableCell> verticalPreviousValues, string dimension, TableRow outputRow, string currentValue, IDataSetModel model, IDataReader currentRow) { this._uniqID++; Table tb = new Table(); TableRow _rw = new TableRow(); Table tb_extra = (this._useSdmxAttr) ? CreateDimensionAttributeTable(dimension, model, currentRow) : null; if (tb_extra != null) { tb_extra.AddAttribute("ID", this._uniqID + "_dim_info_extra_dialog"); tb_extra.AddClass(HtmlClasses.ExtraInfoTable); tb.AddRow(new TableRow(new TableCell(tb_extra))); var tb_btn_extra = new TableCell(); tb_btn_extra.AddClass(HtmlClasses.ExtraInfoWrapper); tb_btn_extra.AddAttribute("ID", this._uniqID + "_dim_info"); _rw.AddCell(tb_btn_extra); } string text = this.GetLocalizedName(dimension, currentValue); var tb_dim = new TableCell(); tb_dim.AddClass(HtmlClasses.VerticalKeyValue); if (dimension == "TIME_PERIOD") tb_dim.AddAttribute("style", "white-space:nowrap"); tb_dim.SetupDisplayText(currentValue, text, dimension, model.GetDisplayMode(dimension, currentValue), this._enhancedOutput); _rw.AddCell(tb_dim); tb.AddRow(_rw); TableCell tb_cell = new TableCell(tb); outputRow.AddCell(tb_cell); verticalPreviousValues[dimension] = tb_cell; }
/// <summary> /// Populate a single value table. This is used when all keys are slice keys. /// </summary> /// <param name="model"> /// The model to render /// </param> /// <param name="table"> /// The html table to populate /// </param> private static void GetSingleValue(IDataSetModel model, HtmlEntityParent<TableRow> table) { if (model.GetRowCount(true) > 1) { throw new Exception( "There are no horizontal & vertical keys, but the number of " + "values from model is " + model.GetRowCount(true) + " instead of 1"); } table.AddElement( model.GetRowCount(true) == 0 ? new TableRow(new TableCell(" ")) : new TableRow(new TableCell(float.Parse(model.FirstObservation.ToString().Replace('.', ',')).ToString()))); }
/// <summary> /// Check if all keys are slice keys /// </summary> /// <param name="model"> /// The model to check /// </param> /// <returns> /// The all keys are slice. /// </returns> protected static bool AllKeysAreSlice(IDataSetModel model) { return model.VerticalKeys.Count == 0 && model.HorizontalKeys.Count == 0; }
/// <summary> /// Initializes a new instance of the <see cref="RendererState"/> class. /// </summary> /// <param name="model"> /// The current <see cref="IDataSetModel"/> /// </param> public RendererState(IDataSetModel model) { this.Model = model; this.CurrentHorizontalKeySetColumn = -1; this._horizontalKeyRows = new Dictionary<string, TableRow>(StringComparer.Ordinal); }
/// <summary> /// Create and setup the titles for vertical dimensions /// </summary> /// <param name="model"> /// The DataSetModel to use /// </param> /// <returns> /// The row with the titles /// </returns> private TableRow CreateVerticalTitles(IDataSetModel model) { var verticalTitles = new TableRow(); verticalTitles.AddClass(HtmlClasses.VerticalKeys); foreach (string dim in model.VerticalKeys) { TableCell tableCell = this.CreateTitle(model.AllValidKeys[dim], dim, HtmlClasses.VerticalKeyTitle); // new TD(); verticalTitles.AddElement(tableCell); } return verticalTitles; }
/// <summary> /// Add vertical key values to the specified output Row /// </summary> /// <param name="verticalPreviousValues"> /// A map of {key, previous value of key} /// </param> /// <param name="dimension"> /// The current key /// </param> /// <param name="outputRow"> /// The row to add the key values /// </param> /// <param name="currentValue"> /// The current value /// </param> /// <param name="model"> /// The dataset model /// </param> private void AddVerticalKeyValues2( IDictionary<string, TableCell> verticalPreviousValues, string dimension, TableRow outputRow, string currentValue, IDataSetModel model) { var tableCell = new TableCell { Text = currentValue }; tableCell.AddClass(HtmlClasses.VerticalKeyValue); string text = this.GetLocalizedName(dimension, currentValue); tableCell.SetupDisplayText( currentValue, text, dimension, model.GetDisplayMode(dimension, currentValue), this._enhancedOutput); outputRow.AddCell(tableCell); verticalPreviousValues[dimension] = tableCell; }
/// <summary> /// Add horrizontal key values to the specified output Row /// </summary> /// <param name="horizontalPreviousValues"> /// A map of {key, previous value of key} /// </param> /// <param name="dimension"> /// The current key /// </param> /// <param name="outputRow"> /// The row to add the key values /// </param> /// <param name="currentValue"> /// The current value /// </param> /// <param name="model"> /// The dataset model /// </param> private void AddHorrizontalKeyValues( IDictionary<string, TableCell> horizontalPreviousValues, string dimension, TableRow outputRow, string currentValue, IDataSetModel model) { TableCell oldValue; if (horizontalPreviousValues.TryGetValue(dimension, out oldValue) && oldValue != null && string.Equals(currentValue, oldValue.SdmxValue)) { oldValue.ColumnSpan++; } else { var tableCell = new TableCell(); string text = this.GetLocalizedName(dimension, currentValue); tableCell.SetupDisplayText( currentValue, text, dimension, model.GetDisplayMode(dimension, currentValue), this._enhancedOutput); tableCell.AddClass(HtmlClasses.HorizontalKeyValue); outputRow.AddCell(tableCell); horizontalPreviousValues[dimension] = tableCell; } }
/// <summary> /// Render to the specified writer the specified model as a csv table /// </summary> /// <param name="model"> /// The model to render /// </param> /// <param name="os"> /// The output to write to /// </param> public override void RenderAllTables(IDataSetModel model, TextWriter os) { this.WriteTableModels(model, os); }
/// <summary> /// Write all data splitted in slices to the specified writer /// </summary> /// <param name="model"> /// The model to write /// </param> /// <param name="writer"> /// The writer to use /// </param> protected override void WriteTableModels(IDataSetModel model, TextWriter writer) { IDataReader allData = model.GetReader(false); string oldKeySetSlice = null; var s = new RendererState(model); while (allData.Read()) { s.InputRow = allData; string currentKeySet = MakeKey(model.SliceKeys, allData); if (!currentKeySet.Equals(oldKeySetSlice)) { oldKeySetSlice = currentKeySet; this.CommitTable(s, writer); Table sliceHeaderTable = this.CreateSliceHeaderTable(s); sliceHeaderTable.WriteCsv(writer, this._separator); s.Table = CreateSliceTable(); this.InitTitles(s); } this.ParseDataRow(s); } allData.Close(); s.InputRow = null; this.CommitTable(s, writer); }
/// <summary> /// Render to the specified writer the specified model as a csv table /// </summary> /// <param name="model"> /// The model to render /// </param> /// <param name="os"> /// The output to write to /// </param> public override void RenderAllTables(IDataSetModel model, Stream os) { var writer = new StreamWriter(os, Encoding.UTF8); this.RenderAllTables(model, writer); writer.Flush(); }
/// <summary> /// Render to the specified writer the current slide as a html table /// </summary> /// <param name="model"> /// The model to render /// </param> /// <param name="os"> /// The output to write to /// </param> public virtual void Render(IDataSetModel model, TextWriter os) { var s = new RendererState(model); Table table = this.CreateTableModel(s); // Table table = this.createTableModel(model); table.Write(os); }
public TabularTextRecordsetAdapter(IDataSetModel partition, int fieldCount) : base(GenerateDataItemType(partition, new TabularSourceResolver(fieldCount))) { }
/// <summary> /// A wrapper around <see cref="RenderAllTables(Estat.Nsi.Client.Renderer.IDataSetModel,System.IO.TextWriter)"/> /// </summary> /// <param name="model"> /// The <see cref="IDataSetModel"/> /// </param> /// <param name="os"> /// The output stream /// </param> public virtual void RenderAllTables(IDataSetModel model, Stream os) { var writer = new StreamWriter(os); this.RenderAllTables(model, writer); writer.Flush(); }
public TabularTextRecordsetAdapter(IDataSetModel partition, IEnumerable <string> fieldNames) : base(GenerateDataItemType(partition, new TabularSourceResolver(fieldNames))) { }
/// <summary> /// Render all data divided into slices to html tables /// </summary> /// <param name="model"> /// The model to render /// </param> /// <param name="os"> /// The output to write to /// </param> public virtual void RenderAllTables(IDataSetModel model, TextWriter os) { this.WriteEmbeddedHtml(os, "html_start.ftl"); this.WriteTableModels(model, os); this.WriteEmbeddedHtml(os, "html_finish.ftl"); }
private static Type GenerateDataItemType(IDataSetModel partition, TabularSourceResolver sourceResolver) { var typeBuilder = DataItemFactory.GetTypeBuilder(partition.Source, typeof(DataItem)); typeBuilder.AddInterfaceImplementation(typeof(ITabularTextInitalizableDataItem)); var patternsDef = typeBuilder.DefineField("__patterns__", typeof(Regex[]), FieldAttributes.Static | FieldAttributes.Private); var cctor = typeBuilder.DefineTypeInitializer(); var initCctor = cctor.GetILGenerator(); initCctor.Emit(OpCodes.Ldc_I4_S, partition.Properties.Count); initCctor.Emit(OpCodes.Newarr, typeof(Regex)); initCctor.Emit(OpCodes.Stsfld, patternsDef); var initializeMethod = typeBuilder.DefineMethod( "TTRider.Osminoq.ITabularTextInitalizableDataItem.Initialize", MethodAttributes.Private | MethodAttributes.Virtual | MethodAttributes.Final | MethodAttributes.HideBySig | MethodAttributes.NewSlot, null, new [] { typeof(string[]) }); typeBuilder.DefineMethodOverride(initializeMethod, typeof(TTRider.Osminoq.ITabularTextInitalizableDataItem).GetMethod("Initialize")); var init = initializeMethod.GetILGenerator(); var templateIndex = 0; foreach (var field in partition.Properties) { var index = sourceResolver.ResolveSource(field.Source); var name = DataItemFactory.CleanupPropertyName(field.Name); var dataHandler = DataItemFactory.GetTypeHandler(field.DataType); var fieldDef = typeBuilder.DefineField("_" + name, dataHandler.ReturnType, FieldAttributes.Private); var propDef = typeBuilder.DefineProperty(name, PropertyAttributes.None, dataHandler.ReturnType, new Type[0]); var propMethod = typeBuilder.DefineMethod("get_" + name, MethodAttributes.Public, dataHandler.ReturnType, new Type[0]); var propMethodInit = propMethod.GetILGenerator(); propMethodInit.DeclareLocal(dataHandler.ReturnType); propMethodInit.Emit(OpCodes.Ldarg_0); propMethodInit.Emit(OpCodes.Ldfld, fieldDef); propMethodInit.Emit(OpCodes.Stloc_0); propMethodInit.Emit(OpCodes.Ldloc_0); propMethodInit.Emit(OpCodes.Ret); propDef.SetGetMethod(propMethod); init.Emit(OpCodes.Ldarg_0); init.Emit(OpCodes.Ldarg_1); init.Emit(OpCodes.Ldc_I4_S, index); init.Emit(OpCodes.Ldelem_Ref); if (!string.IsNullOrWhiteSpace(field.Template)) { initCctor.Emit(OpCodes.Ldsfld, patternsDef); initCctor.Emit(OpCodes.Ldc_I4_S, templateIndex); initCctor.Emit(OpCodes.Ldstr, field.Template); initCctor.Emit(OpCodes.Ldc_I4_S, 9); initCctor.Emit(OpCodes.Newobj, DataItemFactory.GetRegexCtor()); initCctor.Emit(OpCodes.Stelem_Ref); init.Emit(OpCodes.Ldsfld, patternsDef); init.Emit(OpCodes.Ldc_I4_S, templateIndex); init.Emit(OpCodes.Ldelem_Ref); init.Emit(OpCodes.Call, DataItemFactory.ProcessPatternMethod); templateIndex++; } init.Emit(OpCodes.Call, dataHandler); init.Emit(OpCodes.Stfld, fieldDef); } init.Emit(OpCodes.Ret); initCctor.Emit(OpCodes.Ret); return(typeBuilder.CreateType()); }
/// <summary> /// Render to the specified writer the specified DataTable as a csv table /// </summary> /// <param name="model"> /// The model to render /// </param> /// <param name="os"> /// The output to write to /// </param> public void RenderAllTables(IDataSetModel model, TextWriter os) { IDataReader data = model.UnsortedReader; StringBuilder sb = new StringBuilder(); for (int i = 0, j = data.FieldCount; i < j; i++) { // TODO Check if the concept names should be returned instead if (_withQuotation) sb.AppendFormat("\"{0}\"{1}", data.GetName(i), this._separator); else sb.AppendFormat("{0}{1}", data.GetName(i), this._separator); } sb.Length--; sb.AppendLine(); os.Write(sb.ToString()); sb.Length = 0; while (data.Read()) { for (int i = 0, j = data.FieldCount; i < j; i++) { string val = data[i] as string; if (_withQuotation) sb.AppendFormat("\"{0}\"{1}", val, this._separator); else sb.AppendFormat("{0}{1}", val, this._separator); } sb.Length--; sb.AppendLine(); os.Write(sb.ToString()); sb.Length = 0; } data.Close(); }
/// <summary> /// Add horrizontal key values to the specified output Row /// </summary> /// <param name="horizontalPreviousValues"> /// A map of {key, previous value of key} /// </param> /// <param name="dimension"> /// The current key /// </param> /// <param name="outputRow"> /// The row to add the key values /// </param> /// <param name="currentValue"> /// The current value /// </param> /// <param name="model"> /// The dataset model /// </param> private void AddHorrizontalKeyValues( IDictionary<string, TableCell> horizontalPreviousValues, string dimension, TableRow outputRow, string currentValue, IDataSetModel model, IDataReader currentRow) { TableCell oldCell; horizontalPreviousValues.TryGetValue(dimension, out oldCell); string oldValue = string.Empty; if (oldCell != null && oldCell.Children.Count > 0 && oldCell.Children[0].Children.Count > 0 && oldCell.Children[0].Children[0].Children.Count > 1) oldValue = oldCell.Children[0].Children[0].Children[0].SdmxValue; else if (oldCell != null) oldValue = oldCell.SdmxValue; if (oldCell != null && string.Equals(currentValue, oldValue)) { oldCell.ColumnSpan++; } else { this._uniqID++; Table tb = new Table(); TableRow _rw = new TableRow(); Table tb_extra = (this._useSdmxAttr) ? CreateDimensionAttributeTable(dimension, model, currentRow) : null; if (tb_extra != null) { tb_extra.AddAttribute("ID", this._uniqID + "_dim_info_extra_dialog"); tb_extra.AddClass(HtmlClasses.ExtraInfoTable); tb.AddRow(new TableRow(new TableCell(tb_extra))); var tb_btn_extra = new TableCell(); tb_btn_extra.AddClass(HtmlClasses.ExtraInfoWrapper); tb_btn_extra.AddAttribute("ID", this._uniqID + "_dim_info"); _rw.AddCell(tb_btn_extra); } string text = this.GetLocalizedName(dimension, currentValue); var tb_dim = new TableCell(); tb_dim.AddClass(HtmlClasses.HorizontalKeyValue); tb_dim.SetupDisplayText(currentValue, text, dimension, model.GetDisplayMode(dimension, currentValue), this._enhancedOutput); if (dimension == "TIME_PERIOD") tb_dim.AddAttribute("style", "white-space:nowrap"); _rw.AddCell(tb_dim); tb.AddRow(_rw); TableCell tb_cell = new TableCell(tb); tb_cell.SdmxValue = currentValue; outputRow.AddCell(tb_cell); horizontalPreviousValues[dimension] = tb_cell; } }
/// <summary> /// Not implemented by this implementation. Use <see cref="RenderAllTables(Estat.Nsi.Client.Renderer.IDataSetModel,System.IO.Stream)"/> instead /// </summary> /// <param name="model"> /// The parameter is not used. /// </param> /// <param name="os"> /// The parameter is not used. /// </param> public override void RenderAllTables(IDataSetModel model, TextWriter os) { }
private Table CreateDimensionAttributeTable(string dimension, IDataSetModel model, IDataReader currentRow) { // table container Table tb_extra = new Table(); // Get Concept name of dimension group attribute bool hasReference = false; #region GroupAttributes foreach (var attr in model.KeyFamily.GroupAttributes) { IList<string> dim_ref = model.KeyFamily.GetGroup(attr.AttachmentGroup).DimensionRefs; // if current dimensions has reference of attr get the current value if (dim_ref.Contains(dimension)) { var code = currentRow[attr.Id] as string; if (!string.IsNullOrEmpty(code)) { #region Group Attribute Header /* // cell title TableCell cell_title = new TableCell(); cell_title.AddClass(HtmlClasses.ExtraInfoTableLabelTitle); cell_title.ColumnSpan = 2; // cell dimension reference TableCell cell_subtitle = new TableCell(); cell_subtitle.AddClass(HtmlClasses.ExtraInfoTableLabelSubTitle); cell_subtitle.ColumnSpan = 2; cell_title.Text = "Group Attribute"; cell_subtitle.Text = attr.AttachmentGroup; tb_extra.AddRow(new TableRow(cell_title)); tb_extra.AddRow(new TableRow(cell_subtitle)); */ #endregion string codesDescription = string.Empty; if (this._componentCodesDescriptionMap.ContainsKey(attr.Id)) { this._componentCodesDescriptionMap[attr.Id].TryGetValue(code.ToUpper(), out codesDescription); if (string.IsNullOrEmpty(codesDescription)) this._componentCodesDescriptionMap[attr.Id].TryGetValue(code.ToLower(), out codesDescription); } tb_extra.AddRow( CreateAttributeRow( model.AllValidKeys[attr.Id], code, codesDescription, true)); hasReference = true; } } } #endregion #region DimensionGroupAttributes foreach (var attr in model.KeyFamily.DimensionGroupAttributes) { IList<string> dim_ref = attr.DimensionReferences; // if current dimensions has reference of attr get the current value if (dim_ref.Contains(dimension)) { var code = currentRow[attr.Id] as string; if (!string.IsNullOrEmpty(code)) { #region Dimension Group Attributes Header /* // cell title TableCell cell_title = new TableCell(); cell_title.AddClass(HtmlClasses.ExtraInfoTableLabelTitle); cell_title.ColumnSpan = 2; if (dim_ref.Count == (model.KeyFamily.DimensionList.Dimensions.Count - 1)) { cell_title.Text = "Series Attribute"; } else if (dim_ref.Count == 1) { cell_title.Text = "Dimension Attribute"; } else { cell_title.Text = "Dimension Group Attribute"; } tb_extra.AddRow(new TableRow(cell_title)); */ #endregion string codesDescription = string.Empty; if (this._componentCodesDescriptionMap.ContainsKey(attr.Id)) { this._componentCodesDescriptionMap[attr.Id].TryGetValue(code.ToUpper(), out codesDescription); if (string.IsNullOrEmpty(codesDescription)) this._componentCodesDescriptionMap[attr.Id].TryGetValue(code.ToLower(), out codesDescription); } tb_extra.AddRow( CreateAttributeRow( model.AllValidKeys[attr.Id], code, codesDescription, true)); hasReference = true; } } } #endregion return (hasReference) ? tb_extra : null; }
/// <summary> /// Initializes a new instance of the <see cref="RendererState"/> class. /// </summary> /// <param name="model"> /// The current <see cref="IDataSetModel"/> /// </param> public RendererState(IDataSetModel model) { this.Model = model; this.CurrentHorizontalKeySetColumn = -1; this._horizontalKeyRows = new Dictionary <string, TableRow>(StringComparer.Ordinal); }
/// <summary> /// Check if all keys are slice keys /// </summary> /// <param name="model"> /// The model to check /// </param> /// <returns> /// The all keys are slice. /// </returns> protected static bool AllKeysAreSlice(IDataSetModel model) { return(model.VerticalKeys.Count == 0 && model.HorizontalKeys.Count == 0); }
private Table CreateObservationAttribute(IDataSetModel model, IDataReader currentRow) { Table tb_extra = new Table(); /* TableCell cell_title = new TableCell("Observation Attribute"); cell_title.AddClass(HtmlClasses.ExtraInfoTableLabelTitle); cell_title.ColumnSpan = 2; tb_extra.AddRow(new TableRow(cell_title)); */ bool hasReference = false; foreach (var attr in model.KeyFamily.ObservationAttributes) { //var attr_ = model.KeyFamily.GetObservationAttribute(attr); var code = currentRow[attr.Id].ToString().ToLower(); if (!string.IsNullOrEmpty(code)) { string codesDescription = string.Empty; if (this._componentCodesDescriptionMap.ContainsKey(attr.Id)) { this._componentCodesDescriptionMap[attr.Id].TryGetValue(code.ToUpper(), out codesDescription); if (string.IsNullOrEmpty(codesDescription)) this._componentCodesDescriptionMap[attr.Id].TryGetValue(code.ToLower(), out codesDescription); } TableRow tr = CreateAttributeRow( model.AllValidKeys[attr.Id], code, codesDescription, true); tb_extra.AddRow(tr); hasReference = true; } } return (hasReference) ? tb_extra : null; }
/// <summary> /// Write all data splitted in slices to the specified writer /// </summary> /// <param name="model"> /// The dataset model /// </param> /// <param name="doc"> /// The PDF document /// </param> private void WriteTableModels(IDataSetModel model, IDocListener doc) { IDataReader reader = model.GetReader(false); // DIV containerTable = createContainerTable(); string oldKeySet = null; var s = new RendererState(model); while (reader.Read()) { s.InputRow = reader; string currentKeySet = MakeKey(model.SliceKeys, reader); if (!currentKeySet.Equals(oldKeySet)) { oldKeySet = currentKeySet; CommitTable(s, doc); // containerTable = createContainerTable(); this.CreateSliceHeader(doc, s); // addSliceHeading(containerTable, sTable); s.Table = CreateSliceTable(); // addSliceTable(containerTable, s.table); this.InitTitles(s); } this.ParseDataRow(s); } reader.Close(); s.InputRow = null; CommitTable(s, doc); }
/// <summary> /// Create and setup the titles for horizontal dimensions /// </summary> /// <param name="model"> /// The DataSetModel to use /// </param> /// <param name="horizontalRows"> /// The horizontal map to add the titles to /// </param> /// <param name="horizontalOrderedRows"> /// The list of rows /// </param> private void CreateHorizontalTitles( IDataSetModel model, IDictionary<string, TableRow> horizontalRows, ICollection<TableRow> horizontalOrderedRows) { foreach (string dim in model.HorizontalKeys) { var row = new TableRow(); row.AddClass(HtmlClasses.HorizontalKeys); // First cell is the title, which spawns over all columns used for vertical keys... TableCell tableCell = this.CreateTitle(model.AllValidKeys[dim], dim, "hkeytitle"); tableCell.SetColSpan(Math.Max(1, model.VerticalKeys.Count)); row.AddCell(tableCell); horizontalRows.Add(dim, row); horizontalOrderedRows.Add(row); } }