0

以下のブログに従って Azure スケジューラを実装しました

http://fabriccontroller.net/a-complete-overview-to-get-started-with-the-windows-azure-scheduler/

スケジューラーでジョブを作成/更新/削除できるようになりましたが、ジョブコレクションがいっぱいかどうかを確認するにはどうすればよいですか? 基本的に、現在のジョブコレクションがいっぱいになるたびに別のコレクションを作成したいと考えています。

コード スニペットの共有

    public class AzureSchedulerStorage : ISchedulerStorage
    {
        private CertificateCloudCredentials credentials;
        //private CloudServiceManagementClient cloudServiceClient;
        private string cloudServiceName;
       // private IHalseyLogger logger;

        public AzureSchedulerStorage(string cloudServiceName, CertificateCloudCredentials credentials)
        {
            this.cloudServiceName = cloudServiceName;
            this.credentials = credentials;
          //  this.logger = logger;
        }

        public SchedulerOperationStatusResponse CreateJobCollection(string jobCollectionName)
        {
            var schedulerServiceClient = new SchedulerManagementClient(credentials);
            var jobCollectionCreateParameters = new JobCollectionCreateParameters()
            {
                Label = jobCollectionName,
                IntrinsicSettings = new JobCollectionIntrinsicSettings()
                {
                    Plan = JobCollectionPlan.Standard,
                    Quota = new JobCollectionQuota()
                    {
                        MaxJobCount = 50,
                        MaxRecurrence = new JobCollectionMaxRecurrence()
                        {
                            Frequency = JobCollectionRecurrenceFrequency.Minute
                        }
                    }
                }
            };

            var result = schedulerServiceClient.JobCollections.Create(this.cloudServiceName, jobCollectionName, jobCollectionCreateParameters);
            return result;

        }

        public JobCollectionGetResponse GetJobCollection(string jobCollectionName)
        {
            var schedulerServiceClient = new SchedulerManagementClient(credentials);
            var result = schedulerServiceClient.JobCollections.Get(this.cloudServiceName, jobCollectionName);
            return result;
        }

        public void CreateOrUpdate(string jobcollectionName, string jobId, DateTime startDate)
        {
            var schedulerClient = new SchedulerClient(this.cloudServiceName, jobcollectionName, this.credentials);
            var job = new JobCreateOrUpdateParameters()
            {
                Action = new JobAction()
                {
                    Type = JobActionType.Https,
                    Request = new JobHttpRequest()
                    {
                        Body = "customer=sandrino&command=sendnewsletter",
                        Headers = new Dictionary<string, string>()
                        {
                            { "Content-Type", "application/x-www-form-urlencoded" },
                            { "x-something", "value123" }
                        },
                        Method = "POST",
                        Uri = new Uri("http://postcatcher.in/catchers/527af9acfe325802000001cb"),

                    }
                },

                StartTime = startDate,
            };

            var result = schedulerClient.Jobs.CreateOrUpdate(jobId, job);
        }
    }
}
4

1 に答える 1