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


C# IJob.GetType方法代码示例

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


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

示例1: GetWork

        public Task GetWork(IJob job)
        {
            Task task;
            try
            {
                task = job.Execute();
            }
            catch (Exception e)
            {
                QuietLog.LogHandledException(e);
                return new Task(() => {}); // returning dummy task so the job scheduler doesn't see errors
            }

            // wrapping the task inside an outer task which will continue with an error handler.
            return CreateWrappingContinuingTask(task, t =>
            {
                if (t.IsCanceled)
                {
                    Debug.WriteLine("Background Task Canceled: " + job.GetType());
                }
                else if (t.IsFaulted)
                {
                    Debug.WriteLine("Background Task Faulted: " + job.GetType());
                    QuietLog.LogHandledException(task.Exception);
                }
                // else happiness
            }, TaskContinuationOptions.ExecuteSynchronously);
        }
开发者ID:henrycomein,项目名称:NuGetGallery,代码行数:28,代码来源:NuGetJobCoordinator.cs

示例2: CreateDescriptor

        /// <summary>
        /// Tries to create a JobDescriptor for the given job.
        /// </summary>
        /// <param name="job">
        /// The IJob object to create a descriptor for.
        /// </param>
        /// <returns>
        /// An instance of JobDescriptor that describes the job.
        /// </returns>
        public JobDescriptor CreateDescriptor(IJob job)
        {
            if (null == job)
            {
                throw new ArgumentNullException("job");
            }

            JobSpec spec;

            if (!typeToSpecMap.TryGetValue(job.GetType(), out spec))
            {
                throw new UnknownJobException(null, job.GetType().Name);
            }

            JobDescriptor descriptor = spec.Describe(job);

            return descriptor;
        }
开发者ID:rokeller,项目名称:aqua,代码行数:27,代码来源:JobFactory.cs

示例3: ScheduleAsync

        private Task<IJobId> ScheduleAsync(IJob job, Func<IBackgroundJobClient, JobDefinition, string, string> schedule)
        {
            var jobDefinition = _jobDefinitionService.GetJobDefinition(job.GetType());
            var json = _jsonSerializer.Serialize(job);

            var id = schedule(_backgroundJobClient, jobDefinition, json);

            _log.Verbose($"Scheduled job '{id}' in Hangfire");

            return Task.FromResult<IJobId>(new HangfireJobId(id));
        }
开发者ID:liemqv,项目名称:EventFlow,代码行数:11,代码来源:HangfireJobScheduler.cs

示例4: ScheduleNowAsync

        public async Task<IJobId> ScheduleNowAsync(IJob job, CancellationToken cancellationToken)
        {
            var jobDefinition = _jobDefinitionService.GetJobDefinition(job.GetType());
            var json = _jsonSerializer.Serialize(job);

            _log.Verbose(() => $"Executing job '{jobDefinition.Name}' v{jobDefinition.Version}: {json}");

            // Don't schedule, just execute...
            await _jobRunner.ExecuteAsync(jobDefinition.Name, jobDefinition.Version, json, cancellationToken).ConfigureAwait(false);

            return JobId.New;
        }
开发者ID:liemqv,项目名称:EventFlow,代码行数:12,代码来源:InstantJobScheduler.cs

示例5: scheduleJob

        /**
            Método que pérmite calendarizar un nuevo job dentro de los cron del Sistema
        **/
        public static void scheduleJob(IJob jobToSchedule, String cronExpression)
        {

            JobDetailImpl       jobDetail = new JobDetailImpl("Job_" + jobCounter, "Group_" + jobCounter, jobToSchedule.GetType());
            CronTriggerImpl     trigger = null;
            DateTimeOffset?     dateTimOffset = null;

            if ( _scheduler == null)
            {
                initScheduler();
            }

            //Se crea el trigeer con el que se va a lanzar el job
            trigger = new CronTriggerImpl("Trigger_" + jobCounter, "Group_" + jobCounter, cronExpression);
            //Se agrega el calendarizador al scheduler
            _scheduler.ScheduleJob(jobDetail, trigger);

            //Se solicita el date Para el siguiente evento del scheduler
            dateTimOffset = trigger.GetNextFireTimeUtc();
            Console.WriteLine("Job Scheduled");
            Console.WriteLine(jobDetail.FullName + " its about to be fired at "  + dateTimOffset.Value );

            jobCounter++;
        }
开发者ID:mikelemikelo,项目名称:PuntoDeVenta1.1,代码行数:27,代码来源:SchedulerFrontController.cs

示例6: JobTypeString

        /// <summary>
        /// Gets the string used when persisting the type of an <see cref="IJob"/> into a <see cref="JobRecord"/>.
        /// </summary>
        /// <param name="job">The job to get the type string from.</param>
        /// <returns>A job type string.</returns>
        public static string JobTypeString(IJob job)
        {
            if (job == null)
            {
                throw new ArgumentNullException("job", "job cannot be null.");
            }

            return JobTypeString(job.GetType());
        }
开发者ID:ChadBurggraf,项目名称:blue-collar-old,代码行数:14,代码来源:JobRecord.cs

示例7: InitializeJob

        private bool InitializeJob(IJob job)
        {
            string jobName = job.GetType().Name;
            Logger.Instance.LogFormat(LogType.Info, this, Resources.JobInitializeBegin, jobName);

            try
            {
                if (!job.Initialize(_serviceProvider))
                {
                    Logger.Instance.LogFormat(LogType.Warning, this, Resources.JobInitializeError, jobName);
                    return false;
                }

                Logger.Instance.LogFormat(LogType.Info, this, Resources.JobInitializeSuccess, jobName);
                return true;
            }
            catch (Exception ex)
            {
                Logger.Instance.LogFormat(LogType.Error, this, Resources.JobGenericError, jobName, ex.Message);
                Logger.Instance.LogException(this, ex);
                return false;
            }
        }
开发者ID:huoxudong125,项目名称:AlarmWorkflow,代码行数:23,代码来源:JobManager.cs

示例8: RunJobCore

        private void RunJobCore(IJobContext context, Operation operation, IJob job)
        {
            try
            {
                job.Execute(context, operation);

                Logger.Instance.LogFormat(LogType.Trace, this, Resources.JobExecuteFinished, job.GetType().Name);
            }
            catch (Exception ex)
            {
                string message = (job.IsAsync) ? Properties.Resources.JobExecuteAsyncFailed : Properties.Resources.JobExecuteSyncFailed;

                Logger.Instance.LogFormat(LogType.Warning, this, string.Format(message, job.GetType().Name));
                Logger.Instance.LogException(this, ex);
            }
        }
开发者ID:huoxudong125,项目名称:AlarmWorkflow,代码行数:16,代码来源:JobManager.cs

示例9: RunJob

 private void RunJob(IJobContext context, Operation operation, IJob job)
 {
     if (job.IsAsync)
     {
         Logger.Instance.LogFormat(LogType.Info, this, Resources.JobExecuteAsyncStart, job.GetType().Name, context.Phase);
         ThreadPool.QueueUserWorkItem(o => RunJobCore(context, operation, job));
     }
     else
     {
         Logger.Instance.LogFormat(LogType.Info, this, Resources.JobExecuteSyncStart, job.GetType().Name, context.Phase);
         RunJobCore(context, operation, job);
     }
 }
开发者ID:huoxudong125,项目名称:AlarmWorkflow,代码行数:13,代码来源:JobManager.cs

示例10: ScheduleAsync

 public Task<IJobId> ScheduleAsync(IJob job, TimeSpan delay, CancellationToken cancellationToken)
 {
     _log.Warning($"Instant scheduling configured, executing job '{job.GetType().PrettyPrint()}' NOW! Instead of in '{delay}'");
     return ScheduleNowAsync(job, cancellationToken);
 }
开发者ID:liemqv,项目名称:EventFlow,代码行数:5,代码来源:InstantJobScheduler.cs

示例11: ScheduledJobRecord

 public ScheduledJobRecord(IJob job)
 {
     JobKey = JobStatus.GetKey(job.GetType());
 }
开发者ID:kingreatwill,项目名称:fubumvc,代码行数:4,代码来源:ScheduledJobLogRecords.cs

示例12: ReturnJob

 /// <summary>
 /// Allows the the job factory to destroy/cleanup the job if needed.
 /// </summary>
 /// <param name="job"></param>
 public void ReturnJob(IJob job)
 {
     this.logger.DebugFormat("Releasing the component for job '{0}'.", job.GetType());
     this.container.Release(job);
 }
开发者ID:prabhakara,项目名称:Dexter-Blog-Engine,代码行数:9,代码来源:DexterJobFactory.cs

示例13: RunJobAsync

        async Task RunJobAsync(IJob job, CancellationToken cancellationToken)
        {
            var jobtype = job.GetType()
                             .FullName;

            job.Log += InvokeLog;
            job.ExceptionThrown += InvokeExceptionThrown;

            try
            {
                InvokeLog($"\t\tJob {jobtype} {STARTED}");
                await job.RunAsync(cancellationToken);
            }
            catch (OperationCanceledException)
            {
                InvokeLog($"\t\tJob {jobtype} {CANCELLED}");
            }
            catch (Exception exception)
            {
                InvokeLog($"\t\tJob {jobtype} {ERRORED}");
                InvokeLog($"{jobtype} Exception{NewLine}{exception.ToText()}");
                InvokeExceptionThrown(job, new JobExceptionThrownEventArguments { Exception = exception, Job = job });
            }
            finally
            {
                job.ExceptionThrown -= InvokeExceptionThrown;
                job.Log -= InvokeLog;

                InvokeLog($"\t\tJob {jobtype} {FINISHED}");

                job.Dispose();
            }
        }
开发者ID:KatoTek,项目名称:Jobs,代码行数:33,代码来源:Batch.cs

示例14: RunJobCore

        private void RunJobCore(IJobContext context, Operation operation, IJob job)
        {
            // Run the job. If the job fails, ignore that exception as well but log it too!
            try
            {
                job.Execute(context, operation);
            }
            catch (Exception ex)
            {
                string message = (job.IsAsync) ? Properties.Resources.JobExecuteAsyncFailed : Properties.Resources.JobExecuteSyncFailed;

                // Be careful when processing the jobs, we don't want a malicious job to terminate the process!
                Logger.Instance.LogFormat(LogType.Warning, this, string.Format(message, job.GetType().Name));
                Logger.Instance.LogException(this, ex);
            }
        }
开发者ID:Knatter33,项目名称:AlarmWorkflow,代码行数:16,代码来源:JobManager.cs


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