public static void Publish(int PageID) { PageModel page = GetModel(PageID); string url = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + page.TempatePath.Replace("\\", "/") + "?pageid=" + page.PageID; string html = PublishUtil.SendGetRequest(url, null, Encoding.UTF8, Encoding.UTF8); PageCategoryElement Element = ((PageCategorySection)ConfigurationManager.GetSection("pageCategorySection")).PageCategories[Enum.GetName(typeof(PageCategory), page.Category)]; string FileName = Element.PhysicalPathRoot + (page.PhysicalPath.StartsWith("\\") ? page.PhysicalPath.Substring(1, page.PhysicalPath.Length) : page.PhysicalPath); if (!FileName.EndsWith(".shtml") && !FileName.EndsWith(".html") && !FileName.EndsWith(".htm")) { if (!Directory.Exists(FileName)) { Directory.CreateDirectory(FileName); } FileName = FileName.EndsWith("\\") ? FileName + "index.shtml" : FileName + "\\index.shtml"; } if (!(new FileInfo(FileName).Directory).Exists) { (new FileInfo(FileName).Directory).Create(); } StreamWriter sw = new StreamWriter(FileName); sw.Write(html); sw.Flush(); sw.Close(); }
public static void GetPageUrl(int PageID, PageCategoryElement PageCategory, out string PreviewUrl, out string FormalUrl) { PageModel page = GetModel(PageID); PreviewUrl = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + page.TempatePath.Replace("\\", "/") + "?pageid=" + page.PageID; FormalUrl = PageCategory.RootUrl + page.PhysicalPath.Replace("\\", "/"); }