protected void gvItemList_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { DNNGo_PowerForms_ContentItem ContentItem = e.Row.DataItem as DNNGo_PowerForms_ContentItem; if (ContentItem.Extra && !Settings_ExtraTracking) { e.Row.Visible = false; //如果是关闭了追踪,就停止显示 } else { Literal LiContentValue = e.Row.FindControl("LiContentValue") as Literal; TemplateFormat xf = new TemplateFormat(this); xf.FieldList = FieldList; LiContentValue.Text = xf.ViewContentValue(ContentItem); } } }
/// <summary> /// 格式化内容模版 /// </summary> /// <param name="SubmitContent">提交的内容实体</param> /// <param name="Template">模版</param> /// <returns></returns> public String FormatContent(DNNGo_PowerForms_Content SubmitContent, String Template, List <DNNGo_PowerForms_ContentItem> ContentList) { TemplateFormat xf = new TemplateFormat(this); xf.FieldList = FieldList; if (!String.IsNullOrEmpty(Template)) { //为了节约效率,需要先判断模版内有无需要替换的标签 if (Template.IndexOf("[UserName]", StringComparison.CurrentCultureIgnoreCase) >= 0) { Template = Common.ReplaceNoCase(Template, "[UserName]", SubmitContent.UserName); } if (Template.IndexOf("[CultureInfo]", StringComparison.CurrentCultureIgnoreCase) >= 0) { Template = Common.ReplaceNoCase(Template, "[CultureInfo]", SubmitContent.CultureInfo); } if (Template.IndexOf("[SubmitTime]", StringComparison.CurrentCultureIgnoreCase) >= 0) { Template = Common.ReplaceNoCase(Template, "[SubmitTime]", SubmitContent.LastTime.ToString()); } if (Template.IndexOf("[SubmitIP]", StringComparison.CurrentCultureIgnoreCase) >= 0) { Template = Common.ReplaceNoCase(Template, "[SubmitIP]", SubmitContent.LastIP); } if (Template.IndexOf("[Email]", StringComparison.CurrentCultureIgnoreCase) >= 0) { Template = Common.ReplaceNoCase(Template, "[Email]", SubmitContent.Email); } //if (Template.IndexOf("[]", StringComparison.CurrentCultureIgnoreCase) >= 0) Template = Common.ReplaceNoCase(Template, "[]", ""); //2014.4.30 新增更多用户的Token,但需要是用户登陆时提交的才行. if (SubmitContent.LastUser > 0) { DotNetNuke.Entities.Users.UserInfo uInfo = DotNetNuke.Entities.Users.UserController.GetUserById(PortalId, SubmitContent.LastUser); if (uInfo != null && uInfo.UserID > 0) { if (Template.IndexOf("[DisplayName]", StringComparison.CurrentCultureIgnoreCase) >= 0) { Template = Common.ReplaceNoCase(Template, "[DisplayName]", uInfo.DisplayName); } if (Template.IndexOf("[LastName]", StringComparison.CurrentCultureIgnoreCase) >= 0) { Template = Common.ReplaceNoCase(Template, "[LastName]", uInfo.LastName); } if (Template.IndexOf("[FirstName]", StringComparison.CurrentCultureIgnoreCase) >= 0) { Template = Common.ReplaceNoCase(Template, "[FirstName]", uInfo.FirstName); } if (Template.IndexOf("[UserRole]", StringComparison.CurrentCultureIgnoreCase) >= 0) { Template = Common.ReplaceNoCase(Template, "[UserRole]", Common.GetStringByList(uInfo.Roles)); } } else { if (Template.IndexOf("[DisplayName]", StringComparison.CurrentCultureIgnoreCase) >= 0) { Template = Common.ReplaceNoCase(Template, "[DisplayName]", "Anonymous users"); } if (Template.IndexOf("[LastName]", StringComparison.CurrentCultureIgnoreCase) >= 0) { Template = Common.ReplaceNoCase(Template, "[LastName]", "--"); } if (Template.IndexOf("[FirstName]", StringComparison.CurrentCultureIgnoreCase) >= 0) { Template = Common.ReplaceNoCase(Template, "[FirstName]", "--"); } if (Template.IndexOf("[UserRole]", StringComparison.CurrentCultureIgnoreCase) >= 0) { Template = Common.ReplaceNoCase(Template, "[UserRole]", "--"); } } } else { if (Template.IndexOf("[DisplayName]", StringComparison.CurrentCultureIgnoreCase) >= 0) { Template = Common.ReplaceNoCase(Template, "[DisplayName]", "Anonymous users"); } if (Template.IndexOf("[LastName]", StringComparison.CurrentCultureIgnoreCase) >= 0) { Template = Common.ReplaceNoCase(Template, "[LastName]", "--"); } if (Template.IndexOf("[FirstName]", StringComparison.CurrentCultureIgnoreCase) >= 0) { Template = Common.ReplaceNoCase(Template, "[FirstName]", "--"); } if (Template.IndexOf("[UserRole]", StringComparison.CurrentCultureIgnoreCase) >= 0) { Template = Common.ReplaceNoCase(Template, "[UserRole]", "--"); } } //循环打印所有的字段值 foreach (DNNGo_PowerForms_ContentItem item in ContentList) { String item_key = String.Format("[{0}]", item.FieldName); if (Template.IndexOf(item_key, StringComparison.CurrentCultureIgnoreCase) >= 0) { Template = Common.ReplaceNoCase(Template, item_key, xf.ViewContentValue(item)); } } if (Template.IndexOf("[Content]", StringComparison.CurrentCultureIgnoreCase) >= 0) { EffectDB EffectDB = Setting_EffectDB; Hashtable Puts = new Hashtable(); String FormUrl = Globals.NavigateURL(TabId); if (FormUrl.ToLower().IndexOf("http://") < 0 && FormUrl.ToLower().IndexOf("https://") < 0) { FormUrl = string.Format("{2}://{0}{1}", WebHelper.GetHomeUrl(), FormUrl, PortalSettings.SSLEnabled ? "https" : "http"); } Puts.Add("ContentList", ContentList); Puts.Add("FieldList", FieldList); Puts.Add("EffectName", Settings_EffectName); Puts.Add("ThemeName", Settings_EffectThemeName); Puts.Add("Group", EffectDB.Group);//有分组的时候才会显示分组 Puts.Add("FormUrl", FormUrl); Puts.Add("FormTitle", ModuleConfiguration.ModuleTitle); Puts.Add("ExtraTracking", Settings_ExtraTracking);//是否启用跟踪 Template = Common.ReplaceNoCase(Template, "[Content]", ViewTemplate(EffectDB, "EmailTable.html", Puts, xf)); } } return(Template); }