Exemplo n.º 1
0
        public ActionResult StartDatabaseBackup()
        {
            try
            {
                var dc = new ProcurementDataClassesDataContext(ConfigurationManager.ConnectionStrings["BidsForKidsConnectionString"].ConnectionString);

                var result = new ContentResult();

                var backupLocation = ConfigurationManager.AppSettings["SQLBackupLocation"];

                if (string.IsNullOrEmpty(backupLocation) == true)
                {
                    throw new ApplicationException("SQLBackupLocation is not set in web.config");
                }

                dc.BackupDatabase(backupLocation);

                result.Content = "Database has been backed up.";

                return result;
            }
            catch (Exception ex)
            {
                Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                return new ContentResult
                           {
                               Content = "Error backing up database: " + ex.Message
                           };
            }
        }
 public ProcurementRepository(string connectionString)
 {
     dc = new ProcurementDataClassesDataContext(connectionString);
 }
 public ProcurementRepository()
 {
     dc = new ProcurementDataClassesDataContext();
 }