コード例 #1
0
ファイル: ConfigCtrl.cs プロジェクト: jojozhuang/Projects
        public static Collection<FruitInfo> GetMyGardenWarehouse(string strxml)
        {
            try
            {
                XmlDocument objXmlDoc = new XmlDocument();
                objXmlDoc.LoadXml(strxml);
                if (objXmlDoc == null)
                    return null;

                if (objXmlDoc.SelectSingleNode("data/fruit") == null)
                {
                    return new Collection<FruitInfo>();
                }

                DataView dv = GetData(objXmlDoc, "data/fruit");

                Collection<FruitInfo> fruits = new Collection<FruitInfo>();

                for (int ix = 0; ix < dv.Table.Rows.Count; ix++)
                {
                    FruitInfo fruit = new FruitInfo();
                    fruit.FruitId = DataConvert.GetInt32(dv.Table.Rows[ix]["seedid"]);
                    fruit.Num = DataConvert.GetInt32(dv.Table.Rows[ix]["num"]);
                    fruit.Name = DataConvert.GetString(dv.Table.Rows[ix]["name"]);
                    fruits.Add(fruit);
                }
                return fruits;
            }
            catch (Exception ex)
            {
                LogHelper.Write("ConfigCtrl.GetMyGardenWarehouse", strxml, ex, LogSeverity.Error);
                return null;
            }
        }
コード例 #2
0
ファイル: ConfigCtrl.cs プロジェクト: jojozhuang/Projects
        public static Collection<FruitInfo> GetFruits()
        {
            try
            {
                XmlDocument objXmlDoc = GetMasterDataFile(Constants.FILE_FRUITSMASTERDATA);
                if (objXmlDoc == null)
                    return null;

                DataView dv = GetData(objXmlDoc, "data/fruit");

                Collection<FruitInfo> fruits = new Collection<FruitInfo>();

                for (int ix = 0; ix < dv.Table.Rows.Count; ix++)
                {
                    FruitInfo fruit = new FruitInfo();
                    fruit.FruitId = DataConvert.GetInt32(dv.Table.Rows[ix]["fruitid"]);
                    fruit.Name = DataConvert.GetString(dv.Table.Rows[ix]["name"]);
                    fruit.SellPrice = DataConvert.GetInt32(dv.Table.Rows[ix]["sellprice"]);
                    fruits.Add(fruit);
                }

                return fruits;
            }
            catch (Exception ex)
            {
                LogHelper.Write("ConfigCtrl.GetFruits", ex);
                return null;
            }
        }