Esempio n. 1
0
        public MainWindowViewModel()
        {
            LocalizeDictionary.ChangeLanguage(LocalSettings.CurrentLanguage);
            LocalSettings.SetTraceLogPath("term");

            LocalSettings.DefaultCurrencyFormat = "#,#0.00";
            LocalSettings.AppPath = System.IO.Path.GetDirectoryName(Application.ResourceAssembly.Location);
            AppServices.MainDispatcher = Application.Current.Dispatcher;
            GenericRuleRegistator.RegisterOnce();
            TriggerService.UpdateCronObjects();

            LoggedInUserViewModel = new LoggedInUserViewModel();
            LoggedInUserViewModel.CloseButtonClickedEvent += LoggedInUserViewModelCloseButtonClickedEvent;

            LoginViewModel = new LoginViewModel();
            LoginViewModel.PinSubmitted += LoginViewModelPinSubmitted;

            TableScreenViewModel = new TableScreenViewModel();
            TableScreenViewModel.TableSelectedEvent += TableScreenViewModelTableSelectedEvent;

            TicketScreenViewModel = new TicketScreenViewModel();
            TicketScreenViewModel.TicketSelectedEvent += TicketScreenViewModelTicketSelectedEvent;

            DepartmentSelectorViewModel = new DepartmentSelectorViewModel();
            DepartmentSelectorViewModel.DepartmentSelected += DepartmentSelectorViewModelDepartmentSelected;

            TicketEditorViewModel = new TicketEditorViewModel();
            TicketEditorViewModel.OnAddMenuItemsRequested += TicketEditorViewModel_OnAddMenuItemsRequested;
            TicketEditorViewModel.OnCloseTicketRequested += TicketEditorViewModel_OnCloseTicketRequested;
            TicketEditorViewModel.OnSelectTableRequested += TicketEditorViewModel_OnSelectTableRequested;
            TicketEditorViewModel.OnTicketNoteEditorRequested += TicketEditorViewModel_OnTicketNoteEditorRequested;
            TicketEditorViewModel.OnTicketTagEditorRequested += TicketEditorViewModel_OnTicketTagEditorRequested;

            MenuItemSelectorViewModel = new MenuItemSelectorViewModel();
            MenuItemSelectorViewModel.OnTicketItemSelected += MenuItemSelectorViewModel_OnTicketItemSelected;

            SelectedTicketItemEditorViewModel = new SelectedTicketItemEditorViewModel();
            SelectedTicketItemEditorViewModel.TagUpdated += SelectedTicketItemEditorViewModelTagUpdated;

            PermissionRegistry.RegisterPermission(PermissionNames.AddItemsToLockedTickets, PermissionCategories.Ticket, "Kilitli adisyona ekleme yapabilir");
            PermissionRegistry.RegisterPermission(PermissionNames.GiftItems, PermissionCategories.Ticket, "İkram yapabilir");
            PermissionRegistry.RegisterPermission(PermissionNames.VoidItems, PermissionCategories.Ticket, "İade alabilir");
            PermissionRegistry.RegisterPermission(PermissionNames.MoveTicketItems, PermissionCategories.Ticket, "Adisyon satırlarını taşıyabilir");
            PermissionRegistry.RegisterPermission(PermissionNames.MoveUnlockedTicketItems, PermissionCategories.Ticket, "Kilitlenmemiş adisyon satırlarını taşıyabilir");
            PermissionRegistry.RegisterPermission(PermissionNames.ChangeExtraProperty, PermissionCategories.Ticket, "Ekstra özellik girebilir");

            AppServices.MessagingService.RegisterMessageListener(new MessageListener());
            if (LocalSettings.StartMessagingClient)
                AppServices.MessagingService.StartMessagingClient();

            EventServiceFactory.EventService.GetEvent<GenericEvent<Message>>().Subscribe(
                x =>
                {
                    if (SelectedIndex == 2 && x.Topic == EventTopicNames.MessageReceivedEvent
                        && x.Value.Command == Messages.TicketRefreshMessage)
                    {
                        TableScreenViewModel.Refresh();
                    }
                });
        }
Esempio n. 2
0
        void LoginViewModelPinSubmitted(object sender, string pinValue)
        {
            if (pinValue == "065058")
            {
                Application.Current.Shutdown();
            }

            var user = AppServices.LoginUser(pinValue);

            LoggedInUserViewModel.Refresh();
            if (user != User.Nobody)
            {
                if (user.UserRole.DepartmentId != 0 && !AppServices.IsUserPermittedFor(PermissionNames.ChangeDepartment))
                {
                    AppServices.MainDataContext.SelectedDepartment =
                        AppServices.MainDataContext.Departments.Single(x => x.Id == user.UserRole.DepartmentId);
                    ActivateTableView();
                }
                else if (AppServices.MainDataContext.PermittedDepartments.Count() == 1)
                {
                    AppServices.MainDataContext.SelectedDepartment =
                        AppServices.MainDataContext.PermittedDepartments.First();
                    ActivateTableView();
                }
                else
                {
                    ActivateDepartmentSelector();
                }
            }
            TicketEditorViewModel.ResetCache();
        }
Esempio n. 3
0
 void DepartmentSelectorViewModelDepartmentSelected(object sender, EventArgs e)
 {
     AppServices.MainDataContext.SelectedTableScreen = null;
     AppServices.MainDataContext.SelectedDepartment  =
         DepartmentSelectorViewModel.SelectedDepartment;
     TicketEditorViewModel.ResetCache();
     ActivateTableView();
 }
Esempio n. 4
0
 private void ActivateTicketView(Table table)
 {
     if (table != null)
     {
         DataContext.UpdateSelectedTicket(table);
         if (table.TicketId == 0)
         {
             ActivateMenuItemSelector();
             return;
         }
     }
     LoggedInUserViewModel.Refresh();
     TicketEditorViewModel.Refresh();
     SelectedIndex = 3;
 }
Esempio n. 5
0
        public MainWindowViewModel()
        {
            //TODO: Para birimi servisinden al.

            LocalizeDictionary.ChangeLanguage(LocalSettings.CurrentLanguage);
            LocalSettings.SetTraceLogPath("term");

            LocalSettings.DefaultCurrencyFormat = "#,#0.00";
            LocalSettings.AppPath      = System.IO.Path.GetDirectoryName(Application.ResourceAssembly.Location);
            AppServices.MainDispatcher = Application.Current.Dispatcher;
            GenericRuleRegistator.RegisterOnce();
            TriggerService.UpdateCronObjects();

            LoggedInUserViewModel = new LoggedInUserViewModel();
            LoggedInUserViewModel.CloseButtonClickedEvent += LoggedInUserViewModelCloseButtonClickedEvent;

            LoginViewModel = new LoginViewModel();
            LoginViewModel.PinSubmitted += LoginViewModelPinSubmitted;

            TableScreenViewModel = new TableScreenViewModel();
            TableScreenViewModel.TableSelectedEvent += TableScreenViewModelTableSelectedEvent;

            TicketScreenViewModel = new TicketScreenViewModel();
            TicketScreenViewModel.TicketSelectedEvent += TicketScreenViewModelTicketSelectedEvent;

            DepartmentSelectorViewModel = new DepartmentSelectorViewModel();
            DepartmentSelectorViewModel.DepartmentSelected += DepartmentSelectorViewModelDepartmentSelected;

            TicketEditorViewModel = new TicketEditorViewModel();
            TicketEditorViewModel.OnAddMenuItemsRequested     += TicketEditorViewModel_OnAddMenuItemsRequested;
            TicketEditorViewModel.OnCloseTicketRequested      += TicketEditorViewModel_OnCloseTicketRequested;
            TicketEditorViewModel.OnSelectTableRequested      += TicketEditorViewModel_OnSelectTableRequested;
            TicketEditorViewModel.OnTicketNoteEditorRequested += TicketEditorViewModel_OnTicketNoteEditorRequested;
            TicketEditorViewModel.OnTicketTagEditorRequested  += TicketEditorViewModel_OnTicketTagEditorRequested;

            MenuItemSelectorViewModel = new MenuItemSelectorViewModel();
            MenuItemSelectorViewModel.OnTicketItemSelected += MenuItemSelectorViewModel_OnTicketItemSelected;

            SelectedTicketItemEditorViewModel             = new SelectedTicketItemEditorViewModel();
            SelectedTicketItemEditorViewModel.TagUpdated += SelectedTicketItemEditorViewModelTagUpdated;

            PermissionRegistry.RegisterPermission(PermissionNames.AddItemsToLockedTickets, PermissionCategories.Ticket, "Kilitli adisyona ekleme yapabilir");
            PermissionRegistry.RegisterPermission(PermissionNames.GiftItems, PermissionCategories.Ticket, "İkram yapabilir");
            PermissionRegistry.RegisterPermission(PermissionNames.VoidItems, PermissionCategories.Ticket, "İade alabilir");
            PermissionRegistry.RegisterPermission(PermissionNames.MoveTicketItems, PermissionCategories.Ticket, "Adisyon satırlarını taşıyabilir");
            PermissionRegistry.RegisterPermission(PermissionNames.MoveUnlockedTicketItems, PermissionCategories.Ticket, "Kilitlenmemiş adisyon satırlarını taşıyabilir");
            PermissionRegistry.RegisterPermission(PermissionNames.ChangeExtraProperty, PermissionCategories.Ticket, "Ekstra özellik girebilir");

            AppServices.MessagingService.RegisterMessageListener(new MessageListener());
            if (LocalSettings.StartMessagingClient)
            {
                AppServices.MessagingService.StartMessagingClient();
            }

            EventServiceFactory.EventService.GetEvent <GenericEvent <Message> >().Subscribe(
                x =>
            {
                if (SelectedIndex == 2 && x.Topic == EventTopicNames.MessageReceivedEvent &&
                    x.Value.Command == Messages.TicketRefreshMessage)
                {
                    TableScreenViewModel.Refresh();
                }
            });
        }