Execute() public method

public Execute ( ) : bool
return bool
Example #1
0
        public async Task <bool> BackupAsync(Action <string> successCallback, Action <string> failCallback)
        {
            await Task.Delay(1).ConfigureAwait(false);

            if (string.IsNullOrWhiteSpace(this.BackupFileLocation))
            {
                string message = "Cannot find a suitable directory to create a PostgreSQL DB Backup.";
                this.OnOnBackupFail(new ProgressInfo(message));
                failCallback(message);
                return(false);
            }

            string backupDirectory = Path.Combine(this.BackupFileLocation, this.FileName);
            string path            = Path.Combine(backupDirectory, "db.backup");

            Directory.CreateDirectory(backupDirectory);


            var process = new Process(this.Server, path, this.Tenant);

            process.Progress += delegate(ProgressInfo info)
            {
                var progress = this.Progress;
                progress?.Invoke(new ProgressInfo(info.Message));
            };

            process.BackupComplete += delegate(object sender, EventArgs args)
            {
                this.OnOnBackupComplete(sender, args);
                successCallback(this.FileName);
            };

            bool result = process.Execute();

            if (!result)
            {
                string message = "Could not create backup.";
                this.OnOnBackupFail(new ProgressInfo(message));
                failCallback(message);
                return(false);
            }

            return(true);
        }
Example #2
0
        public async Task<bool> BackupAsync(Action<string> successCallback, Action<string> failCallback)
        {
            await Task.Delay(1).ConfigureAwait(false);

            if(string.IsNullOrWhiteSpace(this.BackupFileLocation))
            {
                string message = "Cannot find a suitable directory to create a PostgreSQL DB Backup.";
                this.OnOnBackupFail(new ProgressInfo(message));
                failCallback(message);
                return false;
            }

            string backupDirectory = Path.Combine(this.BackupFileLocation, this.FileName);
            string path = Path.Combine(backupDirectory, "db.backup");

            Directory.CreateDirectory(backupDirectory);


            var process = new Process(this.Server, path, this.Tenant);

            process.Progress += delegate(ProgressInfo info)
                                {
                                    var progress = this.Progress;
                                    progress?.Invoke(new ProgressInfo(info.Message));
                                };

            process.BackupComplete += delegate(object sender, EventArgs args)
                                      {
                                          this.OnOnBackupComplete(sender, args);
                                          successCallback(this.FileName);
                                      };

            bool result = process.Execute();

            if(!result)
            {
                string message = "Could not create backup.";
                this.OnOnBackupFail(new ProgressInfo(message));
                failCallback(message);
                return false;
            }

            return true;
        }