Example #1
0
        /// <summary>
        /// 更新公司基础资料
        /// </summary>
        /// <param name="company">需要更新的公司</param>
        /// <returns>是否更新成功</returns>
        public bool UpdateCompany(COMPANY company)
        {
            bool result = false;

            using (var ctx = new NtripProxyDB())
            {
                if (company.ID != null)
                {
                    ctx.COMPANies.Attach(company);
                    ctx.Entry(company).State = EntityState.Modified;
                    //只更新基础信息不更新关联信息
                    ctx.Entry(company).Property("Company_Chief").IsModified = false;
                    result = ctx.SaveChanges() >= 1;
                }
            }
            return(result);
        }
Example #2
0
        /// <summary>
        /// 更改密码
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public bool ResetUserPassword(USER user)
        {
            bool result = false;

            using (var ctx = new NtripProxyDB())
            {
                if (user.ID != null)
                {
                    user.User_Password = MD5Encrypt(user.User_Password);
                    ctx.USERs.Attach(user);
                    ctx.Entry(user).State = EntityState.Unchanged;
                    //更改密码信息
                    ctx.Entry(user).Property("User_Password").IsModified = true;
                    result = ctx.SaveChanges() >= 1;
                }
            }
            return(result);
        }
Example #3
0
        /// <summary>
        /// 更新账号基础资料
        /// </summary>
        /// <param name="account">需要更新的账号</param>
        /// <returns>是否更新成功</returns>
        public bool UpdateAccount(ACCOUNT account)
        {
            bool result = false;

            using (var ctx = new NtripProxyDB())
            {
                if (account.ID != null)
                {
                    ctx.ACCOUNTs.Attach(account);
                    ctx.Entry(account).State = EntityState.Modified;
                    //只更新基础信息不更新关联信息
                    ctx.Entry(account).Property("Account_Company").IsModified = false;
                    ctx.Entry(account).Property("Account_AddUser").IsModified = false;
                    result = ctx.SaveChanges() >= 1;
                }
            }
            return(result);
        }
Example #4
0
        /// <summary>
        /// 更新单个用户基础资料,不更改密码信息
        /// </summary>
        /// <param name="user">需要更新的用户</param>
        /// <returns>是否更新成功</returns>
        public bool UpdateUser(USER user)
        {
            bool result = false;

            using (var ctx = new NtripProxyDB())
            {
                if (user.ID != null)
                {
                    //User_Password 必须有值,不然无法跳过框架检查,所以设置为password值
                    user.User_Password = "******";
                    ctx.USERs.Attach(user);
                    ctx.Entry(user).State = EntityState.Modified;
                    //不更改密码信息
                    ctx.Entry(user).Property("User_Password").IsModified = false;
                    result = ctx.SaveChanges() >= 1;
                }
            }
            return(result);
        }
Example #5
0
        /// <summary>
        /// 更新用户相关公司
        /// </summary>
        /// <param name="user">用户信息</param>
        /// <param name="company">相关公司</param>
        /// <returns>更新是否成功</returns>
        public bool UpdateUserCompany(USER user, COMPANY company)
        {
            bool result = false;

            using (var ctx = new NtripProxyDB())
            {
                if (user.ID != null && company.ID != null)
                {
                    //User_Password 必须有值,不然无法跳过框架检查,所以设置为password值
                    user.User_Password = "******";
                    user.User_Campany  = company.ID;
                    ctx.USERs.Attach(user);
                    ctx.Entry(user).Property("User_Campany").IsModified  = true;
                    ctx.Entry(user).Property("User_Password").IsModified = false;
                    result = ctx.SaveChanges() >= 1;
                }
            }
            return(result);
        }
Example #6
0
        /// <summary>
        /// 通过用户登陆名查找用户全部信息
        /// </summary>
        /// <param name="loginName">用户登陆名</param>
        /// <returns>查找到的用户信息</returns>
        public USER FindUserByLoginName(string loginName)
        {
            USER user = new USER();

            using (var ctx = new NtripProxyDB())
            {
                user = ctx.USERs.Include("COMPANY").Include("ACCOUNTs").Include("ROLEs").FirstOrDefault(u => u.User_Login == loginName && u.isDelete == false);
                //去除逻辑删除的角色
                user.ROLEs = user.ROLEs.Where(r => r.isDelete == false).ToList <ROLE>();
                foreach (var role in user.ROLEs)
                {
                    ctx.Entry(role).Collection("PERMISSIONs");
                    //去除逻辑删除的权限
                    role.PERMISSIONs = role.PERMISSIONs.Where(p => p.isDelete == false).ToList <PERMISSION>();
                    foreach (var permission in role.PERMISSIONs)
                    {
                        ctx.Entry(permission).Collection("MENUs");
                        //去除逻辑删除的目录
                        permission.MENUs = permission.MENUs.Where(m => m.isDelete == false).ToList <MENU>();
                    }
                }
            }
            return(user);
        }
Example #7
0
        /// <summary>
        /// 更新角色基础信息
        /// </summary>
        /// <param name="role">需要更新的角色</param>
        /// <returns>是否更新成功</returns>
        public bool UpdateRole(ROLE role)
        {
            bool result = false;

            using (var ctx = new NtripProxyDB())
            {
                if (role.ID != null)
                {
                    ctx.ROLEs.Attach(role);
                    ctx.Entry(role).State = EntityState.Modified;
                    result = ctx.SaveChanges() >= 1;
                }
            }
            return(result);
        }
Example #8
0
        /// <summary>
        /// 更新系统账号资料
        /// </summary>
        /// <param name="accountSYS">需要更新的系统账号</param>
        /// <returns>是否更新成功</returns>
        public bool UpdateAccountSYS(ACCOUNTSYS accountSYS)
        {
            bool result = false;

            using (var ctx = new NtripProxyDB())
            {
                if (accountSYS.ID != null)
                {
                    ctx.ACCOUNTSYS.Attach(accountSYS);
                    ctx.Entry(accountSYS).State = EntityState.Modified;
                    result = ctx.SaveChanges() >= 1;
                }
            }
            return(result);
        }
Example #9
0
        /// <summary>
        /// 更新会话历史基础信息
        /// </summary>
        /// <param name="session">会话信息</param>
        /// <returns>是否更新成功</returns>
        public bool UpdateSessionHistory(SessionHistory session)
        {
            bool result = false;

            using (var ctx = new NtripProxyDB())
            {
                if (session.ID != null)
                {
                    ctx.SessionHistories.Attach(session);
                    ctx.Entry(session).State = EntityState.Modified;
                    result = ctx.SaveChanges() >= 1;
                }
            }
            return(result);
        }
Example #10
0
        /// <summary>
        /// 更新菜单基础信息
        /// </summary>
        /// <param name="menu">需要更新的菜单</param>
        /// <returns>是否更新成功</returns>
        public bool UpdateMenu(MENU menu)
        {
            bool result = false;

            using (var ctx = new NtripProxyDB())
            {
                if (menu.ID != null)
                {
                    ctx.MENUs.Attach(menu);
                    ctx.Entry(menu).State = EntityState.Modified;
                    result = ctx.SaveChanges() >= 1;
                }
            }
            return(result);
        }
Example #11
0
        /// <summary>
        /// 更新权限基础信息
        /// </summary>
        /// <param name="permission">需要更新的权限</param>
        /// <returns>是否更新成功</returns>
        public bool UpdatePermission(PERMISSION permission)
        {
            bool result = false;

            using (var ctx = new NtripProxyDB())
            {
                if (permission.ID != null)
                {
                    ctx.PERMISSIONs.Attach(permission);
                    ctx.Entry(permission).State = EntityState.Modified;
                    result = ctx.SaveChanges() >= 1;
                }
            }
            return(result);
        }
Example #12
0
        /// <summary>
        /// 更新账户公司信息
        /// </summary>
        /// <param name="account">账户信息</param>
        /// <param name="company">公司信息</param>
        /// <returns>更新是否成功</returns>
        public bool UpdateAccountCompany(ACCOUNT account, COMPANY company)
        {
            bool result = false;

            using (var ctx = new NtripProxyDB())
            {
                if (account.ID != null && company.ID != null)
                {
                    account.Account_Company = company.ID;
                    ctx.ACCOUNTs.Attach(account);
                    ctx.Entry(account).Property("Account_Company").IsModified = true;
                    result = ctx.SaveChanges() >= 1;
                }
            }
            return(result);
        }
Example #13
0
        /// <summary>
        /// 更新母公司信息
        /// </summary>
        /// <param name="company">公司信息</param>
        /// <param name="parentCompany">母公司</param>
        /// <returns>更新是否成功</returns>
        public bool UpdateParentCompany(COMPANY company, COMPANY parentCompany)
        {
            bool result = false;

            using (var ctx = new NtripProxyDB())
            {
                if (company.ID != null && parentCompany.ID != null)
                {
                    company.Company_Chief = parentCompany.ID;
                    ctx.COMPANies.Attach(company);
                    ctx.Entry(company).Property("Company_Chief").IsModified = true;
                    result = ctx.SaveChanges() >= 1;
                }
            }
            return(result);
        }