public RecurringJobManager( [NotNull] JobStorage storage, [NotNull] IJobFilterProvider filterProvider, [NotNull] ITimeZoneResolver timeZoneResolver) : this(storage, filterProvider, timeZoneResolver, () => DateTime.UtcNow) { }
/// <summary> /// Initializes a new instance of the <see cref="RecurringJobScheduler"/> class /// with custom background job factory, state machine and clocks. /// </summary> /// <param name="factory">Factory that will be used to create background jobs.</param> /// <param name="pollingDelay">Delay before another polling attempt, when no jobs scheduled yet.</param> /// <param name="timeZoneResolver">Function that returns a time zone object by its identifier.</param> /// <exception cref="ArgumentNullException"><paramref name="factory"/> is null.</exception> /// <exception cref="ArgumentNullException"><paramref name="timeZoneResolver"/> is null.</exception> public RecurringJobScheduler( [NotNull] IBackgroundJobFactory factory, TimeSpan pollingDelay, [NotNull] ITimeZoneResolver timeZoneResolver) : this(factory, pollingDelay, timeZoneResolver, () => DateTime.UtcNow) { }
public static RecurringJobEntity GetOrCreateRecurringJob( [NotNull] this IStorageConnection connection, [NotNull] string recurringJobId, [NotNull] ITimeZoneResolver timeZoneResolver, DateTime now) { if (connection == null) { throw new ArgumentNullException(nameof(connection)); } if (recurringJobId == null) { throw new ArgumentNullException(nameof(recurringJobId)); } if (timeZoneResolver == null) { throw new ArgumentNullException(nameof(timeZoneResolver)); } var recurringJob = connection.GetAllEntriesFromHash($"recurring-job:{recurringJobId}"); if (recurringJob == null || recurringJob.Count == 0) { recurringJob = new Dictionary <string, string>(); } return(new RecurringJobEntity(recurringJobId, recurringJob, timeZoneResolver, now)); }
public RecurringJobScheduler( [NotNull] IBackgroundJobFactory factory, TimeSpan pollingDelay, [NotNull] ITimeZoneResolver timeZoneResolver, [NotNull] Func <DateTime> nowFactory) { if (factory == null) { throw new ArgumentNullException(nameof(factory)); } if (nowFactory == null) { throw new ArgumentNullException(nameof(nowFactory)); } if (timeZoneResolver == null) { throw new ArgumentNullException(nameof(timeZoneResolver)); } _factory = factory; _nowFactory = nowFactory; _timeZoneResolver = timeZoneResolver; _pollingDelay = pollingDelay; _profiler = new SlowLogProfiler(_logger); }
public RecurringJobManager( [NotNull] JobStorage storage, [NotNull] IJobFilterProvider filterProvider, [NotNull] ITimeZoneResolver timeZoneResolver, [NotNull] Func <DateTime> nowFactory) : this(storage, new BackgroundJobFactory(filterProvider), timeZoneResolver, nowFactory) { }
public CommentController( IMediator mediator, IBlogConfig blogConfig, ITimeZoneResolver timeZoneResolver) { _mediator = mediator; _blogConfig = blogConfig; _timeZoneResolver = timeZoneResolver; }
public SystemInfoController( SystemInfoManager systemInfoManager, IOptions <UIOptions> uiOptionsAccessor, ITimeZoneResolver timeZoneResolver ) { systemInfo = systemInfoManager; this.timeZoneResolver = timeZoneResolver; uiOptions = uiOptionsAccessor.Value; }
public CommentController( ICommentService commentService, IBlogConfig blogConfig, ITimeZoneResolver timeZoneResolver, IBlogNotificationClient notificationClient) { _commentService = commentService; _blogConfig = blogConfig; _timeZoneResolver = timeZoneResolver; _notificationClient = notificationClient; }
internal RecurringJobManager( [NotNull] JobStorage storage, [NotNull] IBackgroundJobFactory factory, [NotNull] ITimeZoneResolver timeZoneResolver, [NotNull] Func <DateTime> nowFactory) { _storage = storage ?? throw new ArgumentNullException(nameof(storage)); _factory = factory ?? throw new ArgumentNullException(nameof(factory)); _timeZoneResolver = timeZoneResolver ?? throw new ArgumentNullException(nameof(timeZoneResolver)); _nowFactory = nowFactory ?? throw new ArgumentNullException(nameof(nowFactory)); }
public SystemInfoController( SystemInfoManager systemInfoManager, IOptions<UIOptions> uiOptionsAccessor, ITimeZoneResolver timeZoneResolver ) { systemInfo = systemInfoManager; this.timeZoneResolver = timeZoneResolver; uiOptions = uiOptionsAccessor.Value; }
public EditPostModel(IMediator mediator, ITimeZoneResolver timeZoneResolver) { _mediator = mediator; _timeZoneResolver = timeZoneResolver; ViewModel = new() { IsPublished = false, Featured = false, EnableComment = true, FeedIncluded = true }; }
public PostController( IMediator mediator, IBlogConfig blogConfig, ITimeZoneResolver timeZoneResolver, IPingbackSender pingbackSender, ILogger <PostController> logger) { _mediator = mediator; _blogConfig = blogConfig; _timeZoneResolver = timeZoneResolver; _pingbackSender = pingbackSender; _logger = logger; }
public MetaWeblogService( IBlogConfig blogConfig, ITimeZoneResolver timeZoneResolver, ILogger <MetaWeblogService> logger, IBlogImageStorage blogImageStorage, IFileNameGenerator fileNameGenerator, IMediator mediator) { _blogConfig = blogConfig; _timeZoneResolver = timeZoneResolver; _logger = logger; _blogImageStorage = blogImageStorage; _fileNameGenerator = fileNameGenerator; _mediator = mediator; }
public PostController( IPostQueryService postQueryService, IPostManageService postManageService, IBlogConfig blogConfig, ITimeZoneResolver timeZoneResolver, IPingbackSender pingbackSender, ILogger <PostController> logger) { _postQueryService = postQueryService; _postManageService = postManageService; _blogConfig = blogConfig; _timeZoneResolver = timeZoneResolver; _pingbackSender = pingbackSender; _logger = logger; }
public EditPostModel( ICategoryService catService, IPostQueryService postQueryService, ITimeZoneResolver timeZoneResolver) { _catService = catService; _postQueryService = postQueryService; _timeZoneResolver = timeZoneResolver; ViewModel = new() { IsPublished = false, Featured = false, EnableComment = true, ExposedToSiteMap = true, FeedIncluded = true }; }
public MetaWeblogService( IBlogConfig blogConfig, ITimeZoneResolver timeZoneResolver, ILogger <MetaWeblogService> logger, ITagService tagService, ICategoryService categoryService, IPostQueryService postQueryService, IPostManageService postManageService, IBlogPageService blogPageService, IBlogImageStorage blogImageStorage, IFileNameGenerator fileNameGenerator) { _blogConfig = blogConfig; _timeZoneResolver = timeZoneResolver; _logger = logger; _tagService = tagService; _categoryService = categoryService; _postQueryService = postQueryService; _blogPageService = blogPageService; _blogImageStorage = blogImageStorage; _fileNameGenerator = fileNameGenerator; _postManageService = postManageService; }
public RecurringJobManager([NotNull] JobStorage storage, [NotNull] IBackgroundJobFactory factory, [NotNull] ITimeZoneResolver timeZoneResolver) : this(storage, factory, timeZoneResolver, () => DateTime.UtcNow) { }
public RecurringJobEntity( [NotNull] string recurringJobId, [NotNull] IDictionary <string, string> recurringJob, [NotNull] ITimeZoneResolver timeZoneResolver, DateTime now) { if (timeZoneResolver == null) { throw new ArgumentNullException(nameof(timeZoneResolver)); } _recurringJob = recurringJob ?? throw new ArgumentNullException(nameof(recurringJob)); RecurringJobId = recurringJobId ?? throw new ArgumentNullException(nameof(recurringJobId)); if (recurringJob.ContainsKey("Queue") && !String.IsNullOrWhiteSpace(recurringJob["Queue"])) { Queue = recurringJob["Queue"]; } TimeZone = recurringJob.ContainsKey("TimeZoneId") && !String.IsNullOrWhiteSpace(recurringJob["TimeZoneId"]) ? timeZoneResolver.GetTimeZoneById(recurringJob["TimeZoneId"]) : TimeZoneInfo.Utc; if (recurringJob.ContainsKey("Cron") && !String.IsNullOrWhiteSpace(recurringJob["Cron"])) { Cron = recurringJob["Cron"]; } if (recurringJob.ContainsKey("Job") && !String.IsNullOrWhiteSpace(recurringJob["Job"])) { Job = InvocationData.DeserializePayload(recurringJob["Job"]).DeserializeJob(); } if (recurringJob.ContainsKey("LastJobId") && !String.IsNullOrWhiteSpace(recurringJob["LastJobId"])) { LastJobId = recurringJob["LastJobId"]; } if (recurringJob.ContainsKey("LastExecution") && !String.IsNullOrWhiteSpace(recurringJob["LastExecution"])) { LastExecution = JobHelper.DeserializeDateTime(recurringJob["LastExecution"]); } if (recurringJob.ContainsKey("NextExecution") && !String.IsNullOrWhiteSpace(recurringJob["NextExecution"])) { NextExecution = JobHelper.DeserializeDateTime(recurringJob["NextExecution"]); } if (recurringJob.ContainsKey("CreatedAt") && !String.IsNullOrWhiteSpace(recurringJob["CreatedAt"])) { CreatedAt = JobHelper.DeserializeDateTime(recurringJob["CreatedAt"]); } else { CreatedAt = now; } if (recurringJob.ContainsKey("V") && !String.IsNullOrWhiteSpace(recurringJob["V"])) { Version = int.Parse(recurringJob["V"], CultureInfo.InvariantCulture); } }
public async Task <IActionResult> General([FromForm] MagicWrapper <GeneralSettings> wrapperModel, [FromServices] ITimeZoneResolver timeZoneResolver) { var model = wrapperModel.ViewModel; _blogConfig.GeneralSettings = model; _blogConfig.GeneralSettings.TimeZoneUtcOffset = timeZoneResolver.GetTimeSpanByZoneId(model.TimeZoneId).ToString(); await _blogConfig.SaveAsync(_blogConfig.GeneralSettings); AppDomain.CurrentDomain.SetData("CurrentThemeColor", null); return(NoContent()); }
public async Task <IActionResult> General([FromForm] MagicWrapper <GeneralSettingsViewModel> wrapperModel, [FromServices] ITimeZoneResolver timeZoneResolver) { var model = wrapperModel.ViewModel; var settings = _blogConfig.GeneralSettings; settings.MetaKeyword = model.MetaKeyword; settings.MetaDescription = model.MetaDescription; settings.CanonicalPrefix = model.CanonicalPrefix; settings.SiteTitle = model.SiteTitle; settings.Copyright = model.Copyright; settings.LogoText = model.LogoText; settings.SideBarCustomizedHtmlPitch = model.SideBarCustomizedHtmlPitch; settings.SideBarOption = Enum.Parse <SideBarOption>(model.SideBarOption); settings.FooterCustomizedHtmlPitch = model.FooterCustomizedHtmlPitch; settings.TimeZoneUtcOffset = timeZoneResolver.GetTimeSpanByZoneId(model.SelectedTimeZoneId).ToString(); settings.TimeZoneId = model.SelectedTimeZoneId; settings.ThemeId = model.SelectedThemeId; settings.OwnerName = model.OwnerName; settings.OwnerEmail = model.OwnerEmail; settings.Description = model.OwnerDescription; settings.ShortDescription = model.OwnerShortDescription; settings.AutoDarkLightTheme = model.AutoDarkLightTheme; await _blogConfig.SaveAsync(_blogConfig.GeneralSettings); AppDomain.CurrentDomain.SetData("CurrentThemeColor", null); await _blogAudit.AddEntry(BlogEventType.Settings, BlogEventId.SettingsSavedGeneral, "General Settings updated."); return(NoContent()); }
public GeneralModel(IBlogConfig blogConfig, ITimeZoneResolver timeZoneResolver, IThemeService themeService) { _blogConfig = blogConfig; _timeZoneResolver = timeZoneResolver; _themeService = themeService; }
ScheduleRecurringMessageConsumer(IRecurringJobManager recurringJobManager, ITimeZoneResolver timeZoneResolver) { _recurringJobManager = recurringJobManager; _timeZoneResolver = timeZoneResolver; }
public RecurringJobEntity( [NotNull] string recurringJobId, [NotNull] IDictionary <string, string> recurringJob, [NotNull] ITimeZoneResolver timeZoneResolver, DateTime now) { if (timeZoneResolver == null) { throw new ArgumentNullException(nameof(timeZoneResolver)); } _recurringJob = recurringJob ?? throw new ArgumentNullException(nameof(recurringJob)); _now = now; RecurringJobId = recurringJobId ?? throw new ArgumentNullException(nameof(recurringJobId)); if (recurringJob.ContainsKey("Queue") && !String.IsNullOrWhiteSpace(recurringJob["Queue"])) { Queue = recurringJob["Queue"]; } try { TimeZone = recurringJob.ContainsKey("TimeZoneId") && !String.IsNullOrWhiteSpace(recurringJob["TimeZoneId"]) ? timeZoneResolver.GetTimeZoneById(recurringJob["TimeZoneId"]) : TimeZoneInfo.Utc; } catch (Exception ex) { _errors.Add(ex); } if (recurringJob.ContainsKey("Cron") && !String.IsNullOrWhiteSpace(recurringJob["Cron"])) { Cron = recurringJob["Cron"]; } try { if (!recurringJob.ContainsKey("Job") || String.IsNullOrWhiteSpace(recurringJob["Job"])) { throw new InvalidOperationException("The 'Job' field has a null or empty value"); } Job = InvocationData.DeserializePayload(recurringJob["Job"]).DeserializeJob(); } catch (Exception ex) { _errors.Add(ex); } if (recurringJob.ContainsKey("LastJobId") && !String.IsNullOrWhiteSpace(recurringJob["LastJobId"])) { LastJobId = recurringJob["LastJobId"]; } if (recurringJob.ContainsKey("LastExecution") && !String.IsNullOrWhiteSpace(recurringJob["LastExecution"])) { LastExecution = JobHelper.DeserializeDateTime(recurringJob["LastExecution"]); } if (recurringJob.ContainsKey("NextExecution") && !String.IsNullOrWhiteSpace(recurringJob["NextExecution"])) { NextExecution = JobHelper.DeserializeDateTime(recurringJob["NextExecution"]); } if (recurringJob.ContainsKey("CreatedAt") && !String.IsNullOrWhiteSpace(recurringJob["CreatedAt"])) { CreatedAt = JobHelper.DeserializeDateTime(recurringJob["CreatedAt"]); } else { CreatedAt = now; } if (recurringJob.ContainsKey("V") && !String.IsNullOrWhiteSpace(recurringJob["V"])) { Version = int.Parse(recurringJob["V"], CultureInfo.InvariantCulture); } if (recurringJob.TryGetValue("RetryAttempt", out var attemptString) && int.TryParse(attemptString, out var retryAttempt)) { RetryAttempt = retryAttempt; } }
public GeneralModel(IBlogConfig blogConfig, ITimeZoneResolver timeZoneResolver, IMediator mediator) { _blogConfig = blogConfig; _timeZoneResolver = timeZoneResolver; _mediator = mediator; }