public NameValueCollection CreateSiteByOnlineTemplateName(int siteId, bool isImportContents, bool isImportTableStyles, string onlineTemplateName, bool isUseTables, string userKeyPrefix, string administratorName) { var cacheTotalCountKey = userKeyPrefix + CacheTotalCount; var cacheCurrentCountKey = userKeyPrefix + CacheCurrentCount; var cacheMessageKey = userKeyPrefix + CacheMessage; CacheUtils.Insert(cacheTotalCountKey, "4"); //存储需要的页面总数 CacheUtils.Insert(cacheCurrentCountKey, "0"); //存储当前的页面总数 CacheUtils.Insert(cacheMessageKey, string.Empty); //存储消息 //返回“运行结果”、“错误信息”及“执行JS脚本”的字符串数组 NameValueCollection retval; try { CacheUtils.Insert(cacheCurrentCountKey, "1"); CacheUtils.Insert(cacheMessageKey, "开始下载模板压缩包,可能需要几分钟,请耐心等待..."); var filePath = PathUtility.GetSiteTemplatesPath($"T_{onlineTemplateName}.zip"); FileUtils.DeleteFileIfExists(filePath); var downloadUrl = OnlineTemplateManager.GetDownloadUrl(onlineTemplateName); WebClientUtils.SaveRemoteFileToLocal(downloadUrl, filePath); CacheUtils.Insert(cacheCurrentCountKey, "2"); CacheUtils.Insert(cacheMessageKey, "模板压缩包下载成功,开始解压缩,可能需要几分钟,请耐心等待..."); var siteTemplateDir = $"T_{onlineTemplateName}"; var directoryPath = PathUtility.GetSiteTemplatesPath(siteTemplateDir); DirectoryUtils.DeleteDirectoryIfExists(directoryPath); ZipUtils.UnpackFiles(filePath, directoryPath); CacheUtils.Insert(cacheCurrentCountKey, "3"); //存储当前的页面总数 CacheUtils.Insert(cacheMessageKey, "站点模板下载成功,正在导入数据..."); //存储消息 SiteTemplateManager.Instance.ImportSiteTemplateToEmptySite(siteId, siteTemplateDir, isUseTables, isImportContents, isImportTableStyles, administratorName); CreateManager.CreateAll(siteId); CacheUtils.Insert(cacheCurrentCountKey, "4"); //存储当前的页面总数 CacheUtils.Insert(cacheMessageKey, "创建成功!"); //存储消息 var siteInfo = SiteManager.GetSiteInfo(siteId); retval = AjaxManager.GetWaitingTaskNameValueCollection($"站点 <strong>{siteInfo.SiteName}<strong> 创建成功!", string.Empty, $"top.location.href='{PageInitialization.GetRedirectUrl()}';"); } catch (Exception ex) { retval = AjaxManager.GetWaitingTaskNameValueCollection(string.Empty, ex.Message, string.Empty); LogUtils.AddErrorLog(ex); } CacheUtils.Remove(cacheTotalCountKey); //取消存储需要的页面总数 CacheUtils.Remove(cacheCurrentCountKey); //取消存储当前的页面总数 CacheUtils.Remove(cacheMessageKey); //取消存储消息 CacheUtils.ClearAll(); return(retval); }
public void Page_Load(object sender, EventArgs e) { if (IsForbidden) { return; } PageUtils.CheckRequestParameter("PublishmentSystemID"); if (!IsPostBack) { CreateManager.CreateAll(PublishmentSystemId); PageCreateStatus.Redirect(PublishmentSystemId); } }
public void Page_Load(object sender, EventArgs e) { if (IsForbidden) { return; } PageUtils.CheckRequestParameter("siteId"); if (IsPostBack) { return; } CreateManager.CreateAll(SiteId); PageCreateStatus.Redirect(SiteId); }
public NameValueCollection CreateSiteBySiteTemplateDir(int siteId, bool isImportContents, bool isImportTableStyles, string siteTemplateDir, bool isUseTables, string userKeyPrefix, string administratorName) { var cacheTotalCountKey = userKeyPrefix + CacheTotalCount; var cacheCurrentCountKey = userKeyPrefix + CacheCurrentCount; var cacheMessageKey = userKeyPrefix + CacheMessage; CacheUtils.Insert(cacheTotalCountKey, "3"); //存储需要的页面总数 CacheUtils.Insert(cacheCurrentCountKey, "0"); //存储当前的页面总数 CacheUtils.Insert(cacheMessageKey, string.Empty); //存储消息 //返回“运行结果”、“错误信息”及“执行JS脚本”的字符串数组 NameValueCollection retval; try { CacheUtils.Insert(cacheCurrentCountKey, "1"); //存储当前的页面总数 CacheUtils.Insert(cacheMessageKey, "正在创建站点..."); //存储消息 var siteInfo = SiteManager.GetSiteInfo(siteId); CacheUtils.Insert(cacheCurrentCountKey, "2"); //存储当前的页面总数 CacheUtils.Insert(cacheMessageKey, "正在导入数据..."); //存储消息 SiteTemplateManager.Instance.ImportSiteTemplateToEmptySite(siteId, siteTemplateDir, isUseTables, isImportContents, isImportTableStyles, administratorName); CreateManager.CreateAll(siteId); CacheUtils.Insert(cacheCurrentCountKey, "3"); //存储当前的页面总数 CacheUtils.Insert(cacheMessageKey, "创建成功!"); //存储消息 retval = AjaxManager.GetWaitingTaskNameValueCollection( $"站点 <strong>{siteInfo.SiteName}<strong> 创建成功!", string.Empty, $"top.location.href='{PageInitialization.GetRedirectUrl()}';"); } catch (Exception ex) { retval = AjaxManager.GetWaitingTaskNameValueCollection(string.Empty, ex.Message, string.Empty); LogUtils.AddErrorLog(ex); } CacheUtils.Remove(cacheTotalCountKey); //取消存储需要的页面总数 CacheUtils.Remove(cacheCurrentCountKey); //取消存储当前的页面总数 CacheUtils.Remove(cacheMessageKey); //取消存储消息 CacheUtils.ClearAll(); return(retval); }
public NameValueCollection CreatePublishmentSystem(int publishmentSystemId, bool isUseSiteTemplate, bool isImportContents, bool isImportTableStyles, string siteTemplateDir, bool isUseTables, string userKeyPrefix, string returnUrl, bool isTop, string administratorName) { var cacheTotalCountKey = userKeyPrefix + CacheTotalCount; var cacheCurrentCountKey = userKeyPrefix + CacheCurrentCount; var cacheMessageKey = userKeyPrefix + CacheMessage; CacheUtils.Max(cacheTotalCountKey, "3"); //存储需要的页面总数 CacheUtils.Max(cacheCurrentCountKey, "0"); //存储当前的页面总数 CacheUtils.Max(cacheMessageKey, string.Empty); //存储消息 //返回“运行结果”、“错误信息”及“执行JS脚本”的字符串数组 NameValueCollection retval; try { CacheUtils.Max(cacheCurrentCountKey, "1"); //存储当前的页面总数 CacheUtils.Max(cacheMessageKey, "正在创建站点..."); //存储消息 var publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(publishmentSystemId); CacheUtils.Max(cacheCurrentCountKey, "2"); //存储当前的页面总数 CacheUtils.Max(cacheMessageKey, "正在导入数据..."); //存储消息 if (isUseSiteTemplate && !string.IsNullOrEmpty(siteTemplateDir)) { SiteTemplateManager.Instance.ImportSiteTemplateToEmptyPublishmentSystem(publishmentSystemId, siteTemplateDir, isUseTables, isImportContents, isImportTableStyles, administratorName); } CreateManager.CreateAll(publishmentSystemId); CacheUtils.Max(cacheCurrentCountKey, "3"); //存储当前的页面总数 CacheUtils.Max(cacheMessageKey, "创建成功!"); //存储消息 if (!string.IsNullOrEmpty(returnUrl)) { returnUrl = PageUtils.AddQueryString(StringUtils.ValueFromUrl(returnUrl), "PublishmentSystemID", publishmentSystemId.ToString()); retval = AjaxManager.GetWaitingTaskNameValueCollection( $"站点 <strong>{publishmentSystemInfo.PublishmentSystemName}<strong> 创建成功!", string.Empty, isTop ? $"top.location.href='{returnUrl}';" : $"location.href='{returnUrl}';"); } else { var initUrl = PageInitialization.GetRedirectUrl(); retval = AjaxManager.GetWaitingTaskNameValueCollection( $"站点 <strong>{publishmentSystemInfo.PublishmentSystemName}<strong> 创建成功!", string.Empty, isTop ? $"location.href='{initUrl}';" : $"top.location.href='{initUrl}';"); } } catch (Exception ex) { retval = AjaxManager.GetWaitingTaskNameValueCollection(string.Empty, ex.Message, string.Empty); LogUtils.AddErrorLog(ex); } CacheUtils.Remove(cacheTotalCountKey); //取消存储需要的页面总数 CacheUtils.Remove(cacheCurrentCountKey); //取消存储当前的页面总数 CacheUtils.Remove(cacheMessageKey); //取消存储消息 CacheUtils.Clear(); return(retval); }