public override string UpdateDatabaseRecord(DatabaseRecord record, long etag) { bool newTask = false; if (Configuration.TaskId == 0) { // this is a new backup configuration newTask = true; Configuration.TaskId = etag; } else { // modified periodic backup, remove the old one record.DeletePeriodicBackupConfiguration(Configuration.TaskId); } if (string.IsNullOrEmpty(Configuration.Name)) { Configuration.Name = record.EnsureUniqueTaskName(Configuration.GetDefaultTaskName()); } else if (Configuration.Name.StartsWith(ServerWideBackupConfiguration.NamePrefix, StringComparison.OrdinalIgnoreCase)) { throw new InvalidOperationException($"Can't {(newTask ? "create" : "update")} task: '{Configuration.Name}'. " + $"A regular (non server-wide) backup task name can't start with prefix '{ServerWideBackupConfiguration.NamePrefix}'"); } EnsureTaskNameIsNotUsed(record, Configuration.Name); record.PeriodicBackups.Add(Configuration); return(null); }
public override string UpdateDatabaseRecord(DatabaseRecord record, long etag) { if (Configuration.TaskId == 0) { // this is a new backup configuration Configuration.TaskId = etag; } else { // modified periodic backup, remove the old one record.DeletePeriodicBackupConfiguration(Configuration.TaskId); } if (string.IsNullOrEmpty(Configuration.Name)) { Configuration.Name = record.EnsureUniqueTaskName(Configuration.GetDefaultTaskName()); } else if (Configuration.Name.StartsWith(ServerWideBackupConfiguration.NamePrefix, StringComparison.OrdinalIgnoreCase)) { throw new InvalidOperationException($"Can't update task name '{Configuration.Name}', because it is a server wide backup task"); } EnsureTaskNameIsNotUsed(record, Configuration.Name); record.PeriodicBackups.Add(Configuration); return(null); }
public override string UpdateDatabaseRecord(DatabaseRecord record, long etag) { Debug.Assert(TaskId != 0); switch (TaskType) { case OngoingTaskType.Replication: ExternalReplication.RemoveWatcher(ref record.ExternalReplication, TaskId); break; case OngoingTaskType.Backup: record.DeletePeriodicBackupConfiguration(TaskId); return(TaskId.ToString()); case OngoingTaskType.SqlEtl: var sqlEtl = record.SqlEtls?.Find(x => x.TaskId == TaskId); if (sqlEtl != null) { record.SqlEtls.Remove(sqlEtl); } break; case OngoingTaskType.RavenEtl: var ravenEtl = record.RavenEtls?.Find(x => x.TaskId == TaskId); if (ravenEtl != null) { record.RavenEtls.Remove(ravenEtl); } break; } return(null); }
public override void UpdateDatabaseRecord(DatabaseRecord record, long etag) { Debug.Assert(TaskId != 0); switch (TaskType) { case OngoingTaskType.Replication: var replicationTask = record.ExternalReplications?.Find(x => x.TaskId == TaskId); if (replicationTask != null) { if (replicationTask.Name != null && replicationTask.Name.StartsWith(ServerWideExternalReplication.NamePrefix, StringComparison.OrdinalIgnoreCase)) { throw new InvalidOperationException($"Can't delete task id: {TaskId}, name: '{replicationTask.Name}', " + $"because it is a server-wide external replication task. Please use a dedicated operation."); } record.ExternalReplications.Remove(replicationTask); } break; case OngoingTaskType.PullReplicationAsHub: var hubDefinition = record.HubPullReplications.Find(x => x.TaskId == TaskId); if (hubDefinition != null) { _hubNameToDelete = hubDefinition.Name; record.HubPullReplications.Remove(hubDefinition); } break; case OngoingTaskType.PullReplicationAsSink: var pullTask = record.SinkPullReplications?.Find(x => x.TaskId == TaskId); if (pullTask != null) { record.SinkPullReplications.Remove(pullTask); } break; case OngoingTaskType.Backup: record.DeletePeriodicBackupConfiguration(TaskId); _taskIdToDelete = TaskId.ToString(); break; case OngoingTaskType.SqlEtl: var sqlEtl = record.SqlEtls?.Find(x => x.TaskId == TaskId); if (sqlEtl != null) { record.SqlEtls.Remove(sqlEtl); } break; case OngoingTaskType.RavenEtl: var ravenEtl = record.RavenEtls?.Find(x => x.TaskId == TaskId); if (ravenEtl != null) { record.RavenEtls.Remove(ravenEtl); } break; } }
public override string UpdateDatabaseRecord(DatabaseRecord record, long etag) { Debug.Assert(TaskId != 0); switch (TaskType) { case OngoingTaskType.Replication: var replicationTask = record.ExternalReplications?.Find(x => x.TaskId == TaskId); if (replicationTask != null) { record.ExternalReplications.Remove(replicationTask); } break; case OngoingTaskType.PullReplicationAsHub: var hubDefinition = record.HubPullReplications.Find(x => x.TaskId == TaskId); if (hubDefinition != null) { record.HubPullReplications.Remove(hubDefinition); } break; case OngoingTaskType.PullReplicationAsSink: var pullTask = record.SinkPullReplications?.Find(x => x.TaskId == TaskId); if (pullTask != null) { record.SinkPullReplications.Remove(pullTask); } break; case OngoingTaskType.Backup: record.DeletePeriodicBackupConfiguration(TaskId); return(TaskId.ToString()); case OngoingTaskType.SqlEtl: var sqlEtl = record.SqlEtls?.Find(x => x.TaskId == TaskId); if (sqlEtl != null) { record.SqlEtls.Remove(sqlEtl); } break; case OngoingTaskType.RavenEtl: var ravenEtl = record.RavenEtls?.Find(x => x.TaskId == TaskId); if (ravenEtl != null) { record.RavenEtls.Remove(ravenEtl); } break; } return(null); }
public override string UpdateDatabaseRecord(DatabaseRecord record, long etag) { if (Configuration.TaskId == 0) { // this is a new backup configuration Configuration.TaskId = etag; } else { // modified periodic backup, remove the old one record.DeletePeriodicBackupConfiguration(Configuration.TaskId); } if (string.IsNullOrEmpty(Configuration.Name)) { Configuration.Name = record.EnsureUniqueTaskName(Configuration.GetDefaultTaskName()); } record.EnsureTaskNameIsNotUsed(Configuration.Name); record.PeriodicBackups.Add(Configuration); return(null); }