Esempio 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);
            }


        }
Esempio 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);
                }
            });
        }
Esempio 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);
                }
            });

        }