예제 #1
0
 public JobController()
 {
     this.profileRepo = new ProfileRepository(new MVCEntities());
     this.jobRepo = new JobRepository(new MVCEntities());
     this.accountRepo = new AccountRepository(new MVCEntities());
     this.notiRepo = new NotificationRepository(new MVCEntities());
 }
예제 #2
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            StartupIoC.RegisterIoC(_locator);

            // make sure we're able to do work
            _worker = new WorkerRegistrationController(_locator).EnsureWorkerRegistration();
            _jobRepository = _locator.Locate<IJobRepository>();
            _presenter = new WorkloadPresenter(new WorkloadView());

            var poller = new JobPoller(_presenter, _locator, _worker);

            if (_worker.CurrentJob != Guid.Empty)
            {
                // start working on the job
                _presenter.CurrentJob = JobFactory.CreateJob(_jobRepository.GetCurrentJob(_worker.Id), _worker, _locator);
            }

            poller.Start();

            try
            {
                Application.Run((WorkloadView) _presenter.View);
            }
            finally
            {
                poller.Stop();
            }
        }
예제 #3
0
 /// <summary>
 /// Custom constructor using a job repository, a step hander and a job execution.
 /// </summary>
 /// <param name="jobRepository"></param>
 /// <param name="stepHandler"></param>
 /// <param name="execution"></param>
 public JobFlowExecutor(IJobRepository jobRepository, IStepHandler stepHandler, JobExecution execution)
 {
     _jobRepository = jobRepository;
     _stepHandler = stepHandler;
     _execution = execution;
     _stepExecutionHolder.Value = null;
 }
 public JobSchemaController()
 {
     this._IJobSchemaRepository = new JobSchemaRepository(new WorkersInMotionDB());
     this._IJobRepository = new JobRepository(new WorkersInMotionDB());
     this._IUserRepository = new UserRepository(new WorkersInMotionDB());
     //   this._IGroupRepository = new GroupRepository(new WorkersInMotionContext());
 }
예제 #5
0
 public BidController()
 {
     this.accountRepo = new AccountRepository(new MVCEntities());
     this.jobRepo = new JobRepository(new MVCEntities());
     this.bidRepo = new BidRepository(new MVCEntities());
     this.disbidRepo = new DisplayBidRepository(new MVCEntities());
 }
예제 #6
0
 public EmailNotification(ILog logger, IJobRepository jobRepository, IEnumerable<string> emailAddresses, string smtpserver)
 {
     _logger = logger;
     _jobRepository = jobRepository;
     _emailAddresses = emailAddresses;
     _smtpserver = smtpserver;
     _smtpserver = smtpserver;
 }
예제 #7
0
 /// <summary>
 ///In constructor, we can get needed classes/interfaces.
 ///They are sent here by dependency injection system automatically.
 /// </summary>
 public JobAppService(IJobRepository jobRepository, UserManager userManager, IAccountRepository accountRepository, IContactRepository contactrepository)
 {
     _jobRepository = jobRepository;
     _userManager = userManager;
     _accountRepository = accountRepository;
     _contactRepository = contactrepository;
    
 }
예제 #8
0
 public POController()
 {
     this._IPORepository = new PORepository(new WorkersInMotionDB());
     this._IPlaceRepository = new PlaceRepository(new WorkersInMotionDB());
     this._IMarketRepository = new MarketRepository(new WorkersInMotionDB());
     this._IJobRepository = new JobRepository(new WorkersInMotionDB());
     this._ITerritoryRepository = new TerritoryRepository(new WorkersInMotionDB());
     this._IRegionRepository = new RegionRepository(new WorkersInMotionDB());
 }
예제 #9
0
 public JobController(WorkersInMotionDB context)
 {
     this._IPlaceRepository = new PlaceRepository(context);
     this._IMarketRepository = new MarketRepository(context);
     this._IRegionRepository = new RegionRepository(context);
     this._ITerritoryRepository = new TerritoryRepository(context);
     this._IJobRepository = new JobRepository(context);
     this._IJobSchemaRepository = new JobSchemaRepository(context);
 }
예제 #10
0
        public JobPoller(WorkloadPresenter presenter, ILocator locator, WorkerState worker, int? intervalSeconds = null)
        {
            _interval = intervalSeconds ?? _interval;

            _presenter = presenter;
            _jobRepository = locator.Locate<IJobRepository>();
            _worker = worker;
            _serviceLocator = locator;
        }
예제 #11
0
파일: Job.cs 프로젝트: c0d3m0nky/mty
 public void Cancel(IJobRepository jobRepository,Event dblogEvent)
 {
     jobRepository.CancelJob(this, dblogEvent.Monitor == Event.Monitors.CancelOnBulking ? CobCancelCode : F21CancelCode);
     dblogEvent.EventActions.Add(new EventAction()
     {
         Action = EventAction.Actions.JobCancel,
         ActedOnDeliveryGroupId = deliverygroup_id,
         JobId = job_id
     });
 }
 public SelectBuildServerViewModel(IJobRepository jobRepository, IJobController jobController, 
     IJobProviderFactory jobProviderFactory, INavigationService navigationService, 
     ISchedulerAccessor schedulerAccessor, IMessageBoxFacade messageBoxFacade)
 {
     this.jobRepository = jobRepository;
     this.navigationService = navigationService;
     this.schedulerAccessor = schedulerAccessor;
     this.messageBoxFacade = messageBoxFacade;
     this.jobController = jobController;
 }
예제 #13
0
        public Job(JobDescriptor jobDescription, Guid workerId, ILocator locator)
        {
            _serviceLocator = locator;
            _jobRepository = locator.Locate<IJobRepository>();
            _apiRepository = locator.Locate<IApiDataRepository>();

            Id = jobDescription.Id;
            WorkerId = workerId;
            JobDescriptor = jobDescription;
        }
 public JobDetailsController()
 {
     this._IJobRepository = new JobRepository(new WorkersInMotionDB());
     this._IJobSchemaRepository = new JobSchemaRepository(new WorkersInMotionDB());
     this._IPlaceRepository = new PlaceRepository(new WorkersInMotionDB());
     this._IMarketRepository = new MarketRepository(new WorkersInMotionDB());
     this._IRegionRepository = new RegionRepository(new WorkersInMotionDB());
     this._ITerritoryRepository = new TerritoryRepository(new WorkersInMotionDB());
     this._IUserRepository = new UserRepository(new WorkersInMotionDB());
 }
 public StoreVistController(WorkersInMotionDB context)
 {
     this._IPlaceRepository = new PlaceRepository(context);
     this._IPeopleRepository = new PeopleRepository(context);
     this._IMarketRepository = new MarketRepository(context);
     this._IUserProfileRepository = new UserProfileRepository(context);
     this._IRegionRepository = new RegionRepository(context);
     this._ITerritoryRepository = new TerritoryRepository(context);
     this._IJobRepository = new JobRepository(context);
 }
 public AssignJobController(WorkersInMotionDB context)
 {
     this._IGlobalUserRepository = new GlobalUserRepository(context);
     this._IPlaceRepository = new PlaceRepository(context);
     this._IMarketRepository = new MarketRepository(context);
     this._IRegionRepository = new RegionRepository(context);
     this._ITerritoryRepository = new TerritoryRepository(context);
     this._IJobRepository = new JobRepository(context);
     this._IJobSchemaRepository = new JobSchemaRepository(context);
     // this._IGroupRepository = new GroupRepository(context);
 }
		public FavoritesViewModel (IJobRepository jobRepository)
		{
			_jobRepository = jobRepository;

			Jobs = new ObservableCollection<JobItemViewModel>();

			OnJobSelectedCommand = new RelayCommand(OnJobSelected);

			IsLoading = false;

			SubscribeToMessages();
		}
예제 #18
0
 public AddJobsViewModel(INavigationService navigationService, IJobController jobController,
     IJobProviderFactory jobProviderFactory, IJobRepository jobRepository, ISchedulerAccessor schedulerAccessor,
     IApplicationInformation applicationInformation, IMessageBoxFacade messageBoxFacade)
 {
     this.navigationService = navigationService;
     this.jobController = jobController;
     this.jobProviderFactory = jobProviderFactory;
     this.jobRepository = jobRepository;
     this.schedulerAccessor = schedulerAccessor;
     this.applicationInformation = applicationInformation;
     this.messageBoxFacade = messageBoxFacade;
 }
 public JobStatusController(WorkersInMotionDB context)
 {
     this._IGlobalUserRepository = new GlobalUserRepository(context);
     this._IUserProfileRepository = new UserProfileRepository(context);
     this._IPlaceRepository = new PlaceRepository(context);
     this._IMarketRepository = new MarketRepository(context);
     this._ITerritoryRepository = new TerritoryRepository(context);
     this._IRegionRepository = new RegionRepository(context);
     this._IUserRepository = new UserRepository(context);
     this._IJobRepository = new JobRepository(context);
     this._IPORepository = new PORepository(context);
 }
예제 #20
0
파일: Job.cs 프로젝트: c0d3m0nky/mty
        public static IQueryable<Job> GetHotmailRelatedJobsSent(IJobRepository jobRepository, Campaign campaign, DateTime cutOffTime)
        {
            var jobs = jobRepository.GetAll()
                          .Where(j => j.Template.creative_id == campaign.Template.creative_id
                                      && j.Template.fromName.Trim() == campaign.Template.fromName.Trim()
                                      && j.Template.emailSubject.Trim() == campaign.Template.emailSubject
                                      && j.deliverygroup_id.HasValue
                                      && j.DeliveryGroup.CancelOnBulkingEnabled
                                      && DeliveringJobStatusIds.Contains(j.jobstatus_id)
                                      && j.datelaunch < cutOffTime);

            return jobs;
        }
 public UserActivitiesController()
 {
     this._IOrganizationRepository = new OrganizationRepository(new WorkersInMotionDB());
     this._IJobRepository = new JobRepository(new WorkersInMotionDB());
     this._IGlobalUserRepository = new GlobalUserRepository(new WorkersInMotionDB());
     this._IUserProfileRepository = new UserProfileRepository(new WorkersInMotionDB());
     this._IPlaceRepository = new PlaceRepository(new WorkersInMotionDB());
     this._IMarketRepository = new MarketRepository(new WorkersInMotionDB());
     this._ITerritoryRepository = new TerritoryRepository(new WorkersInMotionDB());
     this._IRegionRepository = new RegionRepository(new WorkersInMotionDB());
     this._IUserRepository = new UserRepository(new WorkersInMotionDB());
     this._IPORepository = new PORepository(new WorkersInMotionDB());
 }
예제 #22
0
 public ViewJobViewModel(INavigationService navigationService, IJobRepository jobRepository, 
     ISchedulerAccessor schedulerAccessor, IApplicationTileService applicationTileService, 
     IWebBrowserTaskFacade webBrowserTask, IMessageBoxFacade messageBoxFacade,
     IJobController jobController)
 {
     this.navigationService = navigationService;
     this.jobRepository = jobRepository;
     this.schedulerAccessor = schedulerAccessor;
     this.applicationTileService = applicationTileService;
     this.webBrowserTask = webBrowserTask;
     this.messageBoxFacade = messageBoxFacade;
     this.jobController = jobController;
 }
예제 #23
0
        public static void CancelHotmailJobsByDeliveryGroup(IJobRepository jobRepository, ILog logger, DeliveryGroup deliveryGroup, DateTime cutOffTime, Event dblogEvent)
        {
            var jobs = jobRepository.GetAll().Where(j => j.deliverygroup_id == deliveryGroup.deliverygroup_id
                                                            && j.datelaunch < cutOffTime
                                                            && j.DeliveryGroup.CancelOnBulkingEnabled
                                                            && !CancellationExcludedJobStatusIds.Contains(j.jobstatus_id)).ToArray();

            foreach (var job in jobs)
            {
                job.Cancel(jobRepository,dblogEvent);
                logger.InfoFormat("Cancelled Job {0} and its targets", job.job_id);
            }
            logger.InfoFormat("Cancelled {0} Jobs", jobs.Count());
        }
 public SiteVisitController(WorkersInMotionDB context)
 {
     this._IOrganizationRepository = new OrganizationRepository(context);
     this._IPlaceRepository = new PlaceRepository(context);
     this._IPeopleRepository = new PeopleRepository(context);
     this._IMarketRepository = new MarketRepository(context);
     this._IUserProfileRepository = new UserProfileRepository(context);
     this._IRegionRepository = new RegionRepository(context);
     this._ITerritoryRepository = new TerritoryRepository(context);
     this._IJobRepository = new JobRepository(context);
     this._IUserRepository = new UserRepository(context);
     this._IGlobalUserRepository = new GlobalUserRepository(context);
     this._IPORepository = new PORepository(context);
 }
예제 #25
0
 public UserController()
 {
     this._IUserProfileRepository = new UserProfileRepository(new WorkersInMotionDB());
     //  this._IGroupRepository = new GroupRepository(new WorkersInMotionContext());
     this._IRegionRepository = new RegionRepository(new WorkersInMotionDB());
     this._ITerritoryRepository = new TerritoryRepository(new WorkersInMotionDB());
     this._IUserRepository = new UserRepository(new WorkersInMotionDB());
     this._IGlobalUserRepository = new GlobalUserRepository(new WorkersInMotionDB());
     this._IOrganizationSubscriptionRepository = new OrganizationSubscriptionRepository(new WorkersInMotionDB());
     this._IOrganizationRepository = new OrganizationRepository(new WorkersInMotionDB());
     this._IUserSubscriptionRepository = new UserSubscriptionRepository(new WorkersInMotionDB());
     this._IMarketRepository = new MarketRepository(new WorkersInMotionDB());
     this._IJobRepository = new JobRepository(new WorkersInMotionDB());
 }
예제 #26
0
 public CancelOnBulking(
     ILog logger,
     IMtaAgent mtaAgent,
     EmailNotification notificationEmails,
     IUnitOfWork unitOfWork,
     IEventRepository eventRepository,
     IJobRepository jobRepository
     )
 {
     _logger = logger;
     _unitOfWork = unitOfWork;
     _mtaAgent = mtaAgent;
     _eventRepository = eventRepository;
     _jobRepository = jobRepository;
     _emailNotification = notificationEmails;
 }
예제 #27
0
 public Bootstrap(IApplicationSettings applicationSettings, IClock clock, 
     IMessageBoxFacade messageBox, IMutexService mutexService,
     ILogManager logManager, ISettingsApplier settingsApplier,
     IJobRepository jobRepository, IPeriodicJobUpdateService periodicJobUpdateService,
     IApplicationInformation applicationInformation)
 {
     this.applicationSettings = applicationSettings;
     this.clock = clock;
     this.messageBox = messageBox;
     this.mutexService = mutexService;
     this.logManager = logManager;
     this.jobRepository = jobRepository;
     this.periodicJobUpdateService = periodicJobUpdateService;
     this.settingsApplier = settingsApplier;
     this.applicationInformation = applicationInformation;
 }
 public AIMAdminUnitOfWork(IAIM_DBContext context,
     IApplicantQuestionAnswerRepository applicantQuestionAnswerRepository,
     IApplicantRepository applicantRepository,
     IApplicationRepository applicationRepository,
     IAspNetRoleRepository aspNetRoleRepository,
     IAspNetUserClaimRepository aspNetUserClaimRepository,
     IAspNetUserLoginRepository aspNetUserLoginRepository,
     IAspNetUserRepository aspNetUserRepository,
     IEducationRepository educationRepository,
     IEmployeeRepository employeeRepository,
     IHourRepository hourRepositor,
     IInterviewQuestionRepository interviewQuestionRepository,
     IJobHistoryRepository jobHistoryRepository,
     IJobRepository jobRepository,
     IOpenJobRepository openJobRepository,
     IPersonalInfoRepository personalInfoRepository,
     IQuestionnaireRepository questionnaireRepository,
     IQuestionRepository questionRepository,
     IReferenceRepository referenceRepository,
     IRegionRepository regionRepository,
     IStoreRepository storeRepository,
     IUserRepository userRepository) :
     base(context as DbContext)
 {
     _applicantQuestionAnswerRepository = applicantQuestionAnswerRepository;
     _applicantRepository = applicantRepository;
     _applicationRepository = applicationRepository;
     _aspNetRoleRepository = aspNetRoleRepository;
     _aspNetUserClaimRepository = aspNetUserClaimRepository;
     _aspNetUserLoginRepository = aspNetUserLoginRepository;
     _aspNetUserRepository = aspNetUserRepository;
     _educationRepository = educationRepository;
     _employeeRepository = employeeRepository;
     _hourRepository = hourRepositor;
     _interviewQuestionRepository = interviewQuestionRepository;
     _jobHistoryRepository = jobHistoryRepository;
     _jobRepository = jobRepository;
     _openJobRepository = openJobRepository;
     _personalInfoRepository = personalInfoRepository;
     _questionnaireRepository = questionnaireRepository;
     _questionRepository = questionRepository;
     _referenceRepository = referenceRepository;
     _regionRepository = regionRepository;
     _storeRepository = storeRepository;
     _userRepository = userRepository;
 }
예제 #29
0
 public JobUpdateService(IJobProviderFactory jobProviderFactory, IJobRepository jobRepository,
     IClock clock, ISettingsService settingsService, IMutexService mutexService,
     ISchedulerAccessor schedulerAccessor, IApplicationTileService applicationTileService,
     IJobNotificationService jobNotificationService, ILog log,
     INetworkInterfaceFacade networkInterfaceFacade, IApplicationInformation applicationInformation)
 {
     this.jobProviderFactory = jobProviderFactory;
     this.jobRepository = jobRepository;
     this.clock = clock;
     this.settingsService = settingsService;
     this.mutexService = mutexService;
     this.schedulerAccessor = schedulerAccessor;
     this.applicationTileService = applicationTileService;
     this.jobNotificationService = jobNotificationService;
     this.log = log;
     this.networkInterfaceFacade = networkInterfaceFacade;
     this.applicationInformation = applicationInformation;
 }
예제 #30
0
파일: Job.cs 프로젝트: c0d3m0nky/mty
        public static void CancelHotmailRelatedJobs(IJobRepository jobRepository, ILog logger, Campaign campaign, DateTime cutOffTime, Event dblogEvent)
        {
            var jobs = jobRepository.GetAll()
                          .Where(j => j.Template.creative_id == campaign.Template.creative_id
                                      && j.Template.fromName.Trim() == campaign.Template.fromName.Trim()
                                      && j.Template.emailSubject.Trim() == campaign.Template.emailSubject
                                      && !CancellationExcludedJobStatusIds.Contains(j.jobstatus_id)
                                      && j.deliverygroup_id.HasValue
                                      && j.DeliveryGroup.CancelOnBulkingEnabled
                                      && j.datelaunch < cutOffTime).ToArray();

            foreach (var j in jobs)
            {
                j.Cancel(jobRepository,dblogEvent);
                logger.TraceFormat("Cancelled Job {0} and its targets", j.job_id);
            }
            logger.InfoFormat("Cancelled {0} Jobs", jobs.Count());
        }
 public HomeController(IJobRepository repo, UserManager <AppUser> userMrg)
 {
     repository  = repo;
     userManager = userMrg;
 }
예제 #32
0
 public JobsController(IJobRepository jobRepository)
 {
     this.jobRepository = jobRepository;
 }
예제 #33
0
 public JobController(IJobRepository job, IStringLocalizer <LanguageSub> localizer, IStageRepository stateRepo)
 {
     jobRepository   = job;
     stringLocalizer = localizer;
     stateRepository = stateRepo;
 }
예제 #34
0
 public JobsController(jobsContext context, IMapper mapper)
 {
     _context           = context;
     _mapper            = mapper;
     this.jobRepository = new JobRepository(new jobsContext());
 }
예제 #35
0
 public JobController(ILogger <JobController> logger,
                      IJobRepository jobRepository)
 {
     _logger            = logger;
     this.jobRepository = jobRepository;
 }
예제 #36
0
 public ValidateCommonRuleJobHandler(TypiconDBContext dbContext, IJobRepository jobs, IRuleSerializerRoot serializer)
     : base(dbContext, jobs, serializer)
 {
 }
예제 #37
0
 public GetJobListQueryHandler(IMapper mapper, IJobRepository jobRepository)
 {
     _mapper        = mapper;
     _jobRepository = jobRepository;
 }
예제 #38
0
 public JobManagerImpl(IJobRepository repository = null, IJobFactory factory = null) : base(repository, factory)
 {
 }
예제 #39
0
 public DeleteModel(IJobRepository jobRepository)
 {
     this._jobRepository = jobRepository;
 }
예제 #40
0
 public JobController(IJobRepository jobRepository)
 {
     _jobRepository = jobRepository;
 }
 /// <summary>
 /// Create manager
 /// </summary>
 /// <param name="jobRepository"></param>
 /// <param name="jobRepositoryEventHandlers"></param>
 public DefaultJobService(IJobRepository jobRepository,
                          IEnumerable <IJobEventHandler> jobRepositoryEventHandlers)
 {
     _jobRepository = jobRepository;
     _jobRepositoryEventHandlers = jobRepositoryEventHandlers;
 }
예제 #42
0
        private async Task ProcessNextJob(IJobRepository repository, IJobs jobsApi, CancellationToken cancellationToken)
        {
            InferenceJob       job    = null;
            InferenceJobStatus status = InferenceJobStatus.Fail;

            try
            {
                _logger.Log(LogLevel.Debug, $"Waiting for new job...");
                job = await repository.Take(cancellationToken);

                using (_logger.BeginScope(new LogginDataDictionary <string, object> {
                    { "JobId", job.JobId }, { "PayloadId", job.PayloadId }
                }))
                {
                    switch (job.State)
                    {
                    case InferenceJobState.Creating:
                        await CreateJob(job);

                        break;

                    case InferenceJobState.MetadataUploading:
                        await UploadMetadata(job);

                        break;

                    case InferenceJobState.PayloadUploading:
                        await UploadFiles(job, job.JobPayloadsStoragePath);

                        break;

                    case InferenceJobState.Starting:
                        await jobsApi.Start(job);

                        break;

                    default:
                        throw new InvalidOperationException($"Unsupported job state {job.State}.");
                    }
                    status = InferenceJobStatus.Success;
                }
            }
            catch (OperationCanceledException ex)
            {
                _logger.Log(LogLevel.Warning, ex, "Job Store Service canceled: {0}");
            }
            catch (InvalidOperationException ex)
            {
                _logger.Log(LogLevel.Warning, ex, "Job Store Service may be disposed or Jobs API returned an error: {0}");
            }
            catch (PayloadUploadException ex)
            {
                _logger.Log(LogLevel.Error, ex, ex.Message);
            }
            catch (Exception ex)
            {
                _logger.Log(LogLevel.Error, ex, "Error communicating with Clara Platform.");
            }
            finally
            {
                if (job != null)
                {
                    try
                    {
                        var updatedJob = await repository.TransitionState(job, status, cancellationToken);

                        if (updatedJob.State == InferenceJobState.Completed ||
                            updatedJob.State == InferenceJobState.Faulted)
                        {
                            CleanupJobFiles(updatedJob);
                        }
                    }
                    catch (Exception ex)
                    {
                        _logger.Log(LogLevel.Error, ex, "Error while transitioning job state.");
                    }
                }
            }
        }
예제 #43
0
 public JobController(IJobRepository repo)
 {
     _repository = repo;
 }
예제 #44
0
 public CommandController(IJobRepository jobRepository, ILoggerFactory loggerFactory)
 {
     _JobRepository = jobRepository;
     _logger        = loggerFactory.Create(Loggers.Commanding.Worker);
 }
예제 #45
0
 public JobService(IJobRepository jobRepository, IUnitOfWork unitOfWork)
 {
     this.jobRepository = jobRepository;
     this.unitOfWork    = unitOfWork;
 }
 public static IServiceCollection AddHorariumClient(this IServiceCollection service,
                                                    IJobRepository jobRepository)
 {
     return(service.AddHorariumClient(jobRepository, serviceProvider => new HorariumSettings()));
 }
예제 #47
0
 public CompaniesCollectionController(IJobRepository jobRepository, IMapper mapper)
 {
     this.jobRepository = jobRepository ?? throw new ArgumentNullException(nameof(jobRepository));
     this.mapper        = mapper ?? throw new ArgumentNullException(nameof(mapper));
 }
예제 #48
0
 public JobsController(IJobRepository jobRepository, IBus bus)
 {
     _jobRepository = jobRepository;
     _bus           = bus;
 }
예제 #49
0
 public JobController(IJobRepository Jobs, ILogManager logger, IServiceProvider ServiceProvider)
 {
     this.Jobs            = Jobs;
     this.logger          = logger;
     this.ServiceProvider = ServiceProvider;
 }
예제 #50
0
 public JobController(IJobRepository jobs, ILogManager logger, IServiceProvider serviceProvider)
 {
     _jobs            = jobs;
     _logger          = logger;
     _serviceProvider = serviceProvider;
 }
예제 #51
0
 public DummyPlanner(IEnumerable <IPlugin> plugins, IJobRepository jobRepository, ILogging logging) :
     base(plugins, jobRepository, logging)
 {
 }
예제 #52
0
 public JobService(IJobQuery jobQuery, IJobRepository jobRepository, IJobValidator jobValidator)
 {
     _jobQuery      = jobQuery;
     _jobRepository = jobRepository;
     _jobValidator  = jobValidator;
 }
예제 #53
0
        protected async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            await Task.Yield(); // required so that this method does not block startup

            try
            {
                while (!stoppingToken.IsCancellationRequested)
                {
                    using (var scope = _serviceScopeFactory.CreateScope())
                    {
                        // get name of job
                        string jobType = Utilities.GetFullTypeName(GetType().AssemblyQualifiedName);

                        // load jobs and find current job
                        IJobRepository jobs = scope.ServiceProvider.GetRequiredService <IJobRepository>();
                        Job            job  = jobs.GetJobs().Where(item => item.JobType == jobType).FirstOrDefault();
                        if (job != null && job.IsEnabled && !job.IsExecuting)
                        {
                            // get next execution date
                            DateTime NextExecution;
                            if (job.NextExecution == null)
                            {
                                if (job.StartDate != null)
                                {
                                    NextExecution = job.StartDate.Value;
                                }
                                else
                                {
                                    NextExecution = DateTime.UtcNow;
                                }
                            }
                            else
                            {
                                NextExecution = job.NextExecution.Value;
                            }

                            // determine if the job should be run
                            if (NextExecution <= DateTime.UtcNow && (job.EndDate == null || job.EndDate >= DateTime.UtcNow))
                            {
                                IJobLogRepository jobLogs = scope.ServiceProvider.GetRequiredService <IJobLogRepository>();

                                // create a job log entry
                                JobLog log = new JobLog();
                                log.JobId      = job.JobId;
                                log.StartDate  = DateTime.UtcNow;
                                log.FinishDate = null;
                                log.Succeeded  = false;
                                log.Notes      = "";
                                log            = jobLogs.AddJobLog(log);

                                // update the job to indicate it is running
                                job.IsExecuting = true;
                                jobs.UpdateJob(job);

                                // execute the job
                                try
                                {
                                    log.Notes     = ExecuteJob(scope.ServiceProvider);
                                    log.Succeeded = true;
                                }
                                catch (Exception ex)
                                {
                                    log.Notes     = ex.Message;
                                    log.Succeeded = false;
                                }

                                // update the job log
                                log.FinishDate = DateTime.UtcNow;
                                jobLogs.UpdateJobLog(log);

                                // update the job
                                job.NextExecution = CalculateNextExecution(NextExecution, job.Frequency, job.Interval);
                                job.IsExecuting   = false;
                                jobs.UpdateJob(job);

                                // trim the job log
                                List <JobLog> logs = jobLogs.GetJobLogs().Where(item => item.JobId == job.JobId)
                                                     .OrderByDescending(item => item.JobLogId).ToList();
                                for (int i = logs.Count; i > job.RetentionHistory; i--)
                                {
                                    jobLogs.DeleteJobLog(logs[i - 1].JobLogId);
                                }
                            }
                        }
                    }

                    // wait 1 minute
                    await Task.Delay(TimeSpan.FromMinutes(1), stoppingToken);
                }
            }
            catch
            {
                // can occur during the initial installation as there is no DBContext
            }
        }
예제 #54
0
        public async Task AddJobLog_GivenJobUpdated_EnsuresNewNotificationIsSent()
        {
            //Arrange
            string jobId = "job-id-1";

            JobLogUpdateModel jobLogUpdateModel = new JobLogUpdateModel
            {
                CompletedSuccessfully = false,
                Outcome        = "outcome",
                ItemsFailed    = 40,
                ItemsProcessed = 100,
                ItemsSucceeded = 60
            };

            Job job = new Job
            {
                Id                     = jobId,
                RunningStatus          = RunningStatus.InProgress,
                JobDefinitionId        = "job-definition-id",
                InvokerUserDisplayName = "authorName",
                InvokerUserId          = "authorId",
                ItemCount              = 100,
                SpecificationId        = "spec-id-1",
                Trigger                = new Trigger
                {
                    EntityId   = "spec-id-1",
                    EntityType = "Specification",
                    Message    = "allocating"
                }
            };

            IJobRepository jobRepository = CreateJobRepository();

            jobRepository
            .GetJobById(Arg.Is(jobId))
            .Returns(job);

            jobRepository
            .UpdateJob(Arg.Is(job))
            .Returns(HttpStatusCode.OK);

            jobRepository
            .CreateJobLog(Arg.Any <JobLog>())
            .Returns(HttpStatusCode.OK);

            ILogger logger = CreateLogger();

            INotificationService notificationService = CreateNotificationsService();

            JobManagementService jobManagementService = CreateJobManagementService(jobRepository: jobRepository, logger: logger, notificationService: notificationService);

            //Act
            IActionResult actionResult = await jobManagementService.AddJobLog(jobId, jobLogUpdateModel);

            //Assert
            actionResult
            .Should()
            .BeAssignableTo <OkObjectResult>();

            await
            notificationService
            .Received(1)
            .SendNotification(Arg.Is <JobNotification>(m =>
                                                       m.JobId == jobId &&
                                                       m.JobType == "job-definition-id" &&
                                                       m.CompletionStatus == CompletionStatus.Failed &&
                                                       m.InvokerUserDisplayName == "authorName" &&
                                                       m.InvokerUserId == "authorId" &&
                                                       m.ItemCount == 100 &&
                                                       m.Outcome == "outcome" &&
                                                       m.OverallItemsFailed == 40 &&
                                                       m.OverallItemsProcessed == 100 &&
                                                       m.OverallItemsSucceeded == 60 &&
                                                       m.ParentJobId == null &&
                                                       m.SpecificationId == "spec-id-1" &&
                                                       m.StatusDateTime.Date == DateTimeOffset.Now.ToLocalTime().Date&&
                                                       string.IsNullOrWhiteSpace(m.SupersededByJobId) &&
                                                       m.Trigger.EntityId == "spec-id-1" &&
                                                       m.Trigger.EntityType == "Specification" &&
                                                       m.Trigger.Message == "allocating" &&
                                                       m.RunningStatus == RunningStatus.Completed
                                                       ));
        }
예제 #55
0
 private async Task ResetStates(IJobRepository repository)
 {
     await repository.ResetJobState();
 }
 public EngineerMenuViewComponent(IItemRepository repo, IJobRepository jobrepo)
 {
     repository    = repo;
     jobrepository = jobrepo;
 }
 public GroupService(IMapper mapper, IGroupRepository repository, IJobRepository jobRepository)
 {
     _mapper        = mapper;
     _repository    = repository;
     _jobRepository = jobRepository;
 }
예제 #58
0
 public JobService(IJobRepository jobRepository)
 {
     _jobRepository = jobRepository;
 }
예제 #59
0
        public void SetUp()
        {
            _connectionString = Path.GetRandomFileName();

            _repository = new SQLiteJobRepository(_connectionString);
        }
예제 #60
0
 public ScheduledJobExecutor(IServiceBus serviceBus, IJobRepository jobRepo, ILogger <ScheduledJobExecutor> logger)
 {
     this.serviceBus = serviceBus;
     this.jobRepo    = jobRepo;
     this.logger     = logger;
 }