Beispiel #1
0
		public static void Run()
		{
			try
			{
				Notifier.SetNotifier(new RubezhNotifier());
				Environment.CurrentDirectory = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
				ServiceBootstrapper.Run();
				Logger.Trace(SystemInfo.GetString());

				RubezhService.Service.RubezhService.ServerState = ServerState.Starting;
				LogPresenter.AddLog("Проверка лицензии");
				if (!RubezhLicenseProcessor.TryLoadLicense())
					LogPresenter.AddLog("Ошибка лицензии", true);
				LicensePresenter.Initialize();

				LogPresenter.AddLog("Проверка соединения с БД");
				using (var dbService = new DbService())
				{
					if (dbService.CheckConnection().HasError)
						LogPresenter.AddLog("Ошибка соединения с БД", true);
				}

				LogPresenter.AddLog("Загрузка конфигурации");
				ConfigurationCashHelper.Update();

				if (UACHelper.IsAdministrator)
				{
					LogPresenter.AddLog("Открытие хоста");
					RubezhServiceManager.Open(false);

					GKProcessor.Create();
					LogPresenter.AddLog("Запуск ГК");
					GKPresenter.Initialize();
					GKProcessor.Start();

					AutomationProcessor.Start();
					ScheduleRunner.Start();
					ServerTaskRunner.Start();
					AutomationProcessor.RunOnApplicationRun();
					ClientsManager.StartRemoveInactiveClients(TimeSpan.FromDays(1));
					LogPresenter.AddLog("Готово");
				}
				else
					LogPresenter.AddLog("Для запуска сервера требуются права администратора", true);

				RubezhService.Service.RubezhService.ServerState = ServerState.Ready;

			}
			catch (Exception e)
			{
				Logger.Error(e, "Исключение при вызове Bootstrapper.Run");
				LogPresenter.AddLog("Ошибка при запуске сервера", true);
				Close();
			}
		}
Beispiel #2
0
		public static void Run()
		{
			try
			{
				Notifier.SetNotifier(new RubezhNotifier());
				ServiceBootstrapper.Run();
				Environment.CurrentDirectory = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
				Logger.Trace(SystemInfo.GetString());

				Service.RubezhService.ServerState = ServerState.Starting;

				UILogger.Log("Проверка лицензии");
				if (!RubezhLicenseProcessor.TryLoadLicense())
					UILogger.Log("Ошибка лицензии", true);

				UILogger.Log("Проверка соединения с БД");
				using (var dbService = new DbService())
				{
					if (dbService.CheckConnection().HasError)
						UILogger.Log("Ошибка соединения с БД", true);
				}

				UILogger.Log("Загрузка конфигурации");
				ConfigurationCashHelper.Update();

				UILogger.Log("Открытие хоста");
				RubezhServiceManager.Open();
				//ServerLoadHelper.SetStatus(FSServerState.Opened);

				OpcDaHelper.Initialize(ConfigurationCashHelper.SystemConfiguration.AutomationConfiguration.OpcDaTsServers, ReadTagValue, WriteTagValue);

				GKProcessor.Create();
				UILogger.Log("Запуск ГК");
				GKProcessor.Start();

				UILogger.Log("Запуск сервиса отчетов");
				/*if (ReportServiceManager.Run())
				{
					UILogger.Log("Сервис отчетов запущен: " + ConnectionSettingsManager.ReportServerAddress);
					MainView.Current.SetReportAddress(ConnectionSettingsManager.ReportServerAddress);
				}
				else
				{
					UILogger.Log("Ошибка при запуске сервиса отчетов", true);
					MainView.Current.SetReportAddress("<Ошибка>");
				}*/

				AutomationProcessor.Start();
				ScheduleRunner.Start();
				ServerTaskRunner.Start();
				AutomationProcessor.RunOnApplicationRun();
				ClientsManager.StartRemoveInactiveClients(TimeSpan.FromDays(1));
				UILogger.Log("Запуск OPC DA");
				OpcDaServersProcessor.Start();
				UILogger.Log("Готово");

				Service.RubezhService.ServerState = ServerState.Ready;
			}
			catch (Exception e)
			{
				Logger.Error(e, "Исключение при вызове Bootstrapper.Run");
				UILogger.Log("Ошибка при запуске сервера", true);
				Close();
			}
		}
Beispiel #3
0
		public static void Run()
		{
			try
			{
				Notifier.SetNotifier(new RubezhNotifier());
				ServiceBootstrapper.Run();

				Environment.CurrentDirectory = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
				Logger.Trace(SystemInfo.GetString());
				ServiceFactoryBase.ResourceService.AddResource(typeof(Bootstrapper).Assembly, "DataTemplates/Dictionary.xaml");
				ServiceFactoryBase.ResourceService.AddResource(typeof(ApplicationService).Assembly, "Windows/DataTemplates/Dictionary.xaml");
				WindowThread = new Thread(new ThreadStart(OnWorkThread));
				WindowThread.Name = "Main window";
				WindowThread.Priority = ThreadPriority.Highest;
				WindowThread.SetApartmentState(ApartmentState.STA);
				WindowThread.IsBackground = true;
				WindowThread.Start();
				MainViewStartedEvent.WaitOne();

				RubezhService.Service.RubezhService.ServerState = ServerState.Starting;

				UILogger.Log("Проверка лицензии");
				if (!RubezhLicenseProcessor.TryLoadLicense())
					UILogger.Log("Ошибка лицензии", true);

				UILogger.Log("Проверка соединения с БД");
				using (var dbService = new DbService())
				{
					if (dbService.CheckConnection().HasError)
						UILogger.Log("Ошибка соединения с БД", true);
				}

				UILogger.Log("Загрузка конфигурации");
				ConfigurationCashHelper.Update();

				UILogger.Log("Открытие хоста");
				RubezhServiceManager.Open();
				ServerLoadHelper.SetStatus(FSServerState.Opened);

				OpcDaHelper.Initialize(ConfigurationCashHelper.SystemConfiguration.AutomationConfiguration.OpcDaTsServers, ReadTagValue, WriteTagValue);

				GKProcessor.Create();
				UILogger.Log("Запуск ГК");
				GKProcessor.Start();

				UILogger.Log("Запуск сервиса отчетов");
				if (ReportServiceManager.Run())
				{
					UILogger.Log("Сервис отчетов запущен: " + ConnectionSettingsManager.ReportServerAddress);
					MainViewModel.SetReportAddress(ConnectionSettingsManager.ReportServerAddress);
				}
				else
				{
					UILogger.Log("Ошибка при запуске сервиса отчетов", true);
					MainViewModel.SetReportAddress("<Ошибка>");
				}

				AutomationProcessor.Start();
				RviProcessor.Start();
				ScheduleRunner.Start();
				ServerTaskRunner.Start();
				AutomationProcessor.RunOnApplicationRun();
				ClientsManager.StartRemoveInactiveClients(TimeSpan.FromDays(1));
				UILogger.Log("Запуск OPC DA");
				OpcDaServersProcessor.Start();
				UILogger.Log("Готово");
				RubezhService.Service.RubezhService.ServerState = ServerState.Ready;
				ApplicationService.Closing += ApplicationService_Closing;
			}
			catch (Exception e)
			{
				Logger.Error(e, "Исключение при вызове Bootstrapper.Run");
				UILogger.Log("Ошибка при запуске сервера", true);
				Close();
			}
		}