Пример #1
0
        public ReportEmail()
        {
            HtmlBody = new Body().Add <Class>("Body");

            var oTbl = new Table().Add <Class>("Header");

            HtmlBody.Append(oTbl);

            var oImgLogo = new Img()
                           .Add <Class>("Logo")
                           .Add <Src>("http://www.ezbob.com/app/themes/ezbob/images/header/ezbob_logo.png");

            var oLogoLink = new A()
                            .Add <Href>("http://www.ezbob.com/")
                            .Add <Class>("logo_ezbob")
                            .Add <Class>("indent_text")
                            .Add <ID>("ezbob_logo")
                            .Add <Title>("Fast business loans for Ebay and Amazon merchants")
                            .Add <Alt>("Fast business loans for Ebay and Amazon merchants")
                            .Append(oImgLogo);

            var oTr = new Tr();

            oTbl.Append(oTr);

            oTr.Append(new Td().Append(oLogoLink));

            Title = new H1();

            oTr.Append(new Td().Append(Title));

            ReportBody = new P().Add <Class>("Body");

            HtmlBody.Append(ReportBody);
        }         // constructor
Пример #2
0
        }         // CreateUiExtReport

        private void ProcessTableReportRow(ReportQuery rptDef, SafeReader sr, Tbody oTbody, int lineCounter, List <string> oColumnTypes)
        {
            var oTr = new Tr().Add <Class>(lineCounter % 2 == 0 ? "Odd" : "Even");

            oTbody.Append(oTr);

            var oClassesToApply = new List <string>();

            for (int columnIndex = 0; columnIndex < rptDef.Columns.Length; columnIndex++)
            {
                ColumnInfo col    = rptDef.Columns[columnIndex];
                var        oValue = sr.ColumnOrDefault(col.FieldName);

                if (col.IsVisible)
                {
                    var oTd = new Td();
                    oTr.Append(oTd);

                    if (IsNumber(oValue))
                    {
                        ATag oInnerTag = new Text(NumStr(oValue, col.Format(IsInt(oValue) ? 0 : 2)));

                        if (col.ValueType == ValueType.UserID || col.ValueType == ValueType.BrokerID)
                        {
                            var oLink = new A();

                            oLink.Append(oInnerTag);
                            oLink.Target.Append("_blank");

                            var titleText = "Open this customer in underwriter.";
                            if (col.ValueType == ValueType.UserID)
                            {
                                oLink.Href.Append("https://" + UnderwriterSite + "/UnderWriter/Customers?customerid=" + oValue);
                            }
                            else
                            {
                                oLink.Href.Append("https://" + UnderwriterSite + "/UnderWriter/Customers#broker/" + oValue);
                                titleText = "Open this broker in underwriter.";
                            }

                            oLink.Alt.Append(titleText);
                            oLink.Title.Append(titleText);

                            oInnerTag = oLink;

                            if (oColumnTypes != null)
                            {
                                oColumnTypes[columnIndex] = "user-id";
                            }
                        }
                        else
                        {
                            if (oColumnTypes != null)
                            {
                                oColumnTypes[columnIndex] = "formatted-num";
                            }
                        }                         // if user id

                        oTd.Add <Class>("R").Append(oInnerTag);
                    }
                    else
                    {
                        oTd.Add <Class>("L").Append(new Text(oValue.ToString()));

                        if ((oColumnTypes != null) && (oValue is DateTime))
                        {
                            oColumnTypes[columnIndex] = "date";
                        }
                    }                     // if
                }
                else
                {
                    if (col.ValueType == ValueType.CssClass)
                    {
                        oClassesToApply.Add(oValue.ToString());
                    }
                }         // if
            }             // for each column

            if (oClassesToApply.Count > 0)
            {
                oTr.ApplyToChildren <Class>(string.Join(" ", oClassesToApply.ToArray()));
            }
        }         // ProcessTableReportRow
Пример #3
0
        }         // TableReport

        public ATag TableReport(ReportQuery rptDef, DataTable oReportData, bool isSharones = false, string sRptTitle = "", List <string> oColumnTypes = null)
        {
            int   lineCounter = 0;
            var   tbl         = new Table().Add <Class>("Report");
            Tbody oTbody;

            try {
                if (!isSharones)
                {
                    tbl.Add <ID>("tableReportData");
                }
            }
            catch (Exception e) {
                Alert(e, "Failed to add HTML id to report table.");
                return(tbl);
            }             // try

            try {
                var tr = new Tr().Add <Class>("HR");

                for (int columnIndex = 0; columnIndex < rptDef.Columns.Length; columnIndex++)
                {
                    if (rptDef.Columns[columnIndex].IsVisible)
                    {
                        tr.Append(new Th().Add <Class>("H").Append(new Text(rptDef.Columns[columnIndex].Caption)));
                    }
                }

                tbl.Append(new Thead().Append(tr));
            }
            catch (Exception e) {
                Alert(e, "Failed to initialise table header row.");
                return(tbl);
            }             // try

            try {
                oTbody = new Tbody();
                tbl.Append(oTbody);

                if (oColumnTypes != null)
                {
                    oColumnTypes.Clear();

                    for (int columnIndex = 0; columnIndex < rptDef.Columns.Length; columnIndex++)
                    {
                        oColumnTypes.Add("string");
                    }
                }                 // if
            }
            catch (Exception e) {
                Alert(e, "Failed to initialise report table column types.");
                return(tbl);
            }             // try

            if (oReportData == null)
            {
                try {
                    rptDef.Execute(DB, (sr, bRowsetStart) => {
                        ProcessTableReportRow(rptDef, sr, oTbody, lineCounter, oColumnTypes);
                        lineCounter++;
                        return(ActionResult.Continue);
                    });                     // for each data row
                }
                catch (Exception e) {
                    Alert(e, "Failed to fetch data from DB or create report table body.");
                    return(tbl);
                }                 // try
            }
            else
            {
                try {
                    foreach (DataRow row in oReportData.Rows)
                    {
                        ProcessTableReportRow(rptDef, new SafeReader(row), oTbody, lineCounter, oColumnTypes);
                        lineCounter++;
                    }                     // for each data row
                }
                catch (Exception e) {
                    Alert(e, "Failed to create report table body.");
                    return(tbl);
                }         // try
            }             // if

            try {
                if (oColumnTypes != null)
                {
                    for (int columnIndex = rptDef.Columns.Length - 1; columnIndex >= 0; columnIndex--)
                    {
                        if (!rptDef.Columns[columnIndex].IsVisible)
                        {
                            oColumnTypes.RemoveAt(columnIndex);
                        }
                    }
                }                 // if
            }
            catch (Exception e) {
                Alert(e, "Failed to finalise report table column types.");
            }             // try

            return(tbl);
        }         // TableReport