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


C# IOperableTrigger.Clone方法代码示例

本文整理汇总了C#中IOperableTrigger.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# IOperableTrigger.Clone方法的具体用法?C# IOperableTrigger.Clone怎么用?C# IOperableTrigger.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IOperableTrigger的用法示例。


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

示例1: ComputeFireTimes

        /// <summary>
        /// Returns a list of Dates that are the next fire times of a
        /// <see cref="ITrigger" />.
        /// The input trigger will be cloned before any work is done, so you need
        /// not worry about its state being altered by this method.
        /// </summary>
        /// <param name="trigg">The trigger upon which to do the work</param>
        /// <param name="cal">The calendar to apply to the trigger's schedule</param>
        /// <param name="numTimes">The number of next fire times to produce</param>
        /// <returns>List of java.util.Date objects</returns>
        public static IList<DateTimeOffset> ComputeFireTimes(IOperableTrigger trigg, ICalendar cal, int numTimes)
        {
            List<DateTimeOffset> lst = new List<DateTimeOffset>();

            IOperableTrigger t = (IOperableTrigger) trigg.Clone();

            if (t.GetNextFireTimeUtc() == null || !t.GetNextFireTimeUtc().HasValue)
            {
                t.ComputeFirstFireTimeUtc(cal);
            }

            for (int i = 0; i < numTimes; i++)
            {
                DateTimeOffset? d = t.GetNextFireTimeUtc();
                if (d.HasValue)
                {
                    lst.Add(d.Value);
                    t.Triggered(cal);
                }
                else
                {
                    break;
                }
            }

            return lst.AsReadOnly();
        }
开发者ID:CharlieBP,项目名称:quartznet,代码行数:37,代码来源:TriggerUtils.cs

示例2: ComputeEndTimeToAllowParticularNumberOfFirings

        /// <summary>
        /// Compute the <see cref="DateTimeOffset" /> that is 1 second after the Nth firing of 
        /// the given <see cref="ITrigger" />, taking the triger's associated 
        /// <see cref="ICalendar" /> into consideration.
        /// </summary>
        /// <remarks>
        /// The input trigger will be cloned before any work is done, so you need
        /// not worry about its state being altered by this method.
        /// </remarks>
        /// <param name="trigger">The trigger upon which to do the work</param>
        /// <param name="calendar">The calendar to apply to the trigger's schedule</param>
        /// <param name="numberOfTimes">The number of next fire times to produce</param>
        /// <returns>the computed Date, or null if the trigger (as configured) will not fire that many times</returns>
        public static DateTimeOffset? ComputeEndTimeToAllowParticularNumberOfFirings(IOperableTrigger trigger, ICalendar calendar, int numberOfTimes)
        {
            IOperableTrigger t = (IOperableTrigger) trigger.Clone();

            if (t.GetNextFireTimeUtc() == null)
            {
                t.ComputeFirstFireTimeUtc(calendar);
            }

            int c = 0;
            DateTimeOffset? endTime = null;

            for (int i = 0; i < numberOfTimes; i++)
            {
                DateTimeOffset? d = t.GetNextFireTimeUtc();
                if (d != null)
                {
                    c++;
                    t.Triggered(calendar);
                    if (c == numberOfTimes)
                    {
                        endTime = d;
                    }
                }
                else
                {
                    break;
                }
            }

            if (endTime == null)
            {
                return null;
            }

            endTime = endTime.Value.AddSeconds(1);

            return endTime;
        }
开发者ID:JustAGhosT,项目名称:quartznet,代码行数:52,代码来源:TriggerUtils.cs

示例3: ComputeFireTimesBetween

        /// <summary>
        /// Returns a list of Dates that are the next fire times of a  <see cref="ITrigger" />
        /// that fall within the given date range. The input trigger will be cloned
        /// before any work is done, so you need not worry about its state being
        /// altered by this method.
        /// <para>
        /// NOTE: if this is a trigger that has previously fired within the given
        /// date range, then firings which have already occurred will not be listed
        /// in the output List.
        /// </para>
        /// </summary>
        /// <param name="trigg">The trigger upon which to do the work</param>
        /// <param name="cal">The calendar to apply to the trigger's schedule</param>
        /// <param name="from">The starting date at which to find fire times</param>
        /// <param name="to">The ending date at which to stop finding fire times</param>
        /// <returns>List of java.util.Date objects</returns>
        public static IList<DateTimeOffset> ComputeFireTimesBetween(IOperableTrigger trigg, ICalendar cal, DateTimeOffset from, DateTimeOffset to)
        {
            List<DateTimeOffset> lst = new List<DateTimeOffset>();

            IOperableTrigger t = (IOperableTrigger) trigg.Clone();

            if (t.GetNextFireTimeUtc() == null || !t.GetNextFireTimeUtc().HasValue)
            {
                t.StartTimeUtc = from;
                t.EndTimeUtc = to;
                t.ComputeFirstFireTimeUtc(cal);
            }

            // TODO: this method could be more efficient by using logic specific
            //        to the type of trigger ...
            while (true)
            {
                DateTimeOffset? d = t.GetNextFireTimeUtc();
                if (d.HasValue)
                {
                    if (d.Value < from)
                    {
                        t.Triggered(cal);
                        continue;
                    }
                    if (d.Value > to)
                    {
                        break;
                    }
                    lst.Add(d.Value);
                    t.Triggered(cal);
                }
                else
                {
                    break;
                }
            }
            return lst.AsReadOnly();
        }
开发者ID:CharlieBP,项目名称:quartznet,代码行数:55,代码来源:TriggerUtils.cs

示例4: ApplyMisfire

        /// <summary>
        ///  Determine whether or not the given trigger has misfired.If so, notify {SchedulerSignaler} and update the trigger.
        /// </summary>
        /// <param name="trigger">IOperableTrigger</param>
        /// <returns>applied or not</returns>
        protected bool ApplyMisfire(IOperableTrigger trigger)
        {
            double misfireTime = DateTimeOffset.UtcNow.DateTime.ToUnixTimeMilliSeconds();
            double score = misfireTime;

            if (MisfireThreshold > 0)
            {
                misfireTime = misfireTime - MisfireThreshold;
            }

            //if the trigger has no next fire time or exceeds the misfirethreshold or enable ignore misfirepolicy
            // then dont apply misfire.
            DateTimeOffset? nextFireTime = trigger.GetNextFireTimeUtc();

            if (nextFireTime.HasValue == false ||
               (nextFireTime.HasValue && nextFireTime.Value.DateTime.ToUnixTimeMilliSeconds() > misfireTime) ||
               trigger.MisfireInstruction == -1)
            {
                return false;
            }

            ICalendar calendar = null;

            if (!string.IsNullOrEmpty(trigger.CalendarName))
            {
                calendar = RetrieveCalendar(trigger.CalendarName);
            }

            SchedulerSignaler.NotifyTriggerListenersMisfired((IOperableTrigger)trigger.Clone());

            trigger.UpdateAfterMisfire(calendar);

            StoreTrigger(trigger, true);

            if (nextFireTime.HasValue == false)
            {
                SetTriggerState(RedisTriggerState.Completed,
                                     score, RedisJobStoreSchema.TriggerHashkey(trigger.Key));
                SchedulerSignaler.NotifySchedulerListenersFinalized(trigger);
            }
            else if (nextFireTime.Equals(trigger.GetNextFireTimeUtc()))
            {
                return false;
            }
            return true;
        }
开发者ID:icyice80,项目名称:QuartzRedisJobStore,代码行数:51,代码来源:BaseJobStorage.cs


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