// public static EbOperations Operations = ReportOperations.Instance;

        //public byte[] GetImage(int refId)
        //{
        //    DownloadFileResponse dfs = null;

        //    byte[] fileByte = new byte[0];
        //    dfs = FileClient.Get
        //         (new DownloadImageByIdRequest
        //         {
        //             ImageInfo = new ImageMeta
        //             {
        //                 FileRefId = refId,
        //                 FileCategory = Enums.EbFileCategory.Images
        //             }
        //         });
        //    if (dfs.StreamWrapper != null)
        //    {
        //        dfs.StreamWrapper.Memorystream.Position = 0;
        //        fileByte = dfs.StreamWrapper.Memorystream.ToBytes();
        //    }

        //    return fileByte;
        //}

        public void AddParamsNCalcsInGlobal(EbPdfGlobals globals)
        {
            foreach (string key in CalcValInRow.Keys) //adding Calc to global
            {
                globals["Calc"].Add(key, CalcValInRow[key]);
            }

            if (Parameters != null)
            {
                foreach (Param p in Parameters) //adding Params to global
                {
                    globals["Params"].Add(p.Name, new PdfNTV {
                        Name = p.Name, Type = (PdfEbDbTypes)Convert.ToInt32(p.Type), Value = p.Value
                    });
                }
            }

            if (SummaryValInRow.Count > 0)
            {
                foreach (string key in SummaryValInRow.Keys)
                {
                    globals["Summary"].Add(key.Replace(".", "_"), SummaryValInRow[key]);
                }
            }
        }
        public void RunAppearanceExpression(EbDataField field, int slno)
        {
            if (field.Font is null || field.Font.Size == 0)
            {
                field.Font = new EbFont {
                    Color = "#000000", FontName = "Roboto", Caps = false, Size = 10, Strikethrough = false, Style = Enums.FontStyle.NORMAL, Underline = false
                }
            }
            ;
            PdfGEbFont pg_font = new PdfGEbFont
            {
                Caps          = field.Font.Caps,
                color         = field.Font.Color,
                FontName      = field.Font.FontName,
                Size          = field.Font.Size,
                Strikethrough = field.Font.Strikethrough,
                Style         = (PdfGFontStyle)(int)field.Font.Style,
                Underline     = field.Font.Underline
            };
            EbPdfGlobals globals = new EbPdfGlobals();

            globals["CurrentField"].Add("CurrentField", new PdfNTV
            {
                Name  = "CurrentField",
                Type  = PdfEbDbTypes.Object,
                Value = new PdfGReportField(field.LeftPt, field.WidthPt, field.TopPt, field.HeightPt, field.BackColor, field.ForeColor, field.IsHidden, pg_font)
            });

            object value = ExecuteExpression(AppearanceScriptCollection[this.Name], slno, globals, field.DataFieldsUsedAppearance, true);

            field.SetValuesFromGlobals(globals.CurrentField);
        }
        public void ExecuteLayoutExpression(EbReportField field)
        {
            EbPdfGlobals globals = new EbPdfGlobals
            {
                CurrentField = new PdfGReportField(field.LeftPt, field.WidthPt, field.TopPt, field.HeightPt, field.BackColor, field.ForeColor, field.IsHidden, null)
            };

            string[] _dataFieldsUsed = GetDataFieldsUsed(field.LayoutExpression.GetCode());
            object   value           = ExecuteExpression(field.LayoutExpression.GetCode(), 0, globals, _dataFieldsUsed, false);

            field.SetValuesFromGlobals(globals.CurrentField);
        }
        public void ExecuteHideExpression(EbReportField field)
        {
            EbPdfGlobals globals = new EbPdfGlobals();

            string[] _dataFieldsUsed = GetDataFieldsUsed(field.HideExpression.GetCode());
            object   value           = ExecuteExpression(field.HideExpression.GetCode(), 0, globals, _dataFieldsUsed, false);

            if (value != null)
            {
                field.IsHidden = (bool)value;
            }
        }
        public void CallSummerize(EbDataField field, int serialnumber)
        {
            string       column_val;
            EbPdfGlobals globals = new EbPdfGlobals();

            if (field is EbCalcField)
            {
                column_val = (field as EbCalcField).GetCalcFieldValue(globals, DataSet, serialnumber, this);
            }
            else
            {
                column_val = GetDataFieldValue(field.ColumnName, serialnumber, field.TableIndex);
            }
            List <EbDataField> SummaryList;

            if (GroupSummaryFields.ContainsKey(field.Name))
            {
                SummaryList = GroupSummaryFields[field.Name];
                foreach (EbDataField item in SummaryList)
                {
                    (item as IEbDataFieldSummary).Summarize(column_val);
                }
            }
            if (PageSummaryFields.ContainsKey(field.Name))
            {
                SummaryList = PageSummaryFields[field.Name];
                foreach (EbDataField item in SummaryList)
                {
                    (item as IEbDataFieldSummary).Summarize(column_val);
                }
            }
            if (ReportSummaryFields.ContainsKey(field.Name))
            {
                SummaryList = ReportSummaryFields[field.Name];
                foreach (EbDataField item in SummaryList)
                {
                    (item as IEbDataFieldSummary).Summarize(column_val);
                }
            }
        }
        public void SetVariable(EbPdfGlobals globals)
        {
            Dictionary <string, object> dict = new Dictionary <string, object>
            {
                { "T0", globals["T0"] },
                { "T1", globals["T1"] },
                { "T2", globals["T2"] },
                { "T3", globals["T3"] },
                { "T4", globals["T4"] },
                { "T5", globals["T5"] },
                { "T6", globals["T6"] },
                { "T7", globals["T7"] },
                { "T8", globals["T8"] },
                { "T9", globals["T9"] },
                { "Params", globals["Params"] },
                { "Calc", globals["Calc"] },
                { "Summary", globals["Summary"] },
                { "CurrentField", globals["CurrentField"] }
            };

            evaluator.SetVariable(dict);
        }
        public object ExecuteExpression(string code, int irow, EbPdfGlobals globals, string[] _dataFieldsUsed, bool Isprocessed)
        {
            object value = null;

            try
            {
                string processedCode;
                if (Isprocessed)
                {
                    processedCode = code;
                }
                else
                {
                    processedCode = GetProcessedCode(code, _dataFieldsUsed);
                }

                foreach (string calcfd in _dataFieldsUsed)
                {
                    string TName      = calcfd.Split('.')[0];
                    string fName      = calcfd.Split('.')[1];
                    int    tableIndex = Convert.ToInt32(TName.Substring(1));
                    int    RowIndex   = (tableIndex == this.DetailTableIndex) ? irow : 0;
                    globals[TName].Add(fName, new PdfNTV {
                        Name = fName, Type = (PdfEbDbTypes)(int)this.DataSet.Tables[tableIndex].Columns[fName].Type, Value = this.DataSet.Tables[tableIndex].Rows[irow][fName]
                    });
                }
                AddParamsNCalcsInGlobal(globals);
                SetVariable(globals);

                value = evaluator.Execute(processedCode);
            }
            catch (Exception e)
            {
                string s = e.Message + e.StackTrace;
            }
            return(value);
        }
        public void DoLoopInDetail(int serialnumber)
        {
            ph_Yposition = (PageNumber == 1) ? ReportHeaderHeight + this.Margin.Top : this.Margin.Top;
            dt_Yposition = ph_Yposition + PageHeaderHeight;
            foreach (EbReportDetail detail in Detail)
            {
                string column_val;
                RowHeight   = 0;
                MultiRowTop = 0;
                EbDataField[] SortedList = FieldsNotSummaryPerDetail[detail];
                EbPdfGlobals  globals    = new EbPdfGlobals();
                for (int iSortPos = 0; iSortPos < SortedList.Length; iSortPos++)
                {
                    EbDataField field = SortedList[iSortPos];
                    if (field is EbCalcField)
                    {
                        //globals.CurrentField = field;
                        column_val = (field as EbCalcField).GetCalcFieldValue(globals, DataSet, serialnumber, this);
                        EbDbTypes dbtype = (EbDbTypes)((field as EbCalcField).CalcFieldIntType);

                        if (CalcValInRow.ContainsKey(field.Title))
                        {
                            CalcValInRow[field.Title] = new PdfNTV {
                                Name = field.Title, Type = (PdfEbDbTypes)(int)dbtype, Value = column_val
                            }
                        }
                        ;
                        else
                        {
                            CalcValInRow.Add(field.Title, new PdfNTV {
                                Name = field.Title, Type = (PdfEbDbTypes)(int)dbtype, Value = column_val
                            });
                        }
                        AddParamsNCalcsInGlobal(globals);
                    }
                    else
                    {
                        column_val = GetDataFieldValue(field.ColumnName, serialnumber, field.TableIndex);
                    }

                    if (field.RenderInMultiLine)
                    {
                        field.DoRenderInMultiLine(column_val, this);
                    }
                }
                EbReportField[] SortedReportFields = this.ReportFieldsSortedPerDetail[detail];
                if (SortedReportFields.Length > 0)
                {
                    for (int iSortPos = 0; iSortPos < SortedReportFields.Length; iSortPos++)
                    {
                        EbReportField field = SortedReportFields[iSortPos];
                        if (field is EbDataField)
                        {
                            field.HeightPt += RowHeight;
                        }
                        DrawFields(field, dt_Yposition, serialnumber);
                    }
                    detailprintingtop += detail.HeightPt + RowHeight;
                    detailEnd          = detailprintingtop;
                }
                else
                {
                    detailEnd  = detailprintingtop;
                    IsLastpage = true;
                    Writer.PageEvent.OnEndPage(Writer, Doc);
                    return;
                }
            }
        }
Beispiel #9
0
 public string GetCalcFieldValue(EbPdfGlobals globals, EbDataSet DataSet, int serialnumber, EbReport Rep)
 {
     return(Rep.ExecuteExpression(Rep.ValueScriptCollection[this.Name], serialnumber, globals, DataFieldsUsedInCalc, true)?.ToString());
 }
Beispiel #10
0
        public override void DrawMe(float printingTop, EbReport Rep, List <Param> Params, int slno)
        {
            ColumnText   ct         = new ColumnText(Rep.Canvas);
            string       column_val = string.Empty;
            EbDbTypes    dbtype     = EbDbTypes.String;
            EbPdfGlobals globals    = new EbPdfGlobals();

            try
            {
                column_val = Rep.ExecuteExpression(Rep.ValueScriptCollection[Name], slno, globals, DataFieldsUsedInCalc, true).ToString();
                dbtype     = (EbDbTypes)CalcFieldIntType;

                if (Rep.CalcValInRow.ContainsKey(Title))
                {
                    Rep.CalcValInRow[Title] = new PdfNTV {
                        Name = Title, Type = (PdfEbDbTypes)(int)dbtype, Value = column_val
                    }
                }
                ;
                else
                {
                    Rep.CalcValInRow.Add(Title, new PdfNTV {
                        Name = Title, Type = (PdfEbDbTypes)(int)dbtype, Value = column_val
                    });
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message + e.StackTrace);
            }
            if (SuppressIfZero && !(Convert.ToDecimal(column_val) > 0))
            {
                column_val = String.Empty;
            }
            else
            {
                if (dbtype == EbDbTypes.Decimal)
                {
                    column_val = FormatDecimals(column_val, AmountInWords, DecimalPlaces, Rep.CultureInfo?.NumberFormat, FormatUsingCulture);
                }
                if (Prefix != "" || Suffix != "")
                {
                    column_val = Prefix + " " + column_val + " " + Suffix;
                }
            }
            Phrase phrase = GetPhrase(column_val, (DbType)DbType, Rep.Font);

            if (!string.IsNullOrEmpty(LinkRefId))
            {
                Anchor    a = CreateLink(phrase, LinkRefId, Rep.Doc, Params);
                Paragraph p = new Paragraph {
                    a
                };
                p.Font = GetItextFont(this.Font, Rep.Font);
                ct.AddText(p);
            }
            else
            {
                ct.AddText(phrase);
            }

            float ury = Rep.HeightPt - (printingTop + TopPt + Rep.detailprintingtop);
            float lly = Rep.HeightPt - (printingTop + TopPt + HeightPt + Rep.detailprintingtop);

            ct.SetSimpleColumn(Llx, lly, Urx, ury, Leading, (int)TextAlign);
            ct.Go();
        }