Example #1
0
        public Wei.Core.Domain.Users.User SaveUser(string accesstokenOrAppid, string openid)
        {
            var user = _userService.GetUserById(openid);

            if (user == null)
            {
                user = new Core.Domain.Users.User()
                {
                    OpenId           = openid,
                    CreateTime       = DateTime.Now,
                    LastActivityTime = DateTime.Now,
                    Subscribe        = 1,
                    Channel          = "WX"
                };
                this._userService.InsertUser(user);
            }
            else
            {
                user.Subscribe = 1;
            }
            var wxuser = Senparc.Weixin.MP.AdvancedAPIs.UserApi.Info(WXinConfig.WeixinAppId, openid, Senparc.Weixin.Language.zh_CN);

            user.NickName       = wxuser.nickname;
            user.City           = wxuser.city;
            user.Country        = wxuser.country;
            user.HeadImgUrl     = wxuser.headimgurl;
            user.Province       = wxuser.province;
            user.Sex            = wxuser.sex;
            user.UnionId        = wxuser.unionid;
            user.Subscribe_Time = wxuser.subscribe_time;
            this._userService.UpdateUser(user);

            return(user);
        }
Example #2
0
        /// <summary>
        ///     Ctor.
        /// </summary>
        /// <param name="user"></param>
        /// <param name="roles"></param>
        /// <param name="userGroups"></param>
        /// <param name="userUpdateCommand"></param>
        public UserUpdateViewModel(Core.Domain.Users.User user, IList <string> roles, IList <Core.Domain.Users.UserGroup> userGroups,
                                   UserUpdateCommand userUpdateCommand)
        {
            Require.NotNull(user, "user");

            UserToUpdate      = user;
            Roles             = roles;
            UserGroups        = userGroups;
            UserUpdateCommand = userUpdateCommand;
        }
Example #3
0
        /// <summary>
        ///     Erzeugt eine neue Instanz vom <see cref="UserUpdateCommand" />
        /// </summary>
        /// <param name="user">Der zu ändernde Nutzer</param>
        public UserUpdateCommand(Core.Domain.Users.User user)
        {
            Require.NotNull(user, "user");

            Username                   = user.UserName;
            UserContactDto             = user.GetUserContactDto();
            UserDataDto                = user.GetUserDataDto();
            UserPermissionDto          = user.GetUserPermissionDto();
            UserPaymentDto             = user.GetUserPaymentDto();
            UserNotificationOptionsDto = user.GetNotificationOptions();
        }
Example #4
0
 /// <summary>
 ///     Ctor.
 /// </summary>
 public UserUpdateViewModel(Core.Domain.Users.User user)
     : this(user, new List <string>(), new List <Core.Domain.Users.UserGroup>(), new UserUpdateCommand(user))
 {
 }
Example #5
0
        /// <summary>
        /// 获取最新的关注用户
        /// </summary>
        /// <param name="accesstokenOrAppid"></param>
        public void SaveUserList(string accesstokenOrAppid)
        {
            _logger.Information("SaveUserList Begin");
            List <Senparc.Weixin.MP.AdvancedAPIs.User.BatchGetUserInfoData> openuserlist = null;
            var lastuser = this._userService.GetLastWXinUser();

            _logger.Information(lastuser.OpenId);
            var openids = Senparc.Weixin.MP.AdvancedAPIs.UserApi.Get(WXinConfig.WeixinAppId, lastuser == null? null: lastuser.OpenId);

            while (openids != null && openids.count > 0)
            {
                openuserlist = openids.data.openid.Select(x =>
                {
                    return(new Senparc.Weixin.MP.AdvancedAPIs.User.BatchGetUserInfoData()
                    {
                        openid = x,
                        LangEnum = Senparc.Weixin.Language.zh_CN
                    });
                }).ToList();
                var userinfoResult = Senparc.Weixin.MP.AdvancedAPIs.UserApi.BatchGetUserInfo(WXinConfig.WeixinAppId, openuserlist, 30000);
                foreach (var userinfo in userinfoResult.user_info_list)
                {
                    var user = _userService.GetUserById(userinfo.openid);
                    if (user == null)
                    {
                        user = new Core.Domain.Users.User()
                        {
                            OpenId           = userinfo.openid,
                            CreateTime       = DateTime.Now,
                            LastActivityTime = DateTime.Now,
                            Subscribe        = 1,
                            Channel          = "WX",
                            NickName         = userinfo.nickname,
                            City             = userinfo.city,
                            Country          = userinfo.country,
                            HeadImgUrl       = userinfo.headimgurl,
                            Province         = userinfo.province,
                            Sex            = userinfo.sex,
                            UnionId        = userinfo.unionid,
                            Subscribe_Time = userinfo.subscribe_time
                        };
                        this._userService.InsertUser(user);
                    }
                    else
                    {
                        user.NickName       = userinfo.nickname;
                        user.City           = userinfo.city;
                        user.Country        = userinfo.country;
                        user.HeadImgUrl     = userinfo.headimgurl;
                        user.Province       = userinfo.province;
                        user.Sex            = userinfo.sex;
                        user.UnionId        = userinfo.unionid;
                        user.Subscribe_Time = userinfo.subscribe_time;
                        this._userService.UpdateUser(user);
                    }
                }

                openids = Senparc.Weixin.MP.AdvancedAPIs.UserApi.Get(WXinConfig.WeixinAppId, openids.next_openid);
            }

            _logger.Information("SaveUserList End");
        }
Example #6
0
        public UserDeleteViewModel(Core.Domain.Users.User userToDelete)
        {
            Require.NotNull(userToDelete, "userToDelete");

            UserToDelete = userToDelete;
        }
Example #7
0
 public UserShowViewModel()
 {
     User = new Core.Domain.Users.User();
 }
Example #8
0
 public UserShowViewModel(Core.Domain.Users.User user)
 {
     User = user;
 }