private static bool BackupByPublishmentSystemID(TaskInfo taskInfo, int publishmentSystemID, EBackupType backupType) { var publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(publishmentSystemID); if (publishmentSystemInfo == null) { ExecutionUtils.LogError(taskInfo, new Exception("无法找到对应站点")); return(false); } var filePath = PathUtility.GetBackupFilePath(publishmentSystemInfo, backupType); DirectoryUtils.CreateDirectoryIfNotExists(filePath); FileUtils.DeleteFileIfExists(filePath); if (backupType == EBackupType.Templates) { BackupUtility.BackupTemplates(publishmentSystemInfo.PublishmentSystemId, filePath); } else if (backupType == EBackupType.ChannelsAndContents) { BackupUtility.BackupChannelsAndContents(publishmentSystemInfo.PublishmentSystemId, filePath); } else if (backupType == EBackupType.Files) { BackupUtility.BackupFiles(publishmentSystemInfo.PublishmentSystemId, filePath); } else if (backupType == EBackupType.Site) { BackupUtility.BackupSite(publishmentSystemInfo.PublishmentSystemId, filePath); } return(true); }
protected void ClearScratchFolder() { lock (SCRATCH_FOLDER) { if (Directory.Exists(SCRATCH_FOLDER)) { Directory.Delete(SCRATCH_FOLDER, true); } Directory.CreateDirectory(SCRATCH_FOLDER); utility = new BackupUtility(); } }
public NameValueCollection Backup(int siteId, string backupType, string userKeyPrefix) { //返回“运行结果”和“错误信息”的字符串数组 NameValueCollection retval; var request = new RequestImpl(Request); try { var eBackupType = EBackupTypeUtils.GetEnumType(backupType); var siteInfo = SiteManager.GetSiteInfo(siteId); var filePath = PathUtility.GetBackupFilePath(siteInfo, eBackupType); DirectoryUtils.CreateDirectoryIfNotExists(filePath); FileUtils.DeleteFileIfExists(filePath); if (eBackupType == EBackupType.Templates) { BackupUtility.BackupTemplates(siteId, filePath, request.AdminName); } else if (eBackupType == EBackupType.ChannelsAndContents) { BackupUtility.BackupChannelsAndContents(siteId, filePath, request.AdminName); } else if (eBackupType == EBackupType.Files) { BackupUtility.BackupFiles(siteId, filePath, request.AdminName); } else if (eBackupType == EBackupType.Site) { BackupUtility.BackupSite(siteId, filePath, request.AdminName); } string resultString = $"任务完成,备份地址:<br /><strong> {filePath} </strong> <a href='{ApiRouteActionsDownload.GetUrl(ApiManager.InnerApiUrl, filePath)}'><img src='{SiteServerAssets.GetIconUrl("download.gif")}' />下载</a>。"; retval = AjaxManager.GetWaitingTaskNameValueCollection(resultString, string.Empty, string.Empty); } catch (Exception ex) { retval = AjaxManager.GetWaitingTaskNameValueCollection(string.Empty, ex.Message, string.Empty); LogUtils.AddErrorLog(ex); } return(retval); }
public void The_files_are_copied() { string timeString = BackupUtility.GetTimeString(); utility.CreateBackup(Directory, new Guid("{c1285b30-66b7-4e2f-a85c-6d169d9977c7}"), TemplateName, SCRATCH_FOLDER, timeString); string aaDir = @"Resources\Manifest\TestScratchFolder\.ArchAngel\ArchAngelBackup"; aaDir = Path.Combine(aaDir, timeString); string userDir = Path.Combine(aaDir, "UserFiles"); Assert.That(File.Exists(Path.Combine(userDir, "X.cs"))); string prevgenDir = Path.Combine(aaDir, "PrevGenFiles"); Assert.That(File.Exists(Path.Combine(prevgenDir, "X.cs"))); Assert.That(File.Exists(Path.Combine(prevgenDir, ManifestConstants.MANIFEST_FILENAME))); }
public NameValueCollection Recovery(int siteId, bool isDeleteChannels, bool isDeleteTemplates, bool isDeleteFiles, bool isZip, string path, bool isOverride, bool isUseTable, string userKeyPrefix, RequestImpl request) { //返回“运行结果”和“错误信息”的字符串数组 NameValueCollection retval; try { BackupUtility.RecoverySite(siteId, isDeleteChannels, isDeleteTemplates, isDeleteFiles, isZip, PageUtils.UrlDecode(path), isOverride, isUseTable, request.AdminName); request.AddSiteLog(siteId, "恢复备份数据", request.AdminName); retval = AjaxManager.GetWaitingTaskNameValueCollection("数据恢复成功!", string.Empty, string.Empty); //retval = new string[] { "数据恢复成功!", string.Empty, string.Empty }; } catch (Exception ex) { //retval = new string[] { string.Empty, ex.Message, string.Empty }; retval = AjaxManager.GetWaitingTaskNameValueCollection(string.Empty, ex.Message, string.Empty); LogUtils.AddErrorLog(ex); } return(retval); }
public void The_Process_Doesnt_Fail() { string timeString = BackupUtility.GetTimeString(); utility.CreateBackup(Directory, new Guid("{c1285b30-66b7-4e2f-a85c-6d169d9977c7}"), TemplateName, SCRATCH_FOLDER, timeString); }