Esempio n. 1
0
        public LocalUser GetModelByPhone(string phoneNumber)
        {
            SystemDBContext.DBAutoConnect();
            var result = Applicate.SystemDbContext.user.FirstOrDefault(u => u.Telephone == phoneNumber);

            return(result);
        }
Esempio n. 2
0
        public LocalUser GetModel()
        {
            SystemDBContext.DBAutoConnect();
            var result = (
                from user in Applicate.SystemDbContext.user
                where user.UserId == this.UserId
                select user
                ).FirstOrDefault();

            return(result);
        }
Esempio n. 3
0
        /// <summary>
        /// 更新到数据库
        /// </summary>
        public void Update()
        {
            SystemDBContext.DBAutoConnect();
            var result = (
                from user in Applicate.SystemDbContext.user
                where user.UserId == this.UserId
                select user
                ).FirstOrDefault();

            result = this;
            Applicate.SystemDbContext.SaveChanges();
        }
Esempio n. 4
0
 /// <summary>
 /// 更新到数据库
 /// </summary>
 public void UpdatePwd(string phoneNumber, string password, int pwdLength)
 {
     lock (Applicate.SystemDbContext)
     {
         SystemDBContext.DBAutoConnect();
         var localuser = Applicate.SystemDbContext.user.FirstOrDefault(l => l.Telephone == phoneNumber);
         localuser.LastLoginTime  = LastLoginTime; //设置登录时间
         localuser.Password       = password;      //设置密码
         localuser.PasswordLength = pwdLength;     //设置密码长度
         Applicate.SystemDbContext.SaveChanges();  //保存更改
     }
 }
Esempio n. 5
0
 /// <summary>
 /// 删除
 /// </summary>
 public void Delete(string userId)
 {
     SystemDBContext.DBAutoConnect();
     lock (Applicate.SystemDbContext.user)
     {
         var item = Applicate.SystemDbContext.user.FirstOrDefault(i => i.UserId == userId);
         if (item != null)
         {
             Applicate.SystemDbContext.user.Remove(item);
         }
     }
     Applicate.SystemDbContext.SaveChanges();
 }
Esempio n. 6
0
        /// <summary>
        /// 更新到数据库
        /// </summary>
        public List <LocalUser> GetAllList()
        {
            var result = new List <LocalUser>();

            lock (Applicate.SystemDbContext.user)
            {
                SystemDBContext.DBAutoConnect();
                result = (
                    from user in Applicate.SystemDbContext.user
                    select user
                    ).ToList();
            }
            return(result);
        }
Esempio n. 7
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Areas GetModel()
        {
            SystemDBContext.DBAutoConnect();
            var result = (from area in Applicate.SystemDbContext.tbareas
                          where area.id == this.id
                          select area
                          ).FirstOrDefault();

            if (result == null)
            {
                result = new Areas();
            }

            return(result);
        }
Esempio n. 8
0
 /// <summary>
 /// 插入到数据库
 /// </summary>
 public void InsertOrUpdatePassword()
 {
     lock (Applicate.SystemDbContext)
     {
         SystemDBContext.DBAutoConnect();
         if (this.id == null || this.id == Guid.Empty.ToString("N"))
         {
             this.id = Guid.NewGuid().ToString("N");
         }
         if (Applicate.SystemDbContext.user.Count(l => l.Telephone == this.Telephone) > 0) //如果数据库存在项
         {
             UpdatePwd(this.Telephone, this.Password, this.PasswordLength);                //更新密码
         }
         else
         {
             Applicate.SystemDbContext.user.Add(this);      //插入
         }
         int res = Applicate.SystemDbContext.SaveChanges(); //保存更改
     }
 }
Esempio n. 9
0
 /// <summary>
 /// 更新上次离线时间
 /// </summary>
 /// <param name="userId">对应的用户</param>
 /// <param name="lastexittime">上次离线时间</param>
 internal void UpdateLastExitTime(string userId, long lastexittime)
 {
     lock (Applicate.SystemDbContext)
     {
         if (Applicate.SystemDbContext.user.Count(u => u.UserId == userId) > 0)//如果存在此人
         {
             SystemDBContext.DBAutoConnect();
             var user = Applicate.SystemDbContext.user.FirstOrDefault(u => u.UserId == userId);
             if (user != null)
             {
                 ConsoleLog.Output("用户" + userId + "退出时间为:" + Helpers.StampToDatetime(LastExitTime).ToShortDateString());
                 user.LastExitTime = lastexittime;                  //更新离线时间
                 var tmp = Applicate.SystemDbContext.SaveChanges(); //保存更改
                 ConsoleLog.Output("保存退出时间为:" + tmp);
             }
         }
         else
         {
         }
     }
 }
Esempio n. 10
0
 /// <summary>
 /// 获取子项位置列表
 /// </summary>
 /// <returns></returns>
 public List <Areas> GetChildrenList()
 {
     try
     {
         SystemDBContext.DBAutoConnect();
         var result = (from area in Applicate.SystemDbContext.tbareas
                       where area.parent_id == this.parent_id &&
                       area.type == this.type
                       select area
                       ).ToList();
         if (result == null)
         {
             return(new List <Areas>());
         }
         return(result);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         return(null);
     }
 }
Esempio n. 11
0
        /// <summary>
        /// 根据时间获取本地用户
        /// </summary>
        /// <returns>最后登录的用户</returns>
        internal LocalUser GetLastUserByTime()
        {
            SystemDBContext.DBAutoConnect();
            lock (Applicate.SystemDbContext)
            {
                if (Applicate.SystemDbContext.user.Count() > 0)
                {
                    var u1 = (from users in Applicate.SystemDbContext.user
                              orderby users.LastLoginTime descending
                              select users).FirstOrDefault();

                    var user = (from users in Applicate.SystemDbContext.user
                                orderby users.LastLoginTime ascending
                                select users
                                ).FirstOrDefault();
                    return(u1);
                }
                else
                {
                    return(null);
                }
            }
        }