Exemple #1
0
        public override byte[] ExportResult(List <T> data, params KeyValuePair <string, object>[] additionalData)
        {
            var modelTemplate = new ModelTemplate <T>(data);

            var service = Engine.Razor;

            service.AddTemplate(TType.Name + "HtmlCollection", ExportCollection);
            service.AddTemplate(TType.Name + "HtmlHeader", ExportHeader);
            service.AddTemplate(TType.Name + "HtmlItem", ExportItem);
            service.Compile(TType.Name + "HtmlCollection", typeof(ModelTemplate <T>));
            service.Compile(TType.Name + "HtmlHeader");
            service.Compile(TType.Name + "HtmlItem", typeof(T));
            var result = service.Run(TType.Name + "HtmlCollection", typeof(ModelTemplate <T>), modelTemplate, additionalData.ToDynamicViewBag());

            return(System.Text.Encoding.Unicode.GetBytes(result));
        }
Exemple #2
0
        public string ExportResultStringPart(List <T> data, params KeyValuePair <string, object>[] additionalData)
        {
            var modelTemplate = new ModelTemplate <T>(data);

            var service = Engine.Razor;

            service.AddTemplate(TType.Name + "iTextSharp4Collection", ExportCollection);
            service.AddTemplate(TType.Name + "iTextSharp4Header", ExportHeader);
            service.AddTemplate(TType.Name + "iTextSharp4Item", ExportItem);
            service.Compile(TType.Name + "iTextSharp4Collection", typeof(ModelTemplate <T>));
            service.Compile(TType.Name + "iTextSharp4Header");
            service.Compile(TType.Name + "iTextSharp4Item", typeof(T));
            var result = service.Run(TType.Name + "iTextSharp4Collection", typeof(ModelTemplate <T>), modelTemplate);

            return(result);
        }