protected override void InitializeShell() { try { if (!Bootstrapper.Mutex.WaitOne(TimeSpan.Zero, true))//&& !LocalSettings.AllowMultipleClients { NativeWin32.PostMessage((IntPtr)65535, NativeWin32.WM_SHOWSAMBAPOS, IntPtr.Zero, IntPtr.Zero); Environment.Exit(1); } } catch (AbandonedMutexException) { } Application.Current.ShutdownMode = ShutdownMode.OnMainWindowClose; ServicePointManager.Expect100Continue = false; base.InitializeShell(); Application.Current.MainWindow = (Shell)Shell; Application.Current.MainWindow.Show(); //激活窗体 //Application.Current.MainWindow.Activate(); }
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 Application.Current.ShutdownMode = ShutdownMode.OnMainWindowClose; System.Net.ServicePointManager.Expect100Continue = false; 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>(); var messagingService = ServiceLocator.Current.GetInstance <IMessagingService>(); messagingService.RegisterMessageListener(new MessageListener()); if (LocalSettings.StartMessagingClient) { messagingService.StartMessagingClient(); } 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", 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; } ServiceLocator.Current.GetInstance <ITriggerService>().UpdateCronObjects(); ServiceLocator.Current.GetInstance <IDeviceService>().InitializeDevices(); InteractionService.UserIntraction.ToggleSplashScreen(); EntityCollectionSortManager.Load(LocalSettings.DocumentPath + "\\CollectionSort.txt"); Application.Current.MainWindow.Show(); EventServiceFactory.EventService.PublishEvent(EventTopicNames.ShellInitialized); Mouse.UpdateCursor(); }
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 { }); }