예제 #1
0
        private void ClearJobQueue()
        {
            if (!File.Exists(_settings.FinishedJobsFile))
            {
                JobQueueUtils.CreateJobQueueHeader(_settings.FinishedJobsFile);
            }

            var jobsMap = ReadJobQueue();

            HashSet <string> archievedJobs = new HashSet <string>();

            foreach (var job in jobsMap.Values.Where(ShouldArchieveJob))
            {
                JobQueueUtils.InsertJob(
                    _settings.FinishedJobsFile,
                    job.JobId,
                    job.Timestamp,
                    job.ScheduledTimestamp,
                    job.Assembly,
                    job.JobName,
                    job.Args,
                    job.JobStatus,
                    job.RunCount,
                    job.MaxRunCount,
                    job.Comments);

                archievedJobs.Add(job.JobId);
            }

            JobQueueUtils.CreateJobQueueHeader(_settings.JobQueueFileTmp);

            foreach (var job in jobsMap.Values.Where(j => !archievedJobs.Contains(j.JobId)))
            {
                JobQueueUtils.InsertJob(
                    _settings.JobQueueFileTmp,
                    job.JobId,
                    job.Timestamp,
                    job.ScheduledTimestamp,
                    job.Assembly,
                    job.JobName,
                    job.Args,
                    job.JobStatus,
                    job.RunCount,
                    job.MaxRunCount,
                    job.Comments);
            }

            File.Delete(_settings.JobQueueFile);
            File.Move(_settings.JobQueueFileTmp, _settings.JobQueueFile);
        }
예제 #2
0
        static void Main(string[] args)
        {
            // The DLL or EXE that has the implementation of job should be different from the one the submits the job.

            JobQueueUtils.QueueNewJob(
                @"F:\JobQueueFile.tsv",
                @"F:\Projects\DemoJob\bin\Debug\DemoJob.exe",
                "ComputeJob",
                new [] { "1", "3", @"F:\output-job1.txt" },
                DateTime.Now,
                -1,
                "demo job"
                );
        }
예제 #3
0
        public JobQueueService()
        {
            InitializeComponent();

            _settings = new Settings();
            _settings.Load();

            _timer = new Timer();

            var loggerFileName = Path.Combine(
                _settings.LogDir,
                "JobQueueService_" + DateTime.Now.ToString("yyyy-MM-dd") + ".log");

            _logger = new FileLogger(loggerFileName);

            if (!File.Exists(_settings.JobQueueFile))
            {
                JobQueueUtils.CreateJobQueueHeader(_settings.JobQueueFile);
            }
        }