예제 #1
0
		public OperationResult<DateTime> GetMinJournalDateTime(Guid clientUID)
		{
			using (var dbService = new DbService())
			{
				return dbService.JournalTranslator.GetMinDate();
			}
		}
예제 #2
0
		public JournalTranslator(DbService dbService)
		{
			DbService = dbService;
			Context = DbService.Context;
			JournalSynchroniser = new JounalSynchroniser(dbService);
			PassJournalSynchroniser = new PassJounalSynchroniser(dbService);
		}
예제 #3
0
		public OperationResult<List<JournalItem>> GetFilteredJournalItems(Guid clientUID, JournalFilter filter)
		{
			using (var dbService = new RubezhDAL.DataClasses.DbService())
			{
				return dbService.JournalTranslator.GetFilteredJournalItems(filter);
			}
		}
예제 #4
0
		public static void EditUser(List<byte> bytes)
		{
			var imitatorUser = ImitatorUserFromBytes(bytes);
			var packNo = BytesHelper.SubstructShort(bytes, 255);
			using (var dbService = new DbService())
			{
				dbService.ImitatorUserTraslator.Edit(imitatorUser);
			}
		}
예제 #5
0
		public UsersViewModel()
		{
			Title = "Пользователи прибора";

			using(var dbService = new DbService())
			{
				var users = dbService.ImitatorUserTraslator.Get();
				Users = new ObservableCollection<ImitatorUser>(users);
			}
		}
예제 #6
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();
			}
		}
예제 #7
0
		public SchedulesViewModel()
		{
			Title = "Графики работ прибора";

			using (var dbService = new DbService())
			{
				var schedules = dbService.ImitatorScheduleTranslator.Get();
				schedules.ForEach(x => x.ImitatorSheduleIntervals = x.ImitatorSheduleIntervals.OrderBy(y => y.StartSeconds).ToList());
				Schedules = new ObservableCollection<ImitatorSchedule>(schedules);
			}
		}
예제 #8
0
		public OperationResult<bool> BeginGetJournal(JournalFilter filter, Guid clientUid, Guid journalClientUid)
		{
			ServerTaskRunner.Add(null, "Чтение журнала событий", () =>
			{
				using (var dbService = new RubezhDAL.DataClasses.DbService())
				{
					var result = dbService.JournalTranslator.GetFilteredJournalItems(filter);
					RubezhService.NotifyOperationResult_GetJournal(result, clientUid, journalClientUid);
				}
			});
			return new OperationResult<bool>(true);
		}
예제 #9
0
		public static void AddCommonJournalItems(List<JournalItem> journalItems, Guid? clientUID)
		{
			using (var databaseService = new RubezhDAL.DataClasses.DbService())
			{
				databaseService.JournalTranslator.AddRange(journalItems);
			}
			RubezhService.NotifyJournalItems(journalItems, true);
			var user = clientUID.HasValue ? ConfigurationCashHelper.SecurityConfiguration.Users.FirstOrDefault(x => x.Login == GetLogin(clientUID.Value)) : null;
			foreach (var journalItem in journalItems)
			{
				AutomationProcessor.RunOnJournal(journalItem, user, clientUID ?? UID);
			}
		}
예제 #10
0
		public static ImitatorJournalItem GetByGKNo(int gkNo)
		{
			ImitatorJournalItem imitatorJournalItem;
			lock (lockObject)
			{
				imitatorJournalItem = ImitatorJournalItems.FirstOrDefault(x => x.GkNo == gkNo);
			}
			if (imitatorJournalItem == null)
			{
				using (var dbService = new DbService())
				{
					imitatorJournalItem = dbService.ImitatorJournalTranslator.GetByGKNo(gkNo);
				}
			}
			return imitatorJournalItem;
		}
예제 #11
0
		static JournalCash()
		{
			ImitatorJournalItems = new List<ImitatorJournalItem>();

			using (var dbService = new DbService())
			{
				Count = dbService.ImitatorJournalTranslator.GetCount();
			}

			for (int i = Math.Max(1, Count - 1000); i < Count; i++)
			{
				using (var dbService = new DbService())
				{
					var imitatorJournalItem = dbService.ImitatorJournalTranslator.GetByGKNo(i);
					if (imitatorJournalItem != null)
					{
						ImitatorJournalItems.Add(imitatorJournalItem);
					}
				}
			}
		}
예제 #12
0
		public static void EditShedule(List<byte> bytes)
		{
			var imitatorSchedule = new ImitatorSchedule();
			imitatorSchedule.No = bytes[0];
			imitatorSchedule.Name = BytesHelper.BytesToStringDescription(bytes, 1);
			imitatorSchedule.HolidayScheduleNo = bytes[33];
			imitatorSchedule.PartsCount = BytesHelper.SubstructShort(bytes, 34);
			imitatorSchedule.TotalSeconds = BytesHelper.SubstructInt(bytes, 36);
			imitatorSchedule.WorkHolidayScheduleNo = bytes[40];
			for (int i = 0; i < imitatorSchedule.PartsCount / 2; i++)
			{
				var imitatorSheduleInterval = new ImitatorSheduleInterval();
				imitatorSheduleInterval.StartSeconds = BytesHelper.SubstructInt(bytes, 48 + i * 8);
				imitatorSheduleInterval.EndSeconds = BytesHelper.SubstructInt(bytes, 52 + i * 8);
				imitatorSchedule.ImitatorSheduleIntervals.Add(imitatorSheduleInterval);
			}

			using (var dbService = new DbService())
			{
				dbService.ImitatorScheduleTranslator.AddOrEdit(imitatorSchedule);
			}
		}
예제 #13
0
		private static bool IsInSchedule(DbService dbService, int scheduleNo)
		{
			var timeSpan = DateTime.Now - new DateTime(2000, 1, 1);
			var nowTotalSeconds = timeSpan.TotalSeconds;

			var schedule = dbService.ImitatorScheduleTranslator.GetByNo(scheduleNo);
			if (schedule != null)
			{
				foreach (var imitatorSheduleInterval in schedule.ImitatorSheduleIntervals)
				{
					var delta = 0;
					if (schedule.TotalSeconds > 0)
					{
						var periodsCount = (nowTotalSeconds - imitatorSheduleInterval.StartSeconds) / schedule.TotalSeconds;
						delta = (int)periodsCount * schedule.TotalSeconds;
					}

					if (nowTotalSeconds > imitatorSheduleInterval.StartSeconds + delta ||
						nowTotalSeconds < imitatorSheduleInterval.EndSeconds + delta)
					{
						return true;
					}
				}
			}
			return false;
		}
예제 #14
0
		public GKMetadataTranslator(DbService databaseService)
		{
			Context = databaseService.Context;
		}
예제 #15
0
		public string Test(Guid clientUID, string arg)
		{
			using (var databaseService = new RubezhDAL.DataClasses.DbService())
			{
				databaseService.PassJournalTranslator.InsertPassJournalTestData();
			}
			return "Test";
		}
예제 #16
0
		public GKScheduleTranslator(DbService context)
		{
			DbService = context;
			Context = DbService.Context;
		}
예제 #17
0
		public OperationResult<int> GetArchiveCount(Guid clientUID, JournalFilter filter)
		{
			using (var dbService = new RubezhDAL.DataClasses.DbService())
			{
				return dbService.JournalTranslator.GetArchiveCount(filter);
			}
		}
예제 #18
0
		public GKCardTranslator(DbService databaseService)
		{
			Context = databaseService.Context;
		}
예제 #19
0
		public void AddJournalItem(ImitatorJournalItem journalItem)
		{
			journalItem.UNUSED_KauNo = 0;
			journalItem.UNUSED_KauAddress = 0;
			journalItem.GkObjectNo = GKBaseDescriptor.GetDescriptorNo();
			journalItem.ObjectState = StatesToInt();
			if (GKBaseDescriptor.GKBase is GKDevice)
			{
				journalItem.ObjectDeviceType = (short)(GKBaseDescriptor.GKBase as GKDevice).Driver.DriverTypeNo;
				journalItem.ObjectDeviceAddress = (short)(((GKBaseDescriptor.GKBase as GKDevice).ShleifNo - 1) * 256 + (GKBaseDescriptor.GKBase as GKDevice).IntAddress);
			}
			using (var dbService = new DbService())
			{
				dbService.ImitatorJournalTranslator.Add(journalItem);
			}
			JournalCash.Add(journalItem);
		}
		public CurrentConsumptionTranslator(DbService dbService)
		{
			DbService = dbService;
		}
예제 #21
0
		public NightSettingTranslator(DbService context)
		{
			DbService = context;
		}
예제 #22
0
		public ImitatorScheduleTranslator(DbService dbService)
		{
			DbService = dbService;
		}
예제 #23
0
		public OperationResult<bool> ResetDB(Guid clientUID)
		{
			using (var databaseService = new RubezhDAL.DataClasses.DbService())
			{
				return databaseService.ResetDB();
			}
		}
예제 #24
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();
			}
		}
예제 #25
0
		public PassJounalSynchroniser(DbService dbService)
		{
			_context = dbService.Context;
		}
		public TimeTrackDocumentTypeTranslator(DbService dbService)
		{
			Context = dbService.Context;
		}
예제 #27
0
		public OperationResult<bool> BeginGetArchivePage(JournalFilter filter, int page, Guid clientUid, string userName)
		{
			ServerTaskRunner.Add(null, "Чтение архива", () =>
			{
				using (var dbService = new RubezhDAL.DataClasses.DbService())
				{
					var result = dbService.JournalTranslator.GetArchivePage(filter, page);
					RubezhService.NotifyOperationResult_GetArchivePage(result, clientUid, userName);
				}
			});
			return new OperationResult<bool>(true);
		}
예제 #28
0
		static Tuple<ImitatorUser, bool> GetUserAccess(uint currentCardNo, FormulaOperation formulaOperation, DescriptorViewModel descriptorViewModel)
		{
			var isAccess = false;
			var level = formulaOperation.FirstOperand;
			ImitatorUser user = null;
			var device = descriptorViewModel.GKBase as GKDevice;
			if (device != null && (device.Driver.IsCardReaderOrCodeReader))
			{
				using (var dbService = new DbService())
				{
					user = dbService.ImitatorUserTraslator.GetByNo(currentCardNo);
					if (user != null)
					{
						if (user.Level >= level)
						{
							if (IsInSchedule(dbService, user.ScheduleNo))
								isAccess = true;
						}
						foreach (var imitatorUserDevice in user.ImitatorUserDevices)
						{
							if (imitatorUserDevice.DescriptorNo == formulaOperation.SecondOperand)
							{
								if (IsInSchedule(dbService, imitatorUserDevice.ScheduleNo))
									isAccess = true;
							}
						}
					}
				}
			}
			return new Tuple<ImitatorUser, bool>(user, isAccess);
		}
예제 #29
0
		public TimeTrackDocumentTranslator(DbService databaseService)
		{
			Context = databaseService.Context;
		}
예제 #30
0
		public ImitatorUserTraslator(DbService dbService)
		{
			DbService = dbService;
		}