Exemple #1
0
        public void OnCreating_CapturesCultures_AndSetsThemAsJobParameters()
        {
            Thread.CurrentThread.CurrentCulture   = CultureInfo.GetCultureInfo("ru-RU");
            Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("ru-RU");

            var filter = CreateFilter();

            filter.OnCreating(_creatingContext);

            Assert.Equal("ru-RU", _creatingContext.GetJobParameter <string>("CurrentCulture"));
            Assert.Equal("ru-RU", _creatingContext.GetJobParameter <string>("CurrentUICulture"));
        }
        public void OnCreating(CreatingContext filterContext)
        {
            if (filterContext == null)
            {
                throw new ArgumentNullException(nameof(filterContext));
            }
            var recurringJobId = filterContext.GetJobParameter <string>("RecurringJobId");

            if (!string.IsNullOrWhiteSpace(recurringJobId))
            {
                var recurringJob = filterContext.Connection.GetAllEntriesFromHash("recurring-job:" + recurringJobId);
                var isPauseState = recurringJob.ContainsKey("PauseState") ? SerializationHelper.Deserialize <bool>(recurringJob["PauseState"]) : false;

                if (isPauseState)
                {
                    filterContext.SetJobParameter("PauseState", isPauseState);
                    filterContext.Canceled = true;
                }
            }
        }