public void loadRecipes() { List <Recipe> rList = new List <Recipe>(); foreach (RecipeForList r in recipesList.ListedRecipies) { Recipe re = new Recipe(); XmlTextReader xmlr = new XmlTextReader(RecipeFile + r.id + ".xml"); re.Deserialize(xmlr); xmlr.Close(); // for (int i = 0; i < re.Steps.Count; i++) // for (int j = 0; j < re.Steps[i].Ingredients.Count; j++) // re.Steps[i].Ingredients[j].Product = productsList.getById(re.Steps[i].Ingredients[j].ProductId); rList.Add(re); } recipesList.Recipes = rList; }
Recipe getRecipe(int id) { try { HttpWebRequest req = (HttpWebRequest)WebRequest.Create(config.Current.serverAddress + "/synchro/recipe/" + id); req.AllowWriteStreamBuffering = true; req.KeepAlive = true; req.Method = "Get"; HttpWebResponse HttpWResp = (HttpWebResponse)req.GetResponse(); XmlTextReader xmltr = new XmlTextReader(HttpWResp.GetResponseStream()); Recipe recipe = new Recipe(); recipe.Deserialize(xmltr); HttpWResp.Close(); for (int i = 0; i < recipe.Steps.Count; i++) { for (int j = 0; j < recipe.Steps[i].Ingredients.Count; j++) { recipe.Steps[i].Ingredients[j].Product = productsList.getById(recipe.Steps[i].Ingredients[j].ProductId); } } return(recipe); } catch (WebException ee) { /* * WebResponse resp = ee.Response; * * StreamReader sr=new StreamReader(resp.GetResponseStream()); * string allresp=sr.ReadToEnd(); * string respmes = ee.Message; * */ MessageBox.Show(ee.Message); return(null); } }
Recipe getRecipe(int id) { try { HttpWebRequest req = (HttpWebRequest)WebRequest.Create(config.Current.serverAddress + "/synchro/recipe/"+id); req.AllowWriteStreamBuffering = true; req.KeepAlive = true; req.Method = "Get"; HttpWebResponse HttpWResp = (HttpWebResponse)req.GetResponse(); XmlTextReader xmltr = new XmlTextReader(HttpWResp.GetResponseStream()); Recipe recipe = new Recipe(); recipe.Deserialize(xmltr); HttpWResp.Close(); for (int i = 0; i < recipe.Steps.Count; i++) for (int j = 0; j < recipe.Steps[i].Ingredients.Count; j++) recipe.Steps[i].Ingredients[j].Product = productsList.getById(recipe.Steps[i].Ingredients[j].ProductId); return recipe; } catch (WebException ee) { /* WebResponse resp = ee.Response; StreamReader sr=new StreamReader(resp.GetResponseStream()); string allresp=sr.ReadToEnd(); string respmes = ee.Message; */ MessageBox.Show(ee.Message); return null; } }
public void loadRecipes() { List<Recipe> rList = new List<Recipe>(); foreach (RecipeForList r in recipesList.ListedRecipies) { Recipe re = new Recipe(); XmlTextReader xmlr = new XmlTextReader(RecipeFile+r.id+".xml"); re.Deserialize(xmlr); xmlr.Close(); // for (int i = 0; i < re.Steps.Count; i++) // for (int j = 0; j < re.Steps[i].Ingredients.Count; j++) // re.Steps[i].Ingredients[j].Product = productsList.getById(re.Steps[i].Ingredients[j].ProductId); rList.Add(re); } recipesList.Recipes = rList; }