/// <summary> /// Search an element on FFXIVCrafting /// </summary> private void SearchThread() { string elemToSearch = VPThreading.GetText(_searchTextBox); int minLevel = (int)VPThreading.GetValue(_minLevelNumericUpDown); int maxLevel = (int)VPThreading.GetValue(_maxLevelNumericUpDown); List <string> jobs = new List <string>(); lock (_locker) { jobs = _jobFilter; } Service_Misc.LogText(_logTextBox, "Alright, let's look for " + elemToSearch); List <FFXIVSearchItem> listResults = GarlandTool.Search(elemToSearch, _logTextBox, FFXIVItem.TypeItem.Crafted, jobs, minLevel, maxLevel); //Storing in options MiqoCraftOptions options = new MiqoCraftOptions(); options.Load(OptionLocation.UserOption); options.LastSearchResult = listResults; options.Save(); if (listResults.Count > 0) { Service_Misc.LogText(_logTextBox, "All done ! Found " + listResults.Count + " items!"); } else { Service_Misc.LogText(_logTextBox, "All done ! But I couldn't find your item..."); } DisplayItemList(listResults); }
public void TestFullScenarioImpl(string iItemName, FFXIVItem.TypeItem iExpectedType, int iNbExpectedItems = 1, int iPosItemInList = 0, string iRealName = "", bool iIgnoreCatalyst = false, int iQuantity = 1, bool iCollectable = false, int iNbPerSlot = 1, string iCustomTeleport = "") { InitTestEnvironment(); string elemToSearch = iItemName; int nbExpectedSearchItems = iNbExpectedItems; int nbItemInList = iPosItemInList; string itemFullName = iRealName; if (itemFullName.Length <= 0) { itemFullName = iItemName; } FFXIVItem.TypeItem expectedType = iExpectedType; List <FFXIVSearchItem> listResults = GarlandTool.Search(elemToSearch, null); if (listResults.Count != nbExpectedSearchItems) { throw new Exception("Erreur de recherche de " + elemToSearch + ": " + listResults.Count + " items found while " + nbExpectedSearchItems + " expected."); } FFXIVItem item = listResults[nbItemInList]; if (item.Name != itemFullName) { throw new Exception("Item name is not the expected one: " + item.Name + ", expected : " + itemFullName); } FFXIVItem itemToCraft = GarlandTool.RecBuildCraftingTree(null, item.ID); if (itemToCraft.Type != expectedType) { throw new Exception("Item type is not the expected one: " + itemToCraft.Type + ", expected : " + expectedType); } string solution_dir = Service_Misc.GetExecutionPath(); DirectoryInfo refDirectory = new DirectoryInfo(Path.Combine(solution_dir, "References")); if (!refDirectory.Exists) { throw new Exception("Reference directory " + refDirectory.FullName + " does not exist"); } MiqoCraftCore.MiqoCraftCore.MiqobotScenarioOption options = new MiqoCraftCore.MiqoCraftCore.MiqobotScenarioOption(); options.GatheringRotation = "HQ +10%"; options.CraftPreset = "recommended"; options.NQHQPreset = "balanced"; options.CustomTeleport = iCustomTeleport; options.Quantity = iQuantity; options.NbPerNode = iNbPerSlot; options.Collectable = iCollectable; options.IgnoreCatalysts = iIgnoreCatalyst; string fullScenario = ""; string res = MiqoCraftCore.MiqoCraftCore.GenerateScenario(itemToCraft, options, null, out fullScenario); FileInfo refFile = new FileInfo(Path.Combine(refDirectory.FullName, itemFullName + _dumpSuffix + ".txt")); string pathResult = refFile.FullName.Replace(".txt", "_runresult.txt"); File.WriteAllText(pathResult, res); if (_updateDumps) { File.WriteAllText(refFile.FullName, res); } string fullScenarioResult = File.ReadAllText(pathResult); FileInfo refScenarioFile = new FileInfo(Path.Combine(refDirectory.FullName, itemFullName + _dumpSuffix + " Scenario.txt")); pathResult = refScenarioFile.FullName.Replace(".txt", "_runresult.txt"); File.WriteAllText(pathResult, fullScenario); if (_updateDumps) { File.WriteAllText(refScenarioFile.FullName, fullScenario); } if (!refFile.Exists) { throw new Exception("Reference file " + refFile.FullName + " does not exist"); } string fullScenarioReference = File.ReadAllText(refFile.FullName); //Testing miqobot scenario if (fullScenarioResult.Trim() != fullScenarioReference.Trim()) { throw new Exception("Resulting scenario does not match.; See " + refFile.FullName); } //Testing plain text scenario fullScenarioResult = File.ReadAllText(pathResult); if (!refScenarioFile.Exists) { throw new Exception("Reference file " + refScenarioFile.FullName + " does not exist"); } string fullScenarioTextReference = File.ReadAllText(refScenarioFile.FullName); if (fullScenarioResult.Trim() != fullScenarioTextReference.Trim()) { throw new Exception("Resulting scenario text does not match.; See " + refScenarioFile.FullName); } }
private void DownloadFromURL(string iURL, string iItemName = "", CookieCollection iCookies = null) { VPThreading.SetText(_progressLabel, "Downloading grid from given URL..."); if (null == iCookies) { iCookies = Miqobot.LogInForum(); } List <string> listGridRawContent = Miqobot.GetAllGridsRawContentFromForum(iURL, iCookies); List <MiqobotGrid> listGrids = new List <MiqobotGrid>(); MiqoGridFinderOptions options = new MiqoGridFinderOptions(); options.Load(VPL.Application.Data.OptionLocation.GlobalOption); List <FFXIVSearchItem> listAllGatheredItems = options.ListAllGatheredItems; if (listAllGatheredItems.Count <= 0) { VPThreading.SetText(_progressLabel, "Downloading all item names..."); listAllGatheredItems = GarlandTool.Search("", null, FFXIVItem.TypeItem.Gathered); } options.ListAllGatheredItems = listAllGatheredItems; options.Save(); VPThreading.SetText(_progressLabel, "Reading grids..."); foreach (string rawContent in listGridRawContent) { listGrids.AddRange(Miqobot.GetAllGridsFromContent(rawContent)); } DirectoryInfo exeDirectory = new DirectoryInfo(Service_Misc.GetExecutionPath()); DirectoryInfo cacheDirectory = new DirectoryInfo(Path.Combine(exeDirectory.FullName, "CacheGrid")); DirectoryInfo analyzeDirectory = new DirectoryInfo(Path.Combine(exeDirectory.FullName, "DownloadedGrids")); if (!analyzeDirectory.Exists) { analyzeDirectory.Create(); } if (!cacheDirectory.Exists) { VPThreading.SetText(_progressLabel, "Failed to compute database status, CacheGrid directory does not exist."); return; } VPThreading.SetText(_progressLabel, "Matching grid to item list..."); int gridIndex = 1; foreach (MiqobotGrid grid in listGrids) { List <string> listCorrespondingItemNames = new List <string>(); foreach (FFXIVSearchItem item in listAllGatheredItems) { if (null == grid.Description) { continue; } if (grid.Description.ToLower().Contains(item.Name.ToLower())) { listCorrespondingItemNames.Add(item.Name); } if (grid.Header.ToLower().Contains(item.Name.ToLower())) { listCorrespondingItemNames.Add(item.Name); } } if (listCorrespondingItemNames.Count <= 0 && iItemName != "") { listCorrespondingItemNames.Add(iItemName); } List <string> listFilteredCorrespondingItemNames = new List <string>(); foreach (string itemName in listCorrespondingItemNames) { bool hasBigger = false; foreach (string itemName2 in listCorrespondingItemNames) { if (itemName2 != itemName && itemName2.Contains(itemName)) { hasBigger = true; break; } } if (!hasBigger) { listFilteredCorrespondingItemNames.Add(itemName); } } foreach (string itemName in listFilteredCorrespondingItemNames) { //Check if grid exist string gridItemName = itemName + " Grid"; //Looking into cache directory FileInfo cacheGridFile = new FileInfo(Path.Combine(cacheDirectory.FullName, gridItemName + ".txt")); if (cacheGridFile.Exists) { continue; } //Saving grid string pathGrid = Path.Combine(analyzeDirectory.FullName, gridItemName + "---" + gridIndex + ".txt"); if (File.Exists(pathGrid)) { File.Delete(pathGrid); } File.WriteAllText(pathGrid, "grid." + grid.Header + Environment.NewLine + grid.Content); gridIndex++; } } }