private static void WriteBadgesLists(GeneralUris generalUris, string destDir, VDS.RDF.INamespaceMapper nsMapper) { ConsoleHelper.WriteMilestone("Writing lists of badges ..."); using (var destWriter = new SequentialTurtleWriter(File.CreateText(Path.Combine(destDir, "_badges.ttl")), nsMapper)) { foreach (var siteBadges in GlobalData.GetBadgesPerSite()) { Uri siteUri = generalUris.CreateSiteUri(siteBadges.Item1); SiteUris uris = new SiteUris(generalUris, siteBadges.Item1); foreach (string badgeName in siteBadges.Item2) { WriteBadgeInfo(uris, badgeName, destWriter); } } GlobalData.UpdateStats(destWriter); } Console.WriteLine(" done."); }
private static void ConvertSiteList(GeneralUris generalUris, string tempDir, Uri baseUri, string destDir, VDS.RDF.INamespaceMapper nsMapper) { string srcFile = Path.Combine(tempDir, "Sites.xml"); ConsoleHelper.WriteMilestone("Downloading site list ..."); using (var client = new WebClient()) { client.DownloadFile(new Uri(baseUri, "Sites.xml"), srcFile); } Console.WriteLine(" done."); using (var destWriter = new SequentialTurtleWriter(File.CreateText(Path.Combine(destDir, "_sites.ttl")), nsMapper)) { using (var fs = File.OpenRead(srcFile)) { using (var reader = XmlReader.Create(fs)) { while (reader.NodeType != XmlNodeType.Element) { if (!reader.Read()) { ConsoleHelper.WriteErrorLine("No contents found in file {0}.", srcFile); return; } } if (reader.LocalName == "sitelist") { ConvertSites(generalUris, reader, destWriter); } else { ConsoleHelper.WriteWarningLine("Unknown root element \"{0}\". Skipping document.", reader.LocalName); } } } GlobalData.UpdateStats(destWriter); } Console.WriteLine("Conversion of site list completed."); }
private static void WriteAccountList(GeneralUris generalUris, string destDir, VDS.RDF.INamespaceMapper nsMapper) { ConsoleHelper.WriteMilestone("Writing account list ..."); using (var destWriter = new SequentialTurtleWriter(File.CreateText(Path.Combine(destDir, "_users.ttl")), nsMapper)) { foreach (var id in GlobalData.AccountIds) { destWriter.StartTriple(generalUris.CreateAccountUri(id)); destWriter.AddToTriple(generalUris.TypeProperty, generalUris.AccountType); } GlobalData.UpdateStats(destWriter); } Console.WriteLine(" done."); }