当前位置: 首页>>代码示例>>C#>>正文


C# JobKey类代码示例

本文整理汇总了C#中JobKey的典型用法代码示例。如果您正苦于以下问题:C# JobKey类的具体用法?C# JobKey怎么用?C# JobKey使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


JobKey类属于命名空间,在下文中一共展示了JobKey类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: JobInfo

 public JobInfo(JobKey id, JobDetailImpl job)
 {
     Id = id;
     Job = job;
     Triggers = new TriggerInfo[0];
     TriggerCount = 0;
 }
开发者ID:CaptainCodeman,项目名称:quartznet,代码行数:7,代码来源:JobInfo.cs

示例2: ShouldDisposeScopeAfterJobCompletion

        public void ShouldDisposeScopeAfterJobCompletion()
        {
            var key = new JobKey("disposable", "grp2");
            var job1 = JobBuilder.Create<SampleJob>().WithIdentity(key).StoreDurably(true)
                .Build();
            var trigger =
                TriggerBuilder.Create().WithSimpleSchedule(s => s.WithIntervalInSeconds(1).WithRepeatCount(1)).Build();

            var scopesCreated = 0;
            var scopesDisposed = 0;
            DisposableDependency dependency = null;

            _lifetimeScope.ChildLifetimeScopeBeginning += (sender, args) =>
            {
                scopesCreated++;
                dependency = args.LifetimeScope.Resolve<DisposableDependency>();
                args.LifetimeScope.CurrentScopeEnding += (o, eventArgs) => { scopesDisposed++; };
            };

            _scheduler.ScheduleJob(job1, trigger);
            _scheduler.Start();

            Thread.Sleep(3.Seconds());

            _jobFactory.RunningJobs.Should().BeEmpty("Scope was not disposed after job completion");
            dependency.Disposed.Should().BeTrue("Dependency must be disposed");
            scopesDisposed.Should().Be(scopesCreated, "All scopes must be disposed");
        }
开发者ID:Boichu87,项目名称:Autofac.Extras.Quartz,代码行数:28,代码来源:ScopeTrackerTests.cs

示例3: Deserialize

        public object Deserialize(global::MongoDB.Bson.IO.BsonReader bsonReader, Type nominalType, Type actualType, IBsonSerializationOptions options)
        {
            if (nominalType != typeof(JobKey) || actualType != typeof(JobKey))
            {
                var message = string.Format("Can't deserialize a {0} from {1}.", nominalType.FullName, this.GetType().Name);
                throw new BsonSerializationException(message);
            }

            var bsonType = bsonReader.CurrentBsonType;
            if (bsonType == BsonType.Document)
            {
                JobKey item;
                
                bsonReader.ReadStartDocument();
                item = new JobKey(
                    bsonReader.ReadString("Name"),
                    bsonReader.ReadString("Group"));
                bsonReader.ReadEndDocument();

                return item;
            }
            else if (bsonType == BsonType.Null)
            {
                bsonReader.ReadNull();
                return null;
            }
            else
            {
                var message = string.Format("Can't deserialize a {0} from BsonType {1}.", nominalType.FullName, bsonType);
                throw new BsonSerializationException(message);
            }
        }
开发者ID:Jiangew,项目名称:quartz.net-mongodb,代码行数:32,代码来源:JobKeySerializer.cs

示例4: GetSchedule

            public JobSchedule GetSchedule()
            {
                var jobKey = new JobKey(JobName, JobGroup);

                var trigger = Instance.GetTriggersOfJob(jobKey).FirstOrDefault();

                var js = new JobSchedule();

                if (trigger != null)
                {
                    js.Name = trigger.Key.Name;
                    js.Group = trigger.Key.Group;
                    js.Description = trigger.Description;
                    js.Priority = trigger.Priority;
                    js.TriggerType = trigger.GetType().Name;
                    js.TriggerState = Instance.GetTriggerState(trigger.Key).ToString();

                    DateTimeOffset? startTime = trigger.StartTimeUtc;
                    js.StartTime = TimeZone.CurrentTimeZone.ToLocalTime(startTime.Value.DateTime);

                    var nextFireTime = trigger.GetNextFireTimeUtc();
                    if (nextFireTime.HasValue)
                    {
                        js.NextFire = TimeZone.CurrentTimeZone.ToLocalTime(nextFireTime.Value.DateTime);
                    }

                    var previousFireTime = trigger.GetPreviousFireTimeUtc();
                    if (previousFireTime.HasValue)
                    {
                        js.LastFire = TimeZone.CurrentTimeZone.ToLocalTime(previousFireTime.Value.DateTime);
                    }
                }

                return js;
            }
开发者ID:feik,项目名称:crystal-quartz,代码行数:35,代码来源:Scheduler.cs

示例5: ExceptionPolicyNoRestartImmediately

        public void ExceptionPolicyNoRestartImmediately()
        {
            sched.Start();
            JobKey jobKey = new JobKey("ExceptionPolicyNoRestartJob", "ExceptionPolicyNoRestartGroup");
            JobDetailImpl exceptionJob = new JobDetailImpl(jobKey.Name, jobKey.Group, typeof (ExceptionJob));
            exceptionJob.Durable = true;
            sched.AddJob(exceptionJob, false);

            ExceptionJob.ThrowsException = true;
            ExceptionJob.Refire = false;
            ExceptionJob.UnscheduleAllTriggers = false;
            ExceptionJob.UnscheduleFiringTrigger = false;
            ExceptionJob.LaunchCount = 0;
            sched.TriggerJob(jobKey);

            int i = 10;
            while ((i > 0) && (ExceptionJob.LaunchCount <= 1))
            {
                i--;
                Thread.Sleep(200);
                if (ExceptionJob.LaunchCount > 1)
                {
                    break;
                }
            }
            sched.DeleteJob(jobKey);
            Assert.AreEqual(1, ExceptionJob.LaunchCount, "The job should NOT have been refired after exception");
        }
开发者ID:vaskosound,项目名称:FantasyLeagueStats,代码行数:28,代码来源:ExceptionJobTest.cs

示例6: ScheduleJob

 public static void ScheduleJob(this IScheduler scheduler, JobKey jobKey, string scheduleText, TimeZoneInfo timeZone)
 {
     TextToScheduleFactory factory = new TextToScheduleFactory();
     var english = factory.CreateEnglishParser();
     var results = english.Parse(scheduleText, timeZone);
     results.ScheduleWithJobKey(scheduler, jobKey);
 }
开发者ID:amazing-andrew,项目名称:Quartz.TextToSchedule,代码行数:7,代码来源:TextToScheduleExtensions.cs

示例7: AddRepeatingJob

        public void AddRepeatingJob(Type aType, string aName, string aGroup, int aSecondsToSleep, params JobItem[] aItems)
        {
            JobKey key = new JobKey(aName, aGroup);
            if (Scheduler.GetJobDetail(key) != null)
            {
                Log.Error("AddRepeatingJob(" + aType.Name + ", " + aName + ", " + aGroup + ") already exists");
                return;
            }
            Log.Info("AddRepeatingJob(" + aType.Name + ", " + aName + ", " + aGroup + ", " + aSecondsToSleep + ")");

            _scheduledJobs.Add(key);

            var data = new JobDataMap();
            foreach (JobItem item in aItems)
            {
                data.Add(item.Key, item.Value);
            }

            IJobDetail job = JobBuilder.Create(aType)
                .WithIdentity(key)
                .UsingJobData(data)
                .Build();

            ITrigger trigger = TriggerBuilder.Create()
                .WithIdentity(aName, aGroup)
                .WithSimpleSchedule(x => x.WithIntervalInSeconds(aSecondsToSleep).RepeatForever())
                .Build();

            Scheduler.ScheduleJob(job, trigger);
        }
开发者ID:scottc,项目名称:xdcc-grabscher,代码行数:30,代码来源:AWorker.cs

示例8: GetJobDetailsData

        public JobDetailsData GetJobDetailsData(JobKey jobKey)
        {
            var scheduler = _schedulerProvider.Scheduler;

            if (scheduler.IsShutdown)
            {
                return null;
            }

            var job = scheduler.GetJobDetail(jobKey);
            if (job == null)
            {
                return null;
            }

            var detailsData = new JobDetailsData
            {
                PrimaryData = GetJobData(scheduler, jobKey)
            };

            foreach (var key in job.JobDataMap.Keys)
            {
                detailsData.JobDataMap.Add(key, job.JobDataMap[key]);
            }

            detailsData.JobProperties.Add("Description", job.Description);
            detailsData.JobProperties.Add("Full name", job.Key.Name);
            detailsData.JobProperties.Add("Job type", job.JobType);
            detailsData.JobProperties.Add("Durable", job.Durable);
            //detailsData.JobProperties.Add("Volatile", job.);

            return detailsData;
        }
开发者ID:jiangzhuo,项目名称:CrystalQuartz,代码行数:33,代码来源:DefaultSchedulerDataProvider.cs

示例9: RemoveSchedule

 public void RemoveSchedule(Schedule schedule)
 {
     var triggerKey = new TriggerKey(schedule.Id.ToString(), schedule.CommandId.ToString());
     var jobKey = new JobKey(schedule.Id.ToString(), schedule.CommandId.ToString());
     scheduler.UnscheduleJob(triggerKey);
     scheduler.DeleteJob(jobKey);
 }
开发者ID:vgreggio,项目名称:CrossoverTest,代码行数:7,代码来源:SchedulerEngine.cs

示例10: JobDeleted

 public void JobDeleted(JobKey jobKey)
 {
     foreach (ISchedulerListener listener in listeners)
     {
         listener.JobDeleted(jobKey);
     }
 }
开发者ID:jondhinkle,项目名称:Rock,代码行数:7,代码来源:BroadcastSchedulerListener.cs

示例11: PostTriggerJob

        public HttpResponseMessage PostTriggerJob(string id)
        {
            JobKey jobKey = new JobKey(id);

            _scheduler.TriggerJob(jobKey);

            return new HttpResponseMessage();
        }
开发者ID:gmareater,项目名称:QuartzNetAPI,代码行数:8,代码来源:JobsController.cs

示例12: IsBelongsToGroup

        private bool IsBelongsToGroup(JobKey jobKey)
        {
            var jobDetail = _scheduler.GetJobDetail(jobKey);
            if (jobDetail.JobDataMap == null || !jobDetail.JobDataMap.Contains("data"))
                return false;

            var data = JsonConvert.DeserializeObject<SendCreativePackagesWithIntervalTask.Data>((string) jobDetail.JobDataMap["data"]);
            return data.Group == Group;
        }
开发者ID:mamluka,项目名称:SpeedyMailer,代码行数:9,代码来源:PauseSpecificSendingJobsCommand.cs

示例13: GetTriggers

 private static IEnumerable<TriggerWithState> GetTriggers(ISchedulerWrapper scheduler, JobKey jobKey) {
     var triggers = scheduler.GetTriggersOfJob(jobKey);
     if (triggers == null)
         return null;
     return triggers.Select(t => {
         var state = scheduler.GetTriggerState(t.Key);
         return new TriggerWithState(t, state);
     });
 }
开发者ID:weizhong1988,项目名称:QuartzNetWebConsole,代码行数:9,代码来源:TriggersByJobController.cs

示例14: JobModel

        public JobModel(IScheduler scheduler, JobKey jobKey)
        {
            foreach (ITrigger trigger in scheduler.GetTriggersOfJob(jobKey))
            {
                _triggersForJob.Add(new TriggerModel(trigger));
            }

            MapValuesFromJobDetail(scheduler.GetJobDetail(jobKey));
        }
开发者ID:GrLawrence,项目名称:QuartzPocketWatch,代码行数:9,代码来源:JobModel.cs

示例15: DeleteJob

 /// <summary>
 /// 删除现有任务
 /// </summary>
 /// <param name="JobKey"></param>
 public static void DeleteJob(string JobKey)
 {
     JobKey jk = new JobKey(JobKey);
     if (scheduler.CheckExists(jk))
     {
         //任务已经存在则删除
         scheduler.DeleteJob(jk);
         LogHelper.WriteLog(string.Format("任务“{0}”已经删除", JobKey));
     }
 }
开发者ID:CrazyJson,项目名称:TaskManager,代码行数:14,代码来源:QuartzHelper.cs


注:本文中的JobKey类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。