/* * public IDownloadManager DownloadRelease(string releaseId, string currentFileId = null) * { * // ignore if already launched * if (_currentlyDownloading.Contains(releaseId)) { * _logger.Warn("Skipping already queued release {0}.", releaseId); * return this; * } * _currentlyDownloading.Add(releaseId); * * // retrieve release details * _logger.Info("Retrieving details for release {0} before downloading..", releaseId); * _vpdbManager.GetRelease(releaseId).ObserveOn(Scheduler.Default).Subscribe(release => { * * // match file based on settings * var file = FindLatestFile(release, currentFileId); * * // check if match * if (file == null) { * _logger.Info("Nothing matched current flavor configuration, skipping."); * _currentlyDownloading.Remove(releaseId); * return; * } * * // download * DownloadRelease(release, file); * * }, exception => _vpdbManager.HandleApiError(exception, "retrieving release details during download")); * * return this; * }*/ public IDownloadManager DownloadRelease(AggregatedGame game) { var release = game.MappedRelease; var tableFile = game.MappedTableFile; // also fetch game data for media & co _vpdbManager.GetGame(release.Game.Id, true).Subscribe(g => { var version = _databaseManager.GetVersion(release.Id, tableFile.Reference.Id); _logger.Info($"Checking what to download for {g.DisplayName} - {release.Name} v{version?.Name} ({tableFile.Reference.Id})"); var gameName = release.Game.DisplayName; var system = _pinballXManager.FindSystem(tableFile); var platform = tableFile.Compatibility[0].Platform; var fileTypes = new List <FileType>(); // check if backglass image needs to be downloaded var backglassImagePath = Path.Combine(system.MediaPath, Job.MediaBackglassImages); if (!FileBaseExists(backglassImagePath, gameName)) { fileTypes.Add(FileType.BackglassImage); _jobManager.AddJob(new Job(release, g.Backglass, FileType.BackglassImage, platform)); } // check if wheel image needs to be downloaded var wheelImagePath = Path.Combine(system.MediaPath, Job.MediaWheelImages); if (!FileBaseExists(wheelImagePath, gameName)) { fileTypes.Add(FileType.WheelImage); _jobManager.AddJob(new Job(release, g.Logo, FileType.WheelImage, platform)); } // queue table shot var tableImage = Path.Combine(system.MediaPath, Job.MediaTableImages); if (!FileBaseExists(tableImage, gameName)) { fileTypes.Add(FileType.TableImage); _jobManager.AddJob(new Job(release, tableFile.PlayfieldImage, FileType.TableImage, platform)); } // todo check for ROM to be downloaded, path at HKEY_CURRENT_USER\SOFTWARE\Freeware\Visual PinMame\globals // todo also queue all remaining non-table files of the release. // queue for download var job = new Job(release, tableFile, FileType.TableFile, platform); fileTypes.Add(FileType.TableFile); _logger.Info("Found {0} file type(s) to download: {1}", fileTypes.Count, string.Join(", ", fileTypes)); _jobManager.AddJob(job); game.SetJob(job); _logger.Info("Created new job for {0} - {1} v{2} ({3}): {4}", job.Release.Game.DisplayName, job.Release.Name, job.Version.Name, job.File.Id, tableFile.ToString()); _currentlyDownloading.Remove(release.Id); }, exception => _vpdbManager.HandleApiError(exception, "retrieving game details during download")); return(this); }
private void AddJob(IJobTask task) { var qParams = new QueueParams(task.Tag.NoHashTag, hangfireSettings.Value.ServerName); task = new TwitterJobTask(task.Tag, qParams, settings.Value.TwitterMessagePublishDelay); jobManager.AddJob(task); }
/// <summary> /// 添加Job /// </summary> /// <param name="input"></param> public bool AddJob(JobInfoInputDto input) { var job = _jobInfoRepository.Get(x => x.JobName.Equals(input.jobname) && x.JobGroup.Equals(input.jobgroup), true); if (job == null) { return(false); } var result = _jobManager.AddJob(input.jobname, input.jobgroup, input.jobcron, job.JobValue, job.JobClass) .Result; var trigger_state = _jobManager.GeTriggerState(input.jobname, input.jobgroup); if (trigger_state != TriggerState.Normal || trigger_state != TriggerState.Paused) { return(false); } job.JobCron = input.jobcron; job.IsDelete = 0; job.JobStatus = (int)TriggerState.Normal; job.CreateTime = DateTime.Now; job.UpdateTime = DateTime.Now; _jobInfoRepository.Update(job); return(_jobInfoRepository.SaveChanges() > 0); }
public async Task AddJob_Null() { IContainer container = Registrations(); using (var scope = container.BeginLifetimeScope()) { IJobManager manager = scope.Resolve <IJobManager>(); await Assert.ThrowsAsync <ArgumentNullException>(() => manager.AddJob(null)); } }
public async Task GetAllJobs_Success() { IContainer container = Registrations(); IEnumerable <Job> result; using (var scope = container.BeginLifetimeScope()) { IJobManager manager = scope.Resolve <IJobManager>(); await manager.AddJob(new Job()); await manager.AddJob(new Job()); await manager.AddJob(new Job()); result = await manager.GetAllJobs(); } result.Count().Should().Be(3); }
public async Task AddJob_Success() { IContainer container = Registrations(); using (var scope = container.BeginLifetimeScope()) { IJobManager manager = scope.Resolve <IJobManager>(); var result = await manager.AddJob(new Job()); result.Should().Be(1); } }
public async Task GetJobById_Success() { IContainer container = Registrations(); Job result; using (var scope = container.BeginLifetimeScope()) { IJobManager manager = scope.Resolve <IJobManager>(); var jobId = await manager.AddJob(new Job()); result = await manager.GetJobById(1); } result.Should().NotBeNull(); result.JobId.Should().Be(1); }
private async Task QueueAnyNewReferenceDataJobsAsync(CancellationToken cancellationToken) { IEnumerable <JobType> jobTypes = await _externalDataScheduleService.GetJobs(true, cancellationToken); foreach (JobType jobType in jobTypes) { Job refDataJob = new Job { DateTimeSubmittedUtc = _dateTimeProvider.GetNowUtc(), JobType = jobType, Priority = 1, Status = JobStatusType.Ready, SubmittedBy = "System" }; /* long id = */ await _jobQueueManager.AddJob(refDataJob); } }
public async Task AddJob_Success_Values(JobType jobType) { var job = new Job { DateTimeSubmittedUtc = DateTime.UtcNow, DateTimeUpdatedUtc = DateTime.UtcNow, JobId = 0, Priority = 1, RowVersion = null, Status = JobStatusType.Ready, SubmittedBy = "test user", JobType = jobType, NotifyEmail = "*****@*****.**" }; IContainer container = Registrations(); Job savedJob; using (var scope = container.BeginLifetimeScope()) { IJobManager manager = scope.Resolve <IJobManager>(); await manager.AddJob(job); var result = await manager.GetAllJobs(); savedJob = result.SingleOrDefault(); } savedJob.Should().NotBeNull(); savedJob.JobId.Should().Be(1); savedJob.DateTimeSubmittedUtc.Should().BeOnOrBefore(DateTime.UtcNow); savedJob.DateTimeUpdatedUtc.Should().BeNull(); savedJob.JobType.Should().Be(jobType); savedJob.Priority.Should().Be(1); savedJob.SubmittedBy.Should().Be("test user"); savedJob.Status.Should().Be(JobStatusType.Ready); savedJob.NotifyEmail.Should().Be("*****@*****.**"); savedJob.CrossLoadingStatus.Should().Be(null); }
private void OnDoJob(IJob job) { _jobManager.AddJob(job); _jobManager.ExecuteJobs(); }
public void Handle(JobCreatedMessage message) { var job = _mapper.Map <Job>(message); _manager.AddJob(job); }