private PersonRequest TerminatePersonById(PersonRequest personRequest) { var myQueryDto = new GetPersonByIdQueryDto { PersonId = personRequest.PersonID }; try { var personToTerminate = wfmServiceApplication.OrganizationService.GetPersonsByQuery(myQueryDto).FirstOrDefault(); var terminationDate = personRequest.TerminationDate; personRequest = personRequest.Clone(personToTerminate); personRequest.TerminationDate = terminationDate; if (personToTerminate != null) { DateOnlyDto dateOnly = new DateOnlyDto(); dateOnly.DateTime = personRequest.TerminationDate; dateOnly.DateTimeSpecified = true; personToTerminate.TerminationDate = dateOnly; personToTerminate.ApplicationLogOnName = personToTerminate.Id; personToTerminate.WindowsDomain = @"-"; personToTerminate.WindowsLogOnName = @"-"; personToTerminate.EmploymentNumber = personToTerminate.Id; personToTerminate.Identity = personToTerminate.Id; wfmServiceApplication.OrganizationService.UpdatePerson(personToTerminate); personRequest.WFMReturnCode = 0; personRequest.WFMReturnMessage += String.Format(@"Сотрудник с ID [{0}] уволен: OK; ", personRequest.PersonID); personRequest.ReturnType = ReturnTypes.ReturnTypeEnum.NoError; } else { personRequest.ReturnType = ReturnTypes.ReturnTypeEnum.DataError; personRequest.WFMReturnCode = -2; personRequest.WFMReturnMessage += String.Format(@"Сотрудник с ID [{0}] НЕ найден! ", myQueryDto.PersonId); } } catch (Exception ex) { personRequest.ReturnType = ReturnTypes.ReturnTypeEnum.UnknownError; personRequest.WFMReturnCode = -1; personRequest.WFMReturnMessage += ex.Message; } return personRequest; }
private PersonDto GetPersonById(string personID) { var myQueryDto = new GetPersonByIdQueryDto(); myQueryDto.PersonId = personID; var result = wfmServiceApplication.OrganizationService.GetPersonsByQuery(myQueryDto).FirstOrDefault(); return result; }
private PersonRequest AssignPerson(PersonRequest personRequest) { PersonPeriodLoadOptionDto loadOptionDto = new PersonPeriodLoadOptionDto(); DateOnlyDto dateOnlyDto1 = new DateOnlyDto(); dateOnlyDto1.DateTime = DateTime.Parse("1900.01.01"); dateOnlyDto1.DateTimeSpecified = true; DateOnlyDto dateOnlyDto2 = new DateOnlyDto(); dateOnlyDto2.DateTime = DateTime.Now; dateOnlyDto2.DateTimeSpecified = true; loadOptionDto.LoadAll = true; loadOptionDto.LoadAllSpecified = true; var myQueryDto = new GetPersonByIdQueryDto { PersonId = personRequest.PersonID }; try { var result = wfmServiceApplication.OrganizationService.GetPersonsByQuery(myQueryDto).FirstOrDefault(); if (result != null) { PersonPeriodDto personPeriod = new PersonPeriodDto(); personPeriod.Period = new DateOnlyPeriodDto(); personPeriod.Period.StartDate = new DateOnlyDto(); personPeriod.Period.StartDate.DateTime = personRequest.StartDate; personPeriod.Period.StartDate.DateTimeSpecified = true; var teamRequest = CheckSiteTeam(personRequest); if (teamRequest.ReturnCode != 0) { return teamRequest; } var myTeam = GetTeamById(personRequest.TeamID); personPeriod.Team = myTeam; personPeriod.PersonContract = new PersonContractDto(); LoadOptionDto contractDto = new LoadOptionDto(); contractDto.LoadDeleted = false; contractDto.LoadDeletedSpecified = true; var contract = wfmServiceApplication.OrganizationService.GetContracts(contractDto).FirstOrDefault(); if (contract != null) { personPeriod.PersonContract.ContractId = contract.Id; } LoadOptionDto partTimeDto = new LoadOptionDto(); partTimeDto.LoadDeleted = false; partTimeDto.LoadDeletedSpecified = true; var partTimesPercentage = wfmServiceApplication.OrganizationService.GetPartTimePercentages(contractDto).FirstOrDefault(); if (contract != null) { personPeriod.PersonContract.PartTimePercentageId = partTimesPercentage.Id; } LoadOptionDto contractScheduleDto = new LoadOptionDto(); contractScheduleDto.LoadDeleted = false; contractScheduleDto.LoadDeletedSpecified = true; var contractSchedule = wfmServiceApplication.OrganizationService.GetContractSchedules(contractScheduleDto).FirstOrDefault(); if (contractSchedule != null) { personPeriod.PersonContract.ContractScheduleId = contractSchedule.Id; } personPeriod.SchedulePreferenceDate = personRequest.StartDate; personPeriod.SchedulePublishedToDate = personRequest.StartDate; wfmServiceApplication.OrganizationService.AddPersonPeriod(result, personPeriod); personRequest.WFMReturnCode = 0; personRequest.ReturnType = ReturnTypes.ReturnTypeEnum.NoError; personRequest.WFMReturnMessage += String.Format(@"Сотрудник ID [{0}] назначен в Бизнес-Юнит [{1}] в [{2}]; ", myQueryDto.PersonId, BusinessUnit, myTeam.SiteAndTeam); } else { personRequest.ReturnType = ReturnTypes.ReturnTypeEnum.DataError; personRequest.WFMReturnCode = -2; personRequest.WFMReturnMessage += String.Format(@"Сотрудник Id [{0}] НЕ найден! ", myQueryDto.PersonId); } } catch (Exception ex) { personRequest.ReturnType = ReturnTypes.ReturnTypeEnum.UnknownError; personRequest.WFMReturnCode = -1; personRequest.WFMReturnMessage += ex.Message; personRequest.ReturnCode = -1; personRequest.ReturnMessage = personRequest.WFMReturnMessage; } return personRequest; }
private PersonRequest DeletePersonById(PersonRequest personRequest) { var myQueryDto = new GetPersonByIdQueryDto { PersonId = personRequest.PersonID }; try { var result = wfmServiceApplication.OrganizationService.GetPersonsByQuery(myQueryDto).FirstOrDefault(); if (result != null) { if (result.IsDeleted) { personRequest.ReturnType = ReturnTypes.ReturnTypeEnum.BusinessError; personRequest.WFMReturnCode = 2; personRequest.WFMReturnMessage += String.Format(@"Сотрудник с ID [{0}] уже удален! ", personRequest.PersonID); return personRequest; } result.IsDeleted = true; result.IsDeletedSpecified = true; wfmServiceApplication.OrganizationService.SavePerson(result); personRequest.WFMReturnCode = 0; personRequest.WFMReturnMessage += String.Format(@"Сотрудник с ID [{0}] удален! ", personRequest.PersonID); } else { personRequest.ReturnType = ReturnTypes.ReturnTypeEnum.DataError; personRequest.WFMReturnCode = -2; personRequest.WFMReturnMessage += String.Format(@"Сотрудник с ID [{0}] не найден! ", personRequest.PersonID); } } catch (Exception ex) { personRequest.ReturnType = ReturnTypes.ReturnTypeEnum.UnknownError; personRequest.WFMReturnCode = -1; personRequest.WFMReturnMessage += ex.Message; } return personRequest; }
private static PersonDto UpdatePersonByGuid(string guid) { var myQueryDto = new GetPersonByIdQueryDto(); //myQueryDto.PersonId = @"4CBBF982-0F91-4451-B742-A42F00F0EE98"; myQueryDto.PersonId = guid; var result = teleoptiServiceApplication.OrganizationService.GetPersonsByQuery(myQueryDto).FirstOrDefault(); //teleoptiServiceApplication.OrganizationService; result.Email = @"*****@*****.**"; result.EmploymentNumber = @"0001"; teleoptiServiceApplication.OrganizationService.SavePerson(result); return result; }