Exemplo n.º 1
0
        public void BackupDatabase(string fileName)
        {
            if (!this.IsValidRequest())
            {
                this.Clients.Caller.getNotification(Warnings.AccessIsDenied, Warnings.AccessIsDenied);
                return;
            }

            if (string.IsNullOrWhiteSpace(fileName))
            {
                this.Clients.Caller.backupFailed(Warnings.NoFileSpecified);
                return;
            }

            PostgreSQLServer server = new PostgreSQLServer();
            server.DatabaseName = AppUsers.GetCurrentUserDB();

            BackupAgent agent = new BackupAgent(server, fileName);

            agent.BackupFail += delegate(BackupProgressInfo info)
            {
                this.Clients.Caller.backupFailed(info.Message);                
            };

            agent.Progress += delegate(BackupProgressInfo info)
            {
                this.Clients.Caller.getNotification(info.Message);                
            };

            agent.BackupComplete += delegate
            {
                StringBuilder message = new StringBuilder();
                message.Append(Labels.DatabaseBackupSuccessful);
                message.Append(" ");
                message.Append("<a href='");
                message.Append(
                    PageUtility.ResolveUrl(Path.Combine(server.DatabaseBackupDirectory, fileName + ".zip")));
                message.Append("'");
                message.Append(" target='_blank'>");
                message.Append(Labels.ClickHereToDownload);
                message.Append("</a>");

                this.Clients.Caller.backupCompleted(message.ToString());                
            };

            try
            {
                agent.PerformBackup();
            }
            catch (Exception ex)
            {
                this.Clients.Caller.backupFailed(ex.Message);
            }


        }
Exemplo n.º 2
0
        public void Execute(IJobExecutionContext context)
        {
            ThreadPool.QueueUserWorkItem(callback =>
            {
                PostgreSQLServer server = new PostgreSQLServer();
                string fileName         = DateTime.Now.Ticks.ToString();

                BackupAgent agent = new BackupAgent(server, fileName);

                try
                {
                    agent.PerformBackup();
                }
                catch (Exception ex)
                {
                    Log.Error("Exception occurred executing the backup job. {Exception}.", ex);
                }
            });
        }
Exemplo n.º 3
0
        public void Execute(IJobExecutionContext context)
        {
            ThreadPool.QueueUserWorkItem(callback =>
            {
                PostgreSQLServer server = new PostgreSQLServer();
                string fileName = DateTime.Now.Ticks.ToString();

                BackupAgent agent = new BackupAgent(server, fileName);

                try
                {
                    agent.PerformBackup();
                }
                catch (Exception ex)
                {
                    Log.Error("Exception occurred executing the backup job. {Exception}.", ex);
                }
            });

        }
Exemplo n.º 4
0
 public BackupProcess(PostgreSQLServer server, string fileName)
 {
     this.Server     = server;
     this.PgDumpPath = Path.Combine(this.Server.BinDirectory, "pg_dump.exe");;
     this.FileName   = fileName;
 }
Exemplo n.º 5
0
 public BackupProcess(PostgreSQLServer server, string fileName)
 {
     this.Server = server;
     this.PgDumpPath = Path.Combine(this.Server.BinDirectory, "pg_dump.exe"); ;
     this.FileName = fileName;
 }
Exemplo n.º 6
0
 public BackupAgent(PostgreSQLServer server, string fileName)
 {
     this.FileName = fileName;
     this.PostgreSQL = server;
 }
Exemplo n.º 7
0
 public BatchFile(string fileName, PostgreSQLServer server, string pgDumpPath)
 {
     this.FileName = fileName;
     this.Server = server;
     this.PgDumpPath = pgDumpPath;
 }
Exemplo n.º 8
0
 public BatchFile(string fileName, PostgreSQLServer server, string pgDumpPath)
 {
     this.FileName   = fileName;
     this.Server     = server;
     this.PgDumpPath = pgDumpPath;
 }
Exemplo n.º 9
0
 public BackupAgent(PostgreSQLServer server, string fileName)
 {
     this.FileName   = fileName;
     this.PostgreSQL = server;
 }