Example #1
0
        public void CreateWorkflow2()
        {
            var dl  = WorkflowJob.MakeJob(() => WorkflowMethod("Download"));
            var co1 = WorkflowJob.MakeJob(() => FailingWorkflowMethod("Do something 1"), maxRetries: 1);
            var co2 = WorkflowJob.MakeJob(() => WorkflowMethod("Do something 2"));
            var co3 = WorkflowJob.MakeJob(() => WorkflowMethod("Do something 3"));
            var se1 = WorkflowJob.MakeJob(() => WorkflowMethod("Send email 1"));
            var se3 = WorkflowJob.MakeJob(() => WorkflowMethod("Send email 3"));
            var de  = WorkflowJob.MakeJob(() => WorkflowMethod("Delete email"));

            de.WaitFor(se1, co2, se3);
            co1.ContinueWith(se1);
            co3.ContinueWith(se3);
            var group = WorkflowJobGroup.RunInParallel(co1, co2, co3);

            dl.ContinueWithGroup(group);

            var wf = new Workflow(dl);

            GlobalConfiguration.Configuration.UseSqlServerStorage("db");

            var client = new BackgroundJobClient();

            client.CreateAndEnqueue(wf);
        }
Example #2
0
        public void Workflow()
        {
            var rootJob = WorkflowJob.MakeJob(() => RecurringMethod("1 task", 1));

            rootJob.ContinueWith(WorkflowJob.MakeJob(() => RecurringMethod("2 task", 2)))
            .ContinueWithGroup(
                WorkflowJobGroup.RunInParallel(
                    WorkflowJob.MakeJob(() => RecurringMethod("3 task", 3)),
                    WorkflowJob.MakeJob(() => RecurringMethod("4 task", 4))
                    )).ContinueWith(
                WorkflowJob.MakeJob(() => RecurringMethod("5 task", 5)
                                    ));

            var wf = new Workflow(rootJob);

            wf.SaveWorkflow((t) => { t.QueueJob.JobId = (int)t.QueueJob.Job.Arguments[1]; Debug.WriteLine($"SAved: {t.QueueJob.JobId} - {t.QueueJob.Job.Arguments[0]}"); return((int)t.QueueJob.Job.Arguments[1]); });

            var jobs = wf.GetAllJobs().ToList();
        }
Example #3
0
        public void CreateRecurringWorkflow()
        {
            var dl  = WorkflowJob.MakeJob(() => WorkflowMethod("Download"));
            var co1 = WorkflowJob.MakeJob(() => WorkflowMethod("Do something 1"));
            var co2 = WorkflowJob.MakeJob(() => WorkflowMethod("Do something 2"));
            var co3 = WorkflowJob.MakeJob(() => WorkflowMethod("Do something 3"));
            var se1 = WorkflowJob.MakeJob(() => WorkflowMethod("Send email 1"));
            var se3 = WorkflowJob.MakeJob(() => WorkflowMethod("Send email 3"));
            var de  = WorkflowJob.MakeJob(() => WorkflowMethod("Delete email"));

            de.WaitFor(se1, co2, se3);
            co1.ContinueWith(se1);
            co3.ContinueWith(se3);
            var group = WorkflowJobGroup.RunInParallel(co1, co2, co3);

            dl.ContinueWithGroup(group);

            var wf = new Workflow(dl);

            GlobalConfiguration.Configuration.UseSqlServerStorage("db");
            RecurringWorkflow.AddOrUpdate("test workflow", wf, Cron.MinuteInterval(1));
        }
Example #4
0
        public void CreateWorkflow()
        {
            GlobalConfiguration.Configuration.UseSqlServerStorage("db");

            var contextId = Guid.NewGuid();

            var job1   = WorkflowJob.MakeJob(() => WorkflowMethod("1 task"), contextId: contextId);
            var job2   = WorkflowJob.MakeJob(() => WorkflowMethod("2 task"), contextId: contextId);
            var job31  = WorkflowJob.MakeJob(() => WorkflowMethod("3.1 task"), contextId: contextId);
            var job32  = WorkflowJob.MakeJob(() => WorkflowMethod("3.2 task"), contextId: contextId);
            var job321 = WorkflowJob.MakeJob(() => WorkflowMethod("3.2.1 task"), contextId: contextId);
            var group  = WorkflowJobGroup.RunInParallel(
                job31,
                job32
                );

            var job4 = WorkflowJob.MakeJob(() => WorkflowMethod("4 task"), contextId: contextId);
            var job5 = WorkflowJob.MakeJob(() => WorkflowMethod("5 task"), contextId: contextId);

            job1.ContinueWith(job2);
            job2.ContinueWithGroup(group);
            group.ContinueWith(job4);
            job4.ContinueWith(job5);
            job32.ContinueWith(job321);

            //rootJob.ContinueWith(WorkflowJob.MakeJob(() => RecurringMethod("2 task", 2))
            //    .ContinueWithGroup(
            //        WorkflowJob.MakeJob(() => RecurringMethod("3 task", 3)),
            //        WorkflowJob.MakeJob(() => RecurringMethod("4 task", 4))
            //    ).ContinueWith(WorkflowJob.MakeJob(() => RecurringMethod("5 task", 5))));

            var wf     = new Workflow(job1);
            var client = new BackgroundJobClient();

            client.CreateAndEnqueue(wf);
        }