public void Test02_LoadStableDatabaseTest() { List <Category> ParsedCategoryList = new List <Category>(); List <DatabasePackage> GlobalDependencies = new List <DatabasePackage>(); List <Dependency> Dependencies = new List <Dependency>(); string modInfoXml = string.Empty; Ionic.Zip.ZipFile zipfile = null; XmlDocument modInfoDocument = null; List <string> categoriesXml = new List <string>(); string modInfoxmlURL = ApplicationConstants.BigmodsDatabaseRootEscaped.Replace(@"{dbVersion}", LatestSupportedWoTVersion) + "modInfo.dat"; using (WebClient client = new WebClient()) { //save zip file into memory for later zipfile = Ionic.Zip.ZipFile.Read(new MemoryStream(client.DownloadData(modInfoxmlURL))); //extract modinfo xml string modInfoXml = FileUtils.GetStringFromZip(zipfile, "database.xml"); } modInfoDocument = XmlUtils.LoadXmlDocument(modInfoXml, XmlLoadType.FromString); string globalDependencyFilename = XmlUtils.GetXmlStringFromXPath(modInfoDocument, "/modInfoAlpha.xml/globalDependencies/@file"); string globalDependencyXmlString = FileUtils.GetStringFromZip(zipfile, globalDependencyFilename); string dependencyFilename = XmlUtils.GetXmlStringFromXPath(modInfoDocument, "/modInfoAlpha.xml/dependencies/@file"); string dependenicesXmlString = FileUtils.GetStringFromZip(zipfile, dependencyFilename); foreach (XmlNode categoryNode in XmlUtils.GetXmlNodesFromXPath(modInfoDocument, "//modInfoAlpha.xml/categories/category")) { string categoryFilename = categoryNode.Attributes["file"].Value; categoriesXml.Add(FileUtils.GetStringFromZip(zipfile, categoryFilename)); } zipfile.Dispose(); zipfile = null; DatabaseUtils.ParseDatabase1V1FromStrings(globalDependencyXmlString, dependenicesXmlString, categoriesXml, GlobalDependencies, Dependencies, ParsedCategoryList); DatabaseUtils.BuildLinksRefrence(ParsedCategoryList, false); DatabaseUtils.BuildLevelPerPackage(ParsedCategoryList); TestDatabaseEntries(GlobalDependencies, Dependencies, ParsedCategoryList, false); }
public void Test03_LoadBetaDatabaseTest() { List <Category> ParsedCategoryList = new List <Category>(); List <DatabasePackage> GlobalDependencies = new List <DatabasePackage>(); List <Dependency> Dependencies = new List <Dependency>(); string modInfoXml = string.Empty; //load string constant url from manager info xml string rootXml = ApplicationConstants.BetaDatabaseV2FolderURLEscaped.Replace(@"{branch}", "master") + ApplicationConstants.BetaDatabaseV2RootFilename; //download the xml string into "modInfoXml" using (WebClient client = new WebClient()) { client.Headers.Add("user-agent", "Mozilla / 4.0(compatible; MSIE 6.0; Windows NT 5.2;)"); modInfoXml = client.DownloadString(rootXml); } List <string> downloadURLs = DatabaseUtils.GetBetaDatabase1V1FilesList(ApplicationConstants.BetaDatabaseV2FolderURLEscaped.Replace(@"{branch}", "master"), "master"); string[] downloadStrings = CommonUtils.DownloadStringsFromUrls(downloadURLs); //parse into strings string globalDependencyXmlStringBeta = downloadStrings[0]; string dependenicesXmlStringBeta = downloadStrings[1]; List <string> categoriesXmlBeta = new List <string>(); for (int i = 2; i < downloadURLs.Count; i++) { categoriesXmlBeta.Add(downloadStrings[i]); } //parse into lists DatabaseUtils.ParseDatabase1V1FromStrings(globalDependencyXmlStringBeta, dependenicesXmlStringBeta, categoriesXmlBeta, GlobalDependencies, Dependencies, ParsedCategoryList); DatabaseUtils.BuildLinksRefrence(ParsedCategoryList, false); DatabaseUtils.BuildLevelPerPackage(ParsedCategoryList); TestDatabaseEntries(GlobalDependencies, Dependencies, ParsedCategoryList, true); GlobalDependenciesForSave = GlobalDependencies; DependenciesForSave = Dependencies; ParsedCategoryListForSave = ParsedCategoryList; }