コード例 #1
0
ファイル: UserManageDAO.cs プロジェクト: Brinews/Code
        /// <summary>
        /// 添加新用户。
        /// </summary>
        /// <param name="username">用户名,此用户名不能已存在。</param>
        /// <param name="password">密码</param>
        /// <param name="ipLimit">ip绑定地址</param>
        /// <param name="role">用户角色</param>
        /// <param name="functionModularIDs">用户被赋予的权限列表(使用function_modular表的id组成一个数组。数组中的元素即被赋予的权限。)</param>
        /// <returns>是否插入成功。此方法采用事务处理,所以插入失败不会在数据库产生垃圾数据。</returns>
        public bool AddUser(String username, String password, String ipLimit, UserRole role, IList<String> functionModularIDs)
        {
            User newUser = new User();
            newUser.name = username;
            newUser.password = password;
            newUser.ipLimit = ipLimit;
            newUser.role = role;
            bool result;

            //事务处理:插入失败,事务回滚
            try
            {
                sqlMapper.BeginTransaction();
                //插入user表
                sqlMapper.Insert("InsertUser", newUser);
                //循环插入user_function表
                foreach (String modularId in functionModularIDs)
                {
                    IDictionary<String, String> dic = new Dictionary<String, String>();
                    dic.Add("username", username);
                    dic.Add("functionid", modularId);
                    sqlMapper.Insert("InsertUserFunctionRelation", dic);
                }
                sqlMapper.CommitTransaction();
                result = true;
            }
            catch
            {
                sqlMapper.RollBackTransaction();
                result = false;
            }

            return result;
        }
コード例 #2
0
ファイル: UserManageDAO.cs プロジェクト: Brinews/Code
 /// <summary>
 /// 判断用户登录信息
 /// </summary>
 /// <param name="user"></param>
 /// <returns></returns>
 public static Boolean IsLogin(User user)
 {
     Boolean login = true;
     if (null == user)
     {
         login = false;
     }
     return login;
 }
コード例 #3
0
ファイル: EditWindow.xaml.cs プロジェクト: Brinews/Code
        public EditWindow(User.User aUser)
        {
            InitializeComponent();

            operatePanel.Visibility = Visibility.Hidden;
            scrollViewerLog.Visibility = Visibility.Hidden;
            user = aUser;

            foreach (FunctionModular fm in user.grantedModulars)
            {
                System.Windows.Controls.Button btn = new System.Windows.Controls.Button();
                btn.Content = fm.name;
                btn.Name = fm.id;
                btn.Click += this.buttonRepositorySelection_Click;
                btn.Height = 23;
                btn.Width = 135;
                btn.Margin = new Thickness(0, 10, 0, 0);
                wrapPanelRepositryButtons.Children.Add(btn);
            }

            /****
             * 添加“文件规范”按钮
             */
            System.Windows.Controls.Button btn_wjgf = new System.Windows.Controls.Button();
            btn_wjgf.Content = "文件规范";
            btn_wjgf.Name = "wenjianguifan";
            btn_wjgf.Click += this.buttonRepositorySelection_Click;
            btn_wjgf.Height = 23;
            btn_wjgf.Width = 135;
            btn_wjgf.Margin = new Thickness(0, 10, 0, 0);
            wrapPanelRepositryButtons.Children.Add(btn_wjgf);

            lblUsername.Content = user.name;
            System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();
            lblVersion.Content = assembly.GetName().Version.ToString();
            lblDataTime.Content = DateTime.Today.ToString("yyyy-MM-dd")
                + "  " + DateTime.Today.DayOfWeek.ToString();
            iCurrentReposId = "zhongwenqikan";
            iRepos = new ZWQK_MDB();
            iRepos.user = user;
            lblTitle.Content = iRepos.title;
            setButtonDisable();
        }
コード例 #4
0
ファイル: UserManageDAO.cs プロジェクト: Brinews/Code
 /// <summary>
 /// 通过User类修改一个用户。修改依据为用户名。
 /// 修改的User对象grantedModulars属性中,只关心id,而不关心name。
 /// </summary>
 /// <param name="user">需要修改的用户。</param>
 /// <returns>添加是否成功。</returns>
 public bool UpdateUserByName(User user)
 {
     List<String> functionIds = new List<string>();
     foreach (FunctionModular mod in user.grantedModulars)
         functionIds.Add(mod.id);
     return UpdateUserByName(user.name, user.password, user.ipLimit, user.role, functionIds);
 }