本文整理汇总了C#中IMember.SetValue方法的典型用法代码示例。如果您正苦于以下问题:C# IMember.SetValue方法的具体用法?C# IMember.SetValue怎么用?C# IMember.SetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMember
的用法示例。
在下文中一共展示了IMember.SetValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsSpam
public static bool IsSpam(IMember member, string body)
{
// Members with over 50 karma are trusted automatically
if (member.Karma() >= 50)
return false;
var roles = Roles.GetRolesForUser(member.Username);
var isSpam = roles.Contains("potentialspam") || roles.Contains("newaccount") || NewAndPostsALot(member) || TextContainsSpam(body) || IsSuspiciousBehavior(body);
if (isSpam)
{
//Deduct karma
var reputationTotal = member.GetValue<int>("reputationTotal");
member.SetValue("reputationTotal", reputationTotal >= 0 ? reputationTotal - 1 : 0);
var reputationCurrent = member.GetValue<int>("reputationCurrent");
member.SetValue("reputationCurrent", reputationCurrent >= 0 ? reputationCurrent - 1 : 0);
var memberService = ApplicationContext.Current.Services.MemberService;
memberService.Save(member);
memberService.AssignRole(member.Id, "potentialspam");
}
return isSpam;
}
示例2: SetMemberProperties
private void SetMemberProperties(IMember member)
{
var hriUser = GetRegisteredUserByUsername(member.Username);
// Assign this user their member id
member.SetValue("memberId", hriUser["RegId"].ToString());
// Assign their Morneau Shapell Y Number
member.SetValue("yNumber", hriUser["MemberId"].ToString());
member.SetValue("market", hriUser["Market"].ToString());
if ((string)hriUser["PlanEffectiveDate"] != null)
{
member.SetValue("effectiveYear", hriUser["PlanEffectiveDate"].ToString());
}
if ((string)hriUser["EbixId"] != null)
{
member.SetValue("ebixId", hriUser["EbixId"].ToString());
}
if ((string)hriUser["RxGrpId"] != null)
{
member.SetValue("groupId", hriUser["RxGrpId"].ToString());
}
// Birthday
if ((string)hriUser["DOB"] != null)
{
member.SetValue("birthday", hriUser["DOB"].ToString());
}
// Plan Id
if ((string)hriUser["PlanId"] != null)
{
member.SetValue("healthplanid", hriUser["PlanId"].ToString());
}
// Plan Name
if ((string)hriUser["PlanName"] != null)
{
member.SetValue("healthPlanName", hriUser["PlanName"].ToString());
}
// Morneau Shepell First Name
if ((string)hriUser["MSFirstName"] != null)
{
member.SetValue("msFirstName", hriUser["MSFirstName"].ToString());
}
// Morneau Shepell Last Name
if ((string)hriUser["MSLastName"] != null)
{
member.SetValue("msLastName", hriUser["MSLastName"].ToString());
}
}
示例3: CheckForSpam
public static SpamResult CheckForSpam(IMember member)
{
try
{
// Already blocked, nothing left to do here
if (member.GetValue<bool>("blocked"))
{
return new SpamResult
{
MemberId = member.Id,
Name = member.Name,
Blocked = true
};
}
// If reputation is > ReputationThreshold they've got enough karma, spammers never get that far
var reputation = member.GetValue<int>("reputationTotal");
if (reputation > ReputationThreshold)
return null;
// If they're already marked as suspicious then no need to process again
if (Roles.IsUserInRole(member.Username, SpamMemberGroupName))
{
return new SpamResult
{
MemberId = member.Id,
Name = member.Name,
AlreadyInSpamRole = true
};
}
var spammer = CheckForSpam(member.Email, member.Name, false);
if (spammer != null && spammer.TotalScore > PotentialSpammerThreshold)
{
var memberService = ApplicationContext.Current.Services.MemberService;
memberService.AssignRole(member.Id, SpamMemberGroupName);
spammer.MemberId = member.Id;
SendPotentialSpamMemberMail(spammer);
if (spammer.Blocked)
{
member.SetValue("blocked", true);
memberService.Save(member);
// If blocked, just redirect them to the home page where they'll get a message saying they're blocked
HttpContext.Current.Response.Redirect("/");
}
}
}
catch (Exception ex)
{
LogHelper.Error<Utils>(string.Format("Error trying to CheckForSpam for member {0}", member.Email), ex);
}
return null;
}