Exemplo n.º 1
0
        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));
        }
Exemplo n.º 2
0
        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);
        }