/// <summary> /// 获取网站列表 /// </summary> /// <returns></returns> private SiteEntity GetSiteList() { _status.Text = @"正在登录中"; var body = new SiteListRequestEntity(_btToken) { Tojs = "site.get_list", Table = "sites", Limit = SelectNum.ToString(), P = "1", Search = "", Order = "id desc", Type = TypeId.ToString() }; var client = new RestClient(_btAddress + "/data?action=getData"); var request = new RestRequest(Method.POST); request.AddParameter("tojs", body.Tojs); request.AddParameter("table", body.Table); request.AddParameter("limit", body.Limit); request.AddParameter("p", body.P); request.AddParameter("search", body.Search); request.AddParameter("order", body.Order); request.AddParameter("type", body.Type); SetTokenParam(request, body); Console.WriteLine(body); var jsonResult = client.Execute(request).Content; jsonResult = CheckJsonResultIsNull(jsonResult, client, request); var siteEntity = JsonConvert.DeserializeObject <SiteEntity>(jsonResult); return(siteEntity); }
private ATS GetMatchedElements(string treeScope = null, string name = null, string automationId = null, string className = null, string frameworkId = null, string controlType = null, string index = null, SelectNum selectNumber = SelectNum.Single) { var eleList = new List <AT>(); foreach (var item in GetATCollection()) { try { if (IsElementsMatch(atObj: item, name: name, className: className, automationId: automationId)) { item.GetElement(treeScope: treeScope, name: name, automationId: automationId, className: className, frameworkId: frameworkId, controlType: controlType); eleList.Add(item); if (selectNumber.Equals(AT.SelectNum.Single)) { break; } } } catch (Exception) { //ignored } } if (eleList.Count == 0) { throw new Exception("There is no any item matching."); } var arrAutomationElement = eleList.ToArray(); return(new ATS(arrAutomationElement)); }