コード例 #1
0
 public void OnCreated(CreatedContext filterContext)
 {
     logger.Info(
         "创建任务 `{0}` id为 `{1}`",
         filterContext.Job.Method.Name,
         filterContext.BackgroundJob?.Id);
 }
コード例 #2
0
 public void OnCreated(CreatedContext context)
 {
     _hangfireLogger.InfoFormat(
         "Job that is based on method {0} has been created with id {1}",
         context.Job.Method.Name,
         context.BackgroundJob?.Id);
 }
コード例 #3
0
 public void OnCreated(CreatedContext filterContext)
 {
     logger.InfoFormat(
         "[OnCreated] Job.Method.Name: `{0}` BackgroundJob.Id: `{1}`",
         filterContext.Job.Method.Name,
         filterContext.BackgroundJob?.Id);
 }
コード例 #4
0
        public void OnCreated(CreatedContext filterContext)
        {
            var mi = filterContext.Job.Method;

            if (filterContext.Job.Method.DeclaringType != filterContext.Job.Type)
            {
                // This job (or method) is from an inherited type, we should use reflection to retrieve the correct Job method
                var dmi = filterContext.Job.Type.GetMethod(filterContext.Job.Method.Name,
                                                           filterContext.Job.Method.GetParameters().Select(p => p.ParameterType).ToArray());
                mi = dmi ?? mi;
            }

            var attrs = mi.GetCustomAttributes <TagAttribute>()
                        .Union(mi.DeclaringType?.GetCustomAttributes <TagAttribute>() ?? Enumerable.Empty <TagAttribute>())
                        .SelectMany(t => t.Tag).ToList();

            if (!attrs.Any())
            {
                return;
            }

            if (filterContext.BackgroundJob?.Id == null)
            {
                return;
            }
//                throw new ArgumentException("Background Job cannot be null", nameof(filterContext));

            var args = filterContext.Job.Args.ToArray();
            var tags = attrs.Select(tag => string.Format(tag, args)).Where(a => !string.IsNullOrEmpty(a));

            filterContext.BackgroundJob.Id.AddTags(tags);
        }
コード例 #5
0
        /// <summary>
        /// 创建完成
        /// </summary>
        /// <param name="context"></param>
        public void OnCreated(CreatedContext context)
        {
            var jobname = context.Parameters.FirstOrDefault().Value;
            var arg     = string.Join(" , ", context.Job.Args.ToArray());

            Logger.WarnFormat("  创建完成  Job `{0}` ,  Arg is  `{1}`", jobname, arg);
        }
コード例 #6
0
 public void OnCreated(CreatedContext context)
 {
     Logger.InfoFormat(
         "Job that is based on method `{0}` has been created with id `{1}`",
         context.Job.Method.Name,
         context.BackgroundJob?.Id);
 }
コード例 #7
0
 public void OnCreated(CreatedContext context)
 {
     Console.WriteLine(
         "Job that is based on method `{0}` has been created with id `{1}`",
         context.Job.Method.Name,
         context.BackgroundJob?.Id);
 }
コード例 #8
0
 public void OnCreated(CreatedContext filterContext)
 {
     if (!filterContext.Canceled)
     {
         // job created, mark it as such
         filterContext.Connection.SetRangeInHash(GetJobKey(filterContext.Job),
                                                 new[] { new KeyValuePair <string, string>("jobId", filterContext.BackgroundJob.Id) });
     }
 }
コード例 #9
0
 public void OnCreated(CreatedContext filterContext)
 {
     WriteLog(
         $"{ApiConfig.HangfireLogUrl}\\OnCreated-{(filterContext.BackgroundJob?.Id ?? "0")}-{DateTime.Now:yyyy-MM-dd}.txt",
         $"Job that is based on method `{filterContext.Job.Method.Name}` has been created with id `{filterContext.BackgroundJob?.Id}` . 时间为:{DateTime.Now:yyyy-MM-dd-HH-mm-ss} \r\n");
     Logger.InfoFormat(
         "Job that is based on method `{0}` has been created with id `{1}`",
         filterContext.Job.Method.Name,
         filterContext.BackgroundJob?.Id);
 }
コード例 #10
0
        public void Ctor_CorrectlySetsAllProperties()
        {
            var connection          = new Mock <IStorageConnection>();
            var job                 = Job.FromExpression(() => TestMethod());
            var state               = new Mock <IState>();
            var exception           = new Exception();
            var stateMachineFactory = new Mock <IStateMachineFactory>();

            var createContext = new CreateContext(
                connection.Object, stateMachineFactory.Object, job, state.Object);
            var context = new CreatedContext(createContext, true, exception);

            Assert.True(context.Canceled);
            Assert.Same(exception, context.Exception);
        }
コード例 #11
0
        public void OnCreated(CreatedContext filterContext)
        {
            var mi    = filterContext.BackgroundJob.Job.Method;
            var attrs = mi.GetCustomAttributes <TagAttribute>()
                        .Union(mi.DeclaringType?.GetCustomAttributes <TagAttribute>() ?? Enumerable.Empty <TagAttribute>())
                        .SelectMany(t => t.Tag).ToList();

            if (!attrs.Any())
            {
                return;
            }

            var args = filterContext.Job.Args.ToArray();
            var tags = attrs.Select(tag => string.Format(tag, args)).Where(a => !string.IsNullOrEmpty(a));

            filterContext.BackgroundJob.Id.AddTags(tags);
        }
コード例 #12
0
ファイル: CreateJobFilter.cs プロジェクト: yuzd/Hangfire.Tags
        public void OnCreated(CreatedContext filterContext)
        {
            // BackgroundJob is Nullable from CreatedContext
            var mi = filterContext?.BackgroundJob?.Job.Method ?? throw new ArgumentException("Background Job cannot be null", nameof(filterContext));

            var attrs = mi.GetCustomAttributes <TagAttribute>()
                        .Union(mi.DeclaringType?.GetCustomAttributes <TagAttribute>() ?? Enumerable.Empty <TagAttribute>())
                        .SelectMany(t => t.Tag).ToList();

            if (!attrs.Any())
            {
                return;
            }

            var args = filterContext.Job.Args.ToArray();
            var tags = attrs.Select(tag => string.Format(tag, args)).Where(a => !string.IsNullOrEmpty(a));

            filterContext.BackgroundJob.Id.AddTags(tags);
        }
コード例 #13
0
        public PreserveCultureAttributeFacts()
        {
            _connection = new Mock <IStorageConnection>();
            var job   = Job.FromExpression(() => Sample());
            var state = new Mock <IState>();
            var stateMachineFactory = new Mock <IStateMachineFactory>();

            var createContext = new CreateContext(
                _connection.Object, stateMachineFactory.Object, job, state.Object);

            _creatingContext = new CreatingContext(createContext);
            _createdContext  = new CreatedContext(createContext, false, null);

            var workerContext = new WorkerContextMock();

            var performContext = new PerformContext(
                workerContext.Object, _connection.Object, JobId, job, DateTime.UtcNow, new Mock <IJobCancellationToken>().Object);

            _performingContext = new PerformingContext(performContext);
            _performedContext  = new PerformedContext(performContext, false, null);
        }
コード例 #14
0
ファイル: JobsFilter.cs プロジェクト: kathirv/test-repo
        /// <summary>
        /// Action: OnCreated
        /// Description: It is the second filter to update the sync status to 1 for all jobs validated by previous filter. But jobs are not to be started yet.
        /// Sync status 1 means pending/ongoing.
        /// </summary>
        /// <param name="context"></param>
        void IClientFilter.OnCreated(CreatedContext context)
        {
            if (context.Canceled == false || context.Exception == null)
            {
                Console.WriteLine(string.Format("Job is based on method `{0}` has been created with id `{1}`", context.Job.Method.Name, context.BackgroundJob?.Id));
                var    ccid        = context.Job.Args.ElementAt(2) as string;
                int    connectorId = (int)context.Job.Args.ElementAt(1);
                string jobId       = context.BackgroundJob?.Id;
                if (!string.IsNullOrEmpty(ccid) && connectorId > 0)
                {
                    //set sync status to progress{1}.
                    var connectorLogs = new ConnectorLogs()
                    {
                        sync_started_at = DateTime.UtcNow,
                        sync_ended_at   = null,
                        sync_logs       = new List <string>()
                    };

                    SyncRepository.UpdateSyncInfo(id: connectorId, ccid: ccid, status: 1, count: 0, jobid: jobId, connectorLogs: connectorLogs, totaluniquecount: 0, sync_updated_count: 0, deduped_count: 0, total_records_count: 0);
                }
            }
        }
コード例 #15
0
 public void OnCreated(CreatedContext filterContext)
 {
     //Intentionally Left Blank
 }
コード例 #16
0
 public void OnCreated(CreatedContext context)
 {
     string name = context.BackgroundJob.Job.Method.Name;
 }
コード例 #17
0
 public void OnCreated(CreatedContext filterContext)
 {
     // Não preciso fazer nada aqui
 }
コード例 #18
0
	public CreatedContext created() {
		CreatedContext _localctx = new CreatedContext(Context, State);
		EnterRule(_localctx, 200, RULE_created);
		int _la;
		try {
			EnterOuterAlt(_localctx, 1);
			{
			State = 1976; k_created();
			State = 1981;
			ErrorHandler.Sync(this);
			_la = TokenStream.La(1);
			while (_la==SCOL) {
				{
				{
				State = 1977; Match(SCOL);
				State = 1978; other_param();
				}
				}
				State = 1983;
				ErrorHandler.Sync(this);
				_la = TokenStream.La(1);
			}
			State = 1984; Match(COL);
			State = 1985; date_time();
			State = 1986; Match(CRLF);
			}
		}
		catch (RecognitionException re) {
			_localctx.exception = re;
			ErrorHandler.ReportError(this, re);
			ErrorHandler.Recover(this, re);
		}
		finally {
			ExitRule();
		}
		return _localctx;
	}
コード例 #19
0
 public void OnCreated(CreatedContext filterContext)
 {
     _pusher.NotifyQueueItemsChanged();
 }
コード例 #20
0
 /// <summary>Evento após o registro de uma ação(client)</summary>
 /// <param name="context">Contexto do evento</param>
 public void OnCreated(CreatedContext context)
 {
     Logger.LogInformation($"Job that is based on method `{context.Job.Method.Name}` has been created with id `{context.BackgroundJob?.Id}`");
 }
コード例 #21
0
 public void OnCreated(CreatedContext context)
 {
 }
 void IClientFilter.OnCreated(CreatedContext filterContext)
 {
 }
コード例 #23
0
ファイル: JobCreationProcess.cs プロジェクト: hahmed/HangFire
        private static CreatedContext InvokeClientFilter(
            IClientFilter filter,
            CreatingContext preContext,
            Func<CreatedContext> continuation)
        {
            filter.OnCreating(preContext);
            if (preContext.Canceled)
            {
                return new CreatedContext(
                    preContext, true, null);
            }

            var wasError = false;
            CreatedContext postContext;
            try
            {
                postContext = continuation();
            }
            catch (Exception ex)
            {
                wasError = true;
                postContext = new CreatedContext(
                    preContext, false, ex);

                filter.OnCreated(postContext);

                if (!postContext.ExceptionHandled)
                {
                    throw;
                }
            }

            if (!wasError)
            {
                filter.OnCreated(postContext);
            }

            return postContext;
        }
コード例 #24
0
        public void OnCreated(CreatedContext context)
        {
            string name = context.BackgroundJob.Job.Method.Name;

            _logger.LogInformation(name);
        }
コード例 #25
0
 public void OnCreated(CreatedContext filterContext)
 {
 }
コード例 #26
0
 public void OnCreated(CreatedContext filterContext)
 {
     Logger.InfoFormat($"Job that is based on method `{filterContext.Job.Method.Name}` has been created with id `{filterContext.BackgroundJob?.Id}`");
 }