Beispiel #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            const string jobName = "JobsLibraryTest.JobWorker";
            var          jobData = new JobWorkerParameters
            {
                FileName = "testJMService.txt"
            };

            var context = new InstanceContext(new JobManagerServiceCallback());
            var client  = new JobManagerServiceClient(context);

            var jobDto = new JobDto
            {
                ClassName = jobName,
                Data      = new TransferData(jobData),
                Triggers  = new List <TriggerDto>
                {
                    new TriggerDto
                    {
                        Cron = "0 0/1 * * * ?"
                    }
                }
            };

            var jobId = client.ScheduleJob(jobDto);
        }
Beispiel #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            const string jobName = "JobsLibraryTest.JobWorker";
            var          jobData = new JobWorkerParameters
            {
                FileName = "testJMService.txt"
            };

            var context = new InstanceContext(new JobManagerServiceCallback());
            var client  = new JobManagerServiceClient(context);

            var jobDto = new JobDto
            {
                ClassName = jobName,
                Data      = new TransferData(jobData)
            };

            var t = new Task(() => client.SubscribeClientContext());

            t.ContinueWith(s => { var workerDto = client.RunJob(jobDto); });
            t.Start();

            //var workerDto = client.RunJob(jobDto);
            //WorkersKeeper.Worker1 = workerDto.Id;
            //Thread.Sleep(2000);
            //client.Signal(workerDto.Id, new TransferData("stop"));
        }
        public void WorkerWillBeStarted(WorkerDto worker)
        {
            // Если эта джоба была запущена не нами, то подписаться на ее эвенты
            // ...

            Thread.Sleep(6000);

            var context = new InstanceContext(new JobManagerServiceCallback());
            var client  = new JobManagerServiceClient(context);

            client.SetClientContextToWorker(worker.Id);
        }