public void AddPage(IXSLTemplate dat) { AddPage(new WebBrowserPage(dat)); }
public void AddPage(IXSLTemplate dat) { Web.AddPage(dat); }
public WebBrowserPage(IXSLTemplate dat) : this() { bool useCached = true; // кеширование XSLT #if DEBUG useCached = false; #endif bool verbose = true; DateTime timeStart1 = DateTime.Now; DateTime timeStart = DateTime.Now; DateTime timeStop = DateTime.Now; DateTime timeStop1 = DateTime.Now; XslCompiledTransform _xslt = null; StringBuilder timerString = new StringBuilder(""); XmlDocument xml = new XmlDocument(); try { timeStart = DateTime.Now; xml = dat.Serialize(); timeStop = DateTime.Now; timerString.AppendFormat("Сериализация: {0} ms;<br/>", (timeStop - timeStart).TotalMilliseconds); string filename = dat.GetTemplatePath() + dat.GetTemplateName(); if (!XslPool_WebPage.ContainsKey(filename) || !useCached || XslPool_WebPage[filename] == null) { timeStart = DateTime.Now; try { _xslt = new XslCompiledTransform(true); _xslt.Load(filename); } catch (Exception ex) { _xslt = null; timerString.AppendFormat("Ошибка загрузки XSLT-файла {0}: <font color=\"red\">{1}</font><br/>", filename, Common.ExMessage(ex)); } XslPool_WebPage[filename] = _xslt; timeStop = DateTime.Now; timerString.AppendFormat("Загрузка XSLT: {0} ms;<br/>", (timeStop - timeStart).TotalMilliseconds); } else { _xslt = XslPool_WebPage[filename]; } HTMLContent = Common.TranslateXSL(xml, _xslt); timeStop = DateTime.Now; timerString.AppendFormat("Трансформация: {0} ms;<br/>", (timeStop - timeStart).TotalMilliseconds); } catch (Exception ex) { HTMLContent = Common.TranslateXSL(xml); timerString.AppendFormat("Ошибка XSLT-трансформации: <font color=\"red\">{0}</font>, используем шаблон по-умолчанию.<br/>", Common.ExMessage(ex)); } timeStop1 = DateTime.Now; timerString.AppendFormat("Итого: {0} ms;<br/>", (timeStop1 - timeStart1).TotalMilliseconds); if (verbose) { HTMLContent += "<hr width=\"100%\" size=1 align=left>" + timerString.ToString(); } }