Exemple #1
0
        public NameValueCollection GatherFile(int publishmentSystemId, string gatherRuleNameCollection, string userKeyPrefix, string administratorName)
        {
            var resultBuilder           = new StringBuilder();
            var errorBuilder            = new StringBuilder();
            var gatherRuleNameArrayList = TranslateUtils.StringCollectionToStringList(gatherRuleNameCollection);

            foreach (string gatherRuleName in gatherRuleNameArrayList)
            {
                GatherUtility.GatherFile(publishmentSystemId, gatherRuleName, resultBuilder, errorBuilder, true, userKeyPrefix, administratorName);
            }
            return(AjaxManager.GetProgressTaskNameValueCollection(resultBuilder.ToString(), errorBuilder.ToString()));
        }
Exemple #2
0
        public NameValueCollection SiteTemplateDownload(string downloadUrl, string directoryName, string userKeyPrefix)
        {
            var cacheTotalCountKey   = userKeyPrefix + CacheTotalCount;
            var cacheCurrentCountKey = userKeyPrefix + CacheCurrentCount;
            var cacheMessageKey      = userKeyPrefix + CacheMessage;

            CacheUtils.Insert(cacheTotalCountKey, "5");       //存储需要的页面总数
            CacheUtils.Insert(cacheCurrentCountKey, "0");     //存储当前的页面总数
            CacheUtils.Insert(cacheMessageKey, string.Empty); //存储消息

            //返回“运行结果”和“错误信息”的字符串数组
            NameValueCollection retval;

            try
            {
                CacheUtils.Insert(cacheCurrentCountKey, "1");
                CacheUtils.Insert(cacheMessageKey, "开始下载模板压缩包,可能需要几分钟,请耐心等待");

                var filePath = PathUtility.GetSiteTemplatesPath(directoryName + ".zip");
                FileUtils.DeleteFileIfExists(filePath);
                WebClientUtils.SaveRemoteFileToLocal(downloadUrl, filePath);

                CacheUtils.Insert(cacheCurrentCountKey, "4");
                CacheUtils.Insert(cacheMessageKey, "模板压缩包下载成功,开始解压缩");

                var directoryPath = PathUtility.GetSiteTemplatesPath(directoryName);
                if (!DirectoryUtils.IsDirectoryExists(directoryPath))
                {
                    ZipUtils.UnpackFiles(filePath, directoryPath);
                }

                CacheUtils.Insert(cacheCurrentCountKey, "5");
                CacheUtils.Insert(cacheMessageKey, string.Empty);

                retval = AjaxManager.GetProgressTaskNameValueCollection("站点模板下载成功,请到站点模板管理中查看。", string.Empty);
            }
            catch (Exception ex)
            {
                retval = AjaxManager.GetProgressTaskNameValueCollection(string.Empty,
                                                                        $@"<br />下载失败!<br />{ex.Message}");
            }

            CacheUtils.Remove(cacheTotalCountKey);   //取消存储需要的页面总数
            CacheUtils.Remove(cacheCurrentCountKey); //取消存储当前的页面总数
            CacheUtils.Remove(cacheMessageKey);      //取消存储消息

            return(retval);
        }
Exemple #3
0
        public NameValueCollection PluginDownload(string downloadUrl, string userKeyPrefix)
        {
            var cacheTotalCountKey   = userKeyPrefix + CacheTotalCount;
            var cacheCurrentCountKey = userKeyPrefix + CacheCurrentCount;
            var cacheMessageKey      = userKeyPrefix + CacheMessage;

            CacheUtils.Insert(cacheTotalCountKey, "5");       //存储需要的页面总数
            CacheUtils.Insert(cacheCurrentCountKey, "0");     //存储当前的页面总数
            CacheUtils.Insert(cacheMessageKey, string.Empty); //存储消息

            //返回“运行结果”和“错误信息”的字符串数组
            NameValueCollection retval;

            try
            {
                CacheUtils.Insert(cacheCurrentCountKey, "1");
                CacheUtils.Insert(cacheMessageKey, "开始下载插件压缩包,可能需要几分钟,请耐心等待");

                var fileName = PageUtils.GetFileNameFromUrl(downloadUrl);
                var filePath = PathUtils.GetPluginPath(fileName);
                FileUtils.DeleteFileIfExists(filePath);
                WebClientUtils.SaveRemoteFileToLocal(downloadUrl, filePath);

                CacheUtils.Insert(cacheCurrentCountKey, "4");
                CacheUtils.Insert(cacheMessageKey, "插件压缩包下载成功,开始安装");

                ZipUtils.UnpackFiles(filePath, PathUtils.GetPluginPath(fileName.Substring(0, fileName.IndexOf(".", StringComparison.Ordinal))));

                CacheUtils.Insert(cacheCurrentCountKey, "5");
                CacheUtils.Insert(cacheMessageKey, string.Empty);

                retval = AjaxManager.GetProgressTaskNameValueCollection("插件安装成功,请刷新页面查看。", string.Empty);
            }
            catch (Exception ex)
            {
                retval = AjaxManager.GetProgressTaskNameValueCollection(string.Empty,
                                                                        $@"<br />下载失败!<br />{ex.Message}");
            }

            CacheUtils.Remove(cacheTotalCountKey);   //取消存储需要的页面总数
            CacheUtils.Remove(cacheCurrentCountKey); //取消存储当前的页面总数
            CacheUtils.Remove(cacheMessageKey);      //取消存储消息

            return(retval);
        }
Exemple #4
0
        public NameValueCollection SiteTemplateZip(string directoryName, string userKeyPrefix)
        {
            var cacheTotalCountKey   = userKeyPrefix + CacheTotalCount;
            var cacheCurrentCountKey = userKeyPrefix + CacheCurrentCount;
            var cacheMessageKey      = userKeyPrefix + CacheMessage;

            CacheUtils.Insert(cacheTotalCountKey, "1");       //存储需要的页面总数
            CacheUtils.Insert(cacheCurrentCountKey, "0");     //存储当前的页面总数
            CacheUtils.Insert(cacheMessageKey, string.Empty); //存储消息

            //返回“运行结果”和“错误信息”的字符串数组
            NameValueCollection retval;

            try
            {
                directoryName = PathUtils.RemoveParentPath(directoryName);
                var fileName      = directoryName + ".zip";
                var filePath      = PathUtility.GetSiteTemplatesPath(fileName);
                var directoryPath = PathUtility.GetSiteTemplatesPath(directoryName);

                FileUtils.DeleteFileIfExists(filePath);

                ZipUtils.PackFiles(filePath, directoryPath);

                CacheUtils.Insert(cacheCurrentCountKey, "1");//存储当前的页面总数

                retval = AjaxManager.GetProgressTaskNameValueCollection(
                    $"站点模板压缩成功,<a href='{PageUtils.GetSiteTemplatesUrl(fileName)}' target=_blank>点击下载</a>。", string.Empty);
            }
            catch (Exception ex)
            {
                retval = AjaxManager.GetProgressTaskNameValueCollection(string.Empty,
                                                                        $@"<br />站点模板压缩失败!<br />{ex.Message}");
            }

            CacheUtils.Remove(cacheTotalCountKey);   //取消存储需要的页面总数
            CacheUtils.Remove(cacheCurrentCountKey); //取消存储当前的页面总数
            CacheUtils.Remove(cacheMessageKey);      //取消存储消息

            return(retval);
        }
Exemple #5
0
        public NameValueCollection SiteTemplateUnZip(string fileName, string userKeyPrefix)
        {
            var cacheTotalCountKey   = userKeyPrefix + CacheTotalCount;
            var cacheCurrentCountKey = userKeyPrefix + CacheCurrentCount;
            var cacheMessageKey      = userKeyPrefix + CacheMessage;

            CacheUtils.Insert(cacheTotalCountKey, "1");       //存储需要的页面总数
            CacheUtils.Insert(cacheCurrentCountKey, "0");     //存储当前的页面总数
            CacheUtils.Insert(cacheMessageKey, string.Empty); //存储消息

            //返回“运行结果”和“错误信息”的字符串数组
            NameValueCollection retval;

            try
            {
                var directoryPath = PathUtility.GetSiteTemplatesPath(PathUtils.GetFileNameWithoutExtension(fileName));
                var zipFilePath   = PathUtility.GetSiteTemplatesPath(fileName);

                ZipUtils.UnpackFiles(zipFilePath, directoryPath);

                CacheUtils.Insert(cacheCurrentCountKey, "1");//存储当前的页面总数

                retval = AjaxManager.GetProgressTaskNameValueCollection("站点模板解压成功", string.Empty);
            }
            catch (Exception ex)
            {
                retval = AjaxManager.GetProgressTaskNameValueCollection(string.Empty,
                                                                        $@"<br />站点模板解压失败!<br />{ex.Message}");
            }

            CacheUtils.Remove(cacheTotalCountKey);   //取消存储需要的页面总数
            CacheUtils.Remove(cacheCurrentCountKey); //取消存储当前的页面总数
            CacheUtils.Remove(cacheMessageKey);      //取消存储消息

            return(retval);
        }