partial void DeleteIngredient(Ingredient instance);
 partial void UpdateIngredient(Ingredient instance);
 partial void InsertIngredient(Ingredient instance);
		private void detach_Ingredients(Ingredient entity)
		{
			this.SendPropertyChanging();
			entity.Recipe = null;
		}
		private void attach_Ingredients(Ingredient entity)
		{
			this.SendPropertyChanging();
			entity.Recipe = this;
		}
Esempio n. 6
0
        public static Recipe UpdateRecipe(Recipe r, int crafterCatID, MooglenomicsDatabaseDataContext db)
        {
            r.craftingClass = crafterCatID.ToString();
            WebClient webClient = new WebClient();
            string pageSource = webClient.DownloadString(baseURL + "recipe/" + r.RecipeID);
            r.isHQCraftable = pageSource.Contains("HQ Craftable");
            r.isQuickSynthesis = pageSource.Contains("Quick Synthesis Available");
            MatchCollection m1 = Regex.Matches(pageSource, "<dd class=\"mb20\">(\\d*)", RegexOptions.Singleline);
            r.yeild = Convert.ToInt32(m1[0].Groups[1].Value);
            r.difficulty = Convert.ToInt32(m1[1].Groups[1].Value);
            r.durability = Convert.ToInt32(m1[2].Groups[1].Value);
            r.maxQuality = Convert.ToInt32(m1[3].Groups[1].Value);
            m1 = Regex.Matches(pageSource, "Lv. <span>(\\d*)", RegexOptions.Singleline);
            r.craftingLevel = m1[0].Groups[1].Value;
            m1 = Regex.Matches(pageSource, "Control Required: (\\d*)", RegexOptions.Singleline);
            if (m1.Count != 0)
            {
                r.minControl = Convert.ToInt32(m1[0].Groups[1].Value);
            }
            else
            {
                r.minControl = 0;
            }
            m1 = Regex.Matches(pageSource, "Craftsmanship Required: (\\d*)", RegexOptions.Singleline);
            if (m1.Count != 0)
            {
                r.minCraftmanship = Convert.ToInt32(m1[0].Groups[1].Value);
            }
            else
            {
                r.minCraftmanship = 0;
            }

            //Get Ingredients

            //<a href=\"/lodestone/playguide/db/item/[a-z,A-Z,0-9]*/\" class=\"db_popup highlight\">([A-Z,a-z,\\s]*)<\\/a

            //<a href=\"/lodestone/playguide/db/item/[a-z,A-Z,0-9]*/\" class=\"db_popup highlight\">([A-Z,a-z,\\s]*)&nbsp;\\((\\d*)\\)

            m1 = Regex.Matches(pageSource, "<a href=\"/lodestone/playguide/db/item/[a-z,A-Z,0-9]*/\" class=\"db_popup highlight\">([A-Z,a-z,\\s]*)<\\/a", RegexOptions.Singleline);

            foreach (Match m in m1)
            {
                string itemName = m.Groups[1].Value.Trim();
                Item i = db.Items.SingleOrDefault(p => p.Name.Equals(itemName) && p.isUntradeable == false);
                Ingredient ig = r.Ingredients.SingleOrDefault(p => p.Item == i);
                if (ig == null)
                {
                    ig = new Ingredient();
                    ig.Recipe = r;
                    ig.Item = i;
                    r.Ingredients.Add(ig);
                }
                ig.quantity = 1;

            }

            m1 = Regex.Matches(pageSource, "<a href=\"/lodestone/playguide/db/item/[a-z,A-Z,0-9]*/\" class=\"db_popup highlight\">([A-Z,a-z,\\s]*)&nbsp;\\((\\d*)\\)", RegexOptions.Singleline);

            foreach (Match m in m1)
            {
                string itemName = m.Groups[1].Value.Trim();
                Item i = db.Items.SingleOrDefault(p => p.Name.Equals(itemName) && p.isUntradeable == false);
                Ingredient ig = r.Ingredients.SingleOrDefault(p => p.Item == i);
                if (ig == null)
                {
                    ig = new Ingredient();
                    ig.Recipe = r;
                    ig.Item = i;
                    r.Ingredients.Add(ig);
                }
                ig.quantity = Convert.ToInt32(m.Groups[2].Value);

            }

            m1 = Regex.Matches(pageSource, "<a href=\"/lodestone/playguide/db/item/([a-z,A-Z,0-9]*)/\">\\s*<img", RegexOptions.Singleline);
            string itemID = m1[0].Groups[1].Value;
            r.Item = db.Items.Single(p => p.ItemID.Equals(itemID));
            return r;
        }