/// <summary> /// Appraises the imported list. Designed to work in a separate thread. /// </summary> /// <param name="MKMToolPrice">if set to <c>true</c>, MKMTool price will be computed based on the loaded settings - load the settings /// into the bot BEFORE calling this method.</param> /// <param name="MKMPriceGuide">if set to <c>true</c>, MKM price guide prices will be computed for items for which they were not computed during import.</param> private void appraise(bool MKMToolPrice, bool MKMPriceGuide) { if (MKMPriceGuide) { MainView.Instance.LogMainWindow("Fetching price guides for the imported list..."); // to limit the number of API calls, we can store results from each request and re-use it if there are multiple cards with the same product ID Dictionary <string, XmlNode> products = new Dictionary <string, XmlNode>(); // key == product ID foreach (MKMMetaCard mc in importedValidOnly) { if (!mc.HasPriceGuides) { string productID = mc.GetAttribute(MCAttribute.ProductID); XmlNode product; if (!products.TryGetValue(productID, out product)) { try { // there should always be exactly one product in the list product = MKMInteract.RequestHelper.getProduct( mc.GetAttribute(MCAttribute.ProductID)).GetElementsByTagName("product")[0]; products[productID] = product; } catch (Exception eError) { LogError("fetching MKM price guide for " + mc.GetAttribute(MCAttribute.Name) + ", will not have price guides", eError.Message, false); continue; } } mc.FillProductInfo(product); } } priceGuidesGenerated = true; MainView.Instance.LogMainWindow("Price guides fetched."); } if (MKMToolPrice) { MainView.Instance.LogMainWindow("Generating MKMTool prices for the imported list..."); bot.GeneratePrices(importedValidOnly, checkBoxMyStock.Enabled && checkBoxMyStock.Checked); // the checkbox can be checked, but not enabled if user does not want MKMTool prices toolPriceGenerated = true; MainView.Instance.LogMainWindow("Prices generated."); } }