public void Tags_UnsupportedFormat() { var testFile = TestFiles.Json; var options = new TagsOptions { FileInfo = testFile.ToFileInfo() }; var request = new TagsRequest(options); var ex = Assert.Throws <ApiException>(() => { InfoApi.Tags(request); }); Assert.AreEqual($"The specified file '{testFile.FullName}' has type which is not currently supported.", ex.Message); }
public void Tags_DocumentProtectedException() { var testFile = TestFiles.PasswordProtected; var options = new TagsOptions { FileInfo = testFile.ToFileInfo(), }; var request = new TagsRequest(options); var ex = Assert.Throws <ApiException>(() => { InfoApi.Tags(request); }); Assert.AreEqual($"The specified file '{testFile.FullName}' is protected.", ex.Message); }
/// <summary> /// Configures Hangfire to use Tags. /// </summary> /// <param name="configuration">Global configuration</param> /// <param name="options">Options for tags</param> /// <param name="sqlOptions">Options for sql storage</param> /// <param name="jobStorage">The jobStorage for which this configuration is used.</param> /// <returns></returns> public static IGlobalConfiguration UseTagsWithSql(this IGlobalConfiguration configuration, TagsOptions options = null, SqlServerStorageOptions sqlOptions = null, JobStorage jobStorage = null) { options = options ?? new TagsOptions(); sqlOptions = sqlOptions ?? new SqlServerStorageOptions(); var storage = new SqlTagsServiceStorage(sqlOptions); (jobStorage ?? JobStorage.Current).Register(options, storage); var config = configuration.UseTags(options); return(config); }
public void Tags_FileNotFound() { var testFile = TestFiles.NotExist; var options = new TagsOptions { FileInfo = testFile.ToFileInfo(), }; var request = new TagsRequest(options); var ex = Assert.Throws <ApiException>(() => { InfoApi.Tags(request); }); Assert.AreEqual($"Can't find file located at '{testFile.FullName}'.", ex.Message); }
public void TagsApiTest() { var options = new TagsOptions { FileInfo = TestFiles.Docx.ToFileInfo() }; var request = new TagsRequest(options); var result = InfoApi.Tags(request); Assert.IsNotNull(result.RootPackage); Assert.IsNotEmpty(result.RootPackage.InnerPackages); Assert.IsTrue(result.RootPackage.InnerPackages.Any(x => string.Equals(x.PackageName, "FileFormat"))); Assert.IsTrue(result.RootPackage.InnerPackages.Any(x => x.PackageProperties.First(p => p.Name == "FileFormat").Tags .Select(s => s.Name).Any(e => string.Equals(e, "FileFormat")))); }
public static void Run() { var configuration = new Configuration(Common.MyAppSid, Common.MyAppKey); var apiInstance = new InfoApi(configuration); try { var fileInfo = new FileInfo { FilePath = "documents/input.docx", StorageName = Common.MyStorage }; var options = new TagsOptions { FileInfo = fileInfo }; var request = new TagsRequest(options); // Get tags var response = apiInstance.Tags(request); Console.WriteLine($"Root package: {response.RootPackage.PackageName}"); foreach (var entry in response.RootPackage.InnerPackages[0].PackageProperties) { Console.WriteLine($"{entry.Name}: {entry.Value}"); if (entry.Tags == null) { continue; } foreach (var tag in entry.Tags) { Console.WriteLine($"Tag for property: name - {tag.Name}, category - {tag.Category}"); } } } catch (Exception e) { Console.WriteLine("Exception while calling InfoApi: " + e.Message); } }
/// <summary> /// Configures Hangfire to use Tags. /// </summary> /// <param name="configuration">Global configuration</param> /// <param name="jobStorage">Job storage</param> /// <param name="options">Options for tags</param> /// <param name="sqlOptions">Options for sql storage</param> /// <returns></returns> public static IGlobalConfiguration UseTagsWithSql( this IGlobalConfiguration configuration, SqlServerStorage jobStorage, TagsOptions options = null, SqlServerStorageOptions sqlOptions = null) { if (jobStorage == null) { throw new ArgumentNullException(nameof(jobStorage)); } options = options ?? new TagsOptions(); sqlOptions = sqlOptions ?? new SqlServerStorageOptions(); options.Storage = new SqlTagsServiceStorage(sqlOptions, jobStorage); TagsServiceStorage.Current = options.Storage; var config = configuration.UseTags(options, jobStorage: jobStorage); return(config); }
/// <summary> /// Configures Hangfire to use Tags. /// </summary> /// <param name="configuration">Global configuration</param> /// <param name="options">Options for tags</param> /// <param name="redisOptions">Options for Redis storage</param> /// <returns></returns> public static IGlobalConfiguration UseTagsWithRedis(this IGlobalConfiguration configuration, TagsOptions options = null, RedisStorageOptions redisOptions = null) { options = options ?? new TagsOptions(); redisOptions = redisOptions ?? new RedisStorageOptions(); var storage = new RedisTagsServiceStorage(redisOptions); options.Storage = storage; TagsServiceStorage.Current = options.Storage; var config = configuration.UseTags(options).UseFilter(new RedisStateFilter(storage)); return(config); }
/// <summary> /// This method gets called by the runtime. Use this method to add services to the container. /// </summary> /// <param name="services"></param> public void ConfigureServices(IServiceCollection services) { services.AddDbContext <Models.DB.WebHookHubContext>(opt => opt.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"))); services.AddHangfire(config => { //SqlServer Sample config.UseSqlServerStorage(Configuration.GetConnectionString("DefaultConnection"), new SqlServerStorageOptions { SlidingInvisibilityTimeout = TimeSpan.FromMinutes(5), // To enable Sliding invisibility fetching CommandBatchMaxTimeout = TimeSpan.FromMinutes(5), // To enable command pipelining QueuePollInterval = TimeSpan.FromTicks(1) // To reduce processing delays to minimum }); var options = new TagsOptions { TagsListStyle = TagsListStyle.Dropdown }; config.UseTagsWithSql(options); //end SqlServer Sample config.UseHeartbeatPage(checkInterval: TimeSpan.FromSeconds(1)); }); services.AddHangfire(configuration => configuration .SetDataCompatibilityLevel(CompatibilityLevel.Version_170) .UseSimpleAssemblyNameTypeSerializer() .UseRecommendedSerializerSettings() .UseSqlServerStorage(Configuration.GetConnectionString("DefaultConnection"), new SqlServerStorageOptions { CommandBatchMaxTimeout = TimeSpan.FromMinutes(5), SlidingInvisibilityTimeout = TimeSpan.FromMinutes(5), QueuePollInterval = TimeSpan.Zero, UseRecommendedIsolationLevel = true, DisableGlobalLocks = true }) .UseHeartbeatPage(checkInterval: TimeSpan.FromSeconds(1)) .UseTagsWithSql() .UseMaxArgumentSizeToRender(Configuration.GetValue <int>("HangFireConfig:MaxArgumentToRenderSize")) ); //Retry Intervals var TimeIntervals = Configuration.GetSection("HangFireConfig:HangFireRetryIntervalInSeconds").Get <int[]>(); GlobalJobFilters.Filters.Add(new AutomaticRetryAttribute { Attempts = TimeIntervals.Length, DelaysInSeconds = TimeIntervals, OnAttemptsExceeded = AttemptsExceededAction.Fail }); //Presrve Queue GlobalJobFilters.Filters.Add(new Filters.CustomHangfireFilterAttribute()); services.AddTransient <Services.ApiLogService>(); services.AddTransient <Services.INotificationService, Services.NotificationService>(); // Add the processing server as IHostedService services.AddControllers() .AddJsonOptions(x => { x.JsonSerializerOptions.WriteIndented = true; x.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter()); }) .AddXmlSerializerFormatters(); services.Configure <ForwardedHeadersOptions>(options => { options.ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto; }); services.AddSwaggerGen(c => { c.SwaggerDoc(VERSION, new OpenApiInfo { Version = VERSION, Title = "WebHook HUB API", Description = "", Contact = new OpenApiContact { Name = "Gonzalo Moreno", Email = "*****@*****.**", Url = new Uri("https://github.com/gmoreno90"), } }); var dir = new DirectoryInfo(Path.Combine(AppContext.BaseDirectory)); foreach (var fi in dir.EnumerateFiles("*.xml")) { c.IncludeXmlComments(fi.FullName); } }); }
internal static void Register(JobStorage jobStorage, TagsOptions options, ITagsServiceStorage serviceStorage) { ServiceStorages[jobStorage ?? JobStorage.Current] = new Tuple <TagsOptions, ITagsServiceStorage>(options, serviceStorage); }
public TagsDispatcher(TagsOptions options) { _options = options; }
public static void Register(this JobStorage jobStorage, TagsOptions options, ITagsServiceStorage serviceStorage) { StorageRegistration.Register(jobStorage, options, serviceStorage); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.Configure <CookiePolicyOptions>(options => { // This lambda determines whether user consent for non-essential cookies is needed for a given request. options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.None; }); services.AddHangfire(config => { config.UseMemoryStorage(); //SqlServer Sample config.UseSqlServerStorage(Configuration.GetConnectionString("DefaultConnection"), new SqlServerStorageOptions { SlidingInvisibilityTimeout = TimeSpan.FromMinutes(5), // To enable Sliding invisibility fetching CommandBatchMaxTimeout = TimeSpan.FromMinutes(5), // To enable command pipelining QueuePollInterval = TimeSpan.FromTicks(1) // To reduce processing delays to minimum }); var options = new TagsOptions() { TagsListStyle = TagsListStyle.Dropdown }; config.UseTagsWithSql(options); //end SqlServer Sample //MySql Sample //var mySqlOptions = new MySqlStorageOptions //{ // TransactionIsolationLevel = IsolationLevel.ReadCommitted, // QueuePollInterval = TimeSpan.FromSeconds(15), // JobExpirationCheckInterval = TimeSpan.FromHours(1), // CountersAggregateInterval = TimeSpan.FromMinutes(5), // PrepareSchemaIfNecessary = true, // DashboardJobListLimit = 50000, // TransactionTimeout = TimeSpan.FromMinutes(1), // TablesPrefix = "hangfire" //}; //config.UseStorage(new MySqlStorage(Configuration.GetConnectionString("MySqlConnection"), mySqlOptions)); //var options = new TagsOptions() //{ // TagsListStyle = TagsListStyle.Dropdown //}; //config.UseTagsWithMySql(options,mySqlOptions); //end MySql Sample //postgreSql Sample //config.UsePostgreSqlStorage(Configuration.GetConnectionString("PostgreSqlConnection"), new PostgreSqlStorageOptions //{ // QueuePollInterval = TimeSpan.FromTicks(1) // To reduce processing delays to minimum //}); //var options = new TagsOptions() //{ // TagsListStyle = TagsListStyle.Dropdown //}; //config.UseTagsWithPostgreSql(); //end postgreSql Sample //config.UseNLogLogProvider(); config.UseHeartbeatPage(checkInterval: TimeSpan.FromSeconds(5)); }); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); }
public ProcessingStateRenderer(TagsOptions options) { _options = options; }
public DynamicCssDispatcher(TagsOptions options) { _options = options ?? throw new ArgumentNullException(nameof(options)); }
/// <summary> /// Configures Hangfire to use Tags. /// </summary> /// <param name="configuration">Global configuration</param> /// <param name="options">Options for tags</param> /// <returns></returns> public static IGlobalConfiguration UseTagsWithMemory(this IGlobalConfiguration configuration, TagsOptions options = null) { options = options ?? new TagsOptions(); options.Storage = new MemoryTagsServiceStorage(); var config = configuration.UseTags(options); return(config); }
/// <summary> /// Initializes a new instance of the <see cref="TagsRequest"/> class. /// </summary> /// <param name="options">Tags options.</param> public TagsRequest(TagsOptions options) { this.options = options; }
/// <summary> /// Configures Hangfire to use Tags. /// </summary> /// <param name="configuration">Global configuration</param> /// <param name="multiplexer"></param> /// <param name="options">Options for tags</param> /// <param name="redisOptions">Options for mysql storage</param> /// <returns></returns> public static IGlobalConfiguration UseTagsWithRedis(this IGlobalConfiguration configuration, IConnectionMultiplexer multiplexer, TagsOptions options = null, RedisStorageOptions redisOptions = null) { options = options ?? new TagsOptions(); redisOptions = redisOptions ?? new RedisStorageOptions() { Db = multiplexer.GetDatabase().Database }; GlobalStateHandlers.Handlers.Add(new SucceededStateHandler(redisOptions, multiplexer)); GlobalStateHandlers.Handlers.Add(new DeletedStateHandler(redisOptions, multiplexer)); GlobalStateHandlers.Handlers.Add(new FailedStateHandler(redisOptions, multiplexer)); GlobalStateHandlers.Handlers.Add(new ScheduledStateHandler(redisOptions, multiplexer)); GlobalStateHandlers.Handlers.Add(new EnqueuedStateHandler(redisOptions, multiplexer)); GlobalStateHandlers.Handlers.Add(new ProcessingStateHandler(redisOptions, multiplexer)); GlobalStateHandlers.Handlers.Add(new AwaitingStateHandler(redisOptions, multiplexer)); GlobalJobFilters.Filters.Add(new AutomaticRetryFilter(redisOptions, multiplexer)); options.Storage = new RedisTagsServiceStorage(multiplexer, redisOptions); return(configuration.UseTags(options)); }
/// <summary> /// Configures Hangfire to use Tags. /// </summary> /// <param name="configuration">Global configuration</param> /// <param name="options">Options for tags</param> /// <param name="sqlOptions">Options for sql storage</param> /// <returns></returns> public static IGlobalConfiguration UseTagsWithSql(this IGlobalConfiguration configuration, TagsOptions options = null, SqlServerStorageOptions sqlOptions = null) { options = options ?? new TagsOptions(); sqlOptions = sqlOptions ?? new SqlServerStorageOptions(); options.Storage = new SqlTagsServiceStorage(sqlOptions); TagsServiceStorage.Current = options.Storage; var config = configuration.UseTags(options); return(config); }
/// <summary> /// Configures Hangfire to use Tags. /// </summary> /// <param name="configuration">Global configuration</param> /// <param name="options">Options for tags</param> /// <param name="mongoOptions">Options for Mongo storage</param> /// <returns></returns> public static IGlobalConfiguration UseTagsWithMongo(this IGlobalConfiguration configuration, TagsOptions options = null, MongoStorageOptions mongoOptions = null) { options = options ?? new TagsOptions(); mongoOptions = mongoOptions ?? new MongoStorageOptions(); options.Storage = new MongoTagsServiceStorage(mongoOptions); var config = configuration.UseTags(options); JobsSidebarMenu.Items.RemoveAll(x => x.Method.Module.Assembly == typeof(TagsOptions).Assembly); JobsSidebarMenu.Items.Add(page => new MenuItem("Tags", page.Url.To("/tags/search")) { Active = page.RequestPath.StartsWith("/tags/search"), Metric = new DashboardMetric("tags:count", razorPage => { return(new Metric(((MongoTagsServiceStorage)options.Storage).GetTagsCount())); }) }); return(config); }