Exemplo n.º 1
0
 public int Backup(bool async, string taskId, int userId, int packageId, int serviceId, int serverId,
                   string backupFileName, int storePackageId, string storePackageFolder, string storeServerFolder,
                   bool deleteTempBackup)
 {
     return(BackupController.Backup(async, taskId, userId, packageId, serviceId, serverId,
                                    backupFileName, storePackageId, storePackageFolder, storeServerFolder, deleteTempBackup));
 }
Exemplo n.º 2
0
        /// <summary>
        /// Performs actual backup.
        /// </summary>
        public override void DoWork()
        {
            string backupFileName;
            int    storePackageId;
            string storePackageFolder;
            string storeServerFolder;
            bool   deleteTempBackup;

            BackgroundTask topTask = TaskManager.TopTask;

            try
            {
                backupFileName     = (string)topTask.GetParamValue("BACKUP_FILE_NAME");
                storePackageId     = Convert.ToInt32(topTask.GetParamValue("STORE_PACKAGE_ID"));
                storePackageFolder = (string)topTask.GetParamValue("STORE_PACKAGE_FOLDER");
                storeServerFolder  = (string)topTask.GetParamValue("STORE_SERVER_FOLDER");
                deleteTempBackup   = Convert.ToBoolean(topTask.GetParamValue("DELETE_TEMP_BACKUP"));
            }
            catch (Exception ex)
            {
                TaskManager.WriteError(ex, "Some parameters are absent or have incorrect value.");
                return;
            }

            try
            {
                PackageInfo package = PackageController.GetPackage(topTask.PackageId);
                // We do not take into account service id as long as scheduled tasks run against packages.
                BackupController.Backup(false, "BackupTask", package.UserId, package.PackageId, 0, 0,
                                        backupFileName, storePackageId, storePackageFolder, storeServerFolder, deleteTempBackup);
            }
            catch (Exception ex)
            {
                TaskManager.WriteError(ex, "Failed to do backup.");
            }
        }