コード例 #1
0
        /// <summary>
        /// Pause the <see cref="T:Quartz.IJob"/> with the given key - by
        ///             pausing all of its current <see cref="T:Quartz.ITrigger"/>s.
        /// </summary>
        public override IList <string> PauseJobs(GroupMatcher <JobKey> matcher)
        {
            var pausedJobGroups = new List <string>();

            if (matcher.CompareWithOperator.Equals(StringOperator.Equality))
            {
                var jobGroupSetKey = RedisJobStoreSchema.JobGroupSetKey(matcher.CompareToValue);

                if (Db.SetAdd(RedisJobStoreSchema.PausedJobGroupsSetKey(), jobGroupSetKey))
                {
                    pausedJobGroups.Add(RedisJobStoreSchema.JobGroup(jobGroupSetKey));

                    foreach (RedisValue val in Db.SetMembers(jobGroupSetKey))
                    {
                        PauseJob(RedisJobStoreSchema.JobKey(val));
                    }
                }
            }
            else
            {
                var jobGroupSets = Db.SetMembers(RedisJobStoreSchema.JobGroupsSetKey());

                var jobGroups = jobGroupSets.Where(jobGroupSet => matcher.CompareWithOperator.Evaluate(RedisJobStoreSchema.JobGroup(jobGroupSet), matcher.CompareToValue)).ToDictionary <RedisValue, string, RedisValue[]>(jobGroupSet => jobGroupSet, jobGroupSet => Db.SetMembers(jobGroupSet.ToString()));

                foreach (var jobGroup in jobGroups)
                {
                    if (Db.SetAdd(RedisJobStoreSchema.PausedJobGroupsSetKey(), jobGroup.Key))
                    {
                        pausedJobGroups.Add(RedisJobStoreSchema.JobGroup(jobGroup.Key));

                        foreach (var jobHashKey in jobGroup.Value)
                        {
                            PauseJob(RedisJobStoreSchema.JobKey(jobHashKey));
                        }
                    }
                }
            }

            return(pausedJobGroups);
        }
コード例 #2
0
        /// <summary>
        /// Resume (un-pause) all of the <see cref="T:Quartz.IJob"/>s in
        ///             the given group.
        /// <para>
        /// If any of the <see cref="T:Quartz.IJob"/> s had <see cref="T:Quartz.ITrigger"/> s that
        ///             missed one or more fire-times, then the <see cref="T:Quartz.ITrigger"/>'s
        ///             misfire instruction will be applied.
        /// </para>
        /// </summary>
        public override global::Quartz.Collection.ISet <string> ResumeJobs(GroupMatcher <JobKey> matcher)
        {
            var resumedJobGroups = new List <string>();

            if (matcher.CompareWithOperator.Equals(StringOperator.Equality))
            {
                var jobGroupSetKey = RedisJobStoreSchema.JobGroupSetKey(matcher.CompareToValue);

                var removedPausedResult = Db.SetRemove(RedisJobStoreSchema.PausedJobGroupsSetKey(), jobGroupSetKey);
                var jobsResult          = Db.SetMembers(jobGroupSetKey);


                if (removedPausedResult)
                {
                    resumedJobGroups.Add(RedisJobStoreSchema.JobGroup(jobGroupSetKey));
                }

                foreach (var job in jobsResult)
                {
                    ResumeJob(RedisJobStoreSchema.JobKey(job));
                }
            }
            else
            {
                foreach (var jobGroupSetKey in Db.SetMembers(RedisJobStoreSchema.JobGroupsSetKey()))
                {
                    if (matcher.CompareWithOperator.Evaluate(RedisJobStoreSchema.JobGroup(jobGroupSetKey),
                                                             matcher.CompareToValue))
                    {
                        resumedJobGroups.AddRange(ResumeJobs(
                                                      GroupMatcher <JobKey> .GroupEquals(RedisJobStoreSchema.JobGroup(jobGroupSetKey))));
                    }
                }
            }

            return(new global::Quartz.Collection.HashSet <string>(resumedJobGroups));
        }