Exemplo n.º 1
0
		public TextColumnViewModel(AdditionalColumnType additionalColumnType, Employee employee, AdditionalColumn additionalColumn = null)
		{
			AdditionalColumnType = additionalColumnType;
			Employee = employee;
			AdditionalColumn = additionalColumn != null ? additionalColumn : 
				new AdditionalColumn { AdditionalColumnTypeUID = AdditionalColumnType.UID, ColumnName = AdditionalColumnType.Name, EmployeeUID = Employee.UID, TextData = "" };
		}
Exemplo n.º 2
0
		public GraphicsColumnViewModel(AdditionalColumnType additionalColumnType, Employee employee, AdditionalColumn additionalColumn = null)
		{
			AdditionalColumnType = additionalColumnType;
			Employee = employee;
			AdditionalColumn = additionalColumn != null ? additionalColumn :
				new AdditionalColumn { AdditionalColumnTypeUID = AdditionalColumnType.UID, ColumnName = additionalColumnType.Name, EmployeeUID = Employee.UID, Photo = new Photo() };
		}
Exemplo n.º 3
0
		public OperationResult<bool> SaveEmployee(Employee item, bool isNew)
		{
			return SafeOperationCall(() =>
			{
				var rubezhService = RubezhServiceFactory.Create(TimeSpan.FromMinutes(10));
				using (rubezhService as IDisposable)
					return rubezhService.SaveEmployee(RubezhServiceFactory.UID, item, isNew);
			}, "SaveEmployee");
		}
Exemplo n.º 4
0
		void OnAdd()
		{
			var employee = new Employee();
			employee.LastName = LastName;
			employee.FirstName = FirstName;
			employee.SecondName = SecondName;
			var organisationsResult = ClientManager.FiresecService.GetOrganisations(new OrganisationFilter());
			if(organisationsResult.HasError || organisationsResult.Result.Count == 0)
				return;
			var organisation = organisationsResult.Result.FirstOrDefault();
			employee.OrganisationUID = organisation.UID;
			employee.Type = PersonType.Guest;
			ClientManager.FiresecService.SaveEmployee(employee, true);
		}
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
		public ScheduleSelectionViewModel(Employee employee, EmployeeItem employeeSchedule, DateTime startDate)
		{
			Title = "Выбор графика работы";
			Employee = employee;
			StartDate = startDate;

			Schedules = new ObservableCollection<Schedule>();
			var schedules = ScheduleHelper.GetByOrganisation(Employee.OrganisationUID);
			if (schedules != null)
			{
				foreach (var schedule in schedules)
				{
					Schedules.Add(schedule);
				}
			}
			if (employeeSchedule != null)
			{
				SelectedSchedule = Schedules.FirstOrDefault(x => x.UID == employeeSchedule.UID);
			}
		}
Exemplo n.º 7
0
		public PositionSelectionViewModel(Employee employee, EmployeeItem employeePosition)
		{
			Title = "Выбор должности";
			OrganisationUID = employee.OrganisationUID;
			AddCommand = new RelayCommand(OnAdd, CanAdd);
			ClearCommand = new RelayCommand(OnClear);

			Positions = new ObservableCollection<ShortPosition>();
			var positions = PositionHelper.GetByOrganisation(OrganisationUID);
			if (positions != null)
			{
				foreach (var position in positions)
				{
					Positions.Add(position);
				}
			}
			if (employeePosition != null)
			{
				SelectedPosition = Positions.FirstOrDefault(x => x.UID == employeePosition.UID);
			}
		}
Exemplo n.º 8
0
		public OperationResult<bool> SaveEmployee(Guid clientUID, Employee item, bool isNew)
		{
			if (isNew)
			{
				if (item.Type == PersonType.Employee)
					AddJournalMessage(JournalEventNameType.Редактирование_сотрудника, item.Name, item.UID, clientUID, JournalEventDescriptionType.Добавление_сотрудник, JournalObjectType.Employee);
				else if (item.Type == PersonType.Guest)
					AddJournalMessage(JournalEventNameType.Редактирование_посетителя, item.Name, item.UID, clientUID, JournalEventDescriptionType.Добавление_посетитель, JournalObjectType.Employee);
			}
			else
			{
				if (item.Type == PersonType.Employee)
					AddJournalMessage(JournalEventNameType.Редактирование_сотрудника, item.Name, item.UID, clientUID, JournalEventDescriptionType.Редактирование_сотрудник, JournalObjectType.Employee);
				else if (item.Type == PersonType.Guest)
					AddJournalMessage(JournalEventNameType.Редактирование_посетителя, item.Name, item.UID, clientUID, JournalEventDescriptionType.Редактирование_посетитель, JournalObjectType.Employee);
			}
			using (var databaseService = new RubezhDAL.DataClasses.DbService())
			{
				return databaseService.EmployeeTranslator.Save(item);
			}
		}
Exemplo n.º 9
0
 public void Initialize(Guid? id)
 {
     if (id.HasValue)
     {
         var operationResult = EmployeeHelper.GetDetails(id.Value);
         Employee = operationResult;
     }
     else
     {
         Employee = new Employee();
         Employee.BirthDate = DateTime.Now;
         Employee.CredentialsStartDate = DateTime.Now;
         Employee.DocumentGivenDate = DateTime.Now;
         Employee.DocumentValidTo = DateTime.Now;
         Employee.RemovalDate = DateTime.Now;
         Employee.ScheduleStartDate = DateTime.Now;
     }
     if (Employee.Photo != null && Employee.Photo.Data != null)
     {
         PhotoData = string.Format("data:image/gif;base64,{0}", Convert.ToBase64String(Employee.Photo.Data));
         Employee.Photo.Data = null;
     }
     Employee.AdditionalColumns.ForEach(c => c.Photo = null);
 }
Exemplo n.º 10
0
		public OperationResult<bool> SaveEmployee(Guid clientUID, Employee item, bool isNew)
		{
			return SafeOperationCall(clientUID, () => RubezhService.SaveEmployee(clientUID, item, isNew), "SaveEmployee");
		}
Exemplo n.º 11
0
		public static bool Save(Employee employee, bool isNew)
		{
			var operationResult = ClientManager.RubezhService.SaveEmployee(employee, isNew);
            return Common.ThrowErrorIfExists(operationResult);
        }
Exemplo n.º 12
0
		public void IsShowDeletedPosition()
		{
			var organisation = new Organisation();
			var department = new ShortDepartment { Name = "DeletedDepartment", OrganisationUID = organisation.UID, IsDeleted = true };
			var position = new ShortPosition { Name = "DeletedPosition", OrganisationUID = organisation.UID, IsDeleted = true };
			var employee = new Employee 
			{
				FirstName = "FName",
				SecondName = "SName",
				LastName = "LName",
				OrganisationUID = organisation.UID, 
				DepartmentName = department.Name, 
				DepartmentUID = department.UID, 
				IsDepartmentDeleted = department.IsDeleted,
				PositionName = position.Name,
				PositionUID = position.UID,
				IsPositionDeleted = position.IsDeleted
			};
			var shortEmployee = new ShortEmployee
			{
				UID = employee.UID,
				FirstName = employee.FirstName,
				SecondName = employee.SecondName,
				LastName = employee.LastName,
				OrganisationUID = organisation.UID,
				DepartmentName = department.Name,
				IsDepartmentDeleted = department.IsDeleted,
				PositionName = position.Name,
				IsPositionDeleted = position.IsDeleted
			};
			ClientManager.CurrentUser.PermissionStrings.Add("Oper_SKD_Employees_Edit");
			var mock = new Mock<ISafeRubezhService>();
			mock.Setup(x => x.GetOrganisations(It.IsAny<OrganisationFilter>())).Returns(() =>
			{
				return new OperationResult<List<Organisation>>(new List<Organisation> { organisation });
			});
			mock.Setup(x => x.GetEmployeeList(It.IsAny<EmployeeFilter>())).Returns(() =>
			{
				return new OperationResult<List<ShortEmployee>>(new List<ShortEmployee> { shortEmployee});
			});
			mock.Setup(x => x.GetEmployeeDetails(It.IsAny<Guid>())).Returns(() =>
			{
				return new OperationResult<Employee>(employee);
			});
			mock.Setup(x => x.GetAdditionalColumnTypes(It.IsAny<AdditionalColumnTypeFilter>())).Returns(() =>
			{
				return new OperationResult<List<AdditionalColumnType>>();
			});
			mock.Setup(x => x.SaveEmployee(It.IsAny<Employee>(), It.IsAny<bool>())).Returns(() =>
			{
				return new OperationResult<bool>(true);
			});
			ClientManager.RubezhService = mock.Object;
			(ServiceFactory.DialogService as MockDialogService).OnShowModal += window => (window as EmployeeDetailsViewModel).SaveCommand.Execute();

			var employeesViewModel = new EmployeesViewModel();
			employeesViewModel.Initialize(new EmployeeFilter());
			employeesViewModel.SelectedItem = employeesViewModel.Organisations.FirstOrDefault().Children.FirstOrDefault();
			employeesViewModel.EditCommand.Execute();
			Assert.IsTrue(employeesViewModel.SelectedItem.DepartmentName == null || employeesViewModel.SelectedItem.DepartmentName == "");
			Assert.IsTrue(employeesViewModel.SelectedItem.PositionName == null || employeesViewModel.SelectedItem.PositionName == "");
		}