Пример #1
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="userProfileSettings">用户资料设置</param>
 /// <param name="userSettings">用户设置</param>
 /// <param name="inviteFriendSettings">邀请朋友设置</param>
 public UserSettingsEditModel(UserProfileSettings userProfileSettings, UserSettings userSettings, InviteFriendSettings inviteFriendSettings)
 {
     if (userSettings != null)
     {
         RegistrationMode = userSettings.RegistrationMode;
         AccountActivation = userSettings.AccountActivation;
         EnableNotActivatedUsersToLogin = userSettings.EnableNotActivatedUsersToLogin;
         EnableTrackAnonymous = userSettings.EnableTrackAnonymous;
         UserOnlineTimeWindow = userSettings.UserOnlineTimeWindow;
         UserPasswordFormat = userSettings.UserPasswordFormat;
         AutomaticModerated = userSettings.AutomaticModerated;
         NoModeratedUserPoint = userSettings.NoModeratedUserPoint;
         EnableNickname = userSettings.EnableNickname;
         DisplayNameType = userSettings.DisplayNameType;
         DisallowedUserNames = userSettings.DisallowedUserNames;
         MyHomePageAsSiteEntry = userSettings.MyHomePageAsSiteEntry;
     }
     if (userProfileSettings != null)
     {
         Avatar = userProfileSettings.IntegrityProportions[0];
         Birthday = userProfileSettings.IntegrityProportions[1];
         NowArea = userProfileSettings.IntegrityProportions[2];
         HomeArea = userProfileSettings.IntegrityProportions[3];
         IM = userProfileSettings.IntegrityProportions[4];
         Mobile = userProfileSettings.IntegrityProportions[5];
         EducationExperience = userProfileSettings.IntegrityProportions[6];
         WorkExperience = userProfileSettings.IntegrityProportions[7];
         Introduction = userProfileSettings.IntegrityProportions[8];
         MaxPersonTag = userProfileSettings.MaxPersonTag;
         MinIntegrity = userProfileSettings.MinIntegrity;
     }
     if (inviteFriendSettings != null)
     {
         AllowInvitationCodeUseOnce = inviteFriendSettings.AllowInvitationCodeUseOnce;
         InvitationCodeTimeLiness = inviteFriendSettings.InvitationCodeTimeLiness;
         InvitationCodeUnitPrice = inviteFriendSettings.InvitationCodeUnitPrice;
         DefaultUserInvitationCodeCount = inviteFriendSettings.DefaultUserInvitationCodeCount;
     }
 }
Пример #2
0
        /// <summary>
        /// 解析内容用于创建AtUser
        /// </summary>
        /// <param name="body">待解析的内容</param>
        /// <param name="userId">内容作者UserId</param>
        /// <param name="associateId">关联项Id</param>
        public void ResolveBodyForEdit(string body, long userId, long associateId)
        {
            if (string.IsNullOrEmpty(body) || !body.Contains("@"))
                return;

            List<long> userIds = new List<long>();

            PrivacyService privacyService = new PrivacyService();
            IUserService userService = DIContainer.Resolve<IUserService>();

            string userNameRegex = new UserSettings().NickNameRegex, tempNickName = string.Empty;
            userNameRegex = userNameRegex.TrimStart('^').TrimEnd('$');

            Regex rg = new Regex("(?<=(\\@))" + userNameRegex, RegexOptions.Multiline | RegexOptions.Singleline);
            MatchCollection matches = rg.Matches(body);

            if (matches != null)
            {
                foreach (Match m in matches)
                {
                    if (string.IsNullOrEmpty(m.Value) || tempNickName.Equals(m.Value, StringComparison.CurrentCultureIgnoreCase))
                        continue;

                    tempNickName = m.Value;
                    IUser user = userService.GetUserByNickName(tempNickName);

                    if (user == null
                        || userIds.Contains(user.UserId)
                        || !privacyService.Validate(user.UserId, userId, PrivacyItemKeys.Instance().AtUser()))
                        continue;

                    userIds.Add(user.UserId);
                }
            }

            if (userIds.Count > 0)
                BatchCreateAtUser(userIds, associateId, userId);
        }