} // End Constructor public string GetHtml() { Legende leg = new Legende(); //System.Data.DataTable dtSet = leg.LegendenSettings; //System.Data.DataTable dtData = leg.LegendenDaten; //Console.WriteLine(dtSet.Rows.Count); //Console.WriteLine(dtData.Rows.Count); //Console.WriteLine(leg.TextField); //Console.WriteLine(leg.ValueField); //Console.WriteLine(leg.Language); //Console.WriteLine(leg.Sum); string strHtmlTemplate = GetTextFile("LegendenTemplate.txt"); // strHtmlTemplate = strHtmlTemplate.Replace("{", "{{").Replace("}", "}}"); string logofile = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); logofile = System.IO.Path.Combine(logofile, "../../logos/gmbhco_lect.png"); logofile = System.IO.Path.GetFullPath(logofile); string strLogoData = SimpleHtmlToPdfConverter.Draw.ImageAsDataString(logofile, System.Drawing.Imaging.ImageFormat.Png); string stra = string.Format("<img alt=\"{0}\" width=\"25%\" src=\"{1}\" />", "Logo", strLogoData); string num = leg.FormatNumber(123.456); System.Console.WriteLine(num); string Heading = string.Format("{0} - {1} - {2} - {3}", leg.Location, leg.Premise, leg.Floor, leg.Title); System.Console.WriteLine(Heading); string date = leg.FormatDateTime("dd-MMM-yyyy"); string strHTML = string.Format(strHtmlTemplate, stra, GetRows(leg)); return(strHTML); } // End Function GetHtml
} // End Function GetHtml public string GetRows(Legende leg) { string strRowTemplate = @"<tr{0}> <td class=""bullet {1}""{5}></td> <td class=""legendText""> <div class=""sizelimit""> {2} </div> </td> <td class=""legendValue""> {3} </td> <td> {4} </td> </tr> "; string NumberFormat = leg.NumberFormat; System.Globalization.NumberFormatInfo nfi = new System.Globalization.NumberFormatInfo(); nfi.NumberDecimalSeparator = "."; nfi.NumberGroupSeparator = "'"; nfi.CurrencyDecimalSeparator = "."; nfi.CurrencyGroupSeparator = "'"; nfi.CurrencySymbol = "CHF"; string strInlineStyle = ""; System.Text.StringBuilder sb = new System.Text.StringBuilder(); string strHeader = @"<tr> <td class=""bullet Color0 legendTitle"" colspan=""3""> {0} </td> </tr> <tr> <td colspan=""3""> </td> </tr> <tr> <td class=""bullet Color0""></td> <td class=""legendText""> </td> <td class=""legendValue legendSubTitle""> {1} </td> <td> </td> </tr> "; sb.AppendFormat(strHeader, System.Web.HttpUtility.HtmlEncode(leg.Title), System.Web.HttpUtility.HtmlEncode(leg.ValueTitle)); bool b = 1 == 1; if (leg.WithSum && !leg.SumInData) { string strSumValue = leg.Sum.ToString(NumberFormat, nfi); if (b) { sb.AppendFormat(strRowTemplate, " class=\"sum\"", "Color0", leg.SumText, strSumValue, leg.PdfUnit, strInlineStyle); } else { sb.AppendFormat(strRowTemplate, " class=\"sum\"", "Color0", leg.SumText, strSumValue, leg.HtmlUnit, strInlineStyle); } } // End if (leg.WithSum && !leg.SumInData) for (int i = 0; i < leg.LegendenDaten.Rows.Count; ++i) { System.Data.DataRow dr = leg.LegendenDaten.Rows[i]; int AP_LEG_Pattern = System.Convert.ToInt32(dr["AP_LEG_Pattern"]); int AP_LEG_ForeColor = 0; string strFgColor = System.Convert.ToString(dr["HtmlForegroundColor"]); string strBgColor = System.Convert.ToString(dr["HtmlBackgroundColor"]); string strLineColor = System.Convert.ToString(dr["HtmlLineColor"]); string strAP_LEG_ForeColor = System.Convert.ToString(dr["AP_LEG_ForeColor"]); if (!string.IsNullOrEmpty(strAP_LEG_ForeColor)) { int.TryParse(strAP_LEG_ForeColor, out AP_LEG_ForeColor); } if (string.IsNullOrEmpty(strFgColor)) { strFgColor = "#000000"; } if (System.StringComparer.Ordinal.Equals(strBgColor, "#")) { strBgColor = "#000000"; } if (System.StringComparer.Ordinal.Equals(strLineColor, "#")) { strLineColor = "#000000"; } System.Drawing.Color colFC = System.Drawing.ColorTranslator.FromHtml(strFgColor); System.Drawing.Color colHB = System.Drawing.ColorTranslator.FromHtml(strBgColor); System.Drawing.Color colHL = System.Drawing.ColorTranslator.FromHtml(strLineColor); double dblValue = System.Convert.ToDouble(dr["Value"]); string strText = System.Convert.ToString(dr["Text"]) ?? ""; string strValue = dblValue.ToString(NumberFormat, nfi); strText = System.Web.HttpUtility.HtmlEncode(strText); strValue = System.Web.HttpUtility.HtmlEncode(strValue); string ColorClass = null; if (AP_LEG_Pattern == 12) { ColorClass = "Color" + AP_LEG_ForeColor.ToString(); } else { string src = SimpleHtmlToPdfConverter.Draw.GetHatchRectangleAsDataString(9, colFC, colHB, colHL, System.Drawing.Imaging.ImageFormat.Png); strInlineStyle = string.Format(" style=\"background-image: url({0});\"", src); } string strSumClass = ""; if (leg.WithSum && leg.SumInData && i == 0) { strSumClass = " class=\"sum\""; strText = leg.SumText; } // End if (leg.WithSum && leg.SumInData && i == 0) if (b) { sb.AppendFormat(strRowTemplate, strSumClass, ColorClass, strText, strValue, leg.PdfUnit, strInlineStyle); } else { sb.AppendFormat(strRowTemplate, strSumClass, ColorClass, strText, strValue, leg.HtmlUnit, strInlineStyle); } // AP_LEG_Nr //--,AP_LEG_Mandant //--,AP_LEG_DWG } // Next dr string strHTML = sb.ToString(); sb.Length = 0; sb = null; return(strHTML); } // End Function GetRows