void CheckClearCache(Item item) { if (item != null && item.TemplateID.Equals(Templates.RedirectMap.ID) && !JobsHelper.IsPublishing()) { RedirectsCache.Reset(); } }
public void ConfigureServices(IServiceCollection services) { var appConfiguration = Configuration.GetSection(AppConfiguration.Section).Get <AppConfiguration>(); var csvFileHandlerJobConfig = Configuration.GetSection(CsvFileHandlerJobConfig.Section).Get <CsvFileHandlerJobConfig>(); services.AddAppConfig(Configuration); services.AddAppServices(); services.AddHangfire(x => { x.SetDataCompatibilityLevel(CompatibilityLevel.Version_170) .UseSimpleAssemblyNameTypeSerializer() .UseRecommendedSerializerSettings() .UseSQLiteStorage(appConfiguration.SQLiteDBConn) .UseNLogLogProvider(); var csvFileJob = JobsHelper.GenerateJobInfo( typeof(TestCsvFileHandlerJob), csvFileHandlerJobConfig.JobCron, appConfiguration.TimeZoneId ); CronJob.AddOrUpdate(csvFileJob); }); services.AddHangfireServer(); }
public static void UseManagementPages(this IGlobalConfiguration config, Assembly[] assemblies) { foreach (var assembly in assemblies) { JobsHelper.GetAllJobs(assembly); } CreateManagement(); }
public void DownloadAndReadMetadata_Should_schedule_http_notification() { // Arrange var jobsHelper = new JobsHelper(_context, _downloader, _metadataReader, _client, _postNotificationSender); // Act jobsHelper.DownloadAndReadMetadata(1); // Assert Mock.Get(_client).Verify(c => c.Create(It.IsAny <Job>(), It.IsAny <IState>())); }
public ActionResult BusinessObject(int id, int taskId) { bool userhasboright = false; JobsHelper jhelper = new JobsHelper(); var task = _inFlowDb.T_Tasks.Find(taskId); var boi = _db.BusinessObjectInstances.Find(id); bool readOnly = true; bool usercanaccessTask = jhelper.CanUserAccessTask(taskId, User.Identity.Name); if (usercanaccessTask) { if (task.EditableParameters.Contains("{\"Type\":\"bobasic\",\"Value\":{\"bo\":" + boi.BusinessObjectId + ",\"boi\":" + boi.Id + "}}")) { userhasboright = true; if (task.Done == false) { readOnly = false; } } else if (task.ReadableParameters.Contains("{\"Type\":\"bobasic\",\"Value\":{\"bo\":" + boi.BusinessObjectId + ",\"boi\":" + boi.Id + "}}")) { userhasboright = true; } } if (userhasboright) { BORender bor = new BORender(); ViewBOModel model = new ViewBOModel(); // dynamic model = Newtonsoft.Json.JsonConvert.DeserializeObject<dynamic>(boi.Data); model.BObjectIdentifier = id; //model.BObjectSchema = JObject.Parse(boi.BusinessObject.JsonSchema); //model.BObjectErrors = null; model.ViewData = bor.createHTML(boi.Data, boi.BusinessObject.JsonSchema, boi.BusinessObject.ViewData); model.ReadOnly = readOnly; ViewBag.TaskId = taskId; return(PartialView(model)); } else { return(PartialView("Accessdenied")); } }
public void DownloadAndReadMetadata_Should_get_scheduled_image_from_db_and_process_it() { // Arrange var jobsHelper = new JobsHelper(_context, _downloader, _metadataReader, _client, _postNotificationSender); // Act jobsHelper.DownloadAndReadMetadata(1); // Assert Mock.Get(_scheduledImages).Verify(x => x.Find(It.Is <int>(id => id == 1))); Mock.Get(_downloader).Verify(x => x.Download(It.IsAny <string>())); Mock.Get(_metadataReader).Verify(x => x.ReadFromStream(It.IsAny <MemoryStream>())); }
public static void AddManagementPages(this IServiceCollection services, IConfiguration config, IHostingEnvironment hostingEnvironment, params Assembly[] assemblies) { GlobalLoaderConfiguration.WebRootPath = hostingEnvironment.WebRootPath; GlobalLoaderConfiguration.ContentRootPath = hostingEnvironment.ContentRootPath; services.LoadInstalledModules(hostingEnvironment, assemblies); foreach (var module in GlobalLoaderConfiguration.Modules) { JobsHelper.GetAllJobs(module.Assembly); } services.Build(config, hostingEnvironment); }
private IEnumerable <IDisposable> GetHangfireServers() { GlobalConfiguration.Configuration .UseMemoryStorage() .UseSimpleAssemblyNameTypeSerializer() .UseRecommendedSerializerSettings() .UseManagementPages(typeof(Startup).Assembly); var options = new BackgroundJobServerOptions(); var queues = new List <string>(); queues.Add("default"); queues.AddRange(JobsHelper.GetAllQueues()); options.Queues = queues.Distinct().ToArray(); yield return(new BackgroundJobServer(options)); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddHangfire((configuration) => { configuration .UseMemoryStorage() .UseSimpleAssemblyNameTypeSerializer() .UseRecommendedSerializerSettings() .UseManagementPages(typeof(Startup).Assembly); }); services.AddHangfireServer((options) => { var queues = new List <string>(); queues.Add("default"); queues.AddRange(JobsHelper.GetAllQueues()); options.Queues = queues.Distinct().ToArray(); }); services.AddRazorPages(); }
private static void InitJobs(Assembly assembly) { var jobs = JobsHelper.GetAllJobs(assembly); var methodMeta = jobs.Item1; var pages = jobs.Item2; pages.ForEach(x => JobCategories.Add(x)); methodMeta.ForEach(x => Jobs.Add(x)); Jobs.CollectionChanged += (sender, e) => { if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add) { foreach (JobMetadata v in e.NewItems) { //Add item to manager //ManagementBasePage.Jobs.Add(v); ManagementBasePage.AddCommands(v); } } }; }
public void OnItemCreated(object sender, EventArgs args) { if (JobsHelper.IsPublishing()) { return; } var item = Event.ExtractParameter <ItemCreatedEventArgs>(args, 0).Item; if (CanExecute(item)) { var workflow = GetSiteWorkflow(item); if (workflow != null) { Workflow = workflow.WorkflowID; DefaultWorkflowState = GetWorkflowState(workflow); using (EditContext editContext = new EditContext(item)) { item[FieldIDs.Workflow] = Workflow; item[FieldIDs.DefaultWorkflow] = Workflow; item[FieldIDs.WorkflowState] = DefaultWorkflowState; } } } }
public static void UseManagementPages(this IGlobalConfiguration config, Assembly assembly) { JobsHelper.GetAllJobs(assembly); CreateManagement(); }
public static void UseManagementPages(this IGlobalConfiguration config, Assembly assembly, List <ManagementPageNavigation> navigation) { JobsHelper.GetAllJobs(assembly); CreateManagement(navigation); }
private void ScheduleBackgroundJob(ScheduledImage imageMetadata) { var helper = new JobsHelper(_context, new DownloadToStream(), new CustomMetadataReader(), _backgroundJobClient, _postNotificationSender); _backgroundJobClient.Enqueue(() => helper.DownloadAndReadMetadata(imageMetadata.Id)); }
public ActionResult SubmitBusinessObject(int id, int taskId) { bool userhaseditrights = false; JobsHelper jhelper = new JobsHelper(); var task = _inFlowDb.T_Tasks.Find(taskId); var boi = _db.BusinessObjectInstances.Find(id); if (!task.Done) { bool usercanaccessTask = jhelper.CanUserAccessTask(taskId, User.Identity.Name); if (usercanaccessTask) { if (task.EditableParameters.Contains("{\"Type\":\"bobasic\",\"Value\":{\"bo\":" + boi.BusinessObjectId + ",\"boi\":" + boi.Id + "}}")) { userhaseditrights = true; } } } if (userhaseditrights) { var schemastring = _db.BusinessObjectInstances.Find(id).BusinessObject.JsonSchema; string jsonstring = FlatJson.RequestFormToJsonTree(Request.Form, schemastring); JObject data = JObject.Parse(jsonstring); JsonSchema schema = JsonSchema.Parse(schemastring); IList <string> messages; bool valid = data.IsValid(schema, out messages); if (valid) { ViewBag.BObjectIdentifier = id; ViewBag.Json = jsonstring; boi = _db.BusinessObjectInstances.Find(id); boi.Data = jsonstring; _db.SaveChanges(); Dictionary <string, string> model = new Dictionary <string, string>(); model.Add("json", jsonstring); return(PartialView(model)); } else { boi = _db.BusinessObjectInstances.Find(id); BORender bor = new BORender(); ViewBOModel model = new ViewBOModel(); //dynamic model = Newtonsoft.Json.JsonConvert.DeserializeObject<dynamic>(jsonstring); model.BObjectIdentifier = id; // model.BObjectSchema = JObject.Parse(schemastring); model.BObjectErrors = new List <string>(messages); model.ViewData = bor.createHTML(jsonstring, boi.BusinessObject.JsonSchema, boi.BusinessObject.ViewData); ViewBag.TaskId = taskId; return(PartialView("BusinessObject", model)); } } else { return(PartialView("Accessdenied")); } }