public IActionResult Index(string refid) { var resultlist = this.ServiceClient.Get <EbObjectParticularVersionResponse>(new EbObjectParticularVersionRequest { RefId = refid }); Report = EbSerializers.Json_Deserialize <EbReport>(resultlist.Data[0].Json); if (Report.DataSourceRefId != string.Empty) { cresp = this.Redis.Get <DataSourceColumnsResponse>(string.Format("{0}_columns", Report.DataSourceRefId)); if (cresp.IsNull) { cresp = this.ServiceClient.Get <DataSourceColumnsResponse>(new DataSourceColumnsRequest { RefId = Report.DataSourceRefId }); } __columns = (cresp.Columns.Count > 1) ? cresp.Columns[1] : cresp.Columns[0]; dresp = this.ServiceClient.Get <DataSourceDataResponse>(new DataSourceDataRequest { RefId = Report.DataSourceRefId, Draw = 1, Start = 0, Length = 100 }); dt = dresp.Data; } iTextSharp.text.Rectangle rec = (Report.IsLandscape) ? new iTextSharp.text.Rectangle(Report.Height, Report.Width) : new iTextSharp.text.Rectangle(Report.Width, Report.Height); d = new Document(rec); MemoryStream ms1 = new MemoryStream(); writer = PdfWriter.GetInstance(d, ms1); writer.Open(); d.Open(); writer.PageEvent = new HeaderFooter(this); writer.CloseStream = true;//important cb = writer.DirectContent; CalculateSectionHeights(); d.NewPage(); DrawReportHeader(); DrawDetail(); DrawReportFooter(); d.Close(); ms1.Position = 0; return(new FileStreamResult(ms1, "application/pdf")); }
public void InitFromDataBase(JsonServiceClient ServiceClient) { RowColletion ds = (ServiceClient.Get <DataSourceDataResponse>(new DataSourceDataRequest { RefId = this.DataSourceId, Start = 0, Length = 1000 })).Data; for (int i = 0; i < ds.Count; i++) { EbCard Card = new EbCard() { EbSid = "cardEbsid_" + i }; foreach (EbCardField Field in this.CardFields) { if (Field.DbFieldMap != null) { var tempdata = ds[i][Field.DbFieldMap.Data]; if (Field is EbCardNumericField) { Card.CustomFields[Field.Name] = Convert.ToDouble(tempdata); } else { Card.CustomFields[Field.Name] = tempdata.ToString().Trim(); } //for getting distinct filter values if (this.FilterField?.Name != null && Field.Name == this.FilterField.Name && !this.FilterValues.Contains(tempdata.ToString().Trim())) { this.FilterValues.Add(tempdata.ToString().Trim()); } } } Card.CardId = Convert.ToInt32(ds[i][this.ValueMember.Data]); Card.Name = "CardIn" + this.Name;//------------------------"CardIn" this.CardCollection.Add(Card); } }
private void DrawRows(RowColletion rows) { for (int rowIndex = 0; rowIndex < rows.Count; rowIndex++) { this.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto }); for (int columnIndex = 0; columnIndex < rows[rowIndex].Count; columnIndex++) { Label label = new Label { Padding = 5, BackgroundColor = Color.White, Text = rows[rowIndex][columnIndex]?.ToString(), VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, LineBreakMode = LineBreakMode.WordWrap, FontSize = 13 }; this.Children.Add(label, columnIndex, rowIndex + 1); } } }
public void GetFormatedTable(ref EbDataTable _formattedTable, RowColletion masterRows, ref Dictionary <int, List <object> > summary, User _user) { for (int i = 0; i < masterRows.Count; i++)//filling master data { _formattedTable.Rows.Add(_formattedTable.NewDataRow2()); for (int j = 0; j < masterRows[0].Count; j++) { _formattedTable.Rows[i][j] = masterRows[i][j]; } } CultureInfo _user_culture = CultureHelper.GetSerializedCultureInfo(_user.Preference.Locale).GetCultureInfo(); _user_culture.NumberFormat.NumberDecimalDigits = 0; EbDataRow Row; long value; long prev_value; int summary_last_index = summary.Keys.Last(); string total; for (int i = 0; i < _formattedTable.Rows.Count; i++)//filling consolidated data { Row = _formattedTable.Rows[i]; int _id = (int)Row[PrimaryKeyColumnName]; if (_innerDict.ContainsKey(_id)) { if (!Totals.ContainsKey(_id)) { Totals.Add(_id, new List <long>()); } total = string.Empty; foreach (int columnIndex in _innerDict[_id].GetKeys()) { string val = string.Empty; int j = 0; foreach (DVBaseColumn col in DataColumns) { prev_value = 0; value = _innerDict[_id].GetValue(columnIndex, col.Name); if (ShowGrowthPercentage && CalendarType != AttendanceType.DayWise) { if (columnIndex > this.InitialColumnsCount && Columns.GetColumnByIndex(columnIndex).StartDate > Columns.GetColumnByIndex(columnIndex - 1).StartDate) { prev_value = _innerDict[_id].GetValue(columnIndex - 1, col.Name); } } val += GetFormattedValue(value, Row, columnIndex, prev_value, _user_culture, col); try { if (Totals[_id].Count < j + 1) { Totals[_id].Add(value); } else { Totals[_id][j] = Totals[_id][j] + value; } } catch (Exception e) { Console.WriteLine(e.Message + " " + _id); } summary[columnIndex][j] = (Convert.ToDecimal(summary[columnIndex][0]) + Convert.ToDecimal(value)).ToString("N", _user_culture.NumberFormat); summary[summary_last_index][j] = (Convert.ToDecimal(summary[summary_last_index][0]) + Convert.ToDecimal(value)).ToString("N", _user_culture.NumberFormat);; j++; } Row[columnIndex] = val; } for (int k = 0; k < DataColumns.Count; k++) { if (Totals[_id].Count > k) { total += $"<div class='dataclass {DataColumns[k].Name}_class'>{Convert.ToDecimal(Totals[_id][k]).ToString("N", _user_culture.NumberFormat) }</div>"; } } Row["Total"] = total; } } }