Beispiel #1
0
        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);
        }
Beispiel #2
0
        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)
        {
            if (Watcher == null)
            {
                return(null);
            }

            if (Watcher.TaskId == 0)
            {
                Watcher.TaskId = etag;
            }
            else
            {
                //modified watcher, remove the old one
                ExternalReplication.RemoveExternalReplication(record.ExternalReplications, Watcher.TaskId);
            }
            //this covers the case of a new watcher and edit of an old watcher
            if (string.IsNullOrEmpty(Watcher.Name))
            {
                Watcher.Name = record.EnsureUniqueTaskName(Watcher.GetDefaultTaskName());
            }

            EnsureTaskNameIsNotUsed(record, Watcher.Name);
            record.ExternalReplications.Add(Watcher);
            return(null);
        }
        public override void UpdateDatabaseRecord(DatabaseRecord record, long etag)
        {
            Watcher.AssertValidReplication();

            if (Watcher == null)
            {
                return;
            }

            if (Watcher.TaskId == 0)
            {
                Watcher.TaskId = etag;
            }
            else
            {
                //modified watcher, remove the old one
                ExternalReplicationBase.RemoveExternalReplication(record.ExternalReplications, Watcher.TaskId);
            }
            //this covers the case of a new watcher and edit of an old watcher
            if (string.IsNullOrEmpty(Watcher.Name))
            {
                Watcher.Name = record.EnsureUniqueTaskName(Watcher.GetDefaultTaskName());
            }

            if (Watcher.Name.StartsWith(ServerWideExternalReplication.NamePrefix, StringComparison.OrdinalIgnoreCase))
            {
                var isNewTask = record.ExternalReplications.Exists(x => x.Name.Equals(Watcher.Name, StringComparison.OrdinalIgnoreCase));
                throw new InvalidOperationException($"Can't {(isNewTask ? "create" : "update")} task: '{Watcher.Name}'. " +
                                                    $"A regular (non server-wide) external replication name can't start with prefix '{ServerWideExternalReplication.NamePrefix}'");
            }

            EnsureTaskNameIsNotUsed(record, Watcher.Name);

            record.ExternalReplications.Add(Watcher);
        }
        public override void UpdateDatabaseRecord(DatabaseRecord record, long etag)
        {
            if (PullReplicationAsSink == null)
            {
                return;
            }

            if (PullReplicationAsSink.TaskId == 0)
            {
                PullReplicationAsSink.TaskId = etag;
            }
            else
            {
                // if new definition doesn't have certificate but there is old one with cert
                // it means we want to use existing cert or the server certificate
                if (PullReplicationAsSink.CertificateWithPrivateKey == null)
                {
                    if (UseServerCertificate == true)
                    {
                        PullReplicationAsSink.CertificateWithPrivateKey = null;
                    }
                    else
                    {
                        var existingDefinition = record.SinkPullReplications.Find(x => x.TaskId == PullReplicationAsSink.TaskId);
                        if (existingDefinition?.CertificateWithPrivateKey != null)
                        {
                            // retain existing certificate
                            PullReplicationAsSink.CertificateWithPrivateKey = existingDefinition.CertificateWithPrivateKey;
                            PullReplicationAsSink.CertificatePassword       = existingDefinition.CertificatePassword;
                        }
                    }
                }

                ExternalReplicationBase.RemoveExternalReplication(record.SinkPullReplications, PullReplicationAsSink.TaskId);
            }

            if (string.IsNullOrEmpty(PullReplicationAsSink.Name))
            {
                PullReplicationAsSink.Name = record.EnsureUniqueTaskName(PullReplicationAsSink.GetDefaultTaskName());
            }

            if (string.IsNullOrEmpty(PullReplicationAsSink.ConnectionStringName))
            {
                throw new ArgumentNullException(nameof(PullReplicationAsSink.ConnectionStringName));
            }

            record.EnsureTaskNameIsNotUsed(PullReplicationAsSink.Name);
            record.SinkPullReplications.Add(PullReplicationAsSink);
        }
Beispiel #6
0
        public override string UpdateDatabaseRecord(DatabaseRecord record, long etag)
        {
            if (Configuration.TaskId == 0)
            {
                // this is a new backup configuration
                Configuration.TaskId = etag;
                if (string.IsNullOrEmpty(Configuration.Name))
                {
                    Configuration.Name = record.EnsureUniqueTaskName(Configuration.GetDefaultTaskName());
                }

                record.EnsureTaskNameIsNotUsed(Configuration.Name);
            }

            record.AddPeriodicBackupConfiguration(Configuration);
            return(null);
        }
Beispiel #7
0
        protected void Add(ref List <T> etls, DatabaseRecord record, long etag)
        {
            if (string.IsNullOrEmpty(Configuration.Name))
            {
                Configuration.Name = record.EnsureUniqueTaskName(Configuration.GetDefaultTaskName());
            }

            record.EnsureTaskNameIsNotUsed(Configuration.Name);

            Configuration.TaskId = etag;

            if (etls == null)
            {
                etls = new List <T>();
            }

            etls.Add(Configuration);
        }
        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);
        }