/// <summary> /// Adds the basic service job. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="automaticallyRegisterUserType">if set to <c>true</c> then user type T will be registered in DIContainer with transient lifetime.</param> /// <param name="invokeMethodName">Name of the invoke method.</param> public void AddBasicJob <T>(bool automaticallyRegisterUserType = false, string invokeMethodName = "Run") where T : class { if (automaticallyRegisterUserType) { DIContainer.Current.Register <T>(LifetimeType.Transient); } var job = ServiceJobFactory.CreateServiceJob <T>(invokeMethodName); _jobsList.Add(job); }
/// <summary> /// Adds the job. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="configurationSectionName">Name of the configuration section.</param> /// <param name="invokeMethodName">Name of the invoke method.</param> /// <param name="automaticallyRegisterUserType">if set to <c>true</c> then user type T will be registered in DIContainer with transient lifetime.</param> public void AddJob <T>(string configurationSectionName = null, string invokeMethodName = "Run", bool automaticallyRegisterUserType = false) where T : class { if (automaticallyRegisterUserType) { DIContainer.Current.Register <T>(LifetimeType.Transient); } var job = ServiceJobFactory.CreateCrontabServiceJob <T>(configurationSectionName, invokeMethodName); job.OnCronTimerTick += OnCronTimerTick; job.OnStartWork += OnStartWork; _jobsList.Add(job); }