/// <summary> /// 数据绑定 /// </summary> private void DataListBind(TemplateDB XmlDB) { TemplateFormat xf = new TemplateFormat(this); xf.TemplateName = XmlDB.Name; Hashtable Puts = new Hashtable(); String ContentHTML = ViewTemplate(XmlDB, "View_Template.html", Puts, xf); //动态模块的配置 if (!String.IsNullOrEmpty(ContentHTML) && ContentHTML.IndexOf("[DynamicModules]", StringComparison.CurrentCultureIgnoreCase) >= 0) { //获取动态模块和动态项 Puts = GetDynamics(Puts); ContentHTML = Common.ReplaceNoCase(ContentHTML, "[DynamicModules]", ViewTemplate(GetTemplateDB("DynamicModules"), "View_Template.html", Puts, xf)); } liContentHTML.Text = ContentHTML; }
public VelocityHelper(BaseModule _bpm, TemplateDB _Theme) { XmlTheme = _Theme; pmb = _bpm; Init(_bpm, _Theme); }
/// <summary> /// 数据项绑定 /// </summary> private void DataItemBind(TemplateDB XmlDB) { String ContentHTML = String.Empty; TemplateFormat xf = new TemplateFormat(this); xf.TemplateName = XmlDB.Name; Hashtable Puts = new Hashtable(); if (DataItem != null && DataItem.ID > 0) { if (DataItem.Status == (Int32)EnumStatus.Published && IsPublishTime(DataItem) || (Preview && DataItem.Status == (Int32)EnumStatus.Draft)) { //判断角色权限及区域权限 if (IsPreRoleView(DataItem.Per_AllUsers, DataItem.Per_Roles) && IsPreJurisdictionView(DataItem.Per_AllJurisdictions, DataItem.Per_Jurisdictions)) { //数据项 Puts.Add("DataItem", DataItem); //当前文档关联的文件集 Puts.Add("DownloadFiles", GetDownloadFiles(DataItem)); //详情模板调用 ContentHTML = ViewTemplate(XmlDB, "View_Template_Detail.html", Puts, xf); //动态模块的配置 if (!String.IsNullOrEmpty(ContentHTML) && ContentHTML.IndexOf("[DynamicModules]", StringComparison.CurrentCultureIgnoreCase) >= 0) { //获取动态模块和动态项 Puts = GetDynamics(Puts); ContentHTML = Common.ReplaceNoCase(ContentHTML, "[DynamicModules]", ViewTemplate(GetTemplateDB("DynamicModules"), "View_Template.html", Puts, xf)); } } else { //无权限访问 ContentHTML = "你无当前数据的访问权限"; Response.Redirect(new TemplateFormat(this).GoUiUrl(UIToken)); } } else { //无法访问 ContentHTML = "无法访问内容或未到开始时间"; Response.Redirect(new TemplateFormat(this).GoUiUrl(UIToken)); } } else { ContentHTML = "内容没有找到"; Response.Redirect(new TemplateFormat(this).GoUiUrl(UIToken)); } liContentHTML.Text = ContentHTML; }
/// <summary> /// 数据绑定 /// </summary> private void DataListBind(TemplateDB XmlDB) { TemplateFormat xf = new TemplateFormat(this); xf.TemplateName = XmlDB.Name; Hashtable Puts = new Hashtable(); liContentHTML.Text = ViewTemplate(XmlDB, "View_Template.html", Puts, xf); }
/// <summary> /// 初始话CNVelocity模块 /// </summary> public void Init(BaseModule _bpm, TemplateDB _Theme) { //创建VelocityEngine实例对象 velocity = new VelocityEngine(); //使用设置初始化VelocityEngine ExtendedProperties props = new ExtendedProperties(); props.AddProperty(RuntimeConstants.RESOURCE_LOADER, "file"); props.AddProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, HttpContext.Current.Server.MapPath(String.Format("{0}Templates/{1}/", _bpm.ModulePath, XmlTheme.Name))); props.AddProperty(RuntimeConstants.INPUT_ENCODING, "utf-8"); props.AddProperty(RuntimeConstants.OUTPUT_ENCODING, "utf-8"); //模板的缓存设置 props.AddProperty(RuntimeConstants.FILE_RESOURCE_LOADER_CACHE, false); //是否缓存 props.AddProperty("file.resource.loader.modificationCheckInterval", (Int64)600); //缓存时间(秒) velocity.Init(props); //为模板变量赋值 context = new VelocityContext(); }