コード例 #1
0
 private void checkBoxServiceReporting_Unchecked(object sender, RoutedEventArgs e)
 {
     if (!_updatingLogAndReportingStatus)
     {
         _currentExpectedAction = ExpectedAction.DeactivateReporting;
         _clientLogic.AdminUpdateReportingState(false);
     }
 }
コード例 #2
0
 private void checkBoxServiceLog_Unchecked(object sender, RoutedEventArgs e)
 {
     // dont' respond during initial update
     if (!_updatingLogAndReportingStatus)
     {
         _currentExpectedAction = ExpectedAction.DeactivateLog;
         _clientLogic.AdminDisableLogging();
     }
 }
コード例 #3
0
ファイル: PosViewModel.cs プロジェクト: mickytm/SambaPOS-3
        private void CloseTicket()
        {
            if (SelectedTicket == null)
            {
                return;
            }

            if (!SelectedTicket.CanCloseTicket() && !SelectedTicket.IsTaggedWithDefinedTags(_cacheService.GetTicketTagGroupNames()))
            {
                //SaveTicketIfNew();
                //_ticketViewModel.RefreshVisuals();
                return;
            }

            if (_ticketOrdersViewModel.Orders.Count > 0 && SelectedTicket.GetRemainingAmount() == 0)
            {
                var message = GetPrintError();
                if (!string.IsNullOrEmpty(message))
                {
                    _ticketOrdersViewModel.ClearSelectedOrders();
                    _ticketViewModel.RefreshVisuals();
                    InteractionService.UserIntraction.GiveFeedback(message);
                    return;
                }
            }

            _ticketOrdersViewModel.ClearSelectedOrders();
            var result = _ticketService.CloseTicket(SelectedTicket);

            if (!string.IsNullOrEmpty(result.ErrorMessage))
            {
                InteractionService.UserIntraction.GiveFeedback(result.ErrorMessage);
            }

            SelectedTicket = null;

            if (_applicationState.CurrentTerminal.AutoLogout)
            {
                _userService.LogoutUser(false);
            }
            else
            {
                if (ExpectedAction != null)
                {
                    ExpectedAction.Invoke();
                }
                else
                {
                    EventServiceFactory.EventService.PublishEvent(EventTopicNames.ActivatePosView);
                }
            }
            ExpectedAction = null;
            _messagingService.SendMessage(Messages.TicketRefreshMessage, result.TicketId.ToString(CultureInfo.InvariantCulture));
            _applicationStateSetter.SetApplicationLocked(false);
        }
コード例 #4
0
            public void AddsErrorActionException()
            {
                var request = TestConstants.BuildRequest(DbAuthType.Native);
                var thrown  = new Exception("message");

                ExpectedAction.Setup(AnyCallToMigrateExpression).Throws(thrown);

                var result = CallAction(request);

                Assert.StartsWith("EF Plugin: message", result.ErrorMessages.Single());
            }
コード例 #5
0
        private void ProfileActive_Checked(object sender, RoutedEventArgs e)
        {
            if (!_updatingProfileStatus)
            {
                CheckBox       checkBox = e.OriginalSource as CheckBox;
                DisplayContext context  = checkBox.DataContext as DisplayContext;
                Debug.Assert(context != null);

                _currentExpectedAction = ExpectedAction.ActivateProfile;
                _clientLogic.AdminActivateContext(context.Id);
            }
        }
コード例 #6
0
            public void CallsAction(PersistenceMigratorRequest request)
            {
                var result = CallAction(request);

                Assert.Empty(result.ErrorMessages);
                //Total calls to update
                ExpectedAction.Verify(AnyCallToMigrateExpression, Times.Once);
                //Proper call to update
                ExpectedAction.Verify(m => m.Migrate(request, result), Times.Once);
                //No calls to Rollback
                UnusedAction.Verify(AnyCallToMigrateExpression, Times.Never);
            }
コード例 #7
0
        private void ProfileActive_Unchecked(object sender, RoutedEventArgs e)
        {
            if (!_updatingProfileStatus)
            {
                CheckBox       checkBox = e.OriginalSource as CheckBox;
                DisplayContext context  = checkBox.DataContext as DisplayContext;
                Debug.Assert(context != null);

                // if this is the selected profile then clear the selection
                if (context.Id == UserSettings.Settings.CurrentContextId)
                {
                    UserSettings.Settings.CurrentContextId = UserSettings.InvalidContextId;
                }

                _currentExpectedAction = ExpectedAction.DeactivateProfile;
                _clientLogic.AdminDeactivateContext(context.Id);
            }
        }
コード例 #8
0
        void _clientLogic_ClientLogicError(object sender, ClientLogicErrorEventArgs e)
        {
            if (this.Dispatcher.CheckAccess())
            {
                _updatingLogAndReportingStatus = true;
                _updatingProfileStatus         = true;

                switch (_currentExpectedAction)
                {
                case ExpectedAction.ActivateProfile:
                case ExpectedAction.DeactivateProfile:
                    listViewProfiles.Items.Refresh();
                    break;

                case ExpectedAction.ActivateLog:
                    checkBoxServiceLog.IsChecked = false;
                    break;

                case ExpectedAction.DeactivateLog:
                    checkBoxServiceLog.IsChecked = true;
                    break;

                case ExpectedAction.ActivateReporting:
                    // reporting removed
                    break;

                case ExpectedAction.DeactivateReporting:
                    // reporting removed
                    break;
                }

                _updatingLogAndReportingStatus = false;
                _updatingProfileStatus         = false;

                _currentExpectedAction = ExpectedAction.None;

                UpdateState();
            }
            else
            {
                this.Dispatcher.BeginInvoke(new Action <object, ClientLogicErrorEventArgs>(_clientLogic_ClientLogicError), sender, e);
            }
        }
コード例 #9
0
ファイル: RoundManager.cs プロジェクト: plutoday/TexasBot
        private ExpectedAction GetExpectedAction(Round round)
        {
            ExpectedActionEnum actionEnum = ExpectedActionEnum.Decision;

            if (round.IsSettled)
            {
                switch (round.StageEnum)
                {
                case StageEnum.Preflop:
                    actionEnum = ExpectedActionEnum.Flops;
                    break;

                case StageEnum.Flop:
                    actionEnum = ExpectedActionEnum.Turn;
                    break;

                case StageEnum.Turn:
                    actionEnum = ExpectedActionEnum.River;
                    break;

                case StageEnum.River:
                    actionEnum = ExpectedActionEnum.VillainHoles;
                    break;

                default:
                    throw new InvalidOperationException($"{round.StageEnum} should not be here");
                }
            }

            var action = new ExpectedAction
            {
                Action = actionEnum
            };

            if (action.Action == ExpectedActionEnum.Decision || action.Action == ExpectedActionEnum.VillainHoles)
            {
                action.PlayerName = round.GetCurrentPlayer().Name;
            }

            return(action);
        }
コード例 #10
0
        void _clientLogic_ClientLogicUI(object sender, ClientLogicUIEventArgs e)
        {
            if (this.Dispatcher.CheckAccess())
            {
                // reset expected action
                _currentExpectedAction = ExpectedAction.None;

                switch (e.UIRequest)
                {
                case ClientLogicUIRequest.ProxySettingsUpdated:
                    // before closing try to reselect the active context Id on load
                    if (UserSettings.Settings.CurrentContextId != _activeContextIdOnLoad)
                    {
                        if ((_clientLogic.ContextCollection != null) && (_clientLogic.ContextCollection.Count > 0))
                        {
                            foreach (DisplayContext contextSettings in _clientLogic.ContextCollection)
                            {
                                if ((contextSettings.IsActive) && (contextSettings.Id == _activeContextIdOnLoad))
                                {
                                    UserSettings.Settings.CurrentContextId = contextSettings.Id;
                                    break;
                                }
                            }
                        }
                    }

                    // proxy settings updated on exit so close when complete
                    this.DialogResult = true;
                    break;

                case ClientLogicUIRequest.ContextCollectionReady:
                    UpdateState();
                    UpdateProyControl();

                    _updatingLogAndReportingStatus = true;
                    _updatingProfileStatus         = true;

                    checkBoxServiceLog.IsChecked = _clientLogic.ServiceLogEnabled;
                    listViewProfiles.Items.Refresh();

                    _updatingProfileStatus         = false;
                    _updatingLogAndReportingStatus = false;

                    if (_activateRequired)
                    {
                        _activateRequired = false;
                        _clientLogic.AdminActivateContext(_activateContextId);
                    }
                    break;

                case ClientLogicUIRequest.NewContextSettingsReady:
                    // get DB settings for the add operation - BeginInvoke to free up ClientLogic
                    this.Dispatcher.BeginInvoke(new Action(RunDBConfigForAdd));
                    break;

                case ClientLogicUIRequest.MoveIndexComplete:
                    // update contexts - BeginInvoke to free up ClientLogic
                    this.Dispatcher.BeginInvoke(new Action(UpdateContextSettings));
                    break;
                }
            }
            else
            {
                this.Dispatcher.BeginInvoke(new Action <object, ClientLogicUIEventArgs>(_clientLogic_ClientLogicUI), sender, e);
            }
        }
コード例 #11
0
        public async Task Then_with_single_legal_entity_then_redirects_correctly(bool isTransfer, EmployerAgreementStatus status, int templateVersionNumber, ExpectedAction expectedAction)
        {
            //Arrange
            if (expectedAction == ExpectedAction.AgreementNotSigned)
            {
                _linkGeneratorResult = $"accounts/{_chooseOrganisationRequest.AccountHashedId}/apprentices/{LegalEntityCode}/AgreementNotSigned";
            }

            if (expectedAction == ExpectedAction.SelectProvider)
            {
                _linkGeneratorResult = $"accounts/{_chooseOrganisationRequest.AccountHashedId}/apprentices/provider/create";
            }

            _linkGenerator.Setup(x => x.CommitmentsLink(It.IsAny <string>())).Returns(_linkGeneratorResult);
            _modelMapper.Setup(x => x.Map <SelectLegalEntityViewModel>(It.Is <SelectLegalEntityRequest>(r => r == _chooseOrganisationRequest)))
            .ReturnsAsync(new SelectLegalEntityViewModel
            {
                LegalEntities = new[] { new LegalEntity
                                        {
                                            Agreements = new List <Agreement> {
                                                new Agreement
                                                {
                                                    Status = status,
                                                    TemplateVersionNumber = templateVersionNumber
                                                }
                                            },
                                            Code = LegalEntityCode,
                                            Name = LegalEntityName
                                        } },
                CohortRef = CohortRefViewModel
            });

            //Act
            _chooseOrganisationRequest.transferConnectionCode = isTransfer ? _chooseOrganisationRequest.transferConnectionCode : string.Empty;
            var result = await _controller.SelectLegalEntity(_chooseOrganisationRequest);

            //Assert
            var redirectToActionResult = result as RedirectToActionResult;

            switch (expectedAction)
            {
            case ExpectedAction.AgreementNotSigned:
                Assert.AreEqual(expectedAction.ToString(), redirectToActionResult.ActionName);
                break;

            case ExpectedAction.SelectProvider:
                Assert.AreEqual(expectedAction.ToString(), redirectToActionResult.ActionName);
                break;

            default:
                throw new NotImplementedException();
            }
        }
        public async Task WithSingleLegalEntityThenRedirectsCorrectly(bool isTransfer, EmployerAgreementStatus status, int templateVersionNumber, ExpectedAction expectedAction)
        {
            var transferConnectionCode = GetTransferConnectionCode(isTransfer);

            var response = new OrchestratorResponse <SelectLegalEntityViewModel>
            {
                Data = new SelectLegalEntityViewModel
                {
                    LegalEntities = new[] { new LegalEntity
                                            {
                                                Agreements = new List <Agreement> {
                                                    new Agreement
                                                    {
                                                        Status = status,
                                                        TemplateVersionNumber = templateVersionNumber
                                                    }
                                                },
                                                Code = LegalEntityCode,
                                                Name = LegalEntityName
                                            } },
                    CohortRef = CohortRefViewModel
                }
            };

            Orchestrator.Setup(o => o.GetLegalEntities(HashedAccountId, transferConnectionCode, CohortRefParam, null))
            .ReturnsAsync(response);

            var result = await Controller.SelectLegalEntity(HashedAccountId, transferConnectionCode);

            object expectedRouteValues;

            switch (expectedAction)
            {
            case ExpectedAction.AgreementNotSigned:
                expectedRouteValues = new { TransferConnectionCode = transferConnectionCode, HashedAccountId, LegalEntityCode, CohortRef = CohortRefViewModel, HasSignedAgreement = false, LegalEntityName };
                break;

            case ExpectedAction.SearchProvider:
                expectedRouteValues = new { TransferConnectionCode = transferConnectionCode, LegalEntityCode, CohortRef = CohortRefViewModel };
                break;

            default:
                throw new NotImplementedException();
            }

            AssertRedirectAction(result, expectedAction.ToString(), expectedRouteValues: expectedRouteValues);
        }