public string ConvertSitemap(SitemapConverterOptions options) { string decodedSitemap; try { ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; SitemapXML.SitemapFilter filter = new SitemapXML.SitemapFilter(); filter.GenerateHyperlinks = (bool)options.Hyperlinks; filter.GenerateTable = (bool)options.Tables; filter.SortLexicographically = (bool)options.LexicographicOrder; filter.LoadSitemapFromURL(new Uri(options.Url)); filter.ConvertSitemap(); SDON.Model.Diagram diagram = filter.GetRoot(); decodedSitemap = SDON.SDONBuilder.ToJSON(diagram); } catch (Exception e) { WebOperationContext.Current.OutgoingResponse.StatusCode = (System.Net.HttpStatusCode) 418; return("Error parsing sitemap:\n" + e.Message); } return(decodedSitemap); }
public string ConvertSitemapFinal(Guid uploadID, SitemapConverterOptions options) { string decodedSitemap; try { System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(TempFileLocation + CurrPathSeparator + "tmp-sitemap-" + uploadID.ToString()); SitemapXML.SitemapFilter filter = new SitemapXML.SitemapFilter(); filter.GenerateHyperlinks = (bool)options.Hyperlinks; filter.GenerateTable = (bool)options.Tables; filter.SortLexicographically = (bool)options.LexicographicOrder; filter.LoadSitemapFromFile(dir.FullName + CurrPathSeparator + "sitemap.xml"); filter.ConvertSitemap(); SDON.Model.Diagram diagram = filter.GetRoot(); decodedSitemap = SDON.SDONBuilder.ToJSON(diagram); dir.Delete(true); } catch (Exception e) { WebOperationContext.Current.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.InternalServerError; WebOperationContext.Current.OutgoingResponse.ContentType = "text/plain"; dumpTempFolder(uploadID); return("Error when converting sitemap: " + e.Message); } return(decodedSitemap); }