Пример #1
0
        void Backup()
        {
            try {
                FBDS.FbBackupFile backupFile;
                long fragments = (database.Length /
                                  SCB.Backup.FragmentThreshold);
                int  i = 0;
                long trailingFragmentSize = (database.Length %
                                             SCB.Backup.FragmentThreshold);

                foreach (FC.IFileRepository fr in targets)
                {
                    SCB.Backup.CrmInstance.LogBackupOperation(
                        "Databases are in the process of being backed up.", fr.Name, "In progress", 0);
                }

                SCLP.LogProxy.Log(SCLP.LogLevel.Info,
                                  String.Format(
                                      "{0} has {1} fragment(s), split threshold is {2}KiB.",
                                      database.Name,
                                      fragments + (trailingFragmentSize > 0 ? 1 : 0),
                                      SCB.Backup.FragmentThreshold >> 10));

                while (i < fragments)
                {
                    backupFile = new FBDS.FbBackupFile(
                        CreateBackupFilenamePath(i++),
                        (int)SCB.Backup.FragmentThreshold);
                    SCB.Backup.BackupService.BackupFiles.Add(
                        backupFile);
                }

                if (trailingFragmentSize > 0)
                {
                    backupFile = new FBDS.FbBackupFile(
                        CreateBackupFilenamePath(i),
                        (int)trailingFragmentSize);
                    SCB.Backup.BackupService.BackupFiles.Add(
                        backupFile);
                }

                SCB.Backup.BackupService.Execute();
            } catch (FBDC.FbException fbe) {
                String message = database.FullName +
                                 " failed during backup!\nFragments processed:\n";
                foreach (FBDS.FbBackupFile f in
                         SCB.Backup.BackupService.BackupFiles)
                {
                    message += String.Format("{0}\n", f.BackupFile);
                }

                foreach (FC.IFileRepository fr in targets)
                {
                    SCB.Backup.CrmInstance.LogBackupOperation(
                        message + fbe.ToString(), fr.Name, "Backup Failure", 0);
                }

                throw new SCBE.BackupFailure(message, fbe);
            }
        }
Пример #2
0
 public static void b_(FbConnectionStringBuilder fc,string fbk_)
 {
     is_close = false;
     try
     {
         FbBackupFile fbk = new FbBackupFile(fbk_);
         FbBackup fr = new FbBackup();
         fr.Verbose = true;
         fr.ConnectionString = fc.ConnectionString;
         fr.BackupFiles.Add(fbk);
         fr.Options = FbBackupFlags.NoGarbageCollect;
         fr.ServiceOutput += ServiceOutput;
         fr.Execute();
     }
     catch (FbException ex)
     {
         error = ex.Message;
     }
     finally
     {
         is_close = true;
     }
 }