Exemplo n.º 1
0
		public static ShortEmployeeCardModel Create(SKDCard card)
		{
			var model = new ShortEmployeeCardModel();
			model.Number = card.Number;
			model.UID = card.UID;
			return model;
		}
Exemplo n.º 2
0
 public CardViewModel(SKDCard card)
 {
     Card = card;
     IsCard = true;
     Level = 1;
     IsLeaf = true;
     IsExpanded = false;
     UID = card.UID;
     Init();
 }
Exemplo n.º 3
0
		public EmployeeCardViewModel(Organisation organisation, EmployeeCardsViewModel employeeCardsViewModel, SKDCard card)
		{
			RemoveCommand = new RelayCommand(OnRemove, CanEditDelete);
			EditCommand = new RelayCommand(OnEdit, CanEditDelete);
			PrintCommand = new RelayCommand(OnPrint, CanPrint);
			SelectCardCommand = new RelayCommand(OnSelectCard, CanSelectCard);

			Organisation = organisation;
			EmployeeCardsViewModel = employeeCardsViewModel;
			Card = card;

			SetCardDoors();
		}
		public EmployeeCardDetailsViewModel(Organisation organisation, ShortEmployee employee, SKDCard card = null)
		{
			_employee = employee;

			ChangeReaderCommand = new RelayCommand(OnChangeReader);
			ShowUSBCardReaderCommand = new RelayCommand(OnShowUSBCardReader);

			Organisation = OrganisationHelper.GetSingle(organisation.UID);
			if (card == null)
			{
				IsNewCard = true;
				Title = "Создание пропуска";
				card = new SKDCard()
				{
					EndDate = DateTime.Now.AddYears(1),
					GKCardType = GKCardType.Employee
				};
			}
			else
			{
				Title = string.Format("Свойства пропуска: {0}", card.Number);
			}
			Card = card;
			CopyProperties();
			InitializeGKSchedules();
			AccessDoorsSelectationViewModel = new AccessDoorsSelectationViewModel(Organisation, Card.CardDoors, GKSchedules);
			InitializeAccessTemplates();

			var cards = CardHelper.Get(new CardFilter() { DeactivationType = LogicalDeletationType.Deleted });

			StopListCards = new ObservableCollection<SKDCard>();
			foreach (var item in cards.Where(x => x.IsInStopList))
				StopListCards.Add(item);
			SelectedStopListCard = StopListCards.FirstOrDefault();

			CanChangeCardType = _employee.Type == PersonType.Employee && ClientManager.CheckPermission(RubezhAPI.Models.PermissionType.Oper_SKD_Employees_Edit_CardType);
			GKCardTypes = new ObservableCollection<GKCardType>(Enum.GetValues(typeof(GKCardType)).OfType<GKCardType>());
			SelectedGKCardType = Card.GKCardType;

			AvailableGKControllers = new ObservableCollection<GKControllerViewModel>();
			foreach (var device in GKManager.Devices.Where(x => x.DriverType == GKDriverType.GK))
			{
				var controllerViewModel = new GKControllerViewModel(device);
				controllerViewModel.IsChecked = IsNewCard || (card.GKControllerUIDs != null && card.GKControllerUIDs.Contains(device.UID));
				AvailableGKControllers.Add(controllerViewModel);
			}
		}
Exemplo n.º 5
0
		public PassCardViewModel(Guid employeeUID, SKDCard card)
		{
			Title = "Печать удостоверения " + card.Number;
			_card = card;
			PrintCommand = new RelayCommand(OnPrint, CanPrint);
			_employee = EmployeeHelper.GetDetails(employeeUID);
			if (_employee.DepartmentUID != Guid.Empty && !_employee.IsDepartmentDeleted)
				_department = DepartmentHelper.GetDetails(_employee.DepartmentUID);
			if (_employee.PositionUID != Guid.Empty && !_employee.IsPositionDeleted)
				_position = PositionHelper.GetDetails(_employee.PositionUID);
			_organisation = OrganisationHelper.GetDetails(_employee.OrganisationUID);
			_passCardCanvas = new PassCardCanvas();
			PassCardTemplates = new ObservableCollection<ShortPassCardTemplate>(PassCardTemplateHelper.GetByOrganisation(_organisation.UID));
			ServiceFactory.Events.GetEvent<PainterFactoryEvent>().Unsubscribe(OnPainterFactoryEvent);
			ServiceFactory.Events.GetEvent<PainterFactoryEvent>().Subscribe(OnPainterFactoryEvent);
			SelectedPassCardTemplate = PassCardTemplates.FirstOrDefault();
		}
Exemplo n.º 6
0
        void OnNewCard(SKDCard newCard)
		{
			var condition = newCard.IsInStopList ? (Func<CardViewModel, bool>)(x => x.IsDeactivatedRootItem) : x => x.IsOrganisation && x.Organisation.UID == newCard.OrganisationUID;
			var rootItem = RootItems.FirstOrDefault(condition);
			if (rootItem == null)
			{
				if (newCard.IsInStopList)
					RootItems.Add(CardViewModel.DeactivatedRootItem);
				else
				{
					var organisation = OrganisationHelper.GetSingle(newCard.OrganisationUID);
					if (organisation == null)
						return;
					rootItem = new CardViewModel(organisation);
					RootItems.Add(rootItem);
				}
			}
			var cards = rootItem.Children;
			var cardViewModel = cards.FirstOrDefault(x => x.Card.UID == newCard.UID);
			if (cardViewModel != null)
				cardViewModel.Update(newCard);
			else
				rootItem.AddChild(new CardViewModel(newCard));
			if (!newCard.IsInStopList)
			{
				var deactivatedRoot = RootItems.FirstOrDefault(x => x.IsDeactivatedRootItem);
				if (deactivatedRoot != null)
				{
					var blockedCard = deactivatedRoot.Children.FirstOrDefault(x => x.Card.UID == newCard.UID);
					if (blockedCard != null)
						deactivatedRoot.RemoveChild(blockedCard);
				}
			}
			rootItem.IsExpanded = true;
			RootItems = new ObservableCollection<CardViewModel>(RootItems.OrderBy(x => x.IsDeactivatedRootItem));
			OnPropertyChanged(() => RootItems);
			OnPropertyChanged(() => RootItemsArray);
		}
Exemplo n.º 7
0
		public static OperationResult<bool> AddOrEditCard(GKControllerCardSchedule controllerCardSchedule,
			SKDCard card, string employeeName, int gkCardNo = 0, bool isNew = true, RubezhDAL.DataClasses.DbService dbService = null)
		{
			if (gkCardNo == 0)
			{
				if (dbService == null)
				{
					using (var skdDatabaseService = new RubezhDAL.DataClasses.DbService())
					{
						gkCardNo = skdDatabaseService.GKCardTranslator.GetFreeGKNo(controllerCardSchedule.ControllerDevice.GetGKIpAddress(), card.Number, out isNew);
					}
				}
				else
					gkCardNo = dbService.GKCardTranslator.GetFreeGKNo(controllerCardSchedule.ControllerDevice.GetGKIpAddress(), card.Number, out isNew);
			}

			var user = new GKUser
			{
				GkNo = (ushort)gkCardNo,
				ExpirationDate = card.EndDate,
				Fio = employeeName,
				GkLevel = (byte)card.GKLevel,
				GkLevelSchedule = (byte)card.GKLevelSchedule,
				Password = card.Number,
				UserType = card.GKCardType
			};

			var result = AddOrEditUser(user, controllerCardSchedule.ControllerDevice, isNew, controllerCardSchedule.CardSchedules);
			if (result.HasError)
				return result;

			using (var skdDatabaseService = new RubezhDAL.DataClasses.DbService())
			{
				skdDatabaseService.GKCardTranslator.AddOrEdit(controllerCardSchedule.ControllerDevice.GetGKIpAddress(), gkCardNo, card.Number, employeeName);
			}

			return new OperationResult<bool>(true);
		}
Exemplo n.º 8
0
		public OperationResult<bool> SaveCardTemplate(SKDCard item)
		{
			return SafeOperationCall(() =>
			{
				var rubezhService = RubezhServiceFactory.Create(TimeSpan.FromMinutes(10));
				using (rubezhService as IDisposable)
					return rubezhService.SaveCardTemplate(RubezhServiceFactory.UID, item);
			}, "SaveCardTemplate");
		}
Exemplo n.º 9
0
		public OperationResult<bool> DeletedCard(SKDCard card)
		{
			return SafeOperationCall(() =>
			{
				var rubezhService = RubezhServiceFactory.Create(TimeSpan.FromMinutes(10));
				using (rubezhService as IDisposable)
					return rubezhService.DeletedCard(RubezhServiceFactory.UID, card);
			}, "DeletedCard");
		}
Exemplo n.º 10
0
		public OperationResult<bool> DeleteCardFromEmployee(SKDCard item, string employeeName, string reason = null)
		{
			return SafeOperationCall(() =>
			{
				var rubezhService = RubezhServiceFactory.Create(TimeSpan.FromMinutes(10));
				using (rubezhService as IDisposable)
					return rubezhService.DeleteCardFromEmployee(RubezhServiceFactory.UID, item, employeeName, reason);
			}, "DeleteCardFromEmployee");
		}
Exemplo n.º 11
0
		public OperationResult<bool> EditCard(SKDCard item, string employeeName)
		{
			return SafeOperationCall(() =>
			{
				var rubezhService = RubezhServiceFactory.Create(TimeSpan.FromMinutes(10));
				using (rubezhService as IDisposable)
					return rubezhService.EditCard(RubezhServiceFactory.UID, item, employeeName);
			}, "EditCard");
		}
Exemplo n.º 12
0
	    private List<CardDoor> GetCardDoors(SKDCard card)
		{
			var cardDoors = new List<CardDoor>();
			cardDoors.AddRange(card.CardDoors);
			if (card.AccessTemplateUID != null)
			{
				var result = AccessTemplateHelper.Get(new AccessTemplateFilter());
				var accessTemplates = result;
				if (accessTemplates != null)
				{
					var accessTemplate = accessTemplates.FirstOrDefault(x => x.UID == card.AccessTemplateUID);
					if (accessTemplate != null)
					{
						foreach (var cardZone in accessTemplate.CardDoors)
						{
							if (!cardDoors.Any(x => x.DoorUID == cardZone.DoorUID))
								cardDoors.Add(cardZone);
						}
					}
				}
			}
			return cardDoors;
		}
Exemplo n.º 13
0
		public OperationResult<bool> SaveCardTemplate(Guid clientUID, SKDCard item)
		{
			return SafeOperationCall(clientUID, () => RubezhService.SaveCardTemplate(clientUID, item), "SaveCardTemplate");
		}
Exemplo n.º 14
0
		public OperationResult<bool> DeleteCardFromEmployee(Guid clientUID, SKDCard item, string employeeName, string reason = null)
		{
			return SafeOperationCall(clientUID, () => RubezhService.DeleteCardFromEmployee(clientUID, item, employeeName, reason), "DeleteCardFromEmployee");
		}
Exemplo n.º 15
0
		private void AddRow(EmployeeAccessDataSet ds, EmployeeInfo employee, SKDCard card, CardDoor door, AccessTemplate template, Dictionary<Guid, Tuple<Tuple<GKSKDZone, string>, Tuple<GKSKDZone, string>>> zoneMap, List<Guid> addedZones)
		{
			if (!zoneMap.ContainsKey(door.DoorUID))
				return;
			var zones = zoneMap[door.DoorUID];
			var dataRow = ds.Data.NewDataRow();
			dataRow.Type = card.GKCardType.ToDescription();
			dataRow.Number = card.Number.ToString();
			if (employee != null)
			{
				dataRow.Employee = employee.Name;
				dataRow.Organisation = employee.Organisation;
				dataRow.Department = employee.Department;
				dataRow.Position = employee.Position;
			}
			if (template != null)
				dataRow.Template = template.Name;
			if (zones.Item1 != null && !addedZones.Contains(zones.Item1.Item1.UID))
			{
				var row1 = ds.Data.NewDataRow();
				row1.ItemArray = dataRow.ItemArray;
				row1.Zone = zones.Item1.Item2;
				row1.No = zones.Item1.Item1.No;
				ds.Data.AddDataRow(row1);
				addedZones.Add(zones.Item1.Item1.UID);
			}
			if (zones.Item2 != null && !addedZones.Contains(zones.Item2.Item1.UID))
			{
				var row2 = ds.Data.NewDataRow();
				row2.ItemArray = dataRow.ItemArray;
				row2.Zone = zones.Item2.Item2;
				row2.No = zones.Item2.Item1.No;
				ds.Data.AddDataRow(row2);
				addedZones.Add(zones.Item2.Item1.UID);
			}
		}
Exemplo n.º 16
0
		public static bool Edit(SKDCard card, string employeeName)
		{
			var result = ClientManager.RubezhService.EditCard(card, employeeName);
			Common.ThrowErrorIfExists(result);
			return result.Result;
		}
Exemplo n.º 17
0
		public OperationResult<bool> SaveCardTemplate(Guid clientUID, SKDCard card)
		{
			using (var databaseService = new RubezhDAL.DataClasses.DbService())
			{
				return databaseService.CardTranslator.SavePassTemplate(card);
			}
		}
Exemplo n.º 18
0
		public static List<GKControllerCardSchedule> GetGKControllerCardSchedules(SKDCard card, List<CardDoor> accessTemplateDoors)
		{
			var cardSchedules = new List<GKCardSchedule>();

			var cardDoors = new List<CardDoor>();
			cardDoors.AddRange(accessTemplateDoors);
			cardDoors.AddRange(card.CardDoors.ToList());

			foreach (var cardDoor in cardDoors)
			{
				var door = GKManager.Doors.FirstOrDefault(x => x.UID == cardDoor.DoorUID);
				if (door != null)
				{
					if (door.EnterDevice != null)
					{
						var enterCardSchedule = cardSchedules.FirstOrDefault(x => x.Device.UID == door.EnterDevice.UID);
						if (enterCardSchedule == null)
						{
							enterCardSchedule = new GKCardSchedule();
							cardSchedules.Add(enterCardSchedule);
						}
						enterCardSchedule.Device = door.EnterDevice;
						enterCardSchedule.ScheduleNo = cardDoor.EnterScheduleNo;
					}
					if (door.DoorType != GKDoorType.OneWay && door.ExitDevice != null)
					{
						var exitCardSchedule = cardSchedules.FirstOrDefault(x => x.Device.UID == door.ExitDevice.UID);
						if (exitCardSchedule == null)
						{
							exitCardSchedule = new GKCardSchedule();
							cardSchedules.Add(exitCardSchedule);
						}
						exitCardSchedule.Device = door.ExitDevice;
						exitCardSchedule.ScheduleNo = cardDoor.ExitScheduleNo;
					}
				}
			}

			cardSchedules = cardSchedules.OrderBy(x => x.Device.GKDescriptorNo).ToList();

			var controllerCardSchedules = new List<GKControllerCardSchedule>();
			foreach (var cardSchedule in cardSchedules)
			{
				var gkParent = cardSchedule.Device.GKParent;
				if (gkParent != null)
				{
					var controllerCardSchedule = controllerCardSchedules.FirstOrDefault(x => x.ControllerDevice.UID == gkParent.UID);
					if (controllerCardSchedule == null)
					{
						controllerCardSchedule = new GKControllerCardSchedule();
						controllerCardSchedule.ControllerDevice = gkParent;
						controllerCardSchedules.Add(controllerCardSchedule);
					}
					controllerCardSchedule.CardSchedules.Add(cardSchedule);
				}
			}

			foreach (var controllerUID in card.GKControllerUIDs)
			{
				var controllerDevice = GKManager.Devices.FirstOrDefault(x => x.UID == controllerUID);
				if (controllerDevice != null)
				{
					if (!controllerCardSchedules.Any(x => x.ControllerDevice.UID == controllerUID) && card.GKCardType != GKCardType.Employee)
					{
						var controllerCardSchedule = new GKControllerCardSchedule()
						{
							ControllerDevice = controllerDevice
						};
						controllerCardSchedules.Add(controllerCardSchedule);
					}
				}
			}

			return controllerCardSchedules;
		}
Exemplo n.º 19
0
		public static OperationResult<bool> RemoveCard(GKDevice device, SKDCard card, RubezhDAL.DataClasses.DbService dbService = null)
		{
			var no = 1;
			if (dbService == null)
			{
				using (var skdDatabaseService = new RubezhDAL.DataClasses.DbService())
				{
					no = skdDatabaseService.GKCardTranslator.GetGKNoByCardNo(device.GetGKIpAddress(), card.Number);
				}
			}
			else
				no = dbService.GKCardTranslator.GetGKNoByCardNo(device.GetGKIpAddress(), card.Number);
			if (no == -1)
			{
				return OperationResult<bool>.FromError("По номеру карты не найдена порядковая запись");
			}

			var bytes = new List<byte>();
			bytes.Add(0);
			bytes.AddRange(BytesHelper.ShortToBytes((ushort)(no)));
			bytes.Add(0);
			bytes.Add(1);
			var nameBytes = BytesHelper.StringDescriptionToBytes("-");
			bytes.AddRange(nameBytes);
			bytes.AddRange(BytesHelper.IntToBytes(-1));
			bytes.Add(0);
			bytes.Add(0);

			for (int i = 0; i < 256 - 42; i++)
			{
				bytes.Add(0);
			}

			var sendResult = SendManager.Send(device, (ushort)(bytes.Count), 26, 0, bytes);
			if (sendResult.HasError)
			{
				return OperationResult<bool>.FromError(sendResult.Error);
			}

			using (var skdDatabaseService = new RubezhDAL.DataClasses.DbService())
			{
				skdDatabaseService.GKCardTranslator.Remove(device.GetGKIpAddress(), no, card.Number);
			}

			return new OperationResult<bool>(true);
		}
Exemplo n.º 20
0
        public JsonNetResult GetEmployeeCardDetails(Guid? organisationId, Guid? cardId)
		{
			if (!organisationId.HasValue)
			{
				return new JsonNetResult { Data = new EmployeeCardModel
					{
						Card = new SKDCard(),
						//SelectedStopListCard = new SKDCard(),
						//SelectedSchedule = new GKSchedule(),
						//SelectedAccessTemplate = new AccessTemplate(),
					} 
				};
			}

			SKDCard card;
			if (cardId.HasValue)
			{
				card = CardHelper.GetSingle(cardId.Value);
			}
			else
			{
				card = new SKDCard
				{
					EndDate = DateTime.Now.AddYears(1),
					GKCardType = GKCardType.Employee,
				};
			}

			var cardModel = new EmployeeCardModel();

			cardModel.Card = card;

			cardModel.Schedules = GKScheduleHelper.GetSchedules();
	        cardModel.SelectedSchedule = cardModel.Schedules.FirstOrDefault(s => s.No == cardModel.Card.GKLevelSchedule);

			var operationResult = CardHelper.Get(new CardFilter { DeactivationType = LogicalDeletationType.Deleted });
			cardModel.StopListCards = operationResult.Where(x => x.IsInStopList).ToList();

			cardModel.AvailableGKControllers = GKManager.Devices.Where(x => x.DriverType == GKDriverType.GK)
																.Select(d =>
																{
																	var isChecked = !cardId.HasValue;
																	isChecked |= card.GKControllerUIDs != null && card.GKControllerUIDs.Contains(d.UID);
																	return new GKControllerModel(d.UID, isChecked, d.PresentationName);
																}).ToList();

			var organisation = OrganisationHelper.Get(new OrganisationFilter {UIDs = new List<Guid>{organisationId.Value}}).FirstOrDefault();

			cardModel.Doors = GKManager.DeviceConfiguration.Doors.Where(door => organisation.DoorUIDs.Any(y => y == door.UID))
				.Select(door => new AccessDoorModel(door, card.CardDoors, cardModel.Schedules))
				.ToList();

			var accessTemplateFilter = new AccessTemplateFilter { OrganisationUIDs = new List<Guid> { organisationId.Value } };
			cardModel.AvailableAccessTemplates = new List<AccessTemplate> { new AccessTemplate { UID = Guid.Empty, Name = "<нет>" } }
				.Concat(AccessTemplateHelper.Get(accessTemplateFilter))
				.ToList();
            var selectedAccessTemplate = cardModel.AvailableAccessTemplates.FirstOrDefault(x => x.UID == cardModel.Card.AccessTemplateUID);
            cardModel.SelectedAccessTemplate = selectedAccessTemplate;

            return new JsonNetResult { Data = cardModel };
		}
Exemplo n.º 21
0
		IEnumerable<string> DeleteGKCard(Guid clientUID, SKDCard card, List<CardDoor> accessTemplateDoors, RubezhDAL.DataClasses.DbService databaseService)
		{
			var result = new List<string>();
			var controllerCardSchedules = GKSKDHelper.GetGKControllerCardSchedules(card, accessTemplateDoors);
			foreach (var controllerCardSchedule in controllerCardSchedules)
			{
				var removeResult = GKSKDHelper.RemoveCard(controllerCardSchedule.ControllerDevice, card);
				if (removeResult.HasError)
				{
					result.Add("Не удалось удалить карту из устройства " + controllerCardSchedule.ControllerDevice.PresentationName);
					var pendingResult = databaseService.CardTranslator.DeletePending(card.UID, controllerCardSchedule.ControllerDevice.UID);
					if (pendingResult.HasError)
						result.Add(pendingResult.Error);
				}
			}
			return result;
		}
Exemplo n.º 22
0
		public OperationResult<bool> DeleteCardFromEmployee(Guid clientUID, SKDCard card, string employeeName, string reason = null)
		{
			using (var databaseService = new RubezhDAL.DataClasses.DbService())
			{
				AddJournalMessage(JournalEventNameType.Удаление_карты, employeeName, card.EmployeeUID, clientUID, journalObjectType: JournalObjectType.Employee);

				var saveResult = databaseService.CardTranslator.ToStopList(card, reason);
				if (saveResult.HasError)
				{
					return OperationResult<bool>.FromError(saveResult.Error, false);
				}

				var errors = new List<string>();

				var getAccessTemplateOperationResult = databaseService.AccessTemplateTranslator.GetSingle(card.AccessTemplateUID);
				if (getAccessTemplateOperationResult.HasError)
					errors.AddRange(getAccessTemplateOperationResult.Errors);

				var operationResult = databaseService.CardTranslator.GetSingle(card.UID);
				if (!operationResult.HasError && operationResult.Result != null)
				{
					var cardDoors = getAccessTemplateOperationResult.Result != null ? getAccessTemplateOperationResult.Result.CardDoors : new List<CardDoor>();
					errors.AddRange(DeleteGKCard(clientUID, card, cardDoors, databaseService));
				}
				else
				{
					errors.Add("Не найдена предыдущая карта");
				}

				return OperationResult<bool>.FromError(errors, true);
			}
		}
Exemplo n.º 23
0
		public OperationResult<bool> EditCard(Guid clientUID, SKDCard item, string employeeName)
		{
			return SafeOperationCall(clientUID, () => RubezhService.EditCard(clientUID, item, employeeName), "EditCard");
		}
Exemplo n.º 24
0
		public static bool Delete(SKDCard card)
		{
			var result = ClientManager.RubezhService.DeletedCard(card);
			return Common.ThrowErrorIfExists(result);
		}
Exemplo n.º 25
0
		public OperationResult<bool> DeletedCard(Guid clientUID, SKDCard card)
		{
			return SafeOperationCall(clientUID, () => RubezhService.DeletedCard(clientUID, card), "DeletedCard");
		}
Exemplo n.º 26
0
		public OperationResult<bool> DeletedCard(Guid clientUID, SKDCard card)
		{
			if (card.EmployeeUID != null)
				AddJournalMessage(JournalEventNameType.Удаление_карты, card.EmployeeName, card.EmployeeUID, clientUID, journalObjectType: JournalObjectType.Employee);
			else
				AddJournalMessage(JournalEventNameType.Удаление_карты, card.Number.ToString(), card.UID, clientUID, journalObjectType: JournalObjectType.Card);
			using (var databaseService = new RubezhDAL.DataClasses.DbService())
			{
				var errors = new List<string>();

				var getAccessTemplateOperationResult = databaseService.AccessTemplateTranslator.GetSingle(card.AccessTemplateUID);
				if (getAccessTemplateOperationResult.HasError)
					errors.AddRange(getAccessTemplateOperationResult.Errors);

				var cardDoors = getAccessTemplateOperationResult.Result != null ? getAccessTemplateOperationResult.Result.CardDoors : new List<CardDoor>();
				errors.AddRange(DeleteGKCard(clientUID, card, cardDoors, databaseService));

				var deleteFromDbResult = databaseService.CardTranslator.Delete(card);
				if (deleteFromDbResult.HasError)
					errors.Add(deleteFromDbResult.Error);

				if (errors.Count > 0)
					return OperationResult<bool>.FromError(errors);
				else
					return new OperationResult<bool>(true);
			}
		}
Exemplo n.º 27
0
		public static bool DeleteFromEmployee(SKDCard card, string employeeName, string reason)
		{
			var result = ClientManager.RubezhService.DeleteCardFromEmployee(card, employeeName, reason);
			Common.ThrowErrorIfExists(result);
			return result.Result;
		}
Exemplo n.º 28
0
        private ShortEmployeeCardModel CreateCard(SKDCard card)
		{
			var employeeCard = ShortEmployeeCardModel.Create(card);
			var cardDoors = GetCardDoors(card);
			employeeCard.Doors = ReadOnlyAccessDoorModel.InitializeDoors(cardDoors);
			return employeeCard;
		}
Exemplo n.º 29
0
		public static bool SaveTemplate(SKDCard card)
		{
			var operationResult = ClientManager.RubezhService.SaveCardTemplate(card);
			return Common.ThrowErrorIfExists(operationResult);
		}
Exemplo n.º 30
0
		IEnumerable<string> EditGKCard(Guid clientUID, SKDCard oldCard, AccessTemplate oldAccessTemplate, SKDCard newCard, AccessTemplate newAccessTemplate, RubezhDAL.DataClasses.DbService databaseService)
		{
			var result = new List<string>();
			var employeeOperationResult = databaseService.EmployeeTranslator.GetSingle(newCard.EmployeeUID);
			if (!employeeOperationResult.HasError)
			{
				var cardDoors = oldAccessTemplate != null ? oldAccessTemplate.CardDoors : new List<CardDoor>();
				var oldControllerCardSchedules = GKSKDHelper.GetGKControllerCardSchedules(oldCard, cardDoors);
				cardDoors = newAccessTemplate != null ? newAccessTemplate.CardDoors : new List<CardDoor>();
				var newControllerCardSchedules = GKSKDHelper.GetGKControllerCardSchedules(newCard, cardDoors);
				foreach (var controllerCardSchedule in oldControllerCardSchedules)
				{
					if (!newControllerCardSchedules.Any(x => x.ControllerDevice.UID == controllerCardSchedule.ControllerDevice.UID))
					{
						var removeResult = GKSKDHelper.RemoveCard(controllerCardSchedule.ControllerDevice, newCard);
						if (removeResult.HasError)
						{
							result.Add("Не удалось удалить карту из устройства " + controllerCardSchedule.ControllerDevice.PresentationName);
							var pendingResult = databaseService.CardTranslator.DeletePending(newCard.UID, controllerCardSchedule.ControllerDevice.UID);
							if (pendingResult.HasError)
								result.Add(pendingResult.Error);
						}
					}
				}
				foreach (var controllerCardSchedule in newControllerCardSchedules)
				{
					var addResult = GKSKDHelper.AddOrEditCard(controllerCardSchedule, newCard, employeeOperationResult.Result.FIO);
					if (addResult.HasError)
					{
						result.Add("Не удалось добавить или редактировать карту в устройстве " + controllerCardSchedule.ControllerDevice.PresentationName);
						var pendingResult = databaseService.CardTranslator.AddPending(newCard.UID, controllerCardSchedule.ControllerDevice.UID);
						if (pendingResult.HasError)
							result.Add(pendingResult.Error);
					}
				}
			}
			return result;
		}