Пример #1
0
 // Used for creating 'light' jobs
 internal JobRunContext(OperationContext context, string jobName, JobStartInfo startInfo, JobRunType runType)
 {
     OperationContext = context;
     JobName          = jobName ?? "Unnamed/" + JobRunId;
     StartInfo        = startInfo;
     StartedOn        = context.App.TimeService.UtcNow;
     JobRunId         = Guid.NewGuid();
     JobId            = Guid.NewGuid();
     RunType          = runType;
     _progress        = 0;
     Status           = JobRunStatus.Executing;
     IsPersisted      = false;
     AttemptNumber    = 1;
 }
        internal IJobRun NewJobRun(IJob job, JobRunType runType, DateTime?startOn = null, Guid?dataId = null, string data = null, string hostName = null)
        {
            var session     = EntityHelper.GetSession(job);
            var timeService = session.Context.App.TimeService;
            var jobRun      = session.NewEntity <IJobRun>();

            jobRun.Job           = job;
            jobRun.RunType       = runType;
            jobRun.StartOn       = startOn == null ? timeService.UtcNow : startOn.Value;
            jobRun.DataId        = dataId;
            jobRun.Data          = data;
            jobRun.AttemptNumber = 1;
            jobRun.UserId        = session.Context.User.UserId;
            jobRun.HostName      = hostName ?? _settings.HostName;
            return(jobRun);
        }
        public static AddJobAbstract Get(JobRunType runType, Type jobClass)
        {
            switch (runType)
            {
            case JobRunType.Recurring:
                return(new AddRecurringJob(jobClass));

            case JobRunType.OneTime:
                return(new AddOneTimeJob(jobClass));

            case JobRunType.Delayed:
                return(new AddDelayJob(jobClass));

            default:
                throw new Exception($"unkown runType {runType}");
            }
        }
Пример #4
0
        //internal Thread Thread; //background thread for long-running jobs

        internal JobRunContext(IJobRun jobRun)
        {
            var      session = EntityHelper.GetSession(jobRun);
            var      app     = session.Context.App;
            UserInfo user    = (jobRun.UserId == null) ? UserInfo.System : new UserInfo(jobRun.UserId.Value, null);

            OperationContext = new OperationContext(app, user);
            StartedOn        = app.TimeService.UtcNow;
            JobName          = jobRun.Job.Name;
            JobRunId         = jobRun.Id;
            RunType          = jobRun.RunType;
            AttemptNumber    = jobRun.AttemptNumber;
            var job = jobRun.Job;

            JobId       = job.Id;
            _progress   = jobRun.Progress;
            IsPersisted = true;
            DataId      = jobRun.DataId;
            Data        = jobRun.Data;
        }