public void CreateSchedule(CreateScheduleRequest request)
 {
     Channel.CreateSchedule(request);
 }
Ejemplo n.º 2
0
        public void CreateSchedule(BackupStorageType storageType, StorageParams storageParams, int backupsStored, CronParams cronParams, bool backupMail)
        {
            DemandPermissions();

            ValidateCronSettings(cronParams);

            var scheduleRequest = new CreateScheduleRequest
                {
                    TenantId = CoreContext.TenantManager.GetCurrentTenant().TenantId,
                    BackupMail = backupMail,
                    Cron = cronParams.ToString(),
                    NumberOfBackupsStored = backupsStored,
                    StorageType = storageType
                };

            switch (storageType)
            {
                case BackupStorageType.ThridpartyDocuments:
                case BackupStorageType.Documents:
                    scheduleRequest.StorageBasePath = storageParams.FolderId;
                    break;
                case BackupStorageType.CustomCloud:
                    ValidateS3Settings(storageParams.AccessKeyId, storageParams.SecretAccessKey, storageParams.Bucket, storageParams.Region);
                    CoreContext.Configuration.SaveSection(
                        new AmazonS3Settings
                            {
                                AccessKeyId = storageParams.AccessKeyId,
                                SecretAccessKey = storageParams.SecretAccessKey,
                                Bucket = storageParams.Bucket,
                                Region = storageParams.Region
                            });
                    break;
            }

            using (var service = new BackupServiceClient())
            {
                service.CreateSchedule(scheduleRequest);
            }
        }