Exemplo n.º 1
0
        public void ConfigInheritance_CronjobHasNoAuthConfiguration()
        {
            var template = new ConfigTemplate("")
            {
                Auth = new TokenAuth
                {
                    Scope         = "templatescope",
                    TokenEndpoint = "templateendpoint"
                }
            };

            var project = new Project("")
            {
                Template = template,
                Auth     = new TokenAuth
                {
                    Scope = "projectscope",
                }
            };
            var cronjob = new Cronjob(project)
            {
            };

            Assert.Equal("projectscope", cronjob.EffectiveAuth.Scope);
            Assert.Equal("templateendpoint", cronjob.EffectiveAuth.TokenEndpoint);
        }
Exemplo n.º 2
0
        public void ConfigInheritance_CronjobOverridesEverythingElse()
        {
            var template = new ConfigTemplate("")
            {
                Auth = new TokenAuth
                {
                    Scope         = "templatescope",
                    TokenEndpoint = "templateendpoint"
                }
            };

            var project = new Project("")
            {
                Template = template,
                Auth     = new TokenAuth
                {
                    Scope = "projectscope",
                }
            };
            var cronjob = new Cronjob(project)
            {
                Auth = new TokenAuth
                {
                    Scope = "cronjobscope"
                }
            };

            Assert.Equal("cronjobscope", cronjob.EffectiveAuth.Scope);
            Assert.Equal("templateendpoint", cronjob.EffectiveAuth.TokenEndpoint);
        }
Exemplo n.º 3
0
        public Task <Guid> TriggerAsync(Cronjob cronjob)
        {
            var executionId = Guid.NewGuid();

            _logger.LogInformation("Triggering '{Cronjob}' manually with execution id={ExecutionId}", cronjob.Title, executionId);
            _backgroundJobClient.Enqueue <HttpRequestSender>(job => job.SendRequestAsync(cronjob.Id, executionId, default));
            return(Task.FromResult(executionId));
        }
Exemplo n.º 4
0
 public void UpdateCronjob(Cronjob cronjob)
 {
     try
     {
         using (var mySqlClient = SqlDatabaseManager.GetGlobalClient())
         {
             mySqlClient.ExecuteNonQuery($"UPDATE server_crons SET REPEAT={Convert.ToInt16(cronjob.RepeatedTask)}, TIME={cronjob.ExecutionTime}, INTERVAL={cronjob.Intervals}, ACTIVE={Convert.ToInt32(Global.CronjobManager.Cronjobs.Contains(cronjob))} WHERE ID={cronjob.Id}");
         }
     }
     catch (Exception e)
     {
         new ExceptionLog("db_updcrons", "Error updating crons", e);
     }
 }
 public Task Add(Cronjob cronjob)
 {
     _logger.LogInformation("Registering cronjob '{CronjobTitle}' ({CronjobId}) with Hangfire", cronjob.Title, cronjob.Id);
     _recurringJobManager.AddOrUpdate <HttpRequestJob>(
         cronjob.GetHangfireId(),
         job => job.SendRequestAsync(cronjob.Id, default, null, default),