protected override void InitializeShell() { #if DEBUG // Bypass Singleton check #else if (!Mutex.WaitOne(TimeSpan.Zero, true)) { NativeWin32.PostMessage((IntPtr)NativeWin32.HWND_BROADCAST, NativeWin32.WM_SHOWSAMBAPOS, IntPtr.Zero, IntPtr.Zero); Environment.Exit(1); } #endif LocalizeDictionary.ChangeLanguage(LocalSettings.CurrentLanguage); InteractionService.UserIntraction = ServiceLocator.Current.GetInstance <IUserInteraction>(); InteractionService.UserIntraction.ToggleSplashScreen(); ServiceLocator.Current.GetInstance <IApplicationState>().MainDispatcher = Application.Current.Dispatcher; var logger = ServiceLocator.Current.GetInstance <ILogService>(); AppServices.MessagingService.RegisterMessageListener(new MessageListener()); if (LocalSettings.StartMessagingClient) { AppServices.MessagingService.StartMessagingClient(); } PresentationServices.Initialize(); base.InitializeShell(); try { GenericRuleRegistator.RegisterOnce(); var creationService = new DataCreationService(); creationService.CreateData(); } catch (Exception e) { if (!string.IsNullOrEmpty(LocalSettings.ConnectionString)) { var connectionString = InteractionService.UserIntraction.GetStringFromUser( "Connection String", string.Format(Resources.ConnectionStringError, e.Message), LocalSettings.ConnectionString); var cs = String.Join(" ", connectionString); if (!string.IsNullOrEmpty(cs)) { LocalSettings.ConnectionString = cs.Trim(); } logger.LogError(e, Resources.RestartAppError); } else { logger.LogError(e); LocalSettings.ConnectionString = ""; } LocalSettings.SaveSettings(); Environment.Exit(1); } var rm = Container.GetExportedValue <IRegionManager>(); rm.RegisterViewWithRegion("MessageRegion", typeof(WorkPeriodStatusView)); rm.RegisterViewWithRegion("MessageRegion", typeof(MessageClientStatusView)); Application.Current.MainWindow = (Shell)Shell; if (LocalizeDictionary.Instance.Culture.TextInfo.IsRightToLeft) { Application.Current.MainWindow.FlowDirection = FlowDirection.RightToLeft; } Application.Current.MainWindow.Show(); EventServiceFactory.EventService.PublishEvent(EventTopicNames.ShellInitialized); InteractionService.UserIntraction.ToggleSplashScreen(); ServiceLocator.Current.GetInstance <ITriggerService>().UpdateCronObjects(); ServiceLocator.Current.GetInstance <IApplicationState>().NotifyEvent(RuleEventNames.ApplicationStarted, new { }); }
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(); } }); }
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 }); }
protected override void InitializeShell() { #if DEBUG // Bypass Singleton check #else if (!Mutex.WaitOne(TimeSpan.Zero, true)) { NativeWin32.PostMessage((IntPtr)NativeWin32.HWND_BROADCAST, NativeWin32.WM_SHOWSAMBAPOS, IntPtr.Zero, IntPtr.Zero); Environment.Exit(1); } #endif LocalizeDictionary.ChangeLanguage(LocalSettings.CurrentLanguage); 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(); } PresentationServices.Initialize(); base.InitializeShell(); try { GenericRuleRegistator.RegisterOnce(); var creationService = new DataCreationService(); creationService.CreateData(); } catch (Exception e) { if (!string.IsNullOrEmpty(LocalSettings.ConnectionString)) { var connectionString = InteractionService.UserIntraction.GetStringFromUser( "Connection String", "Şu anki bağlantı ayarları ile veri tabanına bağlanılamıyor. Lütfen aşağıdaki bağlantı bilgisini kontrol ederek tekrar deneyiniz.\r\r" + "Hata Mesajı:\r" + e.Message, LocalSettings.ConnectionString); var cs = String.Join(" ", connectionString); if (!string.IsNullOrEmpty(cs)) { LocalSettings.ConnectionString = cs.Trim(); } AppServices.LogError(e, "Programı yeniden başlatınız. Mevcut problem log dosyasına kaydedildi."); } else { AppServices.LogError(e); LocalSettings.ConnectionString = ""; } LocalSettings.SaveSettings(); Environment.Exit(1); } var rm = Container.GetExportedValue <IRegionManager>(); rm.RegisterViewWithRegion("MessageRegion", typeof(WorkPeriodStatusView)); rm.RegisterViewWithRegion("MessageRegion", typeof(MessageClientStatusView)); Application.Current.MainWindow = (Shell)Shell; Application.Current.MainWindow.Show(); EventServiceFactory.EventService.PublishEvent(EventTopicNames.ShellInitialized); InteractionService.UserIntraction.ToggleSplashScreen(); ServiceLocator.Current.GetInstance <ITriggerService>().UpdateCronObjects(); ServiceLocator.Current.GetInstance <IAutomationService>().NotifyEvent(RuleEventNames.ApplicationStarted, new { }); }