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); }
public static bool ExecuteTask() { var isExecute = false; try { var taskInfoList = ServiceManager.GetAllTaskInfoList(); foreach (var taskInfo in taskInfoList) { if (!ExecutionUtils.IsNeedExecute(taskInfo)) { continue; } try { var taskExecution = new TaskExecution(); if (taskExecution.Execute(taskInfo)) { isExecute = true; var logInfo = new TaskLogInfo(0, taskInfo.TaskID, true, string.Empty, DateTime.Now); DataProvider.TaskLogDao.Insert(logInfo); } } catch (Exception ex) { ExecutionUtils.LogError(taskInfo, ex); } DataProvider.TaskDao.UpdateLastExecuteDate(taskInfo.TaskID); } } catch (Exception ex) { LogUtils.AddAdminLog(string.Empty, "服务组件任务执行失败", ex.ToString()); } return(isExecute); }