📄 chargemanage.cs
字号:
namespace PowerEasy.Contents
{
using PowerEasy.AccessManage;
using PowerEasy.Common;
using PowerEasy.CommonModel;
using PowerEasy.Components;
using PowerEasy.Enumerations;
using PowerEasy.Model.CommonModel;
using PowerEasy.Model.Contents;
using PowerEasy.Model.UserManage;
using PowerEasy.UserManage;
using System;
using System.Globalization;
using System.Web;
public sealed class ChargeManage
{
private CommonModelInfo m_CommonModelInfo;
private ContentChargeInfo m_contentChargeInfo;
private string m_ErrMsg = "";
private string m_errMsg_NeedPoint = GetGlobalString("NeedPoint");
private string m_errMsg_NoCheck = GetGlobalString("NoCheck");
private string m_errMsg_NoLogin = GetGlobalString("NoLogin");
private string m_errMsg_NoMail = GetGlobalString("NoMail");
private string m_errMsg_OutTime = GetGlobalString("OutTime");
private string m_errMsg_Overflow_Today = GetGlobalString("Overflow_Today");
private string m_errMsg_Overflow_Total = GetGlobalString("Overflow_Total");
private string m_errMsg_PurviewCheckedErr = GetGlobalString("PurviewCheckedErr");
private string m_errMsg_PurviewCheckedErr2 = GetGlobalString("PurviewCheckedErr2");
private string m_errMsg_UsePoint = GetGlobalString("UsePoint");
private bool m_IsFree;
private ModelInfo m_ModelInfo;
private NodeInfo m_NodeInfo;
private string m_Pay;
private UserInfo m_UserInfo;
private string m_UserTrueIP;
public ChargeManage()
{
int generalId = DataConverter.CLng(HttpContext.Current.Request["id"]);
this.m_UserInfo = PEContext.Current.User.UserInfo;
this.m_CommonModelInfo = ContentManage.GetCommonModelInfoById(generalId);
this.m_ModelInfo = ModelManager.GetModelInfoById(this.m_CommonModelInfo.ModelId);
this.m_NodeInfo = Nodes.GetCacheNodeById(this.m_CommonModelInfo.NodeId);
this.m_contentChargeInfo = ContentCharge.GetContentChargeInfoById(this.m_CommonModelInfo.GeneralId);
this.m_UserTrueIP = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (string.IsNullOrEmpty(this.m_UserTrueIP))
{
this.m_UserTrueIP = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
}
this.m_UserTrueIP = DataSecurity.FilterBadChar(this.m_UserTrueIP);
this.m_Pay = HttpContext.Current.Request["Pay"];
this.m_errMsg_NoLogin = this.m_errMsg_NoLogin.Replace("{$InstallDir}", SiteConfig.SiteInfo.VirtualPath);
this.m_errMsg_NeedPoint = this.m_errMsg_NeedPoint.Replace("{$InfoPoint}", this.m_contentChargeInfo.InfoPoint.ToString());
this.m_errMsg_NeedPoint = this.m_errMsg_NeedPoint.Replace("{$NeedPoint}", this.m_contentChargeInfo.InfoPoint.ToString());
this.m_errMsg_NeedPoint = this.m_errMsg_NeedPoint.Replace("{$NowPoint}", this.m_UserInfo.UserPoint.ToString());
this.m_errMsg_NeedPoint = this.m_errMsg_NeedPoint.Replace("{$PointName}", SiteConfig.UserConfig.PointName);
this.m_errMsg_NeedPoint = this.m_errMsg_NeedPoint.Replace("{$PointUnit}", SiteConfig.UserConfig.PointUnit);
this.m_errMsg_UsePoint = this.m_errMsg_UsePoint.Replace("{$InfoPoint}", this.m_contentChargeInfo.InfoPoint.ToString());
this.m_errMsg_UsePoint = this.m_errMsg_UsePoint.Replace("{$NowPoint}", this.m_UserInfo.UserPoint.ToString());
this.m_errMsg_UsePoint = this.m_errMsg_UsePoint.Replace("{$FinalPoint}", (this.m_UserInfo.UserPoint - this.m_contentChargeInfo.InfoPoint).ToString());
this.m_errMsg_UsePoint = this.m_errMsg_UsePoint.Replace("{$FileName}", SiteConfig.SiteInfo.VirtualPath + "Item.aspx");
this.m_errMsg_UsePoint = this.m_errMsg_UsePoint.Replace("{$id}", generalId.ToString());
this.m_errMsg_UsePoint = this.m_errMsg_UsePoint.Replace("{$SoftID}", generalId.ToString());
this.m_errMsg_UsePoint = this.m_errMsg_UsePoint.Replace("{$PhotoID}", generalId.ToString());
this.m_errMsg_UsePoint = this.m_errMsg_UsePoint.Replace("{$InstallDir}", SiteConfig.SiteInfo.VirtualPath);
this.m_errMsg_UsePoint = this.m_errMsg_UsePoint.Replace("{$PointName}", SiteConfig.UserConfig.PointName);
this.m_errMsg_UsePoint = this.m_errMsg_UsePoint.Replace("{$PointUnit}", SiteConfig.UserConfig.PointUnit);
}
private UserPointLogInfo AddPointLogInfo()
{
UserPointLogInfo info = new UserPointLogInfo();
info.UserName = this.m_UserInfo.UserName;
info.InfoId = this.m_CommonModelInfo.GeneralId;
info.IncomePayOut = 2;
info.ModuleType = this.m_ModelInfo.ModelId;
info.LogTime = DateTime.Now;
info.IP = this.m_UserTrueIP;
return info;
}
private bool CheckIsAuthenticated()
{
bool flag = true;
if (!PEContext.Current.User.Identity.IsAuthenticated)
{
this.m_ErrMsg = this.m_ErrMsg + this.m_errMsg_NoLogin;
flag = false;
}
return flag;
}
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 0:
this.m_IsFree = true;
return flag;
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;
}
this.m_IsFree = true;
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;
}
private void DividePoint(UserPointLogInfo userPointLogInfo)
{
int infoPoint = DataConverter.CLng((this.m_contentChargeInfo.InfoPoint * this.m_contentChargeInfo.DividePercent) / 100);
if (Users.AddPoint(infoPoint, this.m_CommonModelInfo.Inputer))
{
userPointLogInfo.UserName = this.m_CommonModelInfo.Inputer;
userPointLogInfo.InfoId = 0;
userPointLogInfo.Point = infoPoint;
userPointLogInfo.IncomePayOut = 1;
userPointLogInfo.Remark = "从“" + this.m_CommonModelInfo.Title + "”的收费中分成";
UserPointLog.Add(userPointLogInfo);
}
}
public bool ExecuteContentCharge()
{
object obj2 = HttpContext.Current.Items["IsPay"];
if ((obj2 != null) && ((bool) obj2))
{
return true;
}
if (this.m_IsFree)
{
return true;
}
if ((this.m_contentChargeInfo.InfoPoint <= 0) || (this.m_contentChargeInfo.InfoPoint > 0x270f))
{
return true;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -