示例#1
0
        public DataManager()
        {
            /*
             * if (File.Exists(RecipesFile))
             * {
             *  StreamReader myReader = new StreamReader(RecipesFile);
             *  recipesList = (RecipesList)recipesListSerializer.Deserialize(myReader);
             *  myReader.Close();
             * }
             * else
             *  recipesList = new RecipesList();
             *
             * if (File.Exists(FridgeFile))
             * {
             *  StreamReader myReader = new StreamReader(FridgeFile);
             *  fridge = (Fridge)fridgeSerializer.Deserialize(myReader);
             *  myReader.Close();
             * }
             * else
             *  fridge = new Fridge();
             *
             * if (File.Exists(ProductsFile))
             * {
             *  StreamReader myReader = new StreamReader(ProductsFile);
             *  productsList = (ProductsList)productsListSerializer.Deserialize(myReader);
             *  myReader.Close();
             * }
             * else
             *  productsList = new ProductsList();
             */

            recipesList  = new RecipesList();
            fridge       = new Fridge();
            productsList = new ProductsList();
        }
示例#2
0
        public void getProductsList()
        {
            try
            {
                //  if (cookie == null)
                //    if (!login())
                //      return;
                HttpWebRequest req = (HttpWebRequest)WebRequest.Create(config.Current.serverAddress + "/synchro/products_list");
                req.Headers["Cookie"]         = cookie;
                req.AllowWriteStreamBuffering = true;
                req.KeepAlive = true;
                req.Method    = "Get";
                HttpWebResponse HttpWResp = (HttpWebResponse)req.GetResponse();
                XmlTextReader   xmltr     = new XmlTextReader(HttpWResp.GetResponseStream());
                ProductsList    list      = new ProductsList();
                list.Deserialize(xmltr);
                HttpWResp.Close();

                //mutex.WaitOne(5000, true);
                productsList = list;
                //mutex.ReleaseMutex();
            }
            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);
            }
        }
示例#3
0
文件: DataManager.cs 项目: rkj/ieat
        public DataManager()
        {
            /*
            if (File.Exists(RecipesFile))
            {
                StreamReader myReader = new StreamReader(RecipesFile);
                recipesList = (RecipesList)recipesListSerializer.Deserialize(myReader);
                myReader.Close();
            }
            else
                recipesList = new RecipesList();

            if (File.Exists(FridgeFile))
            {
                StreamReader myReader = new StreamReader(FridgeFile);
                fridge = (Fridge)fridgeSerializer.Deserialize(myReader);
                myReader.Close();
            }
            else
                fridge = new Fridge();

            if (File.Exists(ProductsFile))
            {
                StreamReader myReader = new StreamReader(ProductsFile);
                productsList = (ProductsList)productsListSerializer.Deserialize(myReader);
                myReader.Close();
            }
            else
                productsList = new ProductsList();
            */

            recipesList = new RecipesList();
            fridge = new Fridge();
            productsList = new ProductsList();
        }
示例#4
0
      public void Deserialize(XmlReader xmlr)
      {
          XmlSerializer xs   = new XmlSerializer(typeof(ProductsList));
          ProductsList  list = (ProductsList)xs.Deserialize(xmlr);

          this.Products = list.Products;
      }
示例#5
0
      public void Deserialize(StreamReader iStream)
      {
          XmlSerializer xs   = new XmlSerializer(typeof(ProductsList));
          ProductsList  list = (ProductsList)xs.Deserialize(iStream);

          this.Products = list.Products;
      }
示例#6
0
文件: DataManager.cs 项目: rkj/ieat
        public void getProductsList()
        {
            try
            {
              //  if (cookie == null)
                //    if (!login())
                  //      return;
                HttpWebRequest req = (HttpWebRequest)WebRequest.Create(config.Current.serverAddress+"/synchro/products_list");
                req.Headers["Cookie"] = cookie;
                req.AllowWriteStreamBuffering = true;
                req.KeepAlive = true;
                req.Method = "Get";
                HttpWebResponse HttpWResp = (HttpWebResponse)req.GetResponse();
                XmlTextReader xmltr = new XmlTextReader(HttpWResp.GetResponseStream());
                ProductsList list = new ProductsList();
                list.Deserialize(xmltr);
                HttpWResp.Close();

                //mutex.WaitOne(5000, true);
                productsList = list;
                //mutex.ReleaseMutex();
            }
            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);
            }
        }