private static void ResetCache()
 {
     TriggerService.UpdateCronObjects();
     AppServices.ResetCache();
     AppServices.MainDataContext.SelectedDepartment.PublishEvent(EventTopicNames.SelectedDepartmentChanged);
     CommandManager.InvalidateRequerySuggested();
 }
Example #2
0
        protected override void InitializeShell()
        {
            LocalizeDictionary.ChangeLanguage(LocalSettings.CurrentLanguage);

            LocalSettings.SetTraceLogPath("app");
            InteractionService.UserIntraction = ServiceLocator.Current.GetInstance <IUserInteraction>();
            InteractionService.UserIntraction.ToggleSplashScreen();

            AppServices.MainDispatcher = Application.Current.Dispatcher;

            AppServices.MessagingService.RegisterMessageListener(new MessageListener());

            if (LocalSettings.StartMessagingClient)
            {
                AppServices.MessagingService.StartMessagingClient();
            }

            GenericRuleRegistator.RegisterOnce();

            PresentationServices.Initialize();

            base.InitializeShell();

            try
            {
                var creationService = new DataCreationService();
                creationService.CreateData();
            }
            catch (Exception e)
            {
                if (!string.IsNullOrEmpty(LocalSettings.ConnectionString))
                {
                    var connectionString =
                        InteractionService.UserIntraction.GetStringFromUser(
                            "Connection String",
                            Resources.DatabaseErrorMessage + e.Message,
                            LocalSettings.ConnectionString);

                    var cs = String.Join(" ", connectionString);

                    if (!string.IsNullOrEmpty(cs))
                    {
                        LocalSettings.ConnectionString = cs.Trim();
                    }

                    AppServices.LogError(e, Resources.CurrentErrorLoggedMessage);
                }
                else
                {
                    AppServices.LogError(e);
                    LocalSettings.ConnectionString = "";
                }
                LocalSettings.SaveSettings();
                Environment.Exit(1);
            }

            if (string.IsNullOrEmpty(LocalSettings.MajorCurrencyName))
            {
                LocalSettings.MajorCurrencyName    = Resources.Dollar;
                LocalSettings.MinorCurrencyName    = Resources.Cent;
                LocalSettings.PluralCurrencySuffix = Resources.PluralCurrencySuffix;
            }

            Application.Current.MainWindow = (Shell)Shell;
            Application.Current.MainWindow.Show();
            InteractionService.UserIntraction.ToggleSplashScreen();
            TriggerService.UpdateCronObjects();

            RuleExecutor.NotifyEvent(RuleEventNames.ApplicationStarted, new { CommandLineArguments = LocalSettings.StartupArguments });
        }
Example #3
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();
                }
            });
        }