Exemple #1
0
        public void AddSystemLog(SystemLogDataInfo systemLogDatainfo)
        {
            SystemLog systemLog = SimpleObjectMapper.CreateTargetObject <SystemLogDataInfo, SystemLog>(systemLogDatainfo);

            db.SystemLog.Add(systemLog);
            db.SaveChanges();
        }
Exemple #2
0
        public SystemUserDataInfo GetSystemUserDataInfoByID(int Id)
        {
            SystemUser         user         = db.SystemUser.Find(Id);
            SystemUserDataInfo userDataInfo = SimpleObjectMapper.CreateTargetObject <SystemUser, SystemUserDataInfo>(user);

            return(userDataInfo);
        }
Exemple #3
0
        public UserDataInfo SaveWeiXinUser(UserDataInfo userDataInfo)
        {
            UserDataInfo newUserDataInfo = null;

            try
            {
                User user = db.User.FirstOrDefault(n => n.OpenID == userDataInfo.OpenID);
                if (user == null)
                {
                    user                         = new User();
                    user.OpenID                  = userDataInfo.OpenID;
                    user.AttentionDateTime       = userDataInfo.AttentionDateTime;
                    user.CanAttention            = userDataInfo.CanAttention;
                    user.City                    = userDataInfo.City;
                    user.Country                 = userDataInfo.Country;
                    user.CreationDateTime        = userDataInfo.CreationDateTime;
                    user.DisplayName             = userDataInfo.DisplayName;
                    user.IsUse                   = userDataInfo.IsUse;
                    user.Province                = userDataInfo.Province;
                    user.Remark                  = userDataInfo.Remark;
                    user.Sex                     = userDataInfo.Sex;
                    user.SourceProductID         = userDataInfo.SourceProductID;
                    user.UserFace                = userDataInfo.UserFace;
                    user.CancelAttentionDateTime = null;
                    ServerLogger.Info("SaveWeiXinUser :"******"User",
                        Remark         = string.Format("{0}关注了公众号,用户微信数据为:{1}", userDataInfo.DisplayName, Newtonsoft.Json.JsonConvert.SerializeObject(userDataInfo)),
                        CreationDate   = DateTime.Now,
                        CreationUserID = null
                    });
                }
                else
                {
                    if (!user.CanAttention)
                    {
                        user.CanAttention      = true;
                        user.AttentionDateTime = DateTime.Now;
                        db.SaveChanges();
                        AddSystemLog(new SystemLogDataInfo()
                        {
                            ModulePage     = "User",
                            Remark         = string.Format("{0}重新关注了公众号,用户微信数据为:{1}", userDataInfo.DisplayName, Newtonsoft.Json.JsonConvert.SerializeObject(userDataInfo)),
                            CreationDate   = DateTime.Now,
                            CreationUserID = null
                        });
                    }
                }
                newUserDataInfo = SimpleObjectMapper.CreateTargetObject <User, UserDataInfo>(user);
            }
            catch (Exception e)
            {
                throw e;
            }
            return(newUserDataInfo);
        }
Exemple #4
0
        public SystemUserDataInfo GetSystemUserDataInfoByLogin(string userName, string password)
        {
            SystemUser         user         = db.SystemUser.FirstOrDefault(n => !n.IsDelete && n.UserName == userName && n.Password == password);
            SystemUserDataInfo userDataInfo = SimpleObjectMapper.CreateTargetObject <SystemUser, SystemUserDataInfo>(user);

            if (userDataInfo != null)
            {
                AddSystemLog(new SystemLogDataInfo()
                {
                    ModulePage     = "SystemUser",
                    Remark         = "登录了系统",
                    CreationDate   = DateTime.Now,
                    CreationUserID = userDataInfo.ID,
                });
            }
            return(userDataInfo);
        }
Exemple #5
0
        public void DeleteSystemUser(int Id)
        {
            SystemUser existUser = db.SystemUser.Find(Id);

            if (existUser == null)
            {
                throw new DuplicatedDomainObjectException("用户不存在");
            }
            existUser.IsDelete = true;
            db.SaveChanges();
            SystemUserDataInfo userDataInfo = SimpleObjectMapper.CreateTargetObject <SystemUser, SystemUserDataInfo>(existUser);

            AddSystemLog(new SystemLogDataInfo()
            {
                ModulePage     = "SystemUser",
                Remark         = string.Format("虚拟删除了用户,用户数据为:{0}", Newtonsoft.Json.JsonConvert.SerializeObject(userDataInfo)),
                CreationDate   = DateTime.Now,
                CreationUserID = CurrentAdminUserId,
            });
        }
Exemple #6
0
        public void UpdateSystemUser(SystemUserDataInfo userInfo)
        {
            if (string.IsNullOrEmpty(userInfo.UserName))
            {
                throw new MissingDomainObjectException("用户名不能为空");
            }
            SystemUser existUserByUserName = db.SystemUser.FirstOrDefault(n => !n.IsDelete && n.UserName == userInfo.UserName && n.ID != userInfo.ID);

            if (existUserByUserName != null)
            {
                throw new DuplicatedDomainObjectException(string.Format("【{0}】用户名已存在,修改失败", existUserByUserName.UserName));
            }
            SystemUser         existUser    = db.SystemUser.Find(userInfo.ID);
            SystemUserDataInfo userDataInfo = SimpleObjectMapper.CreateTargetObject <SystemUser, SystemUserDataInfo>(existUser);
            string             oldData      = Newtonsoft.Json.JsonConvert.SerializeObject(userDataInfo);

            if (existUser == null)
            {
                throw new DuplicatedDomainObjectException(string.Format("【{0}】用户不存在", existUser.UserName));
            }
            if (existUser != null)
            {
                existUser.DisplayName = userInfo.DisplayName;
                existUser.UserName    = userInfo.UserName;
                if (!string.IsNullOrEmpty(userInfo.Password))
                {
                    existUser.Password = userInfo.Password;
                }
                db.SaveChanges();
                userDataInfo = SimpleObjectMapper.CreateTargetObject <SystemUser, SystemUserDataInfo>(existUser);
                AddSystemLog(new SystemLogDataInfo()
                {
                    ModulePage     = "SystemUser",
                    Remark         = string.Format("修改了用户,原数据为:{0} 修改后数据为:{1}", oldData, Newtonsoft.Json.JsonConvert.SerializeObject(userDataInfo)),
                    CreationDate   = DateTime.Now,
                    CreationUserID = CurrentAdminUserId,
                });
            }
        }