private void ExecuteAutomationCommand(string automationCommandName, string automationCommandValue, string nextCommandValue) { if (SelectedOrders.Any()) { foreach (var selectedOrder in SelectedOrders.ToList()) { _applicationState.NotifyEvent(RuleEventNames.AutomationCommandExecuted, new { Ticket = SelectedTicket, Order = selectedOrder, AutomationCommandName = automationCommandName, CommandValue = automationCommandValue, NextCommandValue = nextCommandValue }); } } else { _applicationState.NotifyEvent(RuleEventNames.AutomationCommandExecuted, new { Ticket = SelectedTicket, AutomationCommandName = automationCommandName, CommandValue = automationCommandValue, NextCommandValue = nextCommandValue }); } _ticketOrdersViewModel.SelectedTicket = SelectedTicket; ClearSelectedItems(); ClearSelection = true; }
private void OnEndOfDayExecute(string obj) { _applicationState.NotifyEvent(RuleEventNames.BeforeWorkPeriodEnds, new { WorkPeriod = _applicationState.CurrentWorkPeriod }); _workPeriodService.StopWorkPeriod(EndDescription); Refresh(); _applicationState.CurrentWorkPeriod.PublishEvent(EventTopicNames.WorkPeriodStatusChanged); _applicationState.NotifyEvent(RuleEventNames.WorkPeriodEnds, new { WorkPeriod = _applicationState.CurrentWorkPeriod }); InteractionService.UserIntraction.GiveFeedback(Resources.WorkPeriodEndsMessage); EventServiceFactory.EventService.PublishEvent(EventTopicNames.ActivateNavigation); }
public User LoginUser(string pinValue) { Debug.Assert(_applicationState.CurrentLoggedInUser == User.Nobody); var user = CheckPinCodeStatus(pinValue) == LoginStatus.CanLogin ? GetUserByPinCode(pinValue) : User.Nobody; _applicationStateSetter.SetCurrentLoggedInUser(user); Reset(); if (user != User.Nobody) { user.PublishEvent(EventTopicNames.UserLoggedIn); _applicationState.NotifyEvent(RuleEventNames.UserLoggedIn, new { User = user, UserName = user.Name, RoleName = user.UserRole.Name }); } return(user); }
private void ExecuteAutomationCommand(Ticket selectedTicket, Order order, string automationCommand, string automationCommandValue) { if (string.IsNullOrEmpty(automationCommand)) { return; } if (string.IsNullOrEmpty(automationCommandValue)) { var ac = _cacheService.GetAutomationCommandByName(automationCommand); if (ac != null) { if (!string.IsNullOrEmpty(ac.Values)) { ac.PublishEvent(EventTopicNames.SelectAutomationCommandValue); return; } } } _applicationState.NotifyEvent(RuleEventNames.AutomationCommandExecuted, new { Ticket = selectedTicket, Order = order, AutomationCommandName = automationCommand, Value = automationCommandValue ?? "" }); }
private void OnItemSelection(TicketViewData obj) { if (obj == null) { return; } if (!Settings.MultiSelection) { TicketList.ToList().ForEach(x => x.IsSelected = false); obj.IsSelected = true; } else { obj.IsSelected = !obj.IsSelected; } if (!string.IsNullOrEmpty(Settings.CommandName)) { var val = GetCommandValues(); _applicationState.NotifyEvent(RuleEventNames.AutomationCommandExecuted, new { Ticket = Ticket.Empty, AutomationCommandName = Settings.CommandName, Value = val }); } }
private void OnSelectEntityExecuted(EntityScreenItemViewModel obj) { if (!string.IsNullOrWhiteSpace(AutomationCommandName)) { var commandValue = obj.Model.EntityState; if (!string.IsNullOrWhiteSpace(AutomationCommandValue)) { commandValue = AutomationCommandValue; if (commandValue.Contains("{")) { var entity = _cacheService.GetEntityById(obj.Model.EntityId); commandValue = _printerService.ExecuteFunctions(commandValue, entity); } } _applicationState.NotifyEvent(RuleEventNames.AutomationCommandExecuted, new { Ticket = Ticket.Empty, EntityId = obj.Model.EntityId, EntityTypeId = SelectedEntityScreen.EntityTypeId, AutomationCommandName = AutomationCommandName, CommandValue = commandValue }); return; } if (obj.Model.EntityId > 0 && obj.Model.ItemId == 0) { _currentOperationRequest.Publish(_cacheService.GetEntityById(obj.Model.EntityId)); } else if (obj.Model.ItemId > 0) { ExtensionMethods.PublishIdEvent(obj.Model.ItemId, EventTopicNames.DisplayTicket); } }
private void Process(string phoneNumber) { if (CustomerType != null) { var popupName = GetSettings().PopupName; if (string.IsNullOrWhiteSpace(popupName)) { popupName = Name; } var sr = _entityService.SearchEntities(CustomerType, phoneNumber, ""); if (sr.Count == 1) { var entity = sr.First(); InteractionService.UserIntraction.DisplayPopup(popupName, CustomerType.GetFormattedDisplayName(entity.Name, entity), entity.Name + " " + Resources.Calling + ".\r" + entity.SearchString + "\r", "DarkRed", OnClick, phoneNumber); } else { InteractionService.UserIntraction.DisplayPopup(popupName, phoneNumber, phoneNumber + " " + Resources.Calling + "...", "DarkRed", OnClick, phoneNumber); } } _applicationState.NotifyEvent(RuleEventNames.DeviceEventGenerated, new { DeviceName = Name, EventName = "CID_Event", EventData = phoneNumber }); }
private void OnAutomationCommandSelected(AccountScreenAutmationCommandMap obj) { object value = null; if (obj.AutomationCommandValueType == 0) // Account Id { var account = _accountService.GetAccountById(SelectedAccount.AccountId); if (account == null) { return; } value = account.Id; } if (obj.AutomationCommandValueType == 1) //Entity Id { var entities = _entityService.GetEntitiesByAccountId(SelectedAccount.AccountId).ToList(); if (!entities.Any()) { return; } value = entities.Select(x => x.Id).First(); } if (obj.AutomationCommandValueType == 2) //Entity Id List { value = string.Join(",", _entityService.GetEntitiesByAccountId(SelectedAccount.AccountId).Select(x => x.Id)); } _applicationState.NotifyEvent(RuleEventNames.AutomationCommandExecuted, new { obj.AutomationCommandName, CommandValue = value }); }
public override void Process(ActionData actionData) { var name = actionData.GetAsString("Name"); var values = actionData.GetAsString("Values"); if (!string.IsNullOrEmpty(values)) { if (!values.Contains(",") && values.StartsWith("(") && values.EndsWith(")")) { var endStr = values.Trim(new[] { '(', ')' }); int end; var start = 0; if (endStr.Contains("-")) { var parts = endStr.Split('-'); int.TryParse(parts[0], out start); int.TryParse(parts[1], out end); } else { int.TryParse(endStr, out end); } if (end > 0) { for (var i = start; i < end; i++) { _applicationState.NotifyEvent(RuleEventNames.ValueLooped, GenerateDataObject(actionData, name, i.ToString(CultureInfo.InvariantCulture))); } } } else if (values.Contains(":") && File.Exists(values)) { foreach (var value in File.ReadAllLines(values)) { _applicationState.NotifyEvent(RuleEventNames.ValueLooped, GenerateDataObject(actionData, name, value)); } } else { foreach (var value in values.Split(',')) { _applicationState.NotifyEvent(RuleEventNames.ValueLooped, GenerateDataObject(actionData, name, value)); } } } }
private void ExecuteCommand(Task task, TaskCommand command) { _applicationState.NotifyEvent(RuleEventNames.AutomationCommandExecuted, new { AutomationCommandName = command.CommandName, CommandValue = command.GetCommandValue(task) }); }
public void Action(Func <AccountTransactionDocument> action) { var document = action(); if (document != null) { _applicationState.NotifyEvent(RuleEventNames.AccountTransactionDocumentCreated, new { AccountTransactionDocumentName = DocumentType.Name, DocumentId = document.Id }); CommonEventPublisher.PublishEntityOperation(new AccountData(SelectedAccount), EventTopicNames.DisplayAccountTransactions); } }
private void OnItemClicked(AutomationButtonWidgetViewModel obj) { _applicationState.NotifyEvent(RuleEventNames.AutomationCommandExecuted, new { Ticket = Ticket.Empty, AutomationCommandName = obj.Settings.CommandName, obj.Settings.Value }); }
private static void RegisterNotifiers() { EventServiceFactory.EventService.GetEvent <GenericEvent <Message> >().Subscribe(x => { if (x.Topic == EventTopicNames.MessageReceivedEvent && x.Value.Command == "ActionMessage") { ApplicationState.NotifyEvent(RuleEventNames.MessageReceived, new { Command = x.Value.Data }); } }); }
private void OnExecuteAutomationCommand(CommandContainerButton obj) { obj.NextValue(); if (!string.IsNullOrEmpty(obj.CommandContainer.AutomationCommand.Values) && !obj.CommandContainer.AutomationCommand.ToggleValues) { obj.CommandContainer.AutomationCommand.PublishEvent(EventTopicNames.SelectAutomationCommandValue); } else { if (SelectedOrders.Any()) { foreach (var selectedOrder in SelectedOrders) { _applicationState.NotifyEvent(RuleEventNames.AutomationCommandExecuted, new { Ticket = SelectedTicket, Order = selectedOrder, AutomationCommandName = obj.Name, Value = obj.SelectedValue }); } } else { _applicationState.NotifyEvent(RuleEventNames.AutomationCommandExecuted, new { Ticket = SelectedTicket, AutomationCommandName = obj.Name, Value = obj.SelectedValue }); } _ticketOrdersViewModel.SelectedTicket = SelectedTicket; ClearSelectedItems(); ClearSelection = true; RefreshVisuals(); if (SelectedTicket != Ticket.Empty) { EventServiceFactory.EventService.PublishEvent(EventTopicNames.RefreshSelectedTicket); } } }
private void OnButtonClick(PopupData obj) { if (obj.Action != null) obj.Action(obj.ActionParameter); _popupList.Remove(obj); if (obj.Name != "") { _applicationState.NotifyEvent(RuleEventNames.PopupClicked, new { Name = obj.Name, Data = obj.ActionParameter ?? "" }); } Application.Current.MainWindow.Focus(); }
public override void Process(ActionData actionData) { var name = actionData.GetAsString("Name"); var values = actionData.GetAsString("Values"); if (!string.IsNullOrEmpty(values)) { if (!values.Contains(",") && values.StartsWith("(") && values.EndsWith(")")) { var endStr = values.Trim(new[] { '(', ')' }); int end; var start = 0; if (endStr.Contains("-")) { var parts = endStr.Split('-'); int.TryParse(parts[0], out start); int.TryParse(parts[1], out end); } else { int.TryParse(endStr, out end); } if (end > 0) { for (int i = start; i < end; i++) { _applicationState.NotifyEvent(RuleEventNames.ValueLooped, new { Name = name, Value = i.ToString() }); } } } else { foreach (var value in values.Split(',')) { _applicationState.NotifyEvent(RuleEventNames.ValueLooped, new { Name = name, Value = value }); } } } }
private void ExecuteAutomationCommand(AutomationCommand automationCommand, string selectedValue) { if (!string.IsNullOrEmpty(automationCommand.Values) && !automationCommand.ToggleValues) { automationCommand.PublishEvent(EventTopicNames.SelectAutomationCommandValue); } else { if (SelectedOrders.Any()) { foreach (var selectedOrder in SelectedOrders.ToList()) { _applicationState.NotifyEvent(RuleEventNames.AutomationCommandExecuted, new { Ticket = SelectedTicket, Order = selectedOrder, AutomationCommandName = automationCommand.Name, Value = selectedValue }); } } else { _applicationState.NotifyEvent(RuleEventNames.AutomationCommandExecuted, new { Ticket = SelectedTicket, AutomationCommandName = automationCommand.Name, Value = selectedValue }); } _ticketOrdersViewModel.SelectedTicket = SelectedTicket; ClearSelectedItems(); ClearSelection = true; RefreshVisuals(); } }
public void UpdateEntityState(int entityId, int entityTypeId, string stateName, string state) { _entityDao.UpdateEntityState(entityId, stateName, state); var rt = _cacheService.GetEntityTypeById(entityTypeId); _applicationState.NotifyEvent(RuleEventNames.EntityStateUpdated, new { EntityId = entityId, EntityTypeName = rt.Name, StateName = stateName, State = state }); }
public override void Process(ActionData actionData) { var name = actionData.GetAsString("Name"); var values = actionData.GetAsString("Values"); if (!string.IsNullOrEmpty(values)) { foreach (var value in values.Split(',')) { _applicationState.NotifyEvent(RuleEventNames.ValueLooped, new { Name = name, Value = value }); } } }
public void UpdateEntityState(int entityId, int entityTypeId, string stateName, string state, string quantityExp) { var sv = _entityDao.UpdateEntityState(entityId, stateName, state, quantityExp); var rt = _cacheService.GetEntityTypeById(entityTypeId); _applicationState.NotifyEvent(RuleEventNames.EntityStateUpdated, new { EntityId = entityId, EntityTypeName = rt.Name, StateName = stateName, State = state, Quantity = sv.GetStateQuantity(stateName) }); }
protected override void OnInitialization() { base.OnInitialization(); _automationService.Register(); EventServiceFactory.EventService.GetEvent <GenericEvent <ActionData> >().Subscribe(x => _automationService.ProcessAction(x.Value.Action.ActionType, x.Value)); EventServiceFactory.EventService.GetEvent <GenericEvent <Message> >().Subscribe(x => { if (x.Topic == EventTopicNames.MessageReceivedEvent && x.Value.Command == "ActionMessage") { _applicationState.NotifyEvent(RuleEventNames.MessageReceived, new { Command = x.Value.Data }); } }); }
private void FireEntitySelectedRule(Entity entity) { if (entity != null && entity != Entity.Null) { var entityType = _cacheService.GetEntityTypeById(entity.EntityTypeId); if (entityType != null) { _applicationState.NotifyEvent(RuleEventNames.EntitySelected, new { Ticket = SelectedTicket, EntityTypeName = entityType.Name, EntityName = entity.Name, EntityCustomData = entity.CustomData, IsTicketSelected = SelectedTicket != null }); } } }
public NavigationModule(IRegionManager regionManager, NavigationView navigationView, IUserService userService, IApplicationState applicationState) : base(regionManager, AppScreens.Navigation) { _regionManager = regionManager; _navigationView = navigationView; _userService = userService; _applicationState = applicationState; PermissionRegistry.RegisterPermission(PermissionNames.OpenNavigation, PermissionCategories.Navigation, Resources.CanOpenNavigation); EventServiceFactory.EventService.GetEvent <GenericEvent <User> >().Subscribe( x => { if (x.Topic == EventTopicNames.UserLoggedIn) { ActivateNavigation(); } }); EventServiceFactory.EventService.GetEvent <GenericEvent <EventAggregator> >().Subscribe( x => { if (x.Topic == EventTopicNames.ActivateNavigation) { ActivateNavigation(); } }); EventServiceFactory.EventService.GetEvent <GenericEvent <AppScreenChangeData> >().Subscribe( x => { if (x.Topic == EventTopicNames.Changed) { _applicationState.NotifyEvent(RuleEventNames.ApplicationScreenChanged, new { PreviousScreen = Enum.GetName(typeof(AppScreens), x.Value.PreviousScreen), CurrentScreen = Enum.GetName(typeof(AppScreens), x.Value.CurrentScreen) }); } }); }
private void OnCronTrigger(object sender, CronEventArgs e) { using (var workspace = WorkspaceFactory.Create()) { var trigger = workspace.Single <Trigger>(x => x.Id == ((Trigger)e.CronObject.Object).Id); if (trigger != null) { trigger.LastTrigger = DateTime.Now; workspace.CommitChanges(); if (_applicationState.ActiveAppScreen != AppScreens.Management) { _applicationState.NotifyEvent(RuleEventNames.TriggerExecuted, new { TriggerName = trigger.Name }); } } else { e.CronObject.Stop(); } } }
private AccountTransactionDocument CreateDocument(AccountRowViewModel accountRowViewModel) { var document = _accountService.CreateTransactionDocument(accountRowViewModel.Account, SelectedDocumentType, accountRowViewModel.Description, accountRowViewModel.Amount, accountRowViewModel.TargetAccounts.Select( y => new Account { Id = y.SelectedAccountId, AccountTypeId = y.AccountType.Id })); _applicationState.NotifyEvent(RuleEventNames.AccountTransactionDocumentCreated, new { AccountTransactionDocumentName = SelectedDocumentType.Name, DocumentId = document.Id }); return(document); }
public NavigationModule(IRegionManager regionManager, NavigationView navigationView, IUserService userService, IApplicationState applicationState) : base(regionManager, AppScreens.Navigation) { _regionManager = regionManager; _navigationView = navigationView; _userService = userService; _applicationState = applicationState; PermissionRegistry.RegisterPermission(PermissionNames.OpenNavigation, PermissionCategories.Navigation, Resources.CanOpenNavigation); EventServiceFactory.EventService.GetEvent<GenericEvent<User>>().Subscribe( x => { if (x.Topic == EventTopicNames.UserLoggedIn) ActivateNavigation(); }); EventServiceFactory.EventService.GetEvent<GenericEvent<EventAggregator>>().Subscribe( x => { if (x.Topic == EventTopicNames.ActivateNavigation) ActivateNavigation(); }); EventServiceFactory.EventService.GetEvent<GenericEvent<AppScreenChangeData>>().Subscribe( x => { if (x.Topic == EventTopicNames.Changed) { _applicationState.NotifyEvent(RuleEventNames.ApplicationScreenChanged, new { PreviousScreen = Enum.GetName(typeof(AppScreens), x.Value.PreviousScreen), CurrentScreen = Enum.GetName(typeof(AppScreens), x.Value.CurrentScreen) }); } }); }
private void PublishPhoneNumber(string phoneNumber) { if (CustomerType != null) { var sr = _entityService.SearchEntities(CustomerType, phoneNumber, ""); if (sr.Count == 1) { var entity = sr.First(); InteractionService.UserIntraction.DisplayPopup(entity.Name, entity.Name + " " + Resources.Calling + ".\r" + entity.SearchString + "\r", "DarkRed", OnClick, phoneNumber); } else { InteractionService.UserIntraction.DisplayPopup(phoneNumber, phoneNumber + " " + Resources.Calling + "...", "DarkRed", OnClick, phoneNumber); } } _applicationState.NotifyEvent(RuleEventNames.DeviceEventGenerated, new { DeviceName = Name, EventName = "CID_Event", EventData = phoneNumber }); }
public decimal GetReturningAmount(decimal tenderedAmount, decimal paymentDueAmount, ChangePaymentType changeTemplate) { var returningAmount = 0m; if (tenderedAmount > paymentDueAmount) { ReturningAmount = ""; returningAmount = (tenderedAmount - paymentDueAmount); if (changeTemplate != null) { var currency = _cacheService.GetCurrencyById(changeTemplate.Account.ForeignCurrencyId); ReturningAmount = string.Format(Resources.ChangeAmount_f, currency != null ? string.Format(currency.CurrencySymbol, returningAmount / currency.ExchangeRate) : returningAmount.ToString(LocalSettings.CurrencyFormat)); } } if (string.IsNullOrEmpty(ReturningAmount)) { ReturningAmount = string.Format(Resources.ChangeAmount_f, (returningAmount / _paymentEditor.ExchangeRate).ToString(LocalSettings.CurrencyFormat)); } if (returningAmount != 0) { _applicationState.NotifyEvent(RuleEventNames.ChangeAmountChanged, new { Ticket = _paymentEditor.SelectedTicket, TicketAmount = _paymentEditor.SelectedTicket.TotalAmount, ChangeAmount = returningAmount, TenderedAmount = tenderedAmount }); } return(returningAmount); }
public void UpdateEntity(Ticket ticket, int entityTypeId, int entityId, string entityName, int accountTypeId, int accountId, string entityCustomData) { var currentEntity = ticket.TicketEntities.SingleOrDefault(x => x.EntityTypeId == entityTypeId); var currentEntityId = currentEntity != null ? currentEntity.EntityId : 0; var newEntityName = entityName; var oldEntityName = currentEntity != null ? currentEntity.EntityName : ""; var newEntityData = entityCustomData; var oldEntityData = currentEntity != null ? currentEntity.EntityCustomData : ""; if (currentEntity != null && currentEntity.EntityId != entityId) { var entityType = _cacheService.GetEntityTypeById(currentEntity.EntityTypeId); _applicationState.NotifyEvent(RuleEventNames.EntityUpdated, new { EntityTypeId = currentEntity.EntityTypeId, EntityId = currentEntity.EntityId, EntityTypeName = entityType.Name, OpenTicketCount = GetOpenTicketCount(currentEntity.EntityId, ticket.Id) }); } ticket.UpdateEntity(entityTypeId, entityId, entityName, accountTypeId, accountId, entityCustomData); if (currentEntityId != entityId || oldEntityName != newEntityName || newEntityData != oldEntityData) { var entityType = _cacheService.GetEntityTypeById(entityTypeId); _applicationState.NotifyEvent(RuleEventNames.TicketEntityChanged, new { Ticket = ticket, EntityTypeId = entityTypeId, EntityId = entityId, EntityTypeName = entityType.Name, OldEntityName = oldEntityName, NewEntityName = newEntityName, OrderCount = ticket.Orders.Count, OldCustomData = oldEntityData, CustomData = newEntityData }); } }
private void ExecuteCommand(Task task, TaskCommand command, dynamic dataObject) { dataObject.AutomationCommandName = command.CommandName; dataObject.CommandValue = command.GetCommandValue(task); _applicationState.NotifyEvent(RuleEventNames.AutomationCommandExecuted, dataObject); }
private void OnExecuteAutomationCommand(AutomationCommandData obj) { _applicationState.NotifyEvent(RuleEventNames.AutomationCommandExecuted, new { Ticket = _paymentEditor.SelectedTicket, AutomationCommandName = obj.AutomationCommand.Name }); }