static void Main(string[] args) { logger.Info("Starting"); // we need to set the role to admin so we get public entries System.Threading.Thread.CurrentPrincipal = new GenericPrincipal(System.Threading.Thread.CurrentPrincipal.Identity, new string[] { "admin" }); if (args.Length != 1) { logger.Error(@"Usage: DasBlogGraffitiExporter ""c:\mydasblog\content"""); Environment.Exit(1); return; } Console.WriteLine("Press ENTER to continue..."); Console.ReadLine(); string path = args[0]; if (Directory.Exists(path)) { // Check all the files again for bad xml which can happen during multithreaded FTP downloads with SmartFTP, // plus it doesn't hurt and can catch corruption you don't know you have! foreach (string file in Directory.GetFiles(path, "*.xml")) { try { XmlDocument x = new XmlDocument(); x.Load(file); } catch (XmlException ex) { logger.FatalFormat("ERROR: Malformed Xml in file: {0}", file); logger.Fatal("XmlException", ex); } } IBlogDataService dataService = BlogDataServiceFactory.GetService(path, null); List<UrlMap> categoryMap = new List<UrlMap>(); CategoryCacheEntryCollection categories = dataService.GetCategories(); logger.InfoFormat("Found {0} Categories", categories.Count); foreach (CategoryCacheEntry entry in categories) { string name = HttpHelper.GetURLSafeString(entry.Name); UrlMap mapping = new UrlMap(name, InternalCompressTitle(entry.DisplayName)); categoryMap.Add(mapping); logger.InfoFormat("Adding category name:{0}, display name:{1}", entry.Name, entry.DisplayName); } UrlMap.Save(categoryMap, Path.Combine(GetDasBlog301Folder(), "CategoryMapping.xml")); EntryCollection entries = dataService.GetEntriesForDay( DateTime.MaxValue.AddDays(-2), TimeZone.CurrentTimeZone, String.Empty, int.MaxValue, int.MaxValue, String.Empty); logger.InfoFormat("Found {0} entries", entries.Count); List<UrlMap> permalinkMapping = new List<UrlMap>(); foreach (Entry entry in entries) { string title = entry.CompressedTitle; UrlMap mapping = new UrlMap(entry.EntryId, title); permalinkMapping.Add(mapping); logger.InfoFormat("Adding entry id:{0} title:{1}", entry.EntryId, entry.CompressedTitle); } UrlMap.Save(permalinkMapping, Path.Combine(GetDasBlog301Folder(), "PermalinkMapping.xml")); } }
static void Main(string[] args) { logger.Info("Starting"); // we need to set the role to admin so we get public entries System.Threading.Thread.CurrentPrincipal = new GenericPrincipal(System.Threading.Thread.CurrentPrincipal.Identity, new string[] { "admin" }); if (args.Length != 1) { logger.Error(@"Usage: DasBlogGraffitiExporter ""c:\mydasblog\content"""); Environment.Exit(1); return; } Console.WriteLine("Press ENTER to continue..."); Console.ReadLine(); string path = args[0]; if (Directory.Exists(path)) { // Check all the files again for bad xml which can happen during multithreaded FTP downloads with SmartFTP, // plus it doesn't hurt and can catch corruption you don't know you have! foreach (string file in Directory.GetFiles(path, "*.xml")) { try { XmlDocument x = new XmlDocument(); x.Load(file); } catch (XmlException ex) { logger.FatalFormat("ERROR: Malformed Xml in file: {0}", file); logger.Fatal("XmlException", ex); } } IBlogDataService dataService = BlogDataServiceFactory.GetService(path, null); List <UrlMap> categoryMap = new List <UrlMap>(); CategoryCacheEntryCollection categories = dataService.GetCategories(); logger.InfoFormat("Found {0} Categories", categories.Count); foreach (CategoryCacheEntry entry in categories) { string name = HttpHelper.GetURLSafeString(entry.Name); UrlMap mapping = new UrlMap(name, InternalCompressTitle(entry.DisplayName)); categoryMap.Add(mapping); logger.InfoFormat("Adding category name:{0}, display name:{1}", entry.Name, entry.DisplayName); } UrlMap.Save(categoryMap, Path.Combine(GetDasBlog301Folder(), "CategoryMapping.xml")); EntryCollection entries = dataService.GetEntriesForDay( DateTime.MaxValue.AddDays(-2), TimeZone.CurrentTimeZone, String.Empty, int.MaxValue, int.MaxValue, String.Empty); logger.InfoFormat("Found {0} entries", entries.Count); List <UrlMap> permalinkMapping = new List <UrlMap>(); foreach (Entry entry in entries) { string title = entry.CompressedTitle; UrlMap mapping = new UrlMap(entry.EntryId, title); permalinkMapping.Add(mapping); logger.InfoFormat("Adding entry id:{0} title:{1}", entry.EntryId, entry.CompressedTitle); } UrlMap.Save(permalinkMapping, Path.Combine(GetDasBlog301Folder(), "PermalinkMapping.xml")); } }