本文整理汇总了C#中IMember.GetValue方法的典型用法代码示例。如果您正苦于以下问题:C# IMember.GetValue方法的具体用法?C# IMember.GetValue怎么用?C# IMember.GetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMember
的用法示例。
在下文中一共展示了IMember.GetValue方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: UpdateUserEmail
public bool UpdateUserEmail(IMember member, string newEmail)
{
using (var client = new WebClient())
{
client.Headers.Add(HttpRequestHeader.ContentType, "application/json");
var values = new Dictionary<string, string>
{
{ "MemberId", member.GetValue<string>("yNumber") },
{ "EmailAddress", newEmail }
};
var jsonContent = new JavaScriptSerializer().Serialize(values);
// Get ahold of the root/home node
var root = _contentService.GetRootContent().First();
// Get the API uri
var apiUri = root.GetValue<string>("apiUri");
// Apend the command to invoke the register function
var url = apiUri + "/Registration?p1=" + member.Email;
var response = client.UploadString(url, jsonContent);
}
return true;
}
示例3: GetRequestedProps
private Dictionary<string, object> GetRequestedProps(IMember um)
{
if (!Roles.IsUserInRole(um.Username, "agents"))
{
throw new ArgumentException("An Umbraco Member with the ID specified is not an agent");
}
Dictionary<string, object> requestedProperties;
try
{
requestedProperties = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, object>>(um.GetValue<string>("requestedProperties"));
}
catch
{
requestedProperties = new Dictionary<string, object>();
}
return requestedProperties;
}
示例4: SendMemberSignupMail
public static void SendMemberSignupMail(IMember member)
{
try
{
var ipAddress = GetIpAddress();
var client = new RestClient("http://api.stopforumspam.org");
var request = new RestRequest(string.Format("api?ip={0}&email={1}&f=json", ipAddress, HttpUtility.UrlEncode(member.Email)), Method.GET);
var response = client.Execute(request);
var jsonResult = new JsonDeserializer();
var spamCheckResult = jsonResult.Deserialize<SpamCheckResult>(response);
var spammer = new SpamResult
{
MemberId = member.Id,
Name = member.Name,
Company = member.GetValue<string>("company"),
Bio = member.GetValue<string>("profileText"),
Email = member.Email,
Ip = ipAddress
};
if (spamCheckResult.Success == 1)
{
var score = spamCheckResult.Ip.Confidence + spamCheckResult.Email.Confidence;
var blocked = score > SpamBlockThreshold;
spammer.ScoreEmail = spamCheckResult.Email.Confidence.ToString(CultureInfo.InvariantCulture);
spammer.FrequencyEmail = spamCheckResult.Email.Frequency.ToString(CultureInfo.InvariantCulture);
spammer.ScoreIp = spamCheckResult.Ip.Confidence.ToString(CultureInfo.InvariantCulture);
spammer.FrequencyIp = spamCheckResult.Ip.Frequency.ToString(CultureInfo.InvariantCulture);
spammer.Blocked = blocked;
spammer.TotalScore = score;
SendNewMemberMail(spammer);
}
else
{
LogHelper.Warn<Utils>(string.Format("Error checking stopforumspam.org {0}", spamCheckResult.Error));
}
}
catch (Exception ex)
{
LogHelper.Error<Utils>("Error checking stopforumspam.org", ex);
}
}
示例5: 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;
}
示例6: ReadViewedItems
private static JArray ReadViewedItems(string memberPropertyAlias, out IMember um)
{
var mu = System.Web.Security.Membership.GetUser();
if (mu == null)
{
throw new Exception("There is no Umbraco member authenticated.");
}
um = ApplicationContext.Current.Services.MemberService.GetByUsername(mu.UserName);
var storedViewsString = um.GetValue<string>(memberPropertyAlias);
JArray storedViewsArray;
if (String.IsNullOrEmpty(storedViewsString))
{
storedViewsArray = new JArray();
}
else
{
try
{
storedViewsArray = JsonConvert.DeserializeObject<JArray>(storedViewsString);
}
catch (Exception)
{
storedViewsArray = new JArray();
}
}
return storedViewsArray;
}