コード例 #1
0
        public JobItem Create(JobDefinition definition)
        {
            var stateProvider = _context.State;
            var state = stateProvider.Retrieve(definition.JobKey); // State could be null!

            return new JobItem(_context, definition, state);
        }
コード例 #2
0
ファイル: BuildFileList.cs プロジェクト: kapitanov/diploma
        public override void Execute(
            JobDefinition job,
            Action<int, int> notifyProgress,
            Action<string> updateStatus,
            IRepository repositoryService,
            IJobManager jobManager)
        {
            var allFiles = job.Files.ToDictionary(file => file, _ => false);

            var totalItems = job.Tasks.Count;
            var currentItem = 0;
            foreach (var task in job.Tasks)
            {
                updateStatus(string.Format("Processing files used by task \"{0}\"...", task.Name));
                allFiles[task.EntryPoint.Assembly] = true;

                foreach (var file in task.EntryPoint.References)
                    allFiles[file] = true;

                foreach (var file in task.InputFiles)
                    allFiles[file] = true;

                foreach (var file in task.OutputFiles)
                    allFiles[file] = true;

                currentItem++;
                notifyProgress(currentItem, totalItems);
            }

            updateStatus("Building file list...");

            job.Files = allFiles.Where(pair => pair.Value)
                .Select(pair => pair.Key)
                .ToList();
        }
コード例 #3
0
ファイル: LinkFiles.cs プロジェクト: kapitanov/diploma
 public override void Execute(
     JobDefinition job, 
     Action<int, int> notifyProgress, 
     Action<string> updateStatus,
     IRepository repositoryService, 
     IJobManager jobManager)
 {
     updateStatus("Linking files...");
 }
コード例 #4
0
ファイル: CreateJob.cs プロジェクト: kapitanov/diploma
 public override void Execute(
     JobDefinition job, 
     Action<int, int> notifyProgress, 
     Action<string> updateStatus,
     IRepository repositoryService, 
     IJobManager jobManager)
 {
     updateStatus("Creating job...");
     job.Id = jobManager.CreateJob(job.Name).Id;
 }
コード例 #5
0
ファイル: ValidateGraph.cs プロジェクト: kapitanov/diploma
 public override void Execute(
     JobDefinition job,
     Action<int, int> notifyProgress,
     Action<string> updateStatus,
     IRepository repositoryService,
     IJobManager jobManager)
 {
     updateStatus("Validating job's graph...");
     var index = 0;
     var count = job.Tasks.Count;
     if (!job.Tasks.All(task =>
     {
         notifyProgress(++index, count);
         return RecoursiveCheckGraph(task, ImmutableList<Guid>.Empty);
     }))
         throw new Exception("Job is invalid: graph contains cycles.");
 }
コード例 #6
0
ファイル: UploadFiles.cs プロジェクト: kapitanov/diploma
 public override void Execute(
     JobDefinition job, 
     Action<int, int> notifyProgress, 
     Action<string> updateStatus,
     IRepository repositoryService, 
     IJobManager jobManager)
 {
     var index = 0;
     var count = job.Files.Count;
     foreach (var file in job.Files)
     {
         index++;
         notifyProgress(index, count);
         if(file is CreateFileRequest)
             updateStatus(string.Format("Creating file: {0}...", file.Name));
         else
             updateStatus(string.Format("Uploading file: {0}...", file.Name));
         file.SaveFile(repositoryService);
     }
 }
コード例 #7
0
ファイル: UploadTasks.cs プロジェクト: kapitanov/diploma
        public override void Execute(
            JobDefinition job,
            Action<int, int> notifyProgress,
            Action<string> updateStatus,
            IRepository repositoryService,
            IJobManager jobManager)
        {
            var tasks = (from t in job.Tasks
                        select new {Task = t, Dependencies = t.Dependencies.Count}).ToList();

            while (tasks.Count() > 0)
            {
                var task = (from t in tasks
                           where t.Dependencies == 0
                           select t.Task).First();

                updateStatus(string.Format("Creating task \"{0}\"...", task.Name));

                tasks = (from t in tasks
                        where t.Task != task
                        let dependencyList = t.Task.Dependencies
                        let dependencyCount = t.Dependencies
                        select new
                                   {
                                       Task = t.Task,
                                       Dependencies = dependencyList.Contains(task)
                                                          ?
                                                             dependencyCount - 1
                                                          :
                                                             dependencyCount
                                   }).ToList();

                task.Id = jobManager.CreateTask(task.ToContract());
                notifyProgress(tasks.Count(), job.Tasks.Count);
            }
        }
コード例 #8
0
ファイル: Converter.cs プロジェクト: Azure/azure-powershell
        /// <summary>
        /// Converts job definition result to PowerShell job definition.
        /// </summary>
        /// <param name="jobsDefinitionList">Job definition.</param>
        /// <returns>PowerShell job definition.</returns>
        internal static PSSchedulerJobDefinition ConvertJobDefinitionToPS(JobDefinition jobDefinition)
        {
            if (jobDefinition == null)
            {
                throw new ArgumentNullException(paramName: "jobDefinition");
            }

            var psSchedulerJobDefinition = new PSSchedulerJobDefinition()
            {
                ResourceGroupName = jobDefinition.Id.Split('/')[4],
                JobCollectionName = jobDefinition.Name.Split('/')[0],
                JobName = jobDefinition.Name.Split('/')[1],
                Status = jobDefinition.Properties.State.ToString(),
                StartTime = jobDefinition.Properties.StartTime,
                Recurrence = Converter.ConvertRecurrenceToString(jobDefinition.Properties.Recurrence),
                EndSchedule = Converter.GetEndSchedule(jobDefinition.Properties.Recurrence),
            };

            if (jobDefinition.Properties.Status != null)
            {
                psSchedulerJobDefinition.Lastrun = jobDefinition.Properties.Status.LastExecutionTime;
                psSchedulerJobDefinition.Nextrun = jobDefinition.Properties.Status.NextExecutionTime;
                psSchedulerJobDefinition.Failures = jobDefinition.Properties.Status.FailureCount;
                psSchedulerJobDefinition.Faults = jobDefinition.Properties.Status.FaultedCount;
                psSchedulerJobDefinition.Executions = jobDefinition.Properties.Status.ExecutionCount;
            }

            psSchedulerJobDefinition.JobAction = Converter.GetSchedulerJobActionDetails(jobDefinition.Properties.Action);
            psSchedulerJobDefinition.JobErrorAction = Converter.GetSchedulerJobErrorActionDetails(jobDefinition.Properties.Action.ErrorAction);

            return psSchedulerJobDefinition;
        }
コード例 #9
0
ファイル: Job.cs プロジェクト: anogaijin/simplebatch
 internal Job(JobDefinition jobDefinition)
 {
     _jobDefinition = jobDefinition;
 }
コード例 #10
0
ファイル: JobProvider.cs プロジェクト: ShironDrake/NzbDrone
        public virtual void Initialize()
        {
            var currentJobs = All();
            logger.Debug("Initializing jobs. Available: {0} Existing:{1}", _jobs.Count(), currentJobs.Count);

            foreach (var currentJob in currentJobs)
            {
                if (!_jobs.Any(c => c.GetType().ToString() == currentJob.TypeName))
                {
                    logger.Debug("Removing job from database '{0}'", currentJob.Name);
                    _database.Delete(currentJob);
                }
            }

            foreach (var job in _jobs)
            {
                var jobDefinition = currentJobs.SingleOrDefault(c => c.TypeName == job.GetType().ToString());

                if (jobDefinition == null)
                {
                    jobDefinition = new JobDefinition();
                    jobDefinition.TypeName = job.GetType().ToString();
                    jobDefinition.LastExecution = DateTime.Now;
                }

                jobDefinition.Enable = job.DefaultInterval.TotalSeconds > 0;
                jobDefinition.Name = job.Name;
                jobDefinition.Interval = Convert.ToInt32(job.DefaultInterval.TotalMinutes);

                SaveDefinition(jobDefinition);
            }
        }
コード例 #11
0
ファイル: JobProvider.cs プロジェクト: ShironDrake/NzbDrone
 /// <summary>
 /// Adds/Updates definitions for a job
 /// </summary>
 /// <param name="definitions">Settings to be added/updated</param>
 public virtual void SaveDefinition(JobDefinition definitions)
 {
     if (definitions.Id == 0)
     {
         logger.Trace("Adding job definitions for {0}", definitions.Name);
         _database.Insert(definitions);
     }
     else
     {
         logger.Trace("Updating job definitions for {0}", definitions.Name);
         _database.Update(definitions);
     }
 }
コード例 #12
0
 private static void ProcessJob(JobDefinition jobDefinition)
 {
     IBatchElement job = new Job(jobDefinition);
     job.Execute();
 }
コード例 #13
0
ファイル: ExecuteJob.cs プロジェクト: kapitanov/diploma
        public override void Execute(
            JobDefinition job,
            Action<int, int> notifyProgress,
            Action<string> updateStatus,
            IRepository repositoryService,
            IJobManager jobManager)
        {
            updateStatus("Executing job...");
            JobExecutingView dialog = null;

            Owner.Synch(() => dialog = new JobExecutingView(string.Format("Executing job {0}...", job)));

            jobManager.OpenJob(job.Id);
            jobManager.StartJob();

            var isWorking = true;

            dialog.OnCancelled += (s, e) =>
            {
                lock (this)
                {
                    if (!isWorking)
                        return;
                    isWorking = false;
                }

                jobManager.CancelJob();
            };
            Owner.Synch(() => dialog.Show());

            var state = default(JobState);
            while (isWorking)
            {
                state = jobManager.QueryJobState(job.Id);
                if (state == JobState.Completed ||
                   state == JobState.Failed)
                {
                    lock (this)
                    {
                        lock (this)
                            isWorking = false;
                        break;
                    }
                }

                Thread.Sleep(100);
            }
            Owner.Synch(() => dialog.Close());
            if (state == JobState.Completed)
            {
                return;
                // MessageBox.Show(string.Format("Job {0} completed!", job));
            }
            if (state == JobState.Failed)
            {
                var errorReport = jobManager.GetErrorReport(job.Id);
                Owner.Synch(() => ErrorReportView.ShowReport(errorReport));
                throw new StageFailedException("Job failed!");
                //MessageBox.Show(string.Format("Job {0} failed!", job));
            }
        }