Ejemplo n.º 1
0
        public static void RecoverySite(int publishmentSystemId, bool isDeleteChannels, bool isDeleteTemplates, bool isDeleteFiles, bool isZip, string path, bool isOverride, bool isUseTable, string administratorName)
        {
            var importObject = new ImportObject(publishmentSystemId);

            var publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(publishmentSystemId);

            var siteTemplatePath = path;

            if (isZip)
            {
                //解压文件
                siteTemplatePath = PathUtils.GetTemporaryFilesPath(EBackupTypeUtils.GetValue(EBackupType.Site));
                DirectoryUtils.DeleteDirectoryIfExists(siteTemplatePath);
                DirectoryUtils.CreateDirectoryIfNotExists(siteTemplatePath);

                ZipUtils.UnpackFiles(path, siteTemplatePath);
            }
            var siteTemplateMetadataPath = PathUtils.Combine(siteTemplatePath, DirectoryUtils.SiteTemplates.SiteTemplateMetadata);

            if (isDeleteChannels)
            {
                var nodeIdList = DataProvider.NodeDao.GetNodeIdListByParentId(publishmentSystemId, publishmentSystemId);
                foreach (int nodeId in nodeIdList)
                {
                    DataProvider.NodeDao.Delete(nodeId);
                }
            }
            if (isDeleteTemplates)
            {
                var templateInfoList =
                    DataProvider.TemplateDao.GetTemplateInfoListByPublishmentSystemId(publishmentSystemId);
                foreach (var templateInfo in templateInfoList)
                {
                    if (templateInfo.IsDefault == false)
                    {
                        DataProvider.TemplateDao.Delete(publishmentSystemId, templateInfo.TemplateId);
                    }
                }
            }
            if (isDeleteFiles)
            {
                DirectoryUtility.DeletePublishmentSystemFiles(publishmentSystemInfo);
            }

            //导入文件
            importObject.ImportFiles(siteTemplatePath, isOverride);

            //导入模板
            var templateFilePath = PathUtils.Combine(siteTemplateMetadataPath, DirectoryUtils.SiteTemplates.FileTemplate);

            importObject.ImportTemplates(templateFilePath, isOverride, administratorName);

            //导入辅助表
            var tableDirectoryPath = PathUtils.Combine(siteTemplateMetadataPath, DirectoryUtils.SiteTemplates.Table);

            importObject.ImportAuxiliaryTables(tableDirectoryPath, isUseTable);

            //导入菜单
            var menuDisplayFilePath = PathUtils.Combine(siteTemplateMetadataPath, DirectoryUtils.SiteTemplates.FileMenuDisplay);

            importObject.ImportMenuDisplay(menuDisplayFilePath, isOverride);

            //导入标签样式
            var tagStyleFilePath = PathUtils.Combine(siteTemplateMetadataPath, DirectoryUtils.SiteTemplates.FileTagStyle);

            importObject.ImportTagStyle(tagStyleFilePath, isOverride);

            //导入固定广告
            var adFilePath = PathUtils.Combine(siteTemplateMetadataPath, DirectoryUtils.SiteTemplates.FileAd);

            importObject.ImportAd(adFilePath, isOverride);

            //导入采集规则
            var gatherRuleFilePath = PathUtils.Combine(siteTemplateMetadataPath, DirectoryUtils.SiteTemplates.FileGatherRule);

            importObject.ImportGatherRule(gatherRuleFilePath, isOverride);

            //导入提交表单
            var inputDirectoryPath = PathUtils.Combine(siteTemplateMetadataPath, DirectoryUtils.SiteTemplates.Input);

            importObject.ImportInput(inputDirectoryPath, isOverride);

            //导入站点设置
            var configurationFilePath = PathUtils.Combine(siteTemplateMetadataPath, DirectoryUtils.SiteTemplates.FileConfiguration);

            importObject.ImportConfiguration(configurationFilePath);

            //导入内容模型
            var contentModelFilePath = PathUtils.Combine(siteTemplateMetadataPath, DirectoryUtils.SiteTemplates.FileContentModel);

            importObject.ImportContentModel(contentModelFilePath, true);

            //导入栏目及内容
            var siteContentDirectoryPath = PathUtils.Combine(siteTemplateMetadataPath, DirectoryUtils.SiteTemplates.SiteContent);

            importObject.ImportChannelsAndContents(0, siteContentDirectoryPath, isOverride);

            DataProvider.NodeDao.UpdateContentNum(publishmentSystemInfo);

            //导入表样式及清除缓存
            if (isUseTable)
            {
                importObject.ImportTableStyles(tableDirectoryPath);
            }
            importObject.RemoveDbCache();

            CacheUtils.Clear();
        }
Ejemplo n.º 2
0
        public static void RecoverySite(int siteId, bool isDeleteChannels, bool isDeleteTemplates, bool isDeleteFiles, bool isZip, string path, bool isOverride, bool isUseTable, string administratorName)
        {
            var importObject = new ImportObject(siteId, administratorName);

            var siteInfo = SiteManager.GetSiteInfo(siteId);

            var siteTemplatePath = path;

            if (isZip)
            {
                //解压文件
                siteTemplatePath = PathUtils.GetTemporaryFilesPath(EBackupTypeUtils.GetValue(EBackupType.Site));
                DirectoryUtils.DeleteDirectoryIfExists(siteTemplatePath);
                DirectoryUtils.CreateDirectoryIfNotExists(siteTemplatePath);

                ZipUtils.ExtractZip(path, siteTemplatePath);
            }
            var siteTemplateMetadataPath = PathUtils.Combine(siteTemplatePath, DirectoryUtils.SiteTemplates.SiteTemplateMetadata);

            if (isDeleteChannels)
            {
                var channelIdList = ChannelManager.GetChannelIdList(ChannelManager.GetChannelInfo(siteId, siteId), EScopeType.Children, string.Empty, string.Empty, string.Empty);
                foreach (var channelId in channelIdList)
                {
                    DataProvider.ChannelDao.Delete(siteId, channelId);
                }
            }
            if (isDeleteTemplates)
            {
                var templateInfoList =
                    DataProvider.TemplateDao.GetTemplateInfoListBySiteId(siteId);
                foreach (var templateInfo in templateInfoList)
                {
                    if (templateInfo.IsDefault == false)
                    {
                        DataProvider.TemplateDao.Delete(siteId, templateInfo.Id);
                    }
                }
            }
            if (isDeleteFiles)
            {
                DirectoryUtility.DeleteSiteFiles(siteInfo);
            }

            //导入文件
            importObject.ImportFiles(siteTemplatePath, isOverride);

            //导入模板
            var templateFilePath = PathUtils.Combine(siteTemplateMetadataPath, DirectoryUtils.SiteTemplates.FileTemplate);

            importObject.ImportTemplates(templateFilePath, isOverride, administratorName);

            //导入辅助表
            var tableDirectoryPath = PathUtils.Combine(siteTemplateMetadataPath, DirectoryUtils.SiteTemplates.Table);

            //导入站点设置
            var configurationFilePath = PathUtils.Combine(siteTemplateMetadataPath, DirectoryUtils.SiteTemplates.FileConfiguration);

            importObject.ImportConfiguration(configurationFilePath);

            //导入栏目及内容
            var siteContentDirectoryPath = PathUtils.Combine(siteTemplateMetadataPath, DirectoryUtils.SiteTemplates.SiteContent);

            importObject.ImportChannelsAndContents(0, siteContentDirectoryPath, isOverride);

            //导入表样式及清除缓存
            if (isUseTable)
            {
                importObject.ImportTableStyles(tableDirectoryPath);
            }
            importObject.RemoveDbCache();

            CacheUtils.ClearAll();
        }
Ejemplo n.º 3
0
        public void ImportSiteTemplateToEmptyPublishmentSystem(int publishmentSystemId, string siteTemplateDir, bool isUseTables, bool isImportContents, bool isImportTableStyles, string administratorName)
        {
            var siteTemplatePath = PathUtility.GetSiteTemplatesPath(siteTemplateDir);

            if (DirectoryUtils.IsDirectoryExists(siteTemplatePath))
            {
                var publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(publishmentSystemId);

                var templateFilePath         = PathUtility.GetSiteTemplateMetadataPath(siteTemplatePath, DirectoryUtils.SiteTemplates.FileTemplate);
                var tableDirectoryPath       = PathUtility.GetSiteTemplateMetadataPath(siteTemplatePath, DirectoryUtils.SiteTemplates.Table);
                var menuDisplayFilePath      = PathUtility.GetSiteTemplateMetadataPath(siteTemplatePath, DirectoryUtils.SiteTemplates.FileMenuDisplay);
                var tagStyleFilePath         = PathUtility.GetSiteTemplateMetadataPath(siteTemplatePath, DirectoryUtils.SiteTemplates.FileTagStyle);
                var adFilePath               = PathUtility.GetSiteTemplateMetadataPath(siteTemplatePath, DirectoryUtils.SiteTemplates.FileAd);
                var seoFilePath              = PathUtility.GetSiteTemplateMetadataPath(siteTemplatePath, DirectoryUtils.SiteTemplates.FileSeo);
                var stlTagPath               = PathUtility.GetSiteTemplateMetadataPath(siteTemplatePath, DirectoryUtils.SiteTemplates.FileStlTag);
                var gatherRuleFilePath       = PathUtility.GetSiteTemplateMetadataPath(siteTemplatePath, DirectoryUtils.SiteTemplates.FileGatherRule);
                var inputDirectoryPath       = PathUtility.GetSiteTemplateMetadataPath(siteTemplatePath, DirectoryUtils.SiteTemplates.Input);
                var configurationFilePath    = PathUtility.GetSiteTemplateMetadataPath(siteTemplatePath, DirectoryUtils.SiteTemplates.FileConfiguration);
                var siteContentDirectoryPath = PathUtility.GetSiteTemplateMetadataPath(siteTemplatePath, DirectoryUtils.SiteTemplates.SiteContent);
                var contentModelPath         = PathUtility.GetSiteTemplateMetadataPath(siteTemplatePath, DirectoryUtils.SiteTemplates.FileContentModel);

                var importObject = new ImportObject(publishmentSystemId);

                importObject.ImportFiles(siteTemplatePath, true);

                importObject.ImportTemplates(templateFilePath, true, administratorName);

                importObject.ImportAuxiliaryTables(tableDirectoryPath, isUseTables);

                importObject.ImportMenuDisplay(menuDisplayFilePath, true);

                importObject.ImportTagStyle(tagStyleFilePath, true);

                importObject.ImportAd(adFilePath, true);

                importObject.ImportSeo(seoFilePath, true);

                importObject.ImportStlTag(stlTagPath, true);

                importObject.ImportGatherRule(gatherRuleFilePath, true);

                importObject.ImportInput(inputDirectoryPath, true);

                importObject.ImportConfiguration(configurationFilePath);

                importObject.ImportContentModel(contentModelPath, true);

                var filePathArrayList = ImportObject.GetSiteContentFilePathArrayList(siteContentDirectoryPath);

                foreach (string filePath in filePathArrayList)
                {
                    importObject.ImportSiteContent(siteContentDirectoryPath, filePath, isImportContents);
                }

                DataProvider.NodeDao.UpdateContentNum(publishmentSystemInfo);

                if (isImportTableStyles)
                {
                    importObject.ImportTableStyles(tableDirectoryPath);
                }

                importObject.RemoveDbCache();
            }
        }