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


C# IOperableTrigger类代码示例

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


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

        protected override SimplePropertiesTriggerProperties GetTriggerProperties(IOperableTrigger trigger)
        {
            CalendarIntervalTriggerImpl calTrig = (CalendarIntervalTriggerImpl) trigger;

            SimplePropertiesTriggerProperties props = new SimplePropertiesTriggerProperties();

            props.Int1 = (calTrig.RepeatInterval);
            props.String1 = (calTrig.RepeatIntervalUnit.ToString());
            props.Int2 = (calTrig.TimesTriggered);

            return props;
        }
开发者ID:NickJosevski,项目名称:quartznet,代码行数:12,代码来源:CalendarIntervalTriggerPersistenceDelegate.cs

示例3: InsertExtendedTriggerProperties

        public int InsertExtendedTriggerProperties(ConnectionAndTransactionHolder conn, IOperableTrigger trigger, string state, IJobDetail jobDetail)
        {
            ICronTrigger cronTrigger = (ICronTrigger) trigger;

            using (IDbCommand cmd = DbAccessor.PrepareCommand(conn, AdoJobStoreUtil.ReplaceTablePrefix(StdAdoConstants.SqlInsertCronTrigger, TablePrefix, SchedNameLiteral)))
            {
                DbAccessor.AddCommandParameter(cmd, "triggerName", trigger.Key.Name);
                DbAccessor.AddCommandParameter(cmd, "triggerGroup", trigger.Key.Group);
                DbAccessor.AddCommandParameter(cmd, "triggerCronExpression", cronTrigger.CronExpressionString);
                DbAccessor.AddCommandParameter(cmd, "triggerTimeZone", cronTrigger.TimeZone.Id);

                return cmd.ExecuteNonQuery();
            }
        }
开发者ID:CharlieBP,项目名称:quartznet,代码行数:14,代码来源:CronTriggerPersistenceDelegate.cs

示例4: TriggerFiredBundle

 /// <summary>
 /// Initializes a new instance of the <see cref="TriggerFiredBundle"/> class.
 /// </summary>
 /// <param name="job">The job.</param>
 /// <param name="trigger">The trigger.</param>
 /// <param name="cal">The calendar.</param>
 /// <param name="jobIsRecovering">if set to <c>true</c> [job is recovering].</param>
 /// <param name="fireTimeUtc">The fire time.</param>
 /// <param name="scheduledFireTimeUtc">The scheduled fire time.</param>
 /// <param name="prevFireTimeUtc">The previous fire time.</param>
 /// <param name="nextFireTimeUtc">The next fire time.</param>
 public TriggerFiredBundle(IJobDetail job, IOperableTrigger trigger, ICalendar cal, bool jobIsRecovering,
     DateTimeOffset? fireTimeUtc,
     DateTimeOffset? scheduledFireTimeUtc,
     DateTimeOffset? prevFireTimeUtc,
     DateTimeOffset? nextFireTimeUtc)
 {
     this.job = job;
     this.trigger = trigger;
     this.cal = cal;
     this.jobIsRecovering = jobIsRecovering;
     this.fireTimeUtc = fireTimeUtc;
     this.scheduledFireTimeUtc = scheduledFireTimeUtc;
     this.prevFireTimeUtc = prevFireTimeUtc;
     this.nextFireTimeUtc = nextFireTimeUtc;
 }
开发者ID:vaskosound,项目名称:FantasyLeagueStats,代码行数:26,代码来源:TriggerFiredBundle.cs

示例5: InsertExtendedTriggerProperties

        public int InsertExtendedTriggerProperties(ConnectionAndTransactionHolder conn, IOperableTrigger trigger, string state, IJobDetail jobDetail)
        {
            ISimpleTrigger simpleTrigger = (ISimpleTrigger) trigger;

            using (IDbCommand cmd = commandAccessor.PrepareCommand(conn, AdoJobStoreUtil.ReplaceTablePrefix(StdAdoConstants.SqlInsertSimpleTrigger, tablePrefix, schedNameLiteral)))
            {
                commandAccessor.AddCommandParameter(cmd, "triggerName", trigger.Key.Name);
                commandAccessor.AddCommandParameter(cmd, "triggerGroup", trigger.Key.Group);
                commandAccessor.AddCommandParameter(cmd, "triggerRepeatCount", simpleTrigger.RepeatCount);
                commandAccessor.AddCommandParameter(cmd, "triggerRepeatInterval", simpleTrigger.RepeatInterval.TotalMilliseconds);
                commandAccessor.AddCommandParameter(cmd, "triggerTimesTriggered", simpleTrigger.TimesTriggered);

                return cmd.ExecuteNonQuery();
            }
        }
开发者ID:neumik,项目名称:quartznet,代码行数:15,代码来源:SimpleTriggerPersistenceDelegate.cs

示例6: GetTriggerProperties

        protected override SimplePropertiesTriggerProperties GetTriggerProperties(IOperableTrigger trigger)
        {
            CalendarIntervalTriggerImpl calTrig = (CalendarIntervalTriggerImpl) trigger;

            SimplePropertiesTriggerProperties props = new SimplePropertiesTriggerProperties();

            props.Int1 = calTrig.RepeatInterval;
            props.String1 = calTrig.RepeatIntervalUnit.ToString();
            props.Int2 = calTrig.TimesTriggered;
            props.String2 = calTrig.TimeZone.Id;
            props.Boolean1 = calTrig.PreserveHourOfDayAcrossDaylightSavings;
            props.Boolean2 = calTrig.SkipDayIfHourDoesNotExist;

            return props;
        }
开发者ID:nunomaia,项目名称:quartznet,代码行数:15,代码来源:CalendarIntervalTriggerPersistenceDelegate.cs

示例7: GetTriggerProperties

        protected override SimplePropertiesTriggerProperties GetTriggerProperties(IOperableTrigger trigger)
        {
            DailyTimeIntervalTriggerImpl dailyTrigger = (DailyTimeIntervalTriggerImpl) trigger;
            SimplePropertiesTriggerProperties props = new SimplePropertiesTriggerProperties();

            props.Int1 = dailyTrigger.RepeatInterval;
            props.String1 = dailyTrigger.RepeatIntervalUnit.ToString();
            props.Int2 = dailyTrigger.TimesTriggered;

            ISet<DayOfWeek> days = dailyTrigger.DaysOfWeek;
            string daysStr = string.Join(",", days.Cast<int>().Select(x => x.ToString(CultureInfo.InvariantCulture)).ToArray());
            props.String2 = daysStr;

            StringBuilder timeOfDayBuffer = new StringBuilder();
            TimeOfDay startTimeOfDay = dailyTrigger.StartTimeOfDay;
            if (startTimeOfDay != null)
            {
                timeOfDayBuffer.Append(startTimeOfDay.Hour).Append(",");
                timeOfDayBuffer.Append(startTimeOfDay.Minute).Append(",");
                timeOfDayBuffer.Append(startTimeOfDay.Second).Append(",");
            }
            else
            {
                timeOfDayBuffer.Append(",,,");
            }

            TimeOfDay endTimeOfDay = dailyTrigger.EndTimeOfDay;
            if (endTimeOfDay != null)
            {
                timeOfDayBuffer.Append(endTimeOfDay.Hour).Append(",");
                timeOfDayBuffer.Append(endTimeOfDay.Minute).Append(",");
                timeOfDayBuffer.Append(endTimeOfDay.Second);
            }
            else
            {
                timeOfDayBuffer.Append(",,,");
            }
            props.String3 = timeOfDayBuffer.ToString();
            props.Long1 = dailyTrigger.RepeatCount;
            return props;
        }
开发者ID:jvilalta,项目名称:quartznet,代码行数:41,代码来源:DailyTimeIntervalTriggerPersistenceDelegate.cs

示例8: 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

示例9: DoUpdateOfMisfiredTrigger

        private void DoUpdateOfMisfiredTrigger(ConnectionAndTransactionHolder conn, IOperableTrigger trig,
                                               bool forceState, string newStateIfNotComplete, bool recovering)
        {
            ICalendar cal = null;
            if (trig.CalendarName != null)
            {
                cal = RetrieveCalendar(conn, trig.CalendarName);
            }

            schedSignaler.NotifyTriggerListenersMisfired(trig);

            trig.UpdateAfterMisfire(cal);

            if (!trig.GetNextFireTimeUtc().HasValue)
            {
                StoreTrigger(conn, trig, null, true, StateComplete, forceState, recovering);
                schedSignaler.NotifySchedulerListenersFinalized(trig);
            }
            else
            {
                StoreTrigger(conn, trig, null, true, newStateIfNotComplete, forceState, false);
            }
        }
开发者ID:valeriob,项目名称:quartznet,代码行数:23,代码来源:JobStoreSupport.cs

示例10: TriggerFired

        protected virtual TriggerFiredBundle TriggerFired(ConnectionAndTransactionHolder conn, IOperableTrigger trigger)
        {
            IJobDetail job;
            ICalendar cal = null;

            // Make sure trigger wasn't deleted, paused, or completed...
            try
            {
                // if trigger was deleted, state will be StateDeleted
                string state = Delegate.SelectTriggerState(conn, trigger.Key);
                if (!state.Equals(StateAcquired))
                {
                    return null;
                }
            }
            catch (Exception e)
            {
                throw new JobPersistenceException("Couldn't select trigger state: " + e.Message, e);
            }

            try
            {
                job = RetrieveJob(conn, trigger.JobKey);
                if (job == null)
                {
                    return null;
                }
            }
            catch (JobPersistenceException jpe)
            {
                try
                {
                    Log.Error("Error retrieving job, setting trigger state to ERROR.", jpe);
                    Delegate.UpdateTriggerState(conn, trigger.Key, StateError);
                }
                catch (Exception sqle)
                {
                    Log.Error("Unable to set trigger state to ERROR.", sqle);
                }
                throw;
            }

            if (trigger.CalendarName != null)
            {
                cal = RetrieveCalendar(conn, trigger.CalendarName);
                if (cal == null)
                {
                    return null;
                }
            }

            try
            {
                Delegate.UpdateFiredTrigger(conn, trigger, StateExecuting, job);
            }
            catch (Exception e)
            {
                throw new JobPersistenceException("Couldn't insert fired trigger: " + e.Message, e);
            }

            DateTimeOffset? prevFireTime = trigger.GetPreviousFireTimeUtc();

            // call triggered - to update the trigger's next-fire-time state...
            trigger.Triggered(cal);

            string state2 = StateWaiting;
            bool force = true;

            if (job.ConcurrentExecutionDisallowed)
            {
                state2 = StateBlocked;
                force = false;
                try
                {
                    Delegate.UpdateTriggerStatesForJobFromOtherState(conn, job.Key, StateBlocked, StateWaiting);
                    Delegate.UpdateTriggerStatesForJobFromOtherState(conn, job.Key, StateBlocked, StateAcquired);
                    Delegate.UpdateTriggerStatesForJobFromOtherState(conn, job.Key, StatePausedBlocked, StatePaused);
                }
                catch (Exception e)
                {
                    throw new JobPersistenceException("Couldn't update states of blocked triggers: " + e.Message, e);
                }
            }

            if (!trigger.GetNextFireTimeUtc().HasValue)
            {
                state2 = StateComplete;
                force = true;
            }

            StoreTrigger(conn, trigger, job, true, state2, force, false);

            job.JobDataMap.ClearDirtyFlag();

            return new TriggerFiredBundle(
                job,
                trigger,
                cal,
                trigger.Key.Group.Equals(SchedulerConstants.DefaultRecoveryGroup),
                SystemTime.UtcNow(),
//.........这里部分代码省略.........
开发者ID:valeriob,项目名称:quartznet,代码行数:101,代码来源:JobStoreSupport.cs

示例11: TriggerJob

        /// <summary>
        /// Store and schedule the identified <see cref="IOperableTrigger"/>
        /// </summary>
        /// <param name="trig"></param>
        public void TriggerJob(IOperableTrigger trig)
        {
            ValidateState();

            trig.ComputeFirstFireTimeUtc(null);

            bool collision = true;
            while (collision)
            {
                try
                {
                    resources.JobStore.StoreTrigger(trig, false);
                    collision = false;
                }
                catch (ObjectAlreadyExistsException)
                {
                    trig.Key = new TriggerKey(NewTriggerId(), SchedulerConstants.DefaultGroup);
                }
            }

            NotifySchedulerThread(trig.GetNextFireTimeUtc());
            NotifySchedulerListenersScheduled(trig);
        }
开发者ID:natenho,项目名称:quartznet,代码行数:27,代码来源:QuartzScheduler.cs

示例12: ApplyMisfire

        /// <summary>
        /// Applies the misfire.
        /// </summary>
        /// <param name="tw">The trigger wrapper.</param>
        /// <returns></returns>
        protected virtual bool ApplyMisfire(IOperableTrigger trigger)
        {
            DateTimeOffset misfireTime = SystemTime.UtcNow();
            if (MisfireThreshold > TimeSpan.Zero)
            {
                misfireTime = misfireTime.AddMilliseconds(-1 * MisfireThreshold.TotalMilliseconds);
            }

            DateTimeOffset? tnft = trigger.GetNextFireTimeUtc();
            if (!tnft.HasValue || tnft.Value > misfireTime
                || trigger.MisfireInstruction == MisfireInstruction.IgnoreMisfirePolicy)
            {
                return false;
            }

            ICalendar cal = null;
            if (trigger.CalendarName != null)
            {
                cal = this.RetrieveCalendar(trigger.CalendarName);
            }

            signaler.NotifyTriggerListenersMisfired(trigger);

            trigger.UpdateAfterMisfire(cal);
            this.StoreTrigger(trigger, true);

            if (!trigger.GetNextFireTimeUtc().HasValue)
            {
                this.Triggers.Update(
                    Query.EQ("_id", trigger.Key.ToBsonDocument()),
                    Update.Set("State", "Complete"));

                signaler.NotifySchedulerListenersFinalized(trigger);
            }
            else if (tnft.Equals(trigger.GetNextFireTimeUtc()))
            {
                return false;
            }

            return true;
        }
开发者ID:KevinVoell,项目名称:quartznet-mongodb,代码行数:46,代码来源:JobStore.cs

示例13: 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

示例14: StoreTrigger

 /// <summary>
 /// Store the given <see cref="ITrigger" />.
 /// </summary>
 /// <param name="newTrigger">The <see cref="ITrigger" /> to be stored.</param>
 /// <param name="replaceExisting">
 /// If <see langword="true" />, any <see cref="ITrigger" /> existing in
 /// the <see cref="IJobStore" /> with the same name &amp; group should
 /// be over-written.
 /// </param>
 /// <exception cref="ObjectAlreadyExistsException">
 /// if a <see cref="ITrigger" /> with the same name/group already
 /// exists, and replaceExisting is set to false.
 /// </exception>
 public void StoreTrigger(IOperableTrigger newTrigger, bool replaceExisting)
 {
     ExecuteInLock(
         (LockOnInsert || replaceExisting) ? LockTriggerAccess : null,
         conn => StoreTrigger(conn, newTrigger, null, replaceExisting, StateWaiting, false, false));
 }
开发者ID:valeriob,项目名称:quartznet,代码行数:19,代码来源:JobStoreSupport.cs

示例15: StoreJobAndTrigger

 /// <summary>
 /// Store the given <see cref="IJobDetail" /> and <see cref="IOperableTrigger" />.
 /// </summary>
 /// <param name="newJob">Job to be stored.</param>
 /// <param name="newTrigger">Trigger to be stored.</param>
 public void StoreJobAndTrigger(IJobDetail newJob, IOperableTrigger newTrigger)
 {
     ExecuteInLock((LockOnInsert) ? LockTriggerAccess : null, conn =>
                                                                  {
                                                                      StoreJob(conn, newJob, false);
                                                                      StoreTrigger(conn, newTrigger, newJob, false, StateWaiting, false, false);
                                                                      return null;
                                                                  });
 }
开发者ID:valeriob,项目名称:quartznet,代码行数:14,代码来源:JobStoreSupport.cs


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