Exemplo n.º 1
0
        public async Task Run <T>(T configuration, CancellationToken cancellationToken, PerformContext context) where T : BaseJobConfiguration
        {
            if (typeof(T) != typeof(HttpJobConfiguration))
            {
                throw new ArgumentException("Wrong configuration type for this job.");
            }

            var config = configuration as HttpJobConfiguration;

            context.AddTags(config.Tags);

            var restService = new RestService <object, Tout>(config.Endpoint);

            await restService.Post(config.Body, config.Headers, null, cancellationToken);
        }
Exemplo n.º 2
0
        public async Task Run <T>(T configuration, CancellationToken cancellationToken, PerformContext context) where T : BaseJobConfiguration
        {
            if (typeof(T) != typeof(StoredProcedureJobConfiguration))
            {
                throw new ArgumentException("Wrong configuration type for this job.");
            }

            var config = configuration as StoredProcedureJobConfiguration;

            context.AddTags(config.Tags);

            var parameterValues = config.Parameters.Select(pair => new SqlParameter(pair.Key, pair.Value));
            var parameterKeys   = config.Parameters.Select(x => x.Key);
            var sqlCommand      = SqlStoredProcedureStringBuilder.Build(config.StoredProcedureName, parameterKeys);

            unitOfWork.Context.Database.ExecuteSqlCommand(sqlCommand, parameterValues);

            await unitOfWork.Commit();
        }
Exemplo n.º 3
0
 public void Job(string name, PerformContext ctx)
 {
     // TextBuffer.WriteLine("Background Job completed succesfully!");
     ctx.AddTags("finished");
 }
Exemplo n.º 4
0
 public static PerformContext AddTags(this PerformContext context, IEnumerable <string> tags)
 {
     return(context.AddTags(tags.ToArray()));
 }
Exemplo n.º 5
0
 public void DoJob(PerformContext context)
 {
     context?.AddTags("server-two-tag-three", "server-two-tag-four", "server-two-tag-five");
 }
Exemplo n.º 6
0
 [AutomaticRetry(Attempts = 0)] // Disable retry
 public void FailedTask(PerformContext context)
 {
     context.AddTags("throw");
     throw new Exception("Fail please!");
 }
Exemplo n.º 7
0
 public void SuccessTask(PerformContext context, IJobCancellationToken token)
 {
     TextBuffer.WriteLine("Recurring Job completed successfully!");
     context.AddTags("finished");
 }
Exemplo n.º 8
0
 public void DoJob(PerformContext context)
 {
     context?.AddTags("server-one-tag-one", "server-one-tag-two");
 }
Exemplo n.º 9
0
 [AutomaticRetry(Attempts = 0)] // Disable retry
 public void FailedTask(PerformContext context, IJobCancellationToken token)
 {
     context.AddTags("throw");
     throw new Exception("Fail please!");
 }