当前位置: 首页>>代码示例>>C#>>正文


C# IMember.GetValue方法代码示例

本文整理汇总了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;
        }
开发者ID:umbraco,项目名称:OurUmbraco,代码行数:25,代码来源:SpamChecker.cs

示例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;
        }
开发者ID:osaamadasun,项目名称:HRI-Umbraco,代码行数:24,代码来源:HriApiService.cs

示例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;
 }
开发者ID:AzarinSergey,项目名称:project-site,代码行数:17,代码来源:AgentApiController.cs

示例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);
            }
        }
开发者ID:umbraco,项目名称:OurUmbraco,代码行数:45,代码来源:Utils.cs

示例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;
        }
开发者ID:umbraco,项目名称:OurUmbraco,代码行数:59,代码来源:Utils.cs

示例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;
 }
开发者ID:AzarinSergey,项目名称:project-site,代码行数:27,代码来源:Scandia.SiteUtils.cs


注:本文中的IMember.GetValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。