/// <summary>
 /// 删除操作命令
 /// </summary>
 /// <param name="command">命令</param>
 public void Delete(AuthorizationCommand command)
 {
     IList<AuthorizationCommand> lcs = db.Query<AuthorizationCommand>((AuthorizationCommand cmd) => cmd.Name == command.Name && cmd.CommandUri == cmd.CommandUri);
     foreach (AuthorizationCommand cmd in lcs) {
         db.Delete(cmd); // 删除所有的操作
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Adds the command.
        /// </summary>
        /// <param name="category">The category.</param>
        /// <param name="command">The command.</param>
        public void AddCommand(AuthorizationCommand command)
        {
            Guard.ArgumentNotNull(command, "Authorization command");

            if (!commands.Contains(command))
            {
                commands.Add(command);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Removes the command.
        /// </summary>
        /// <param name="category">The category.</param>
        /// <param name="command">The command.</param>
        public void RemoveCommand(AuthorizationCommand command)
        {
            Guard.ArgumentNotNull(command, "Authorization command");

            if (commands.Contains(command))
            {
                commands.Remove(command);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 删除操作命令
        /// </summary>
        /// <param name="command">命令</param>
        public void Delete(AuthorizationCommand command)
        {
            IList <AuthorizationCommand> lcs = db.Query <AuthorizationCommand>((AuthorizationCommand cmd) => cmd.Name == command.Name && cmd.CommandUri == cmd.CommandUri);

            foreach (AuthorizationCommand cmd in lcs)
            {
                db.Delete(cmd); // 删除所有的操作
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Handles the Click event of the btnOK control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (AuthNode == null) // 操作模拟的保存工作
            {
                Presenter.AuthorizationCommandService.Delete(edtCommandUri.Text);
                AuthorizationCommand command = new AuthorizationCommand() {
                    Name = edtName.Text,
                    CommandUri = edtCommandUri.Text,
                    Category = edtCategory.Text
                };
                if ((!String.IsNullOrEmpty(edtImage.Text) || edtImage.Text.Length != 0)
                    && edtImage.Text.IndexOf("${") == -1)
                    command.Image = "${" + Path.GetFileNameWithoutExtension(edtImage.Text) + "}";


                try {
                    Presenter.AuthorizationCommandService.Save(command);
                    btnOK.DialogResult = DialogResult.OK;
                }
                catch (Exception ex) {
                    XtraMessageBox.Show("保存命令 \"" + edtName.Text + "\" 时失败," + ex.Message);
                    btnOK.DialogResult = DialogResult.None;
                }
            }
            else {
                AuthorizationCommand command = new AuthorizationCommand() { 
                    Name = edtName.Text,
                    CommandUri = edtCommandUri.Text,
                    Category = edtCategory.Text
                };
                if ((!String.IsNullOrEmpty(edtImage.Text) || edtImage.Text.Length != 0)
                    && edtImage.Text.IndexOf("${") == -1)
                    command.Image = "${" + Path.GetFileNameWithoutExtension(edtImage.Text) + "}";

                foreach (AuthorizationCommand cmd in AuthNode.Commands) {
                    // 删除列表中原来的操作项
                    if (cmd.Name == command.Name || cmd.CommandUri == command.CommandUri) {
                        AuthNode.RemoveCommand(cmd);
                        break;
                    }
                }

                // 保存新的操作
                AuthNode.AddCommand(command);
                if (!Presenter.AuthorizationCommandService.Exists(command.Name, command.CommandUri))
                    Presenter.AuthorizationCommandService.Save(command); // 保存到操作模板中去
                try {
                    Presenter.AuthorizationNodeService.Save(AuthNode);
                    btnOK.DialogResult = DialogResult.OK;
                }
                catch (Exception ex) {
                    XtraMessageBox.Show("保存操作 \"" + edtName.Text + "\" 时间失败," + ex.Message);
                    btnOK.DialogResult = DialogResult.None;
                }
            }
        }
Esempio n. 6
0
        /// <summary>
        /// 保存操作命令
        /// </summary>
        /// <param name="command">命令</param>
        public void Save(AuthorizationCommand command)
        {
            Delete(command);

            // 为操作指定一个唯一的序号
            if (command.Sequence == -1)
            {
                IList <AuthorizationCommand> lcs = db.Query <AuthorizationCommand>((AuthorizationCommand cmd) => cmd.Category == command.Category);
                command.Sequence = lcs.Count + 1;
            }
            db.Store(command);
        }
 /// <summary>
 /// 检查指定的授权操作是否存在
 /// </summary>
 /// <param name="command">授权操作</param>
 /// <returns>
 /// 如果存在返回<see cref="true"/>否则为<see cref="false"/>
 /// </returns>
 public bool Exists(AuthorizationCommand command)
 {
     return Exists(command.Name, command.CommandUri);
 }
        /// <summary>
        /// 保存操作命令
        /// </summary>
        /// <param name="command">命令</param>
        public void Save(AuthorizationCommand command)
        {
            Delete(command);

            // 为操作指定一个唯一的序号
            if (command.Sequence == -1) {
                IList<AuthorizationCommand> lcs = db.Query<AuthorizationCommand>((AuthorizationCommand cmd) => cmd.Category == command.Category);
                command.Sequence = lcs.Count + 1;
            }
            db.Store(command);
        }
Esempio n. 9
0
 /// <summary>
 /// 检查指定的授权操作是否存在
 /// </summary>
 /// <param name="command">授权操作</param>
 /// <returns>
 /// 如果存在返回<see cref="true"/>否则为<see cref="false"/>
 /// </returns>
 public bool Exists(AuthorizationCommand command)
 {
     return(Exists(command.Name, command.CommandUri));
 }
Esempio n. 10
0
        /// <summary>
        /// Bindings the command.
        /// </summary>
        /// <param name="command">The command.</param>
        public void BindingCommand(AuthorizationCommand command)
        {
            edtName.Text = command.Name;
            edtCommandUri.Text = command.CommandUri;
            edtCategory.Text = command.Category;
            edtImage.Text = command.Image;

            if (!String.IsNullOrEmpty(edtImage.Text))
                image.ContentImage = Presenter.ImageService.GetBitmap(edtImage.Text);
        }