public void JobMetaDataToEntity_Test()
        {
            var job = new FileUploadJob
            {
                FileName         = "test.xml",
                JobId            = 1,
                StorageReference = "test-ref",
                Ukprn            = 1000,
                CollectionName   = "ILR1819",
                PeriodNumber     = 10,
                FileSize         = 1000
            };

            var entity = new FileUploadJobMetaData();

            JobConverter.Convert(job, entity);

            entity.JobId.Should().Be(1);
            entity.FileName.Should().Be("test.xml");
            entity.StorageReference.Should().Be("test-ref");
            entity.Ukprn.Should().Be(1000);
            entity.CollectionName.Should().Be("ILR1819");
            entity.PeriodNumber.Should().Be(10);
            entity.FileSize.Should().Be(1000);
        }
        public void JobToJobEntity_Test()
        {
            var currentTime = DateTime.UtcNow;
            var job         = new Job
            {
                DateTimeSubmittedUtc = currentTime,
                DateTimeUpdatedUtc   = currentTime,
                JobId              = 1,
                Priority           = 1,
                RowVersion         = "test",
                Status             = JobStatusType.Ready,
                SubmittedBy        = "test",
                NotifyEmail        = "*****@*****.**",
                JobType            = JobType.IlrSubmission,
                CrossLoadingStatus = JobStatusType.Ready
            };

            var convertedJob = JobConverter.Convert(job);

            convertedJob.JobId.Should().Be(1);
            convertedJob.DateTimeSubmittedUtc.Should().Be(currentTime);
            convertedJob.DateTimeUpdatedUtc.Should().Be(currentTime);
            convertedJob.JobType.Should().Be(1);
            convertedJob.Priority.Should().Be(1);
            convertedJob.Status.Should().Be(1);
            convertedJob.NotifyEmail.Should().Be("*****@*****.**");
            convertedJob.SubmittedBy.Should().Be("test");
            convertedJob.CrossLoadingStatus.Should().Be((short)JobStatusType.Ready);
        }
        public void JobEntityToJob_Test()
        {
            var currentTime = DateTime.UtcNow;
            var job         = new Data.Entities.Job
            {
                DateTimeSubmittedUtc = currentTime,
                DateTimeUpdatedUtc   = currentTime,
                JobId              = 1,
                JobType            = 1,
                Priority           = 1,
                RowVersion         = null,
                Status             = 1,
                NotifyEmail        = "*****@*****.**",
                SubmittedBy        = "test",
                CrossLoadingStatus = (short)JobStatusType.Ready
            };

            var convertedJob = JobConverter.Convert(job);

            convertedJob.JobId.Should().Be(1);
            convertedJob.DateTimeSubmittedUtc.Should().Be(currentTime);
            convertedJob.DateTimeUpdatedUtc.Should().Be(currentTime);
            convertedJob.JobType.Should().Be(1);
            convertedJob.Priority.Should().Be(1);
            convertedJob.Status.Should().Be(1);
            convertedJob.NotifyEmail.Should().Be("*****@*****.**");
            convertedJob.SubmittedBy.Should().Be("test");
            convertedJob.CrossLoadingStatus.Should().Be(JobStatusType.Ready);
        }
        public void JobEntityToJob_Test_Null()
        {
            Data.Entities.Job job = null;
            var convertedJob      = JobConverter.Convert(job);

            convertedJob.Should().BeNull();
        }
        public void JobToJobEntity_Test_Null()
        {
            Job job          = null;
            var convertedJob = JobConverter.Convert(job);

            convertedJob.Should().BeNull();
        }
        public void JobMetaDataEntityToJobMetaData_Test()
        {
            var entity = new FileUploadJobMetaData
            {
                FileName         = "test.xml",
                JobId            = 1,
                StorageReference = "test-ref",
                Ukprn            = 1000,
                CollectionName   = "ILR1819",
                PeriodNumber     = 10,
                FileSize         = 1000,
                Job = new Data.Entities.Job {
                    JobId = 1
                }
            };

            var job = new FileUploadJob();

            JobConverter.Convert(entity, job);

            job.JobId.Should().Be(1);
            job.FileName.Should().Be("test.xml");
            job.StorageReference.Should().Be("test-ref");
            job.Ukprn.Should().Be(1000);
            job.CollectionName.Should().Be("ILR1819");
            job.PeriodNumber.Should().Be(10);
            job.FileSize.Should().Be(1000);
        }
Exemplo n.º 7
0
 private void InitializeJobs()
 {
     _jobFactory    = new JobFactory();
     _jobConverter  = new JobConverter(_jobFactory, _skillConverter, _toolConverter, _zoneConverter);
     _jobs          = new ConcurrentDictionary <int, IJob>();
     _activitiesMap = new ConcurrentDictionary <int, IActivity>();
     _scheduledJobs = new ConcurrentDictionary <Guid, IActivitySchedule>();
 }
Exemplo n.º 8
0
        public void TestTask()
        {
            IDataAccessor da = taskDA;

            read(da);
            DataTable table = dataSet.task;

            Assert.AreEqual(0, table.Rows.Count, "Table is empty");
            DataRow personRow = dataSet.person.NewRow();
            Person  person    = new Person("person", "", Person.PersonType.ADMIN);

            PersonConverter.toDataRow(personRow, person);
            dataSet.person.Rows.Add(personRow);
            write(personDA);
            DataRow modelRow = dataSet.model.NewRow();
            Model   model    = new Model("model");

            ModelConverter.toDataRow(modelRow, model);
            dataSet.model.Rows.Add(modelRow);
            write(modelDA);
            DataRow jobRow = dataSet.job.NewRow();
            Job     job    = new Job(0, "job", DateTime.Now, "test", 0, 0);

            JobConverter.toDataRow(jobRow, job);
            dataSet.job.Rows.Add(jobRow);
            write(jobDA);
            DataRow printerRow = dataSet.printer.NewRow();
            Printer printer    = new Printer("printer");

            PrinterConverter.toDataRow(printerRow, printer);
            dataSet.printer.Rows.Add(printerRow);
            write(printerDA);
            DataRow newRow = table.NewRow();

            TaskConverter.toDataRow(newRow, new Task(0, "TestTask", 0, 0, DateTime.Now, DateTime.Now, DateTime.Now, Task.TaskStatus.NEW, 0));
            table.Rows.Add(newRow);
            write(da);
            Assert.AreEqual(1, table.Rows.Count, "Added one record");
            DataRow firstRow = table.Rows[0];

            Assert.AreEqual("TestTask", firstRow["name"], "Names are equals");
            firstRow["name"] = "RenameTest";
            write(da);
            List <DataRow> findList = table.Select("name = 'RenameTest'").OfType <DataRow>().ToList();

            Assert.AreEqual("RenameTest", findList[0]["name"], "Names are equals");
            firstRow.Delete();
            write(da);
            read(da);
            int count = dataSet.task.Rows.Count;

            Assert.AreEqual(0, count);
        }
Exemplo n.º 9
0
        /// <summary>
        /// ステータスバー(ヘッダ)の書き換え
        /// </summary>
        private void WriteStatusBarHeader()
        {
            StringBuilder sb = new StringBuilder();

            foreach (LocalDataBaseDataSet.JobMasterRow row in this.Dac.JobMaster.Select("", "JobID"))
            {
                sb.Append(JobConverter.ToString(row.JobID));

                if ("En" == this.JpEnMode)
                {
                    sb.Append("\t");
                }
            }

            this.stbHeader.Text = sb.ToString();
        }
Exemplo n.º 10
0
        public void TestJob()
        {
            IDataAccessor da = jobDA;

            read(da);
            Assert.AreEqual(0, dataSet.job.Rows.Count, "Table is empty");
            DataRow personRow = dataSet.person.NewRow();
            Person  person    = new Person("person", "", Person.PersonType.ADMIN);

            PersonConverter.toDataRow(personRow, person);
            dataSet.person.Rows.Add(personRow);
            write(personDA);
            DataRow modelRow = dataSet.model.NewRow();
            Model   model    = new Model("model");

            ModelConverter.toDataRow(modelRow, model);
            dataSet.model.Rows.Add(modelRow);
            write(modelDA);
            read(modelDA);
            DataRow newRow = dataSet.job.NewRow();

            JobConverter.toDataRow(newRow, new Job(0, "TestJob", DateTime.Now, "test", 0, 0));
            dataSet.job.Rows.Add(newRow);
            write(da);
            read(da);
            Assert.AreEqual(1, dataSet.job.Rows.Count, "Added one record");
            DataRow firstRow = dataSet.job.Rows[0];

            Assert.AreEqual("TestJob", firstRow["name"], "Names are equals");
            firstRow["name"] = "RenameTest";
            write(da);
            read(da);
            List <DataRow> findList = dataSet.job.Select("name = 'RenameTest'").OfType <DataRow>().ToList();

            Assert.AreEqual("RenameTest", findList[0]["name"], "Names are equals");
            firstRow = dataSet.job.Rows[0];
            firstRow.Delete();
            write(da);
            read(da);
            int count = dataSet.job.Rows.Count;

            Assert.AreEqual(0, count);
        }
Exemplo n.º 11
0
        public IEnumerable <Job> GetStuckJobs()
        {
            DateTime   utcNow = _dateTimeProvider.GetNowUtc();
            List <Job> jobs   = new List <Job>();

            using (var context = new JobQueueDataContext(_contextOptions))
            {
                IEnumerable <JobEntity> jobEntities = context.Jobs
                                                      .Where(x => x.CrossLoadingStatus != null && x.CrossLoadingStatus.Value == _crossLoadingStatus)
                                                      .AsEnumerable()
                                                      .Where(x => x.DateTimeUpdatedUtc != null && x.DateTimeUpdatedUtc.Value.AddMinutes(_numberOfMinutesBeforeFail) < utcNow);
                foreach (JobEntity jobEntity in jobEntities)
                {
                    jobs.Add(JobConverter.Convert(jobEntity));
                }
            }

            return(jobs);
        }
        public SolverDataManager(ProjectDataSet model, ConstraintSolverResult data)
        {
            _model        = model;
            _solverResult = data;

            var jobFactory    = new JobFactory();
            var skillFactory  = new SkillFactory();
            var workerFactory = new WorkerFactory();
            var toolFactory   = new ToolFactory();
            var zoneFactory   = new ZoneFactory();
            var shiftFactory  = new ShiftFactory();

            var shiftConverter = new ShiftConverter(shiftFactory);
            var skillConverter = new SkillConverter(skillFactory);
            var toolConverter  = new ToolConverter(toolFactory, shiftConverter);
            var zoneConverter  = new ZoneConverter(zoneFactory);
            var laborConverter = new LaborConverter(workerFactory, shiftConverter, skillConverter);
            var jobConverter   = new JobConverter(jobFactory, skillConverter, toolConverter, zoneConverter);

            _shiftManager = new ShiftManager(shiftConverter, skillConverter, laborConverter, toolConverter);
            _jobManager   = new JobManager(jobConverter);
            _zoneManager  = new ZoneManager(zoneConverter);
        }
        public SolverDataManager(ProjectDataSet model, ConstraintSolverResult data)
        {
            _model = model;
            _solverResult = data;

            var jobFactory = new JobFactory();
            var skillFactory = new SkillFactory();
            var workerFactory = new WorkerFactory();
            var toolFactory = new ToolFactory();
            var zoneFactory = new ZoneFactory();
            var shiftFactory = new ShiftFactory();
            
            var shiftConverter = new ShiftConverter(shiftFactory);
            var skillConverter = new SkillConverter(skillFactory);
            var toolConverter = new ToolConverter(toolFactory, shiftConverter);
            var zoneConverter = new ZoneConverter(zoneFactory);
            var laborConverter = new LaborConverter(workerFactory, shiftConverter, skillConverter);
            var jobConverter = new JobConverter(jobFactory, skillConverter, toolConverter, zoneConverter);

            _shiftManager = new ShiftManager(shiftConverter, skillConverter, laborConverter, toolConverter);
            _jobManager = new JobManager(jobConverter);
            _zoneManager = new ZoneManager(zoneConverter);
        }
 private void InitializeJobs()
 {
     _jobFactory = new JobFactory();
     _jobConverter = new JobConverter(_jobFactory, _skillConverter, _toolConverter, _zoneConverter);
     _jobs = new ConcurrentDictionary<int, IJob>();
     _activitiesMap = new ConcurrentDictionary<int, IActivity>();
     _scheduledJobs = new ConcurrentDictionary<Guid, IActivitySchedule>();
 }
Exemplo n.º 15
0
 public JobManager(JobConverter jobConverter)
 {
     _jobConverter = jobConverter;
 }