Example #1
0
 public MainWindowViewModel(AuthorizationCommand authorizationCommand, CreateNewAccountCommand createNewAccountCommand,
                            ObservableCollection <User> users)
 {
     AuthorizationCommand    = authorizationCommand;
     CreateNewAccountCommand = createNewAccountCommand;
     Users = users;
 }
Example #2
0
        public async Task Autorizacao()
        {
            var command = new AuthorizationCommand()
            {
                Amount                 = 1000,
                Caputre                = false,
                CardHolderName         = "Artur Ribeiro",
                CardNumber             = "01234567890123",
                SecurityCode           = "12",
                DistributorAffiliation = "12345",
                ExpirationMonth        = 12,
                ExpirationYear         = 2026,
                Installments           = 0,
                Origin                 = Origin.eRede,
                Reference              = "012345679",
                SoftDescriptor         = "teste",
                Subscription           = false,
                TransactionType        = TransactionType.Credit
            };


            var result = await client.PostAsync(command, "Authorization/Authorize");


            result.StatusCode.Should().Be(HttpStatusCode.OK);
        }
        public IPaymentCommand CreatePaymentCommand(XmlElement settings)
        {
            AuthorizationCommand cmd = new AuthorizationCommand(_transport, this);

            cmd.Status += RaiseIntermediateStatusEvent;
            ReadSettings(cmd, settings);
            return(cmd);
        }
Example #4
0
 public UpdateService(IBotService botService, ICommandService commandService, IChatRepository chatRepository, IAuthRepository authRepository, AuthorizationCommand authorizationCommand)
 {
     this.botService           = botService;
     this.commandService       = commandService;
     this.chatRepository       = chatRepository;
     this.authRepository       = authRepository;
     this.authorizationCommand = authorizationCommand;
 }
Example #5
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);
            }
        }
 public RequestHandler(
     IUserItemsStorage <TrelloApiToken> userTokenStorage,
     AuthorizationCommand authorizationCommand,
     ICommandWithPrefixValidation[] commandsWithPrefixValidation,
     ICommand defaultCommand,
     ITextButtonMenuProvider textButtonMenuProvider)
 {
     this.userTokenStorage             = userTokenStorage;
     this.commandsWithPrefixValidation = commandsWithPrefixValidation;
     this.authorizationCommand         = authorizationCommand;
     this.defaultCommand         = defaultCommand;
     this.textButtonMenuProvider = textButtonMenuProvider;
 }
Example #7
0
        /// <summary>
        /// 触发当前命令项变化事件
        /// </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 bsCommands_CurrentChanged(object sender, EventArgs e)
        {
            AuthorizationCommand cmd = bsCommands.Current as AuthorizationCommand;

            if (cmd != null)
            {
                Presenter.CurrentCommand = cmd;
                if (CurrentCommandChanged != null)
                {
                    CurrentCommandChanged(this, new EventArgs <AuthorizationCommand>(cmd));
                }

                Presenter.WorkItem.State.Remove(Constants.CurrentCommand);
                Presenter.WorkItem.State[Constants.CurrentCommand] = cmd;
            }
        }
Example #8
0
        /// <summary>
        /// 保存当前角色的权限信息
        /// </summary>
        private void SaveAuthorizationForRole(TreeListNode authNode)
        {
            foreach (TreeListNode node in authNode.Nodes)
            {
                if (node.Tag != null && node.Tag is AuthorizationCommand)
                {
                    AuthorizationCommand command = node.Tag as AuthorizationCommand;
                    string authorizationUri      = GetAuthorizationUri(node); // 获取当前操作的权限路径
                    authStore.Authorization(SecurityUtility.HashObject(authorizationUri + command.CommandUri),
                                            node.Checked ? AuthorizationAction.Allow : AuthorizationAction.Deny);
                }
                SaveAuthorizationForRole(node); // 保存子节点的权限授权信息
            }

            // 保存到对象数据库中
            Presenter.AuthorizationStoreService.SaveAuthorization(authStore);
        }
        private void LoginViaSavedAccount()
        {
            var selectedAccountNickName = SettingsManager.GetSettings()
                                          .Auth.SavedAccounts[SelectedSavedAccountIndex].Nickname;
            var creds = Storage.GetSecuredCreds(selectedAccountNickName);

            Login          = selectedAccountNickName;
            UseAccessToken = Storage.IsToken(creds.Password);
            if (UseAccessToken)
            {
                AccessToken = Storage.PasswordFromRawPassword(creds.Password);
            }
            else
            {
                Password = Storage.PasswordFromRawPassword(creds.Password);
            }
            AuthorizationCommand.Execute(null);
        }
Example #10
0
 public ATMViewModel()
 {
     atm = new BankLibrary.ATM();
     atm.AuthorizationSucceeded += () => AuthorizationSucceeded();
     atm.AuthorizationFailed    += message => AuthorizationFailed(message);
     atm.BalanceChanged         += balance =>
     {
         Balance = balance;
         OnPropertyChanged(nameof(Balance));
     };
     atm.TransferSucceeded += () => TransferSucceeded();
     atm.TransferFailed    += message => TransferFailed(message);
     atm.Error             += e => MessageBox.Show(e.Message);
     AuthorizationCommand   = new AuthorizationCommand(atm);
     CheckBalanceCommand    = new CheckBalanceCommand(atm);
     TransferCommand        = new TransferCommand(atm);
     InsertCardCommand      = new InsertCardCommand(atm);
     ExitCommand            = new ExitCommand(atm);
 }
        /// <summary>
        /// 删除选定数据资料
        /// </summary>
        public override void Delete()
        {
            if (XtraMessageBox.Show("你真的要删除选定的操作项吗?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                base.Delete();

                AuthorizationCommand command = View.TLCommands.Selection[0].Tag as AuthorizationCommand; // 获取准备删除的操作项

                if (CurrentAuthNode != null)
                {
                    AuthorizationNode authNode = CurrentAuthNode.Tag as AuthorizationNode;
                    authNode.RemoveCommand(command);
                    View.TLCommands.DeleteNode(View.TLCommands.Selection[0]);
                    CurrentAuthNode.Tag = authNode;
                    AuthorizationNodeService.Save(authNode); // 将变化保存回后端数据库

                    UpdateRoleAuthorization(authNode);
                }
            }
        }
Example #12
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;
                }
            }
        }