public JsonObjectPageMaker(string modelName, WriteSettings settings) { Add(PageMakerUtil.IsType(SourceOutputType.ToolkitObject), new InternalJsonObjectPageMaker(modelName, settings)); Add(PageMakerUtil.IsType(SourceOutputType.String), new SourceOutputPageMaker(ContentTypeConst.JSON)); }
string IRedirector.Redirect(ISource source, IPageData pageData, OutputData data) { TkDebug.AssertArgumentNull(data, "data", this); PageMakerUtil.AssertType(this, data, SourceOutputType.String); return(data.Data.Convert <string>()); }
public virtual IContent WritePage(ISource source, IPageData pageData, OutputData outputData) { PageMakerUtil.AssertType(source, outputData, SourceOutputType.DataSet); DataSet ds = outputData.Data.Convert <DataSet>(); var metaTables = GetTableData(); DataSet resultSet = new DataSet(ds.DataSetName) { Locale = ds.Locale }; using (resultSet) { foreach (DataTable table in ds.Tables) { ITableData tableData; if (metaTables.TryGetValue(table.TableName, out tableData)) { resultSet.Tables.Add(CreateResultTable(pageData, ds, table, tableData)); } else { resultSet.Tables.Add(table.Copy()); } } ProcessResult(resultSet); using (XmlReader reader = new XmlDataSetReader(resultSet, true, false)) { string xml = XmlUtil.GetJson(reader); return(new SimpleContent(ContentTypeConst.JSON, xml)); } } }
public IContent WritePage(ISource source, IPageData pageData, OutputData outputData) { TkDebug.AssertArgumentNull(outputData, "outputData", this); PageMakerUtil.AssertType(source, outputData, SourceOutputType.String); return(new SimpleContent(fContentType, PageMakerUtil.GetString(outputData))); }
public IContent WritePage(ISource source, IPageData pageData, OutputData outputData) { TkDebug.AssertArgumentNull(outputData, "outputData", this); PageMakerUtil.AssertType(source, outputData, SourceOutputType.ToolkitObject); string xml = outputData.Data.WriteXml(ModelName, fSettings, fRoot); return new SimpleContent(ContentTypeConst.XML, xml); }
public XmlPageMaker(WriteSettings settings, QName root) { Add(PageMakerUtil.IsType(SourceOutputType.XmlReader, SourceOutputType.DataSet), XmlReaderPageMaker.PageMaker); Add(PageMakerUtil.IsType(SourceOutputType.ToolkitObject), new XmlObjectPageMaker(settings, root)); Add(PageMakerUtil.IsType(SourceOutputType.String), new SourceOutputPageMaker(ContentTypeConst.XML)); }
public JsonPageMaker() { Add(PageMakerUtil.IsType(SourceOutputType.XmlReader, SourceOutputType.DataSet), JsonDataSetXmlReaderPageMaker.PageMaker); Add(PageMakerUtil.IsType(SourceOutputType.ToolkitObject), new InternalJsonObjectPageMaker(null, null)); Add(PageMakerUtil.IsType(SourceOutputType.String), new SourceOutputPageMaker(ContentTypeConst.JSON)); }
public IContent WritePage(ISource source, IPageData pageData, OutputData outputData) { TkDebug.AssertArgumentNull(outputData, "outputData", this); PageMakerUtil.AssertType(source, outputData, SourceOutputType.ToolkitObject); string json = outputData.Data.WriteJson(fModelName, fSettings); return(new SimpleContent(ContentTypeConst.JSON, json)); }
public IContent WritePage(ISource source, IPageData pageData, OutputData outputData) { TkDebug.AssertArgumentNull(outputData, "outputData", this); PageMakerUtil.AssertType(source, outputData, SourceOutputType.XmlReader, SourceOutputType.DataSet); using (XmlReader reader = PageMakerUtil.GetDataSetReader(outputData)) { string xml = XmlUtil.GetXml(reader); return(new SimpleContent(xml)); } }
protected internal IContent WritePage(IPageData pageData, OutputData outputData) { PageMakerUtil.AssertType(this, outputData, SourceOutputType.XmlReader, SourceOutputType.String, SourceOutputType.DataSet, SourceOutputType.ToolkitObject); string xsltFile = GetRealXsltFile(pageData); // Path.Combine(AppSetting.Current.XmlPath, XsltFile); TkDebug.AssertNotNullOrEmpty(xsltFile, "没有设置XsltFile属性,该值为空", this); TkDebug.Assert(File.Exists(xsltFile), string.Format(ObjectUtil.SysCulture, "系统中并不存在文件名为{0}的文件,请检查路径!", xsltFile), this); XsltArgumentList args = null; if (UseXsltArgs) { args = new XsltArgumentList(); AddXsltParam(args, pageData); } string content = string.Empty; XmlReader reader = null; switch (outputData.OutputType) { case SourceOutputType.XmlReader: reader = outputData.Data.Convert <XmlReader>(); break; case SourceOutputType.String: reader = XmlTransformUtil.GetXmlReader(outputData.Data.Convert <string>()); break; case SourceOutputType.ToolkitObject: XDocument doc = outputData.Data.CreateXDocument(null, ObjectUtil.WriteSettings, QName.ToolkitNoNS); reader = doc.CreateReader(); break; case SourceOutputType.DataSet: reader = new XmlDataSetReader(outputData.Data.Convert <DataSet>()); break; default: TkDebug.ThrowImpossibleCode(this); break; } content = XmlTransformUtil.Transform(reader, xsltFile, args, TransformSetting.All); Encoding encoding = Encoding ?? (pageData.IsPost ? Encoding.UTF8 : null); return(CreateContent(pageData, content, encoding)); }
public IContent WritePage(ISource source, IPageData pageData, OutputData outputData) { TkDebug.AssertArgumentNull(outputData, "outputData", this); PageMakerUtil.AssertType(source, outputData, SourceOutputType.ToolkitObject); ExceptionData data = outputData.Data.Convert <ExceptionData>(); XDocument doc = data.CreateXDocument(null, ObjectUtil.WriteSettings, QName.ToolkitNoNS); string xsltFile = FileUtil.GetRealFileName(@"xslttemplate/bin/Exception.xslt", FilePathPosition.Xml); string content = XmlTransformUtil.Transform(doc.CreateReader(), xsltFile, null, TransformSetting.All); return(new SimpleContent(ContentTypeConst.HTML, content)); }
public IContent WritePage(ISource source, IPageData pageData, OutputData outputData) { TkDebug.AssertArgumentNull(outputData, "outputData", this); PageMakerUtil.AssertType(source, outputData, SourceOutputType.String); StringReader strReader = new StringReader(PageMakerUtil.GetString(outputData)); using (XmlReader reader = XmlReader.Create(strReader, new XmlReaderSettings { CloseInput = true })) { string xml = XmlUtil.GetJson(reader); return(new SimpleContent(ContentTypeConst.JSON, xml)); } }
public IContent WritePage(ISource source, IPageData pageData, OutputData outputData) { TkDebug.AssertArgumentNull(outputData, "outputData", this); PageMakerUtil.AssertType(source, outputData, SourceOutputType.XmlReader, SourceOutputType.DataSet); if (outputData.OutputType == SourceOutputType.DataSet) { DataSet ds = PageMakerUtil.GetObject <DataSet>(outputData); DataTableCollection tables = ds.Tables; foreach (string tableName in fRemoveTables) { if (tables.Contains(tableName)) { tables.Remove(tableName); } } foreach (var mapping in fTableMappings) { if (tables.Contains(mapping.Key)) { DataTable table = tables[mapping.Key]; DataColumnCollection columns = table.Columns; foreach (string field in mapping.Value) { if (columns.Contains(field)) { columns.Remove(field); } } } } } using (XmlReader reader = PageMakerUtil.GetDataSetReader(outputData)) { string xml = XmlUtil.GetJson(reader, Result); return(new SimpleContent(ContentTypeConst.JSON, xml)); } }
IContent IPageMaker.WritePage(ISource source, IPageData pageData, OutputData outputData) { PageMakerUtil.AssertType(this, outputData, SourceOutputType.FileContent); FileContent content = outputData.Data.Convert <FileContent>(); bool useCache = pageData.QueryString["Cache"].Value <bool>(); ContentDisposition disposition; if (Disposition.HasValue) { disposition = Disposition.Value; } else { disposition = pageData.QueryString["Disposition"].Value <ContentDisposition>( ContentDisposition.Attachment); } return(new WebFileContent(content, useCache) { Disposition = disposition }); }
public JsonpDataSetPageMaker() { Add(PageMakerUtil.IsType(SourceOutputType.XmlReader, SourceOutputType.DataSet), JsonDataSetXmlReaderPageMaker.PageMaker); Add(PageMakerUtil.IsType(SourceOutputType.String), JsonDataSetTextPageMaker.PageMaker); }
private JsonResultPageMaker() { fChild = new JsonDataSetResultPageMaker(); Add(PageMakerUtil.IsType(SourceOutputType.XmlReader, SourceOutputType.DataSet), fChild); }