public override Task OnDisconnectedAsync(Exception exception)
        {
            var conID = Context.ConnectionId;

            _ConSer.RemoveHConn(conID);
            _ConSer.RemoveHConGroup(conID);
            var userId      = _ConSer.gethuserId(conID);
            var trigforusr  = "******" + userId;
            var grpnameuser = "******" + userId;
            var names       = _scheduler.GetTriggerGroupNames().Result;

            foreach (var item in names)
            {
                if (item.ToString() == grpnameuser)
                {
                    _scheduler.UnscheduleJob(new TriggerKey(trigforusr, grpnameuser));
                }
            }

            var    jobid    = "foruser" + userId;
            var    jobgroup = "quartzUpdateOdds";
            JobKey jk       = new Quartz.JobKey(jobid, jobgroup);

            _scheduler.DeleteJob(jk);
            return(base.OnDisconnectedAsync(exception));
        }
        public async Task <IActionResult> GetOffers(string userId, int EventId, string MarketName)
        {
            var trigforusr  = "******" + userId;
            var grpnameuser = "******" + userId;
            var names       = _scheduler.GetTriggerGroupNames().Result;

            foreach (var item in names)
            {
                if (item.ToString() == grpnameuser)
                {
                    await _scheduler.UnscheduleJob(new TriggerKey(trigforusr, grpnameuser));
                }
            }

            var    jobid    = "foruser" + userId;
            var    jobgroup = "quartzUpdateOdds";
            JobKey jk       = new Quartz.JobKey(jobid, jobgroup);
            await _scheduler.DeleteJob(jk);


            IJobDetail job = JobBuilder.Create <UpdateOddsJob>()
                             .UsingJobData("EventId", EventId)
                             .UsingJobData("MarketName", MarketName)
                             .WithIdentity(/*"UpdateOddsJob"+EventId+"and market"+MarketName+*/ "foruser" + userId, "quartzUpdateOdds")
                             .RequestRecovery()
                             .StoreDurably(false)
                             .Build();
            ITrigger trigger = TriggerBuilder.Create()
                               .ForJob(job)
                               .UsingJobData("EventId", EventId)
                               .UsingJobData("MarketName", MarketName)
                               .WithIdentity("foruser" + userId, "quartzUpdateOddsTriggers" + userId)

                               .StartNow()
                               .WithSimpleSchedule(z => z.WithIntervalInSeconds(1).RepeatForever().WithMisfireHandlingInstructionIgnoreMisfires())
                               .Build();

            await _scheduler.ScheduleJob(job, trigger);

            // var jobsinpro = _scheduler.GetCurrentlyExecutingJobs();
            return(Ok());
        }
Example #3
0
 /// <summary>
 /// Use a <see cref="JobKey" /> to identify the JobDetail.
 /// </summary>
 /// <remarks>
 /// <para>If none of the 'withIdentity' methods are set on the JobBuilder,
 /// then a random, unique JobKey will be generated.</para>
 /// </remarks>
 /// <param name="key">the Job's JobKey</param>
 /// <returns>the updated JobBuilder</returns>
 /// <seealso cref="JobKey" />
 /// <seealso cref="IJobDetail.Key" />
 public JobBuilder WithIdentity(JobKey key)
 {
     this.key = key;
     return(this);
 }
 public IServiceCollectionTriggerConfigurator ForJob(JobKey jobKey)
 {
     triggerBuilder.ForJob(jobKey);
     return(this);
 }
Example #5
0
 /// <summary>
 /// Set the identity of the Job which should be fired by the produced
 /// Trigger - a <code>JobKey</code> will be produced with the given
 /// name and group.
 /// </summary>
 /// <remarks>
 /// </remarks>
 /// <param name="jobName">the name of the job to fire.</param>
 /// <param name="jobGroup">the group of the job to fire.</param>
 /// <returns>the updated TriggerBuilder</returns>
 /// <seealso cref="ITrigger.JobKey" />
 public TriggerBuilder ForJob(string jobName, string jobGroup)
 {
     jobKey = new JobKey(jobName, jobGroup);
     return(this);
 }
Example #6
0
 /// <summary>
 /// Set the identity of the Job which should be fired by the produced
 /// Trigger - a <code>JobKey</code> will be produced with the given
 /// name and default group.
 /// </summary>
 /// <remarks>
 /// </remarks>
 /// <param name="jobName">the name of the job (in default group) to fire.</param>
 /// <returns>the updated TriggerBuilder</returns>
 /// <seealso cref="ITrigger.JobKey" />
 public TriggerBuilder ForJob(string jobName)
 {
     jobKey = new JobKey(jobName, null);
     return(this);
 }
Example #7
0
 /// <summary>
 /// Set the identity of the Job which should be fired by the produced
 /// Trigger.
 /// </summary>
 /// <remarks>
 /// </remarks>
 /// <param name="jobKey">the identity of the Job to fire.</param>
 /// <returns>the updated TriggerBuilder</returns>
 /// <seealso cref="ITrigger.JobKey" />
 public TriggerBuilder ForJob(JobKey jobKey)
 {
     this.jobKey = jobKey;
     return(this);
 }
Example #8
0
 /// <summary>
 /// Use a <see cref="JobKey" /> with the given name and group to
 /// identify the JobDetail.
 /// </summary>
 /// <remarks>
 /// <para>If none of the 'withIdentity' methods are set on the JobBuilder,
 /// then a random, unique JobKey will be generated.</para>
 /// </remarks>
 /// <param name="name">the name element for the Job's JobKey</param>
 /// <param name="group"> the group element for the Job's JobKey</param>
 /// <returns>the updated JobBuilder</returns>
 /// <seealso cref="JobKey" />
 /// <seealso cref="IJobDetail.Key" />
 public JobBuilder WithIdentity(string name, string group)
 {
     key = new JobKey(name, group);
     return(this);
 }
Example #9
0
 /// <summary>
 /// Use a <see cref="JobKey" /> with the given name and default group to
 /// identify the JobDetail.
 /// </summary>
 /// <remarks>
 /// <para>If none of the 'withIdentity' methods are set on the JobBuilder,
 /// then a random, unique JobKey will be generated.</para>
 /// </remarks>
 /// <param name="name">the name element for the Job's JobKey</param>
 /// <returns>the updated JobBuilder</returns>
 /// <seealso cref="JobKey" />
 /// <seealso cref="IJobDetail.Key" />
 public JobBuilder WithIdentity(string name)
 {
     key = new JobKey(name, null);
     return(this);
 }
Example #10
0
        /// <summary>
        /// 删除Job
        /// 删除功能Quartz提供有很多,以后可扩充
        /// </summary>
        /// <param name="JobName"></param>
        public static void DeleteJob(string JobName)
        {
            JobKey jk = new JobKey(JobName, JobName + "_Group");

            sched.DeleteJob(jk);
        }