Example #1
0
        /// <summary>
        /// 修改或者添加用户权限
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void permissionButton_Click(object sender, EventArgs e)
        {
            string userName = userComboBox.Text.Trim();

            if (userName.Length != 0)
            {
                string password = passwordTextBox.Text.Trim();
                user   user     = user.Table.Cache.Get(userName);
                if (user == null)
                {
                    if (password.Length != 0)
                    {
                        user = user.Table.Insert(new user {
                            Name = userName, Password = password
                        });
                    }
                }
                else if (user.Password != password && password.Length != 0)
                {
                    user = user.Table.Update(new user {
                        Name = userName, Password = password
                    }, updatePasswordMember);
                }
                if (user != null)
                {
                    string path = pathTextBox.Text.Trim(), backupPath = backupPathTextBox.Text.Trim();
                    if (path.Length != 0)
                    {
#if NotFastCSharpCode
                        fastCSharp.log.Error.Throw(fastCSharp.log.exceptionType.NotFastCSharpCode);
#else
                        try
                        {
                            path = new DirectoryInfo(path).fullName().toLower();
                            if (backupPath.Length != 0)
                            {
                                backupPath = new DirectoryInfo(backupPath).fullName().toLower();
                            }
                            permissionType permissionType = permissionType.List;
                            if (readPermissionCheckBox.Checked)
                            {
                                permissionType |= permissionType.Read;
                            }
                            if (writePermissionCheckBox.Checked)
                            {
                                permissionType |= permissionType.Write;
                            }
                            permission permissionValue = permission.Table.Cache.Get(new permission.primaryKey {
                                UserName = userName, Path = path
                            });
                            if (permissionValue == null)
                            {
                                permission.Table.Insert(new permission {
                                    UserName = userName, Path = path, BackupPath = backupPath, Type = permissionType
                                });
                                setPath(userName);
                            }
                            else if (permissionValue.Type != permissionType || permissionValue.BackupPath != backupPath)
                            {
                                permission.Table.Update(new permission {
                                    UserName = userName, Path = path, BackupPath = backupPath, Type = permissionType
                                }, updatePermissionMember);
                                setPath(userName);
                            }
                        }
                        catch (Exception error)
                        {
                            MessageBox.Show(error.ToString());
                        }
#endif
                    }
                }
            }
        }
Example #2
0
 /// <summary>
 /// 用户更新事件
 /// </summary>
 /// <param name="value"></param>
 private void onUserChange(user value)
 {
     context.Post(onUserChange, user.Table.Cache.GetArray());
 }
Example #3
0
 /// <summary>
 /// 用户更新事件
 /// </summary>
 /// <param name="value"></param>
 private void onUserChange(user value, user oldValue, memberMap memberMap)
 {
     context.Post(onUserChange, user.Table.Cache.GetArray());
 }
Example #4
0
 /// <summary>
 /// 设置当前用户
 /// </summary>
 /// <param name="user"></param>
 private void setUser(user user)
 {
     passwordTextBox.Text = user.Password;
     setPath(user.Name);
 }