private void AddCharge(DataTable dataTable) { int generalId = DataConverter.CLng(dataTable.Select("FieldName = 'generalId'")[0]["FieldValue"].ToString()); NodeInfo cacheNodeById = EasyOne.Contents.Nodes.GetCacheNodeById(DataConverter.CLng(dataTable.Select("FieldName = 'nodeId'")[0]["FieldValue"].ToString())); ContentPermissionInfo contentPermissionInfo = new ContentPermissionInfo(); contentPermissionInfo.GeneralId = generalId; contentPermissionInfo.PermissionType = 0; PermissionContent.Delete(generalId); if (PermissionContent.Add(contentPermissionInfo)) { ContentCharge.Delete(generalId); if (cacheNodeById.Settings.DefaultItemPoint > 0) { ContentChargeInfo contentChargeInfo = new ContentChargeInfo(); contentChargeInfo.GeneralId = generalId; contentChargeInfo.InfoPoint = cacheNodeById.Settings.DefaultItemPoint; contentChargeInfo.ChargeType = cacheNodeById.Settings.DefaultItemChargeType; contentChargeInfo.PitchTime = cacheNodeById.Settings.DefaultItemPitchTime; contentChargeInfo.ReadTimes = cacheNodeById.Settings.DefaultItemReadTimes; contentChargeInfo.DividePercent = cacheNodeById.Settings.DefaultItemDividePercent; ContentCharge.Add(contentChargeInfo); } } }
public bool Update(ContentPermissionInfo contentPermissionInfo) { Parameters parms = new Parameters(); GetParameter(contentPermissionInfo, parms); return(DBHelper.ExecuteSql("UPDATE PE_ContentPermission SET GeneralId = @GeneralId, PermissionType = @PermissionType, ArrGroupId = @ArrGroupId WHERE GeneralId = @GeneralId", parms)); }
private void InitCharge(int generalId, bool enableCharge) { ContentPermissionInfo contentPermissionInfoById = PermissionContent.GetContentPermissionInfoById(generalId); if (!contentPermissionInfoById.IsNull) { this.RadlInfoPurview.SelectedValue = contentPermissionInfoById.PermissionType.ToString(); if (!string.IsNullOrEmpty(contentPermissionInfoById.ArrGroupId)) { string[] strArray = contentPermissionInfoById.ArrGroupId.Split(new char[] { ',' }); for (int i = 0; i < strArray.Length; i++) { this.EChklUserGroupList.Items.FindByValue(strArray[i]).Selected = true; } } } if (enableCharge) { ContentChargeInfo contentChargeInfoById = EasyOne.Contents.ContentCharge.GetContentChargeInfoById(generalId); if (!contentChargeInfoById.IsNull) { this.TxtInfoPoint.Text = contentChargeInfoById.InfoPoint.ToString(); this.ShowChargeType.ChargeType = contentChargeInfoById.ChargeType; this.ShowChargeType.PitchTime = contentChargeInfoById.PitchTime; this.ShowChargeType.ReadTimes = contentChargeInfoById.ReadTimes; this.TxtDividePercent.Text = contentChargeInfoById.DividePercent.ToString(); } } }
private int AddPermissionAndCharge(DataTable dataTable, bool enableCharge) { int generalId = GetGeneralId(dataTable); ContentPermissionInfo contentPermissionInfo = new ContentPermissionInfo(); contentPermissionInfo.GeneralId = generalId; contentPermissionInfo.PermissionType = DataConverter.CLng(this.RadlInfoPurview.SelectedValue); contentPermissionInfo.ArrGroupId = this.EChklUserGroupList.SelectList(); int num2 = DataConverter.CLng(this.TxtInfoPoint.Text); PermissionContent.Delete(generalId); if (PermissionContent.Add(contentPermissionInfo)) { EasyOne.Contents.ContentCharge.Delete(generalId); if (enableCharge && (num2 > 0)) { ContentChargeInfo contentChargeInfo = new ContentChargeInfo(); contentChargeInfo.GeneralId = generalId; contentChargeInfo.InfoPoint = num2; contentChargeInfo.ChargeType = this.ShowChargeType.ChargeType; contentChargeInfo.PitchTime = this.ShowChargeType.PitchTime; contentChargeInfo.ReadTimes = this.ShowChargeType.ReadTimes; contentChargeInfo.DividePercent = DataConverter.CLng(this.TxtDividePercent.Text); EasyOne.Contents.ContentCharge.Add(contentChargeInfo); } } return(num2); }
private static ContentPermissionInfo ContentPermissionFromDataReader(NullableDataReader dr) { ContentPermissionInfo info = new ContentPermissionInfo(); info.GeneralId = dr.GetInt32("GeneralId"); info.PermissionType = dr.GetInt32("PermissionType"); info.ArrGroupId = dr.GetString("ArrGroupId"); return(info); }
public bool Add(ContentPermissionInfo contentPermissionInfo) { Parameters parms = new Parameters(); GetParameter(contentPermissionInfo, parms); string strSql = "INSERT INTO PE_ContentPermission(GeneralId, PermissionType, ArrGroupId) VALUES (@GeneralId, @PermissionType, @ArrGroupId)"; return(DBHelper.ExecuteSql(strSql, parms)); }
public static bool BatchUpdate(ContentPermissionInfo contentPermissionInfo, string itemId, Dictionary <string, bool> checkItem, int batchType) { if (!DataValidator.IsValidId(itemId)) { return(false); } if (!checkItem.ContainsValue(true)) { return(false); } StringBuilder sb = new StringBuilder(); int generalId = 0; if (batchType == 1) { foreach (CommonModelInfo info in ContentManage.GetCommonModelInfoList(itemId)) { if (!dal.Exists(info.GeneralId)) { contentPermissionInfo.GeneralId = info.GeneralId; dal.Add(contentPermissionInfo); } else { StringHelper.AppendString(sb, info.GeneralId.ToString()); } } } else { foreach (string str in itemId.Split(new char[] { ',' })) { generalId = DataConverter.CLng(str); if (generalId != 0) { if (!dal.Exists(generalId)) { contentPermissionInfo.GeneralId = generalId; dal.Add(contentPermissionInfo); } else { StringHelper.AppendString(sb, str); } } } } if (sb.Length > 0) { return(dal.BatchUpdate(contentPermissionInfo, sb.ToString(), checkItem)); } return(true); }
private void CheckPermission() { int permissionType; ContentPermissionInfo contentPermissionInfoById = PermissionContent.GetContentPermissionInfoById(this.m_GeneralId); if (contentPermissionInfoById == null) { permissionType = 0; } else { permissionType = contentPermissionInfoById.PermissionType; } switch (permissionType) { case 0: switch (this.m_NodeInfo.PurviewType) { case 1: this.CheckIsAuthenticated(); return; case 2: this.CheckIsAuthenticated(); if (UserPermissions.AccessCheck(OperateCode.NodeContentPreview, this.m_NodeInfo.NodeId)) { break; } TemplatePage.WriteErrMsg("您没有查看该页的权限,请与网站管理员联系", "Default.aspx"); return; } return; case 1: this.CheckIsAuthenticated(); return; case 2: this.CheckIsAuthenticated(); if (!StringHelper.FoundCharInArr(contentPermissionInfoById.ArrGroupId, PEContext.Current.User.GroupId.ToString())) { TemplatePage.WriteErrMsg("您没有查看该页的权限,请与网站管理员联系", "Default.aspx"); } break; default: return; } }
private void UpdatePurview(int batchType, StringBuilder itemId) { if (this.GetCheckItem()["InfoPurview"]) { ContentPermissionInfo contentPermissionInfo = new ContentPermissionInfo(); contentPermissionInfo.PermissionType = DataConverter.CLng(this.RadlInfoPurview.SelectedValue); StringBuilder sb = new StringBuilder(""); for (int i = 0; i < this.EChklUserGroupList.Items.Count; i++) { if (this.EChklUserGroupList.Items[i].Selected) { StringHelper.AppendString(sb, this.EChklUserGroupList.Items[i].Value); } } contentPermissionInfo.ArrGroupId = sb.ToString(); if (!PermissionContent.BatchUpdate(contentPermissionInfo, itemId.ToString(), this.GetCheckItem(), batchType)) { AdminPage.WriteErrMsg("批量设置收费权限失败!"); } } }
/// <summary> /// 支付模板处理 /// </summary> /// <param name="templateInfo"></param> private void Charge(TemplateInfo templateInfo) { if (templateInfo.IsDynamicPage) { ChargeManage manage = new ChargeManage(); if (manage.CheckPermission()) { manage.ExecuteContentCharge(); } if (!string.IsNullOrEmpty(manage.ErrMsg)) { string pattern = @"{PE\.Charge}(([\s\S](?!{PE\.Charge))*?){\/PE.Charge}"; foreach (Match match in Regex.Matches(templateInfo.TemplateContent, pattern, RegexOptions.IgnoreCase)) { templateInfo.TemplateContent = templateInfo.TemplateContent.Replace(match.Value, manage.ErrMsg); } } } else if (templateInfo.PageType == 0) { ContentPermissionInfo contentPermissionInfoById = PermissionContent.GetContentPermissionInfoById(DataConverter.CLng(templateInfo.QueryList["id"])); if (!contentPermissionInfoById.IsNull) { if (contentPermissionInfoById.PermissionType == 0) { if (!ContentCharge.GetContentChargeInfoById(DataConverter.CLng(templateInfo.QueryList["id"])).IsNull) { this.ChargeTips(templateInfo); } } else { this.ChargeTips(templateInfo); } } } templateInfo.TemplateContent = templateInfo.TemplateContent.Replace("{PE.Charge}", string.Empty).Replace("{/PE.Charge}", string.Empty); }
public bool BatchUpdate(ContentPermissionInfo contentPermissionInfo, string itemId, Dictionary <string, bool> checkItem) { StringBuilder builder = new StringBuilder(); Parameters cmdParams = new Parameters(); builder.Append("UPDATE PE_ContentPermission SET "); if (checkItem["InfoPurview"]) { builder.Append("PermissionType = @PermissionType,"); cmdParams.AddInParameter("@PermissionType", DbType.Int32, contentPermissionInfo.PermissionType); builder.Append("ArrGroupId = @ArrGroupId,"); cmdParams.AddInParameter("@ArrGroupId", DbType.String, contentPermissionInfo.ArrGroupId); } if (builder.Length <= 0x20) { return(true); } builder.Remove(builder.Length - 1, 1); builder.Append(" WHERE "); builder.Append(" GeneralID IN ( "); builder.Append(DBHelper.ToValidId(itemId)); builder.Append(" )"); return(DBHelper.ExecuteSql(builder.ToString(), cmdParams)); }
public static bool Add(ContentPermissionInfo contentPermissionInfo) { return(dal.Add(contentPermissionInfo)); }
public bool CheckPermission() { int permissionType; bool flag = true; ContentPermissionInfo contentPermissionInfoById = PermissionContent.GetContentPermissionInfoById(DataConverter.CLng(HttpContext.Current.Request["id"])); if (contentPermissionInfoById == null) { permissionType = 0; } else { permissionType = contentPermissionInfoById.PermissionType; } switch (permissionType) { case 0: switch (this.m_NodeInfo.PurviewType) { case 1: case 2: if (!this.CheckIsAuthenticated()) { flag = false; } if (string.IsNullOrEmpty(this.m_ErrMsg)) { if (this.m_NodeInfo.ParentId > 0) { if (!UserPermissions.AccessCheck(OperateCode.NodeContentPreview, this.m_NodeInfo.ParentPath + "," + this.m_NodeInfo.NodeId)) { flag = false; } } else if (!UserPermissions.AccessCheck(OperateCode.NodeContentPreview, this.m_NodeInfo.NodeId)) { flag = false; } if (!flag) { this.m_ErrMsg = this.m_ErrMsg + this.m_errMsg_PurviewCheckedErr; } } return(flag); } return(flag); case 1: if (!this.CheckIsAuthenticated()) { flag = false; } return(flag); case 2: if (!this.CheckIsAuthenticated()) { flag = false; } if (!StringHelper.FoundCharInArr(contentPermissionInfoById.ArrGroupId, PEContext.Current.User.GroupId.ToString())) { this.m_ErrMsg = this.m_ErrMsg + this.m_errMsg_PurviewCheckedErr2; flag = false; } return(flag); } return(flag); }
/// <summary> /// 数据字段标签解析 /// </summary> /// <param name="templateStr"></param> /// <param name="dataSourceid"></param> /// <param name="inode"></param> /// <param name="proctype"></param> /// <param name="templateInfo"></param> /// <returns></returns> private string FieldProc(string templateStr, string dataSourceid, XmlElement inode, int proctype, TemplateInfo templateInfo) { XmlDocument document = new XmlDocument(); string pattern = @"{PE\.Field([\s\S](?!{PE))*?\/}"; foreach (Match match in Regex.Matches(templateStr, pattern, RegexOptions.IgnoreCase)) { XmlElement firstChild; try { document.LoadXml(match.Value.Replace("{", "<").Replace("}", ">")); firstChild = (XmlElement)document.FirstChild; } catch (XmlException exception) { templateStr = templateStr.Replace(match.Value, "[err:数据字段标签" + match.Value.Replace("{", string.Empty).Replace("}", string.Empty) + "错,原因:" + exception.Message + "]"); continue; } if ((proctype == 1) || (string.Compare(dataSourceid, XmlManage.GetAttributesValue(firstChild, "id"), StringComparison.OrdinalIgnoreCase) == 0)) { if (firstChild.HasAttribute("fieldname")) { string xpath = string.Empty; if (proctype == 1) { xpath = firstChild.GetAttribute("fieldname"); } else { xpath = "//" + firstChild.GetAttribute("fieldname"); } string errMsg = (inode.SelectSingleNode(xpath) == null) ? string.Empty : inode.SelectSingleNode(xpath).InnerText; if (DataConverter.CBoolean(XmlManage.GetAttributesValue(firstChild, "htmldecode"))) { errMsg = DataSecurity.HtmlDecode(errMsg); } if (DataConverter.CLng(XmlManage.GetAttributesValue(firstChild, "length")) > 0) { errMsg = StringHelper.SubString(errMsg, DataConverter.CLng(XmlManage.GetAttributesValue(firstChild, "length")), ""); } if (DataConverter.CBoolean(XmlManage.GetAttributesValue(firstChild, "charge"))) { if (templateInfo.IsDynamicPage) { ChargeManage manage = new ChargeManage(); if (manage.CheckPermission()) { manage.ExecuteContentCharge(); } if (!string.IsNullOrEmpty(manage.ErrMsg)) { if (DataConverter.CBoolean(XmlManage.GetAttributesValue(firstChild, "showerr"))) { errMsg = manage.ErrMsg; } else { errMsg = ""; } } } else if (templateInfo.PageType == 0) { if (DataConverter.CBoolean(XmlManage.GetAttributesValue(firstChild, "showerr"))) { ContentPermissionInfo contentPermissionInfoById = PermissionContent.GetContentPermissionInfoById(DataConverter.CLng(templateInfo.QueryList["id"])); if (!contentPermissionInfoById.IsNull) { if (contentPermissionInfoById.PermissionType == 0) { if (!ContentCharge.GetContentChargeInfoById(DataConverter.CLng(templateInfo.QueryList["id"])).IsNull) { errMsg = "$$$EasyOne.ChargeTips$$$"; } } else { errMsg = "$$$EasyOne.ChargeTips$$$"; } } } else { errMsg = ""; } } } if (DataConverter.CBoolean(XmlManage.GetAttributesValue(firstChild, "noprocinlabel"))) { this.tempstr.Add(this.loopmark.ToString(), errMsg); templateStr = templateStr.Replace(match.Value, "###labelmark" + this.loopmark.ToString() + "###"); this.loopmark++; } else { templateStr = templateStr.Replace(match.Value, errMsg); } continue; } templateStr = templateStr.Replace(match.Value, string.Empty); } } return(templateStr); }
private static void GetParameter(ContentPermissionInfo contentPermissionInfo, Parameters parms) { parms.AddInParameter("@GeneralId", DbType.Int32, contentPermissionInfo.GeneralId); parms.AddInParameter("@PermissionType", DbType.Int32, contentPermissionInfo.PermissionType); parms.AddInParameter("@ArrGroupId", DbType.String, contentPermissionInfo.ArrGroupId); }
public static bool Update(ContentPermissionInfo contentPermissionInfo) { return(dal.Update(contentPermissionInfo)); }
protected void Page_Load(object sender, EventArgs e) { ContentChargeInfo info4; int generalId = BaseUserControl.RequestInt32("GeneralID"); this.contentDataTable = ContentManage.GetContentDataById(generalId); if ((this.contentDataTable == null) || (this.contentDataTable.Rows.Count == 0)) { BaseUserControl.WriteErrMsg("指定的信息不存在!"); } if (ModelManager.GetModelInfoById(DataConverter.CLng(this.contentDataTable.Rows[0]["ModelID"].ToString())).IsNull) { BaseUserControl.WriteErrMsg("信息隶属模型不存在!"); } IList <UserGroupsInfo> userGroupList = UserGroups.GetUserGroupList(0, 0); ContentPermissionInfo contentPermissionInfoById = PermissionContent.GetContentPermissionInfoById(generalId); if (!contentPermissionInfoById.IsNull) { switch (contentPermissionInfoById.PermissionType) { case 0: this.LitInfoPurview.Text = "继承栏目权限"; goto Label_0186; case 1: this.LitInfoPurview.Text = "所有会员"; goto Label_0186; } this.LitInfoPurview.Text = "指定会员组:"; if (!string.IsNullOrEmpty(contentPermissionInfoById.ArrGroupId)) { string[] strArray = contentPermissionInfoById.ArrGroupId.Split(new char[] { ',' }); for (int i = 0; i < strArray.Length; i++) { foreach (UserGroupsInfo info3 in userGroupList) { if (info3.GroupId == DataConverter.CLng(strArray[i])) { this.LitInfoPurview.Text = this.LitInfoPurview.Text + " " + info3.GroupName; break; } } } } } Label_0186: info4 = EasyOne.Contents.ContentCharge.GetContentChargeInfoById(generalId); if (!info4.IsNull) { this.LblInfoPoint.Text = DataConverter.CLng(info4.InfoPoint).ToString(); switch (info4.ChargeType) { case 1: this.LblChargeType.Text = "距离上次收费时间" + DataConverter.CLng(info4.PitchTime).ToString() + "小时后重新收费"; break; case 2: this.LblChargeType.Text = "会员重复阅读此文章" + DataConverter.CLng(info4.ReadTimes).ToString() + "次后重新收费"; break; case 3: this.LblChargeType.Text = "上述两者都满足时重新收费"; break; case 4: this.LblChargeType.Text = "上述两者任一个满足时就重新收费"; break; case 5: this.LblChargeType.Text = "每阅读一次就重复收费一次(建议不要使用)"; break; default: this.LblChargeType.Text = "不重复收费"; break; } this.LblDividePercent.Text = DataConverter.CLng(info4.DividePercent).ToString() + "%"; } }