public void ConvertJobPositions(Period period, List <UnitDTO> unitList, List <JobDTO> jobList) { Console.WriteLine("Starting jobPositions Convert progress..."); this.unitList = unitList; jobInPeriodList = jobList; root = jobPositionDataProvider.GetRoot(); totalJobPositionsCount = jobPositionDataProvider.GetCount(); convertJobPosition_Rec(root, period.Id, null); publisher.Publish(new JobPositionConverted(jobPositionList)); }
private JobPositionDTO createDestinationJobPosition(JobPositionIntegrationDTO sourceJobPosition) { var res = new JobPositionDTO { Name = sourceJobPosition.JobPositionName, DictionaryName = sourceJobPosition.ID.ToString(), TransferId = sourceJobPosition.TransferId }; return(res); }
private void convertJobPosition_Rec(JobPositionIntegrationDTO sourceJobPositionDTO, long periodId, long?jobPositionParentIdParam) { var jobPosition = jobPositionService.GetByTransferId(sourceJobPositionDTO.TransferId); if (jobPosition == null) { var desJobPositionDTO = createDestinationJobPosition(sourceJobPositionDTO); jobPosition = jobPositionService.AddJobPosition(desJobPositionDTO); } var unit = unitList.Single(u => sourceJobPositionDTO.UnitIntegrationDTO.TransferId == u.TransferId); var job = jobInPeriodList.Single(u => sourceJobPositionDTO.JobIntegrationDto.TransferId == u.TransferId); var jobPositionInPriodAssignment = createDestinationJobPositionInPeriod(jobPosition, periodId, unit.Id, job.Id, jobPositionParentIdParam); var res = jobPositionInPeriodServiceWrapper.AddJobPositionInPeriod(jobPositionInPriodAssignment); jobPositionList.Add(jobPosition); var jobPositionDataChildIdList = jobPositionDataProvider.GetChildIDs(sourceJobPositionDTO.ID); foreach (var jobPositionDataChildId in jobPositionDataChildIdList) { var jobPositiondataChid = jobPositionDataProvider.GetJobPositionDetail(jobPositionDataChildId); convertJobPosition_Rec(jobPositiondataChid, periodId, res.JobPositionId); } Console.WriteLine("JobPosition convert progress state: " + jobPositionList.Count + " From " + totalJobPositionsCount.ToString()); }
public JobPositionIntegrationDTO GetJobPositionDetail(int id) { db = new PersonnelSoft2005Entities(); try { var jobPosition = db.VW_OrganTree.Single(c => c.ID == id); var job = (from c in db.PMS_JobTitle where c.ID == jobPosition.ID_PMS_JobTitle.Value select c).Single(); var interMediateUnit = (from c in db.VW_OrganTree where c.ID == jobPosition.PID.Value select c).Single(); while (interMediateUnit.NodeType == DataEFConfig.NodeType_Section) { interMediateUnit = (from c in db.VW_OrganTree where c.ID == interMediateUnit.PID.Value select c).Single(); } var jobPositionIntegrationDTO = new JobPositionIntegrationDTO { ID = jobPosition.ID, JobPositionName = jobPosition.NodeName, TransferId = jobPosition.TranferId.Value, JobIntegrationDto = new JobIntegrationDto { Title = job.Title, TransferId = job.TransferId.Value }, UnitIntegrationDTO = new UnitIntegrationDTO { TransferId = interMediateUnit.TranferId.Value, ID = interMediateUnit.ID, UnitName = interMediateUnit.NodeName } }; return(jobPositionIntegrationDTO); //return (from c in db.VW_OrganTree // where c.ID == id // select new JobPositionIntegrationDTO // { // ID = c.ID, // JobPositionName = c.NodeName, // TransferId = c.TranferId.Value, // JobIntegrationDto = (from d in db.PMS_JobTitle // where d.ID == c.ID_PMS_JobTitle.Value // select new JobIntegrationDto // { // Title = d.Title, // TransferId = d.TransferId.Value // }).FirstOrDefault(), // UnitIntegrationDTO = (var temp=(from e in db.VW_OrganTree // where e.ID == c.PID // ).FirstOrDefault() // select new UnitIntegrationDTO // { // TransferId = e.TranferId.Value, // UnitName = e.NodeName, // ID = e.ID // }).FirstOrDefault() // }).Single(); } catch (Exception e) { throw e; } }