public SKDZoneSelectationViewModel(GKSKDZone zone)
		{
			Title = "Выбор зоны";
			Zones = new ObservableCollection<GKSKDZone>(GKManager.SKDZones);
			if (zone != null)
				SelectedZone = Zones.FirstOrDefault(x => x.UID == zone.UID);
		}
示例#2
0
		public SKDZoneViewModel(GKSKDZone skdZone)
		{
			OpenCommand = new RelayCommand(OnOpen, CanControl);
			CloseCommand = new RelayCommand(OnClose, CanControl);
			ShowOnPlanCommand = new RelayCommand(OnShowOnPlan, CanShowOnPlan);
			ShowJournalCommand = new RelayCommand(OnShowJournal);
			ShowPropertiesCommand = new RelayCommand(OnShowProperties);
			ShowOnPlanOrPropertiesCommand = new RelayCommand(OnShowOnPlanOrProperties);

			SKDZone = skdZone;
			State.StateChanged += OnStateChanged;
			OnStateChanged();

			EnterDoors = new ObservableCollection<GKDoor>();
			ExitDoors = new ObservableCollection<GKDoor>();
			foreach (var door in GKManager.Doors)
			{
				if (door.EnterZoneUID == skdZone.UID)
				{
					EnterDoors.Add(door);
				}
				if (door.ExitZoneUID == skdZone.UID)
				{
					ExitDoors.Add(door);
				}
			}
		}
		public SKDZoneDetailsViewModel(GKSKDZone zone = null)
		{
			if (zone == null)
			{
				Title = "Создание новой зоны";
				Zone = new GKSKDZone()
				{
					Name = "Новая зона",
					No = 1,
				};
				if (GKManager.SKDZones.Count != 0)
					Zone.No = (GKManager.SKDZones.Select(x => x.No).Max() + 1);
			}
			else
			{
				Title = string.Format("Свойства зоны: {0}", zone.Name);
				Zone = zone;
			}
			CopyProperties();

			var availableNames = new HashSet<string>();
			var availableDescriptions = new HashSet<string>();
			foreach (var existingSKDZone in GKManager.SKDZones)
			{
				availableNames.Add(existingSKDZone.Name);
				availableDescriptions.Add(existingSKDZone.Description);
			}
			AvailableNames = new ObservableCollection<string>(availableNames);
			AvailableDescriptions = new ObservableCollection<string>(availableDescriptions);
		}
示例#4
0
		public void TestTwoWayHasNoDevices()
		{
			var enterDevice = AddDevice(kauDevice11, GKDriverType.RSR2_CardReader);
			var exitDevice = AddDevice(kauDevice11, GKDriverType.RSR2_CodeReader);
			var lockDevice = AddDevice(kauDevice11, GKDriverType.RSR2_RM_1);
			var lockControlDevice = AddDevice(kauDevice11, GKDriverType.RSR2_AM_1);
			var zone1 = new GKSKDZone();
			GKManager.SKDZones.Add(zone1);
			var zone2 = new GKSKDZone();
			GKManager.SKDZones.Add(zone2);
			var door = new GKDoor
			{
				DoorType = GKDoorType.TwoWay,
				EnterDeviceUID = enterDevice.UID,
				ExitDeviceUID = exitDevice.UID,
				LockDeviceUID = lockDevice.UID,
				LockControlDeviceUID = lockControlDevice.UID,
				EnterZoneUID = zone1.UID,
				ExitZoneUID = zone2.UID
			};
			GKManager.Doors.Clear();
			GKManager.Doors.Add(door);
			var errors = Validate();
			Assert.IsFalse(errors.Any(x => x.ErrorLevel == ValidationErrorLevel.CannotWrite && x.Error == "К точке доступа не подключено устройство на вход"));
			door.EnterDeviceUID = Guid.Empty;
			errors = Validate();
			Assert.IsTrue(errors.Any(x => x.ErrorLevel == ValidationErrorLevel.CannotWrite && x.Error == "К точке доступа не подключено устройство на вход"));

			Assert.IsFalse(errors.Any(x => x.ErrorLevel == ValidationErrorLevel.CannotWrite && x.Error == "К точке доступа не подключено устройство на выход"));
			door.ExitDeviceUID = Guid.Empty;
			errors = Validate();
			Assert.IsTrue(errors.Any(x => x.ErrorLevel == ValidationErrorLevel.CannotWrite && x.Error == "К точке доступа не подключено устройство на выход"));

			Assert.IsFalse(errors.Any(x => x.ErrorLevel == ValidationErrorLevel.CannotWrite && x.Error == "К точке доступа не подключен замок"));
			door.LockDeviceUID = Guid.Empty;
			errors = Validate();
			Assert.IsTrue(errors.Any(x => x.ErrorLevel == ValidationErrorLevel.CannotWrite && x.Error == "К точке доступа не подключен замок"));

			door.AntipassbackOn = true;
			errors = Validate();

			Assert.IsFalse(errors.Any(x => x.ErrorLevel == ValidationErrorLevel.CannotWrite && x.Error == "При включенном Antipassback, отсутствует датчик контроля двери"));
			door.LockControlDeviceUID = Guid.Empty;
			errors = Validate();
			Assert.IsTrue(errors.Any(x => x.ErrorLevel == ValidationErrorLevel.CannotWrite && x.Error == "При включенном Antipassback, отсутствует датчик контроля двери"));

			Assert.IsFalse(errors.Any(x => x.ErrorLevel == ValidationErrorLevel.CannotWrite && x.Error == "При включенном Antipassback, отсутствует зона на вход"));
			door.EnterZoneUID = Guid.Empty;
			errors = Validate();
			Assert.IsTrue(errors.Any(x => x.ErrorLevel == ValidationErrorLevel.CannotWrite && x.Error == "При включенном Antipassback, отсутствует зона на вход"));

			Assert.IsFalse(errors.Any(x => x.ErrorLevel == ValidationErrorLevel.CannotWrite && x.Error == "При включенном Antipassback, отсутствует зона на выход"));
			door.ExitZoneUID = Guid.Empty;
			errors = Validate();
			Assert.IsTrue(errors.Any(x => x.ErrorLevel == ValidationErrorLevel.CannotWrite && x.Error == "При включенном Antipassback, отсутствует зона на выход"));
		}
示例#5
0
		public SKDZoneViewModel(GKSKDZone zone)
		{
			ManageOutputDoorsCommand = new RelayCommand(OnManageOutputDoors);
			ManageInputDoorsCommand = new RelayCommand(OnManageInputDoors);
			ShowOnPlanCommand = new RelayCommand(OnShowOnPlan);

			OutputDoors = new ObservableCollection<DoorSkdZoneViewModel>();
			InputDoors = new ObservableCollection<DoorSkdZoneViewModel>();
			Zone = zone;
			zone.PlanElementUIDsChanged += UpdateVisualizationState;
			Update();
		}
		public SKDZoneDetailsViewModel(GKSKDZone zone)
		{
			ShowCommand = new RelayCommand(OnShow);
			ShowJournalCommand = new RelayCommand(OnShowJournal);
			OpenCommand = new RelayCommand(OnOpen);
			CloseCommand = new RelayCommand(OnClose);

			Zone = zone;
			Title = Zone.PresentationName;
			State.StateChanged += new Action(OnStateChanged);
			PlanLinks = new PlanLinksViewModel(Zone);
		}
		public TimeTrackZone(GKSKDZone zone)
		{
			GKSKDZone = zone;
			UID = zone.UID;
			Name = zone.PresentationName;
			Description = zone.Description;
		}
示例#8
0
		public void GKCloseSKDZone(GKSKDZone zone)
		{
			SafeOperationCall(() =>
			{
				var rubezhService = RubezhServiceFactory.Create(TimeSpan.FromMinutes(10));
				using (rubezhService as IDisposable)
					rubezhService.GKCloseSKDZone(RubezhServiceFactory.UID, zone.UID);
			}, "GKCloseSKDZone");
		}
		GKDoor CreateDoor(GKDeviceConfiguration deviceConfiguration, string name, int no, GKSKDZone enterZone, GKSKDZone exitZone)
		{
			var cardReaderDevice = CreateCardReader();
			var alsDevice = deviceConfiguration.Devices.FirstOrDefault(x => x.DriverType == GKDriverType.RSR2_KAU_Shleif);
			var am1Device = CreateAm1(alsDevice);
			var logic = CreateLogic(am1Device);

			var door = new GKDoor
			{
				Name = "Точка доступа",
				No = 1,
				OpenRegimeLogic = logic,
				CloseRegimeLogic = logic,
				NormRegimeLogic = logic,
				EnterZoneUID = enterZone.UID,
				ExitZoneUID = exitZone.UID,
				EnterDevice = cardReaderDevice,
				EnterDeviceUID = cardReaderDevice.UID,
				ExitDevice = cardReaderDevice,
				ExitDeviceUID = cardReaderDevice.UID
			};
			return door;
		}
示例#10
0
		GKSKDZone CreateSKDZone(GKDeviceConfiguration deviceConfiguration, string name, int no, Guid uid)
		{
			var cardReader = CreateCardReader();
			var skdZone = new GKSKDZone
			{
				Name = name,
				No = no,
				UID = uid
			};
			deviceConfiguration.SKDZones.Add(skdZone);
			return skdZone;
		}
示例#11
0
		public static void RemoveSKDZone(GKSKDZone zone)
		{
			SKDZones.Remove(zone);
			zone.OnChanged();
		}
示例#12
0
		public CommonZoneViewModel(GKSKDZone gkZone)
		{
			UID = gkZone.UID;
			Name = gkZone.Name;
			Description = gkZone.Description;
		}
示例#13
0
		public void TestAntipassback4()
		{
			var cardReader1 = AddDevice(kauDevice1, GKDriverType.RSR2_CardReader);
			var cardReader2 = AddDevice(kauDevice1, GKDriverType.RSR2_CardReader);
			var am1 = AddDevice(kauDevice1, GKDriverType.RSR2_AM_1);
			var am2 = AddDevice(kauDevice1, GKDriverType.RSR2_AM_1);
			var am3 = AddDevice(kauDevice1, GKDriverType.RSR2_AM_1);
			var am4 = AddDevice(kauDevice1, GKDriverType.RSR2_AM_1);
			var rm1 = AddDevice(kauDevice1, GKDriverType.RSR2_RM_1);
			var rm2 = AddDevice(kauDevice1, GKDriverType.RSR2_RM_1);
			var zone1 = new GKSKDZone();
			GKManager.SKDZones.Add(zone1);
			var zone2 = new GKSKDZone();
			GKManager.SKDZones.Add(zone2);
			var door = new GKDoor()
			{
				DoorType = GKDoorType.AirlockBooth,
				AntipassbackOn = true,
				EnterDeviceUID = cardReader1.UID,
				ExitDeviceUID = cardReader2.UID,
				LockDeviceUID = rm1.UID,
				LockDeviceExitUID = rm2.UID,
				LockControlDeviceUID = am1.UID,
				LockControlDeviceExitUID = am2.UID,
				EnterButtonUID = am3.UID,
				ExitButtonUID = am4.UID,
				EnterZoneUID = zone1.UID,
				ExitZoneUID = zone2.UID
			};
			GKManager.Doors.Add(door);
			Compile();
		}
示例#14
0
		/// <summary>
		/// Валидация того, что номер зоны не превышает 255
		/// </summary>
		/// <param name="zone"></param>
		void ValidateSKDZoneMaxNo(GKSKDZone zone)
		{
			if (zone.No > 255)
				AddError(zone, "Номер зоны не должен превышать 255", ValidationErrorLevel.CannotWrite);
		}
示例#15
0
		public static void GKCloseSKDZone(GKSKDZone zone)
		{
			foreach (var door in GKManager.Doors)
			{
				if (door.EnterZoneUID == zone.UID)
				{
					AddGKMessage(JournalEventNameType.Закрытие_зоны_СКД, JournalEventDescriptionType.NULL, "", zone, null);
					Watcher.SendControlCommand(door, GKStateBit.TurnOff_InAutomatic, "Выключить в автоматике");
				}
			}
		}
示例#16
0
		public static void CalculateSKDZone(GKSKDZone zone)
		{
			var stateClasses = new HashSet<XStateClass>();
			zone.State = new GKState(zone);
			foreach (var door in GKManager.Doors)
			{
				if (door.EnterZoneUID == zone.UID || door.ExitZoneUID == zone.UID)
				{
					foreach (var stateClass in door.State.StateClasses)
					{
						stateClasses.Add(stateClass);
					}
				}
			}
			zone.State.StateClasses = stateClasses.ToList();
			zone.State.StateClass = GKStatesHelper.GetMinStateClass(zone.State.StateClasses);
		}
示例#17
0
		public GKState(GKSKDZone zone)
			: this()
		{
			SKDZone = zone;
			UID = zone.UID;
			BaseObjectType = GKBaseObjectType.SKDZone;
		}
示例#18
0
		private void OnShowZone(GKSKDZone zone)
		{
			if (zone != null)
				ServiceFactory.Events.GetEvent<ShowGKSKDZoneEvent>().Publish(zone.UID);
		}
示例#19
0
		public static void EditSKDZone(GKSKDZone zone)
		{
			zone.OnChanged();
		}
示例#20
0
		public GKSKDZoneState(GKSKDZone zone)
			: this()
		{
			Zone = zone;
			UID = zone.UID;
		}
		public SelectationScheduleZoneViewModel(GKSKDZone zone, Schedule schedule, Guid doorUID)
		{
			DoorUID = doorUID;
			ZoneUID = zone.UID;
			Name = zone.Name;
			No = zone.No;
			ScheduleUID = schedule.UID;
			Description = zone.Description;
			IsChecked = schedule.Zones.Any(x => x.ZoneUID == zone.UID);
		}
示例#22
0
		public ObjectViewModel(GKSKDZone skdZone)
		{
			SKDZone = skdZone;
			Name = skdZone.PresentationName;
			ImageSource = skdZone.ImageSource;
			Address = "";
			PresentationZoneOrLogic = "";
			ObjectType = ObjectType.SKDZone;
			SortingName = "l " + skdZone.No;
		}
示例#23
0
		public static void ChangeExitZone(GKDoor door, GKSKDZone zone)
		{
			door.ExitZoneUID = zone != null ? zone.UID : Guid.Empty;
			door.OnChanged();
		}