Beispiel #1
0
        public PagingLogic(XmlElement pagingSettings, MakoPrintText makoPrintTextLogic)
        {
            string pagingEnabledStr = Utility.GetAtributeValueOrNull(pagingSettings, "enabled");

            this.Enabled = !String.IsNullOrEmpty(pagingEnabledStr) && pagingEnabledStr.ToUpperInvariant() == "TRUE";

            string ratioStr = Utility.GetAtributeValueOrNull(pagingSettings, "ratio");

            this.Ratio = String.IsNullOrEmpty(ratioStr) ? null : System.Convert.ToDecimal(ratioStr, CultureInfo.InvariantCulture) as decimal?;

            this.defaultFontSizeStr = Utility.GetAtributeValueOrNull(pagingSettings, "default-font-size") ?? "8.0";
            if (!this.defaultFontSizeStr.Contains("."))
            {
                this.defaultFontSizeStr += ".0";
            }

            this.DefaultFontSize = !String.IsNullOrEmpty(this.defaultFontSizeStr)
                                ? System.Convert.ToDecimal(this.defaultFontSizeStr, CultureInfo.InvariantCulture) : 8;

            this.DefaultPageWidth = makoPrintTextLogic.DefaultPageWidth;
            this.MarginText       = makoPrintTextLogic.MarginText;

            string displayPagingWhenOnePageStr = Utility.GetAtributeValueOrNull(pagingSettings, "displayPagingWhenOnePage");

            this.DisplayPagingWhenOnePage =
                !String.IsNullOrEmpty(displayPagingWhenOnePageStr) && displayPagingWhenOnePageStr.ToUpperInvariant() == "TRUE";
        }
Beispiel #2
0
        public static string Generate(string xml, Stream output, string driverConfigXml = null)
        {
            StreamWriter w = new StreamWriter(output, Encoding.UTF8);

            MakoPrintText mp          = new MakoPrintText();
            XmlDocument   xmlDocument = new XmlDocument();

            xmlDocument.PreserveWhitespace = true;
            xmlDocument.LoadXml(xml);
            string result = mp.Convert(xmlDocument);

            #region Extract paging element
            if (driverConfigXml != null)
            {
                XmlDocument xdoc = new XmlDocument();
                xdoc.LoadXml(driverConfigXml);
                XmlNodeList list = xdoc.DocumentElement.GetElementsByTagName("paging");
                if (list.Count > 0 && list[0].NodeType == XmlNodeType.Element)
                {
                    XmlElement  pagingElement = (XmlElement)list[0];
                    PagingLogic pagingLogic   = new PagingLogic(pagingElement, mp);
                    result = pagingLogic.TryApplyPaging(result);
                }
            }
            #endregion
            foreach (XmlNode child in xmlDocument.DocumentElement.ChildNodes)
            {
                xmlDocument.DocumentElement.RemoveChild(child);
            }
            w.Write(xmlDocument.DocumentElement.OuterXml);
            w.Write("@@@@");
            w.Write(result);
            w.Flush();

            return(result);
        }