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


C# IMember.SetValue方法代码示例

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

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

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


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