private bool GetCategoryGoodsItems(int pageIndex) { bool hasNewElement = false; List <XmlNode> allGoodsParentNodes = AppAccess.GetXmlElementsByXPath(new string[] { "//android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.GridView/android.widget.FrameLayout", "//android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.ListView/android.widget.GridView/android.widget.FrameLayout", "//android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.ListView/android.widget.GridView/android.widget.FrameLayout" }, false); if (allGoodsParentNodes != null) { foreach (XmlNode goodsParentNode in allGoodsParentNodes) { XmlNodeList goodsInfoNodes = goodsParentNode.SelectNodes("./android.widget.RelativeLayout/android.widget.TextView"); if (goodsInfoNodes.Count >= 3) { string nameValue = goodsInfoNodes[goodsInfoNodes.Count - 3].Attributes["text"].Value; string priceValue = goodsInfoNodes[goodsInfoNodes.Count - 2].Attributes["text"].Value; string unitValue = goodsInfoNodes[goodsInfoNodes.Count - 1].Attributes["text"].Value; if (!GoodsElementList.Exist(nameValue) && priceValue.StartsWith("¥")) { NcpAppElement appElement = GoodsElementList.Add(nameValue, nameValue, ""); decimal price = decimal.Parse(priceValue.Substring(1).Trim()); appElement.Attributes.Add("price", price.ToString()); appElement.Attributes.Add("unit", unitValue.Substring(1)); hasNewElement = true; } } } } if (!hasNewElement && hasNoneNewElementTime < 2) { hasNoneNewElementTime++; hasNewElement = true; Thread.Sleep(2000); } else { hasNoneNewElementTime = 0; } return(hasNewElement); }
private bool GetSubCategoryItems(int pageIndex) { int pageOffset = pageIndex * 2000; bool hasNewElement = false; XmlNodeList allC2ParentNodes = AppAccess.GetXmlElementsByXPath("//android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.ListView/android.widget.LinearLayout", true); foreach (XmlNode c2ParentNode in allC2ParentNodes) { XmlNode c2Node = c2ParentNode.SelectSingleNode("./android.widget.LinearLayout/android.widget.TextView"); if (c2Node != null) { string text = c2Node.Attributes["text"].Value; string id = text + "Level2"; if (!_CategoryElementList.Exist(id)) { NcpAppElement appElement = CategoryElementList.Add(id, text, "Level2"); hasNewElement = true; } } XmlNodeList allC3Nodes = c2ParentNode.SelectNodes("./android.widget.LinearLayout/android.widget.GridView/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.TextView"); if (allC3Nodes != null) { foreach (XmlNode c3Node in allC3Nodes) { string text = c3Node.Attributes["text"].Value; string id = text + "Level3"; if (!_CategoryElementList.Exist(id)) { NcpAppElement appElement = CategoryElementList.Add(id, text, "Level3"); hasNewElement = true; } } } } return(hasNewElement); }