Esempio n. 1
0
        public static ListItem GetListItem(EBackupType type, bool selected)
        {
            var item = new ListItem(GetText(type), GetValue(type));

            if (selected)
            {
                item.Selected = true;
            }
            return(item);
        }
Esempio n. 2
0
 public static bool Equals(EBackupType type, string typeStr)
 {
     if (string.IsNullOrEmpty(typeStr))
     {
         return(false);
     }
     if (string.Equals(GetValue(type).ToLower(), typeStr.ToLower()))
     {
         return(true);
     }
     return(false);
 }
        public static string GetBackupFilePath(SiteInfo siteInfo, EBackupType backupType)
        {
            var extention = ".zip";
            var siteName  = siteInfo.SiteDir;

            if (!string.IsNullOrEmpty(siteName))
            {
                siteName += "_";
            }
            if (backupType == EBackupType.Templates)
            {
                extention = ".xml";
            }
            return(PathUtils.Combine(PathUtils.PhysicalSiteFilesPath, DirectoryUtils.SiteFiles.BackupFiles, siteInfo.SiteDir, DateTime.Now.ToString("yyyy-MM"), EBackupTypeUtils.GetValue(backupType) + "_" + siteName + DateTime.Now.ToString("yyyy-MM-dd-HH-mm") + extention));
        }
Esempio n. 4
0
 public static string GetValue(EBackupType type)
 {
     if (type == EBackupType.Templates)
     {
         return("Templates");
     }
     if (type == EBackupType.ChannelsAndContents)
     {
         return("ChannelsAndContents");
     }
     if (type == EBackupType.Files)
     {
         return("Files");
     }
     if (type == EBackupType.Site)
     {
         return("Site");
     }
     return("Undefined");
 }
Esempio n. 5
0
        public static string GetText(EBackupType type)
        {
            if (type == EBackupType.Templates)
            {
                return("显示模板");
            }
            if (type == EBackupType.ChannelsAndContents)
            {
                return("栏目及内容");
            }
            if (type == EBackupType.Files)
            {
                return("文件");
            }
            if (type == EBackupType.Site)
            {
                return("整站");
            }

            return("Undefined");
        }
Esempio n. 6
0
        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);
        }
Esempio n. 7
0
 public static bool Equals(string typeStr, EBackupType type)
 {
     return(Equals(type, typeStr));
 }