Ejemplo n.º 1
0
        public Client()
        {
            var entry   = GlobalConfiguration.Configuration.UseSqlServerStorage(ConectionString);
            var current = entry.Entry;
            var states  = current.GetMonitoringApi();
            List <RecurringJobDto> recurringJobs = JobStorage.Current.GetConnection().GetRecurringJobs();

            recurringJobs.ForEach(x => Console.WriteLine(x.Id));
            hfClient = new BackgroundJobClient(current);

            CreateJob();

            //var jobId = BackgroundJob.Enqueue(() => Console.WriteLine("Pozdrav z klienta !"));
            //var jobId2 = hfClient.ContinueWith(jobId, () => Console.WriteLine("Následuje po pozdravu z klienta !"));
            ////var job = new Hangfire.Common.Job(() => Console.WriteLine("Pozdrav z klienta !"));
            //Console.WriteLine($"jobId={jobId},jobId2={jobId2}");

            //System.Threading.Thread.Sleep(2000);

            //Console.WriteLine(hfClient.RetryAttempts);

            //if (hfClient.Delete(jobId, "Succeeded"))
            //    Console.WriteLine($"Succeeded deleted {jobId}");

            var monitoringApi = JobStorage.Current.GetMonitoringApi();
            var deletedJobs   = monitoringApi.DeletedJobs(0, 10);
            // If no queue name was defined somewhere, probably this will be "default".
            // If no items have been queued, then the queue won't exist, and it will error here.
            var queue = monitoringApi.Queues().First().Name;

            var enqueudjobs = monitoringApi.SucceededJobs(0, 10);

            enqueudjobs.ForEach(x => hfClient.Delete(x.Key));
        }
        public async Task <UserCourseModel> UnSubscribeFromCourseAsync(UserCourseModel userCourseModel)
        {
            var userCourse = await _context.UserCourses.Where(uc => uc.StudentId == userCourseModel.StudentId &&
                                                              uc.CourseId == userCourseModel.CourseId)
                             .SingleOrDefaultAsync();

            if (userCourse != null)
            {
                var user = await _context.Users.Include(u => u.ScheduledJobs)
                           .Where(u => u.Id == userCourseModel.StudentId)
                           .SingleOrDefaultAsync();

                if (user != null)
                {
                    foreach (var item in user.ScheduledJobs)
                    {
                        _backgroundJob.Delete(item.Id);
                        _context.ScheduledJobs.Remove(item);
                    }
                }

                _context.UserCourses.Remove(userCourse);
                await _context.SaveChangesAsync();

                return(_mapper.Map <UserCourseModel>(userCourse));
            }
            return(null);
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> CancelUpgrade([FromQuery] string jobId)
        {
            await _mediator.Send(new RemoveBuildingUpgradeJob.Command(jobId));

            var client = new BackgroundJobClient();

            client.Delete(jobId);
            RecurringJob.RemoveIfExists(jobId);

            return(Ok());
        }
Ejemplo n.º 4
0
Archivo: Job.cs Proyecto: clawit/Fan
 public static bool Delete(string jobId, string fromState)
 {
     if (_storage == null || _client == null)
     {
         throw new Exception("Init has not been called yet.");
     }
     else
     {
         return(_client.Delete(jobId, fromState));
     }
 }
Ejemplo n.º 5
0
        public async Task <UserModel> DeleteAsync(int studentId)
        {
            var studentToDelete = await _context.Users.Include(u => u.ScheduledJobs)
                                  .Where(u => u.Id == studentId)
                                  .SingleOrDefaultAsync();

            if (studentToDelete != null)
            {
                foreach (var item in studentToDelete.ScheduledJobs)
                {
                    _backgroundJob.Delete(item.Id);
                    _context.ScheduledJobs.Remove(item);
                }
                _context.Users.Remove(studentToDelete);
                await _context.SaveChangesAsync();

                return(_mapper.Map <UserModel>(studentToDelete));
            }

            return(null);
        }
        public FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer)
        {
            var token  = (TaskEntityToken)entityToken;
            var client = new BackgroundJobClient(JobStorage.Current);

            client.Delete(token.Id, ScheduledState.StateName);

            var treeRefresher = new SpecificTreeRefresher(flowControllerServicesContainer);

            treeRefresher.PostRefreshMesseges(new FolderEntityToken(TaskType.Scheduled));

            return(null);
        }
Ejemplo n.º 7
0
        static DashboardRoutes()
        {
            Routes = new RouteCollection();
            Routes.AddRazorPage("/", x => new DashboardPage());
            Routes.Add("/stats", new JsonStats());

            #region Embedded static content

            Routes.Add("/js", new CombinedResourceDispatcher(
                           "application/javascript",
                           typeof(DashboardRoutes).Assembly,
                           GetContentFolderNamespace("js"),
                           Javascripts));

            Routes.Add("/css", new CombinedResourceDispatcher(
                           "text/css",
                           typeof(DashboardRoutes).Assembly,
                           GetContentFolderNamespace("css"),
                           Stylesheets));

            Routes.Add("/fonts/glyphicons-halflings-regular/eot", new EmbeddedResourceDispatcher(
                           "application/vnd.ms-fontobject",
                           typeof(DashboardRoutes).Assembly,
                           GetContentResourceName("fonts", "glyphicons-halflings-regular.eot")));

            Routes.Add("/fonts/glyphicons-halflings-regular/svg", new EmbeddedResourceDispatcher(
                           "image/svg+xml",
                           typeof(DashboardRoutes).Assembly,
                           GetContentResourceName("fonts", "glyphicons-halflings-regular.svg")));

            Routes.Add("/fonts/glyphicons-halflings-regular/ttf", new EmbeddedResourceDispatcher(
                           "application/octet-stream",
                           typeof(DashboardRoutes).Assembly,
                           GetContentResourceName("fonts", "glyphicons-halflings-regular.ttf")));

            Routes.Add("/fonts/glyphicons-halflings-regular/woff", new EmbeddedResourceDispatcher(
                           "application/font-woff",
                           typeof(DashboardRoutes).Assembly,
                           GetContentResourceName("fonts", "glyphicons-halflings-regular.woff")));

            #endregion

            #region Razor pages and commands

            Routes.AddRazorPage("/job/(?<JobId>.+)", x => new JobDetailsPage(x.Groups["JobId"].Value));

            Routes.AddRazorPage("/queues", x => new QueuesPage());
            Routes.AddRazorPage(
                "/queues/fetched/(?<Queue>.+)",
                x => new FetchedJobsPage(x.Groups["Queue"].Value));
            Routes.AddRazorPage(
                "/queues/(?<Queue>.+)",
                x => new EnqueuedJobsPage(x.Groups["Queue"].Value));

            Routes.AddClientBatchCommand("/enqueued/delete", (client, jobId) => client.Delete(jobId));
            Routes.AddClientBatchCommand("/enqueued/requeue", (client, jobId) => client.Requeue(jobId));

            Routes.AddRazorPage("/processing", x => new ProcessingJobsPage());
            Routes.AddClientBatchCommand(
                "/processing/delete",
                (client, jobId) => client.Delete(jobId, ProcessingState.StateName));

            Routes.AddClientBatchCommand(
                "/processing/requeue",
                (client, jobId) => client.Requeue(jobId, ProcessingState.StateName));

            Routes.AddRazorPage("/scheduled", x => new ScheduledJobsPage());

            Routes.AddClientBatchCommand(
                "/scheduled/enqueue",
                (client, jobId) => client.Requeue(jobId, ScheduledState.StateName));

            Routes.AddClientBatchCommand(
                "/scheduled/delete",
                (client, jobId) => client.Delete(jobId, ScheduledState.StateName));

            Routes.AddRazorPage("/servers", x => new ServersPage());
            Routes.AddRazorPage("/succeeded", x => new SucceededJobs());
            Routes.AddClientBatchCommand(
                "/succeeded/requeue",
                (client, jobId) => client.Requeue(jobId, SucceededState.StateName));

            Routes.AddRazorPage("/failed", x => new FailedJobsPage());

            Routes.AddClientBatchCommand(
                "/failed/requeue",
                (client, jobId) => client.Requeue(jobId, FailedState.StateName));

            Routes.AddClientBatchCommand(
                "/failed/delete",
                (client, jobId) => client.Delete(jobId, FailedState.StateName));

            Routes.AddRazorPage("/deleted", x => new DeletedJobsPage());

            Routes.AddClientBatchCommand(
                "/deleted/requeue",
                (client, jobId) => client.Requeue(jobId, DeletedState.StateName));

            Routes.AddCommand(
                "/actions/requeue/(?<JobId>.+)",
                context =>
            {
                var client = new BackgroundJobClient(context.JobStorage);
                return(client.Requeue(context.UriMatch.Groups["JobId"].Value));
            });

            Routes.AddCommand(
                "/actions/delete/(?<JobId>.+)",
                context =>
            {
                var client = new BackgroundJobClient(context.JobStorage);
                return(client.Delete(context.UriMatch.Groups["JobId"].Value));
            });

            Routes.AddRazorPage("/recurring", x => new RecurringJobsPage());
            Routes.AddRecurringBatchCommand(
                "/recurring/remove",
                (manager, jobId) => manager.RemoveIfExists(jobId));

            Routes.AddRecurringBatchCommand(
                "/recurring/trigger",
                (manager, jobId) => manager.Trigger(jobId));

            #endregion
        }
Ejemplo n.º 8
0
        static DashboardRoutes()
        {
            Routes = new RouteCollection();
            Routes.AddRazorPage("/", x => new HomePage());
            Routes.Add("/stats", new JsonStats());
            
            #region Embedded static content

            Routes.Add("/js", new CombinedResourceDispatcher(
                "application/javascript", 
                typeof(DashboardRoutes).Assembly,
                GetContentFolderNamespace("js"),
                Javascripts));

            Routes.Add("/css", new CombinedResourceDispatcher(
                "text/css",
                typeof(DashboardRoutes).Assembly,
                GetContentFolderNamespace("css"),
                Stylesheets));

            Routes.Add("/fonts/glyphicons-halflings-regular/eot", new EmbeddedResourceDispatcher(
                "application/vnd.ms-fontobject",
                typeof(DashboardRoutes).Assembly,
                GetContentResourceName("fonts", "glyphicons-halflings-regular.eot")));

            Routes.Add("/fonts/glyphicons-halflings-regular/svg", new EmbeddedResourceDispatcher(
                "image/svg+xml",
                typeof(DashboardRoutes).Assembly,
                GetContentResourceName("fonts", "glyphicons-halflings-regular.svg")));

            Routes.Add("/fonts/glyphicons-halflings-regular/ttf", new EmbeddedResourceDispatcher(
                "application/octet-stream",
                typeof(DashboardRoutes).Assembly,
                GetContentResourceName("fonts", "glyphicons-halflings-regular.ttf")));

            Routes.Add("/fonts/glyphicons-halflings-regular/woff", new EmbeddedResourceDispatcher(
                "application/font-woff",
                typeof(DashboardRoutes).Assembly,
                GetContentResourceName("fonts", "glyphicons-halflings-regular.woff")));

            #endregion

            #region Razor pages and commands

            Routes.AddRazorPage("/jobs/enqueued", x => new QueuesPage());
            Routes.AddRazorPage(
                "/jobs/enqueued/fetched/(?<Queue>.+)",
                x => new FetchedJobsPage(x.Groups["Queue"].Value));

            Routes.AddClientBatchCommand("/jobs/enqueued/delete", (client, jobId) => client.Delete(jobId));
            Routes.AddClientBatchCommand("/jobs/enqueued/requeue", (client, jobId) => client.Requeue(jobId));

            Routes.AddRazorPage(
                "/jobs/enqueued/(?<Queue>.+)",
                x => new EnqueuedJobsPage(x.Groups["Queue"].Value));

            Routes.AddRazorPage("/jobs/processing", x => new ProcessingJobsPage());
            Routes.AddClientBatchCommand(
                "/jobs/processing/delete", 
                (client, jobId) => client.Delete(jobId, ProcessingState.StateName));

            Routes.AddClientBatchCommand(
                "/jobs/processing/requeue",
                (client, jobId) => client.Requeue(jobId, ProcessingState.StateName));

            Routes.AddRazorPage("/jobs/scheduled", x => new ScheduledJobsPage());

            Routes.AddClientBatchCommand(
                "/jobs/scheduled/enqueue", 
                (client, jobId) => client.Requeue(jobId, ScheduledState.StateName));

            Routes.AddClientBatchCommand(
                "/jobs/scheduled/delete",
                (client, jobId) => client.Delete(jobId, ScheduledState.StateName));

            Routes.AddRazorPage("/jobs/succeeded", x => new SucceededJobs());
            Routes.AddClientBatchCommand(
                "/jobs/succeeded/requeue",
                (client, jobId) => client.Requeue(jobId, SucceededState.StateName));

            Routes.AddRazorPage("/jobs/failed", x => new FailedJobsPage());

            Routes.AddClientBatchCommand(
                "/jobs/failed/requeue",
                (client, jobId) => client.Requeue(jobId, FailedState.StateName));

            Routes.AddClientBatchCommand(
                "/jobs/failed/delete",
                (client, jobId) => client.Delete(jobId, FailedState.StateName));

            Routes.AddRazorPage("/jobs/deleted", x => new DeletedJobsPage());

            Routes.AddClientBatchCommand(
                "/jobs/deleted/requeue",
                (client, jobId) => client.Requeue(jobId, DeletedState.StateName));

            Routes.AddRazorPage("/jobs/awaiting", x => new AwaitingJobsPage());
            Routes.AddClientBatchCommand("/jobs/awaiting/enqueue", (client, jobId) => client.ChangeState(
                jobId, new EnqueuedState(), AwaitingState.StateName));
            Routes.AddClientBatchCommand("/jobs/awaiting/delete", (client, jobId) => client.ChangeState(
                jobId, new DeletedState(), AwaitingState.StateName));

            Routes.AddCommand(
                "/jobs/actions/requeue/(?<JobId>.+)",
                context =>
                {
                    var client = new BackgroundJobClient(context.JobStorage);
                    return client.Requeue(context.UriMatch.Groups["JobId"].Value);
                });

            Routes.AddCommand(
                "/jobs/actions/delete/(?<JobId>.+)",
                context =>
                {
                    var client = new BackgroundJobClient(context.JobStorage);
                    return client.Delete(context.UriMatch.Groups["JobId"].Value);
                });

            Routes.AddRazorPage("/jobs/details/(?<JobId>.+)", x => new JobDetailsPage(x.Groups["JobId"].Value));

            Routes.AddRazorPage("/recurring", x => new RecurringJobsPage());
            Routes.AddRecurringBatchCommand(
                "/recurring/remove", 
                (manager, jobId) => manager.RemoveIfExists(jobId));

            Routes.AddRecurringBatchCommand(
                "/recurring/trigger", 
                (manager, jobId) => manager.Trigger(jobId));

            Routes.AddRazorPage("/servers", x => new ServersPage());
            Routes.AddRazorPage("/retries", x => new RetriesPage());

            #endregion
        }