public IContent WritePage(ISource source, IPageData pageData, OutputData outputData)
        {
            IPageTemplate template = CreatePageTemplate(PageTemplateName);

            if (Scripts == null)
            {
                Scripts = new UserScript(null);
            }
            object pageDataObj = PageData;

            if (pageDataObj == null)
            {
                pageDataObj = template.GetDefaultPageData(source, pageData, outputData);
            }
            if (pageDataObj != null)
            {
                OnSetPageData(new PageDataEventArgs(source, pageData, outputData, pageDataObj));
            }

            object model = WebRazorUtil.GetModel(outputData);

            var    viewBag = WebRazorUtil.GetNewViewBag(pageData, fMetaData, Scripts, pageDataObj);
            string content = Execute(template, PageTemplateName, ModelCreator, RazorFile,
                                     WebRazorUtil.GetModel(outputData), viewBag, source, pageData, outputData);

            return(new SimpleContent(ContentTypeConst.HTML, content));
        }
        private string GetFileName()
        {
            if (string.IsNullOrEmpty(FileName))
            {
                return(DEFAULT_FILE);
            }

            return(UseTemplate ? WebRazorUtil.GetTemplateFile(FileName) : FileName);
        }
Esempio n. 3
0
 public string GetTemplateFile(ISource source, IInputData input, OutputData outputData)
 {
     if (input.QueryString["GetData"] == "Page" || input.IsPost)
     {
         return(WebRazorUtil.GetTemplateFile("StatList/listmain.cshtml"));
     }
     else
     {
         return(WebRazorUtil.GetTemplateFile("StatList/template.cshtml"));
     }
 }
Esempio n. 4
0
        public IContent WritePage(ISource source, IPageData pageData, OutputData outputData)
        {
            object       model   = WebRazorUtil.GetModel(outputData);
            var          viewBag = WebRazorUtil.GetViewBag(pageData, fMetaData, null, RazorData);
            IRazorEngine engine  = RazorEnginePlugInFactory.CreateRazorEngine(EngineName);

            string fileName = UseTemplate ? WebRazorUtil.GetTemplateFile(fFileName) : fFileName;

            string content = Task.Run(async()
                                      => await RazorExtension.CompileRenderWithLayoutAsync(engine, fileName,
                                                                                           Layout, model, null, viewBag)).GetAwaiter().GetResult();

            return(new SimpleContent(ContentTypeConst.HTML, content));
        }
Esempio n. 5
0
        public IPageMaker CreateObject(params object[] args)
        {
            IInputData input = ObjectUtil.QueryObject <IInputData>(args);

            TkDebug.AssertNotNull(input, "参数args中缺少IInputData类型", this);

            if (input.IsPost)
            {
                return(new ExceptionPostPageMaker());
            }
            else
            {
                string fileName = UseTemplate ? WebRazorUtil.GetTemplateFile(PART_FILE_NAME) : FILE_NAME;
                return(new FreeRazorPageMaker(fileName));
            }
        }
Esempio n. 6
0
        public RazorTableOutput(string editRazorFile, string detailRazorFile,
                                string detailHeadRazorFile = null, string detailListRazorFile = null)
        {
            TkDebug.AssertArgumentNullOrEmpty(editRazorFile, nameof(editRazorFile), null);
            TkDebug.AssertArgumentNullOrEmpty(detailRazorFile, nameof(detailRazorFile), null);

            EditRazorFile   = WebRazorUtil.GetTemplateFile(editRazorFile);
            DetailRazorFile = WebRazorUtil.GetTemplateFile(detailRazorFile);
            if (!string.IsNullOrEmpty(detailHeadRazorFile))
            {
                DetailHeadRazorFile = WebRazorUtil.GetTemplateFile(detailHeadRazorFile);
            }
            if (!string.IsNullOrEmpty(detailListRazorFile))
            {
                DetailListRazorFile = WebRazorUtil.GetTemplateFile(detailListRazorFile);
            }
            else
            {
                DetailListRazorFile = WebRazorUtil.GetTemplateFile(DEFAULT_DLIST_FILENAME);
            }
        }
Esempio n. 7
0
 public string GetTemplateFile(ISource source, IInputData input, OutputData outputData)
 {
     return(WebRazorUtil.GetTemplateFile("Detail/template.cshtml"));
 }
Esempio n. 8
0
        private IPageMaker CreatePageMaker()
        {
            string fileName = UseTemplate ? WebRazorUtil.GetTemplateFile(PART_FILE_NAME) : FILE_NAME;

            return(new FreeRazorPageMaker(fileName));
        }
Esempio n. 9
0
 public string GetTemplateFile(ISource source, IInputData input, OutputData outputData)
 {
     return(WebRazorUtil.GetTemplateFile(fConfig.TemplateFile));
 }