public void ConvertJobs(Period period, List <JobIndexInPeriodDTO> jobIndexInperiodListParam, List <JobIndexDTO> jobIndexListParam) { Console.WriteLine("Starting jobs convert progress..."); jobIndexInperiodList = jobIndexInperiodListParam; jobIndexList = jobIndexListParam; var jobIdList = jobDataProvider.GetJobIds(); totalJobsCount = jobIdList.Count; foreach (var jobId in jobIdList) { var sourceJobDTO = jobDataProvider.GetJobDetails(jobId); var job = jobService.GetByTransferId(sourceJobDTO.TransferId); if (job == null) { var desJobDTO = createDestinationJob(sourceJobDTO); job = jobService.AddJob(desJobDTO); } var sourceJobIndicesForAssignment = jobDataProvider.GetJobIndecesByJobId(jobId); var jobInPriodAssignment = createDestinationJobInPeriod(job, sourceJobIndicesForAssignment); jobInPeriodServiceWrapper.AddJobInPeriod(period.Id, jobInPriodAssignment); jobList.Add(job); Console.WriteLine("Jobs Convert progress state: " + jobList.Count + " From " + totalJobsCount.ToString()); } publisher.Publish(new JobConverted(jobList)); }
private async Task <int> GetJobsAsync(PeriodDTO periodDto) { var idList = jobDataProvider.GetJobIds(); foreach (var id in idList) { Random rndNumber = new Random(); var jobDetail = jobDataProvider.GetJobDetails(id); var desJob = new JobDTO(); desJob.Name = jobDetail.Title; desJob.DictionaryName = "DicName" + Guid.NewGuid(); desJob.CustomFields = new List <CustomFieldDTO>(); JobDTO CurrentJob = new JobDTO(); CurrentJob = GetJob(jobDetail.Id); if (CurrentJob.Id != null && CurrentJob.Id != 0) { jobService.UpdateJob((res, exp) => { if (exp != null) { throw new Exception("Error In Update Job!"); } //System.Threading.Thread.Sleep(100); //ProgressCount++; }, CurrentJob); } else { jobService.AddJob( (r, e) => { if (e != null) { throw new Exception("Error In AddJob!"); } //System.Threading.Thread.Sleep(100); //ProgressCount++; }, desJob); } ProgressCount++; } return(ProgressCount); }
private void save() { if (!job.Validate()) { return; } ShowBusyIndicator(); job.TransferId = Guid.NewGuid(); if (actionType == ActionType.CreateJob) { jobService.AddJob((res, exp) => appController.BeginInvokeOnDispatcher(() => { HideBusyIndicator(); if (exp != null) { appController.HandleException(exp); } else { FinalizeAction(); } }), job); } else if (actionType == ActionType.ModifyJob) { jobService.UpdateJob((res, exp) => appController.BeginInvokeOnDispatcher(() => { HideBusyIndicator(); if (exp != null) { appController.HandleException(exp); } else { FinalizeAction(); } }), job); } }