//Attempts to click the element on the page, with specific and default exception handling
 public void Click(SearchType type, string text){
     try{
         if (type == SearchType.Id){
             WebDriver.FindElement(By.Id(text)).Click();
         }
         else if (type == SearchType.LinkText){
             WebDriver.FindElement(By.LinkText(text)).Click();
         }
         else if (type == SearchType.Name){
             WebDriver.FindElement(By.Name(text)).Click();
         }
         else if (type == SearchType.Xpath){
             WebDriver.FindElement(By.XPath(text)).Click();
         }
         else{
             System.Console.WriteLine(type.ToString() + " is an unsupported SearchType for this method.");
         }
     }
     catch (NoSuchElementException ex){
         System.Console.WriteLine("Error, could not find webElement of type " + type.ToString() + " with id {0}", text);
         System.Console.WriteLine(ex.ToString());
         return;
     }
     catch (Exception ex){
         System.Console.WriteLine("Unspecified exception in Click().");
         System.Console.WriteLine(ex.ToString());
         return;
     }
 }
Exemple #2
0
        protected new void btnSave_Click(object sender, EventArgs e)
        {
            SearchType search = SearchType.StandardLdap;

            if (rbtGeneric.Checked)
            {
                search = SearchType.GenericText;
            }
            else if (rbtCustom.Checked)
            {
                search = SearchType.CustomCode;
            }

            switch (type)
            {
            case CustomQueryType.ManagerSearch:
                Properties.Settings.Default.CustomManagerSearchType = search.ToString();
                break;

            case CustomQueryType.DirectReportSearch:
                Properties.Settings.Default.CustomDirectReportSearchType = search.ToString();
                break;
            }

            Properties.Settings.Default.Save();
            this.Close();
        }
        /// <summary>
        /// Builds a full URL search request including the object type, the query, and the fields to return.
        /// </summary>
        /// <param name="resourceType">An actual infoblox class type.</param>
        /// <param name="searchType">The type of search to be performed.</param>
        /// <param name="searchField">The field to search on.</param>
        /// <param name="recordValue">The value to search for.</param>
        /// <returns></returns>
        internal static string BuildGetSearchRequest(Type resourceType, SearchType searchType, string searchField, string recordValue, IEnumerable <string> fieldsToReturn)
        {
            if (resourceType == null)
            {
                throw new ArgumentNullException("resourceType", "The resource type to get cannot be null.");
            }

            if (String.IsNullOrEmpty(searchField))
            {
                throw new ArgumentNullException("searchField", "The field to search on cannot be null or empty.");
            }

            if (InfobloxSDKExtensionMethods.IsInfobloxType(resourceType))
            {
                if (fieldsToReturn != null && fieldsToReturn.Any())
                {
                    if (fieldsToReturn.Contains("ALL", StringComparer.OrdinalIgnoreCase))
                    {
                        fieldsToReturn = resourceType.GetTypeInfo().GetProperties().Where(x => !x.IsAttributeDefined <NotReadableAttribute>()).Select(x => x.Name);
                    }
                    else if (fieldsToReturn.Contains("BASIC", StringComparer.OrdinalIgnoreCase))
                    {
                        fieldsToReturn = resourceType.GetTypeInfo().GetProperties().Where(x => !x.IsAttributeDefined <NotReadableAttribute>()).Where(x => x.IsAttributeDefined <BasicAttribute>()).Select(x => x.Name);
                    }
                }
                else
                {
                    fieldsToReturn = resourceType.GetTypeInfo().GetProperties().Where(x => !x.IsAttributeDefined <NotReadableAttribute>()).Where(x => x.IsAttributeDefined <BasicAttribute>()).Select(x => x.Name);
                }

                string Fields = String.Join(",", RefObject.RemoveRefProperty(fieldsToReturn));

                MemberInfo[] Info = typeof(SearchType).GetTypeInfo().GetMember(searchType.ToString());

                if (Info != null && Info.Length > 0)
                {
                    string searchOperator = Info[0].GetCustomAttribute <DescriptionAttribute>().Description;

                    if (searchType.IsSearchTypeAllowed(resourceType, searchField))
                    {
                        return($"{resourceType.GetNameAttribute()}?{searchField.ToLower()}{searchOperator}{recordValue}&_return_fields%2B={Fields}");
                    }
                    else
                    {
                        throw new Exception($"The search type {searchType.ToString()} is not allowed on field {searchField}");
                    }
                }
                else
                {
                    throw new ArgumentException("Reflection evaluation on the search type object failed and no member info could be read.");
                }
            }
            else
            {
                throw new ArgumentException("The resource type must be an infoblox class.");
            }
        }
Exemple #4
0
        public static string GetValue(this SearchType searchType)
        {
            FieldInfo fi = searchType.GetType().GetField(searchType.ToString());

            DescriptionAttribute[] attributes = fi.GetCustomAttributes(typeof(DescriptionAttribute), false) as DescriptionAttribute[];

            if (attributes != null && attributes.Any())
            {
                return(attributes.First().Description);
            }

            return(searchType.ToString());
        }
Exemple #5
0
        public async Task Get(SearchType st, params string[] args)
        {
            string param = "";
            string url   = "";
            string id;

            //lnc.ClearReqSeq();
            switch (st)
            {
            case SearchType.SONGS:
                param = NeParams.SEARCH.FormatE(args);
                url   = NeParams.NE_SEARCH;
                id    = st.ToString();
                break;

            case SearchType.DETAIL:
                param = NeParams.DETAIL.FormatE(args);
                url   = NeParams.NE_DETAIL;
                id    = st.ToString();
                break;

            case SearchType.DOWNLOAD:
                param = NeParams.DOWNLOAD.FormatE(args);
                url   = NeParams.NE_DOWNLOAD;
                id    = st.ToString();
                break;

            case SearchType.LYRIC:
                param = NeParams.LYRIC.FormatE(args);
                url   = NeParams.NE_LYRIC;
                id    = st.ToString();
                break;

            default:
                return;
            }
            param = Utils.GetEncodedParams(param);
            RBody r = new RBody()
            {
                URL           = url,
                RequestMethod = HttpMethod.POST
            };

            r.AddParameter("params", param);
            r.AddParameter("encSecKey", NeParams.encSecKey);
            lnc.AddRequestBody(r, id);
            await lnc.RequestAsyn();
        }
Exemple #6
0
		/// <summary>
		/// Returns the first occurrence of the given search-parameter.
		/// </summary>
		/// <param name="dataType">The type to search through (Schema, Item or Field).</param>
		/// <param name="searchType">If the given String should contain, start/end with or equal the searched entries.</param>
		/// <param name="searchBy">Searches for this String in every entry of given type.</param>
		/// <param name="limitBySchema">Optionally only search through a specific Schema.</param>
		/// <returns></returns>
		public static string Find(GDEDataType dataType, SearchType searchType, string searchBy, string limitBySchema = "")
		{
			foreach(var entry in ListAllBy(dataType))
			{
				switch(searchType)
				{
					case SearchType.Contains:
						if(entry.Contains(searchBy)) return entry;
						break;
					case SearchType.Equals:
						if(entry == searchBy) return entry;
						break;
					case SearchType.DoesNotContain:
						if(!entry.Contains(searchBy)) return entry;
						break;
					case SearchType.DoesNotEqual:
						if(entry != searchBy) return entry;
						break;
					case SearchType.StartsWith:
						if(entry.StartsWith(searchBy)) return entry;
						break;
					case SearchType.EndsWith:
						if(entry.EndsWith(searchBy)) return entry;
						break;
				}
			}

			UnityEngine.Debug.LogWarning("Couldn't find any matching " + searchBy.ToString()
										  + " which " + searchType.ToString() + " \"" + searchBy + "\".");

			return "";
		}
Exemple #7
0
        /// <summary>
        /// 사용자 정보를 가져옵니다.
        /// </summary>
        /// <param name="userID"></param>
        /// <returns></returns>
        public static DataTable GetProductList(SaleType saleType, SearchType searchType, string keyword, string searchCount)
        {
            DataTable  dt = new DataTable();
            DataAccess da = new SQLServerDB();

            if (!da.IsConnected)
            {
                Connect(ref da);
            }
            try
            {
                string          procedureName = "SP_GET_PRODUCT_LIST";
                ParameterEngine param         = ParameterEngine.New(da);
                param.Add("@SEARCH_TYPE", searchType.ToString().ToUpper());
                param.Add("@SALE_TYPE", saleType.ToString().ToUpper());
                param.Add("@KEY_WORD", keyword);
                param.Add("@SEARCH_COUNT", searchCount);


                DbCommand command = da.GenerateCommand(procedureName, CommandType.StoredProcedure, param);
                dt = da.GetData(command);
            }
            catch (Exception ex)
            {
                WriteTextLog("GetUserList", ex.Message.ToString());
            }
            finally
            {
                DisConnect(ref da);
            }

            return(dt);
        }
Exemple #8
0
 /// <summary>
 ///  SELECT指令查找邮件
 /// </summary>
 /// <param name="flags"></param>
 /// <returns></returns>
 public String SEARCHResponse(SearchType searchType)
 {
     streamWriter.WriteLine("A04 SEARCH " + searchType.ToString());
     streamWriter.Flush();
     response = readToEnd();
     return(response);
 }
Exemple #9
0
 private int GetSearchResultCount(IEnumerable <TraktSearchResult> searchResults, SearchType type)
 {
     if (searchResults == null)
     {
         return(0);
     }
     return(searchResults.Where(s => s.Type == type.ToString()).Count());
 }
Exemple #10
0
        public BookDatabase(string search, SearchType section)
        {
            DatabaseAccess dbAccess = new DatabaseAccess();

            data          = dbAccess.FetchSearchedBooksInDb(search, section.ToString());
            SearchTerm    = search;
            SearchMessage = "Showing results for: " + search + "\n\n";
        }
Exemple #11
0
 private Expression CreateCallExpression(Expression property, string query)
 {
     // LINQ to SQL does not support the overloads StartsWith(string, StringComparer) or EndsWith(string, StringComparer)
     // and Contains has not overload that takes a StringComparer
     if (SearchType == SearchType.Contains || (ViewState["ComparisonType"] == null))
     {
         return(Expression.Call(property, SearchType.ToString(), Type.EmptyTypes, Expression.Constant(query, property.Type)));
     }
     return(Expression.Call(property, SearchType.ToString(), Type.EmptyTypes, Expression.Constant(query, property.Type), Expression.Constant(ComparisonType)));
 }
Exemple #12
0
        public static string GetStringValue(this SearchType enumValue)
        {
            switch (enumValue)
            {
            case SearchType.QueryThenFetch: return("query_then_fetch");

            case SearchType.DfsQueryThenFetch: return("dfs_query_then_fetch");
            }
            throw new ArgumentException($"'{enumValue.ToString()}' is not a valid value for enum 'SearchType'");
        }
Exemple #13
0
        public static List <SongInfo> Search(string criteria, SearchType type)
        {
            StringBuilder url = new StringBuilder(Feeds[BeatSaverFeeds.SEARCH].BaseUrl);

            url.Replace(SEARCHTYPEKEY, type.ToString());
            url.Replace(SEARCHKEY, criteria);
            string pageText = GetPageText(url.ToString());

            return(ParseSongsFromPage(pageText));
        }
        public T SearchGames <T>(string query, SearchType searchType = SearchType.suggest, bool live = false) where T : new()
        {
            var request = _requestFactory("search/games", Method.GET);

            request.AddParameter("q", query);
            request.AddParameter("type", searchType.ToString().ToLower());
            var response = _restClient.Execute <T>(request);

            return(response.Data);
        }
        internal string Search(string queryKeywords, int limit, int offset, SearchType type)
        {
            limit = Math.Min(50, limit);
            StringBuilder builder = new StringBuilder(APIBase + "/search");

            builder.Append("?q=" + queryKeywords);
            builder.Append("&type=" + type.ToString().Replace(" ", ""));
            builder.Append("&limit=" + limit);
            builder.Append("&offset=" + offset);

            return(builder.ToString());
        }
Exemple #16
0
        public void Search()
        {
            string search = SearchString.Trim();

            if (search.Length > 0)
            {
                m_UnfilteredSearchResults.Clear();
                SearchResults.Clear();
                string type = m_SearchType.ToString().ToLowerInvariant();
                m_DataModel.ServerSession.Send(MPDCommandFactory.Search(type, SearchString));
            }
        }
Exemple #17
0
 public Task <SearchResultModel> SearchAsync(String query, SearchType types, Int32 offset = 0, Int32 limit = OpenTidlConstants.DEFAULT_LIMIT)
 {
     return(RestClient.HandleAsync <SearchResultModel>(
                "/search", new
     {
         query,
         types = types.ToString(),
         offset,
         limit,
         countryCode = GetCountryCode()
     }, null, "GET"));
 }
 public async Task <SearchResultModel> Search(String query, SearchType types, Int32 offset = 0, Int32 limit = 9999)
 {
     return(HandleResponse(await RestClient.Process <SearchResultModel>(
                               "/search", new
     {
         query = query,
         types = types.ToString(),
         offset = offset,
         limit = limit,
         token = Configuration.Token,
         countryCode = GetCountryCode()
     }, null, "GET")));
 }
Exemple #19
0
        public SearchItem Search(string q, SearchType searchType = SearchType.artist, string market = "US", int limit = 20, int offset = 0)
        {
            var queryParameters = new Dictionary <string, string>()
            {
                { "q", q },
                { "type", searchType.ToString().Replace(" ", string.Empty) },
                { "market", market },
                { "limit", limit.ToString() },
                { "offset", offset.ToString() }
            };

            return(Rest.SendRequestAndGetData <SearchItem>("/v1/search", queryParameters));
        }
Exemple #20
0
        public static async Task <List <Result> > Search(SearchType type, string name)
        {
            string route = string.Format("/{0}?name_en_cont={1}", type.ToString().ToLower(), name);

            SearchResponse response = await Request.Send <SearchResponse>(route);

            if (response.Results == null)
            {
                return(new List <Result>());
            }

            return(response.Results);
        }
        public string GetIdBySearch(SearchType type, string title, string artist, bool exact = true)
        {
            Dictionary <string, string> data = new Dictionary <string, string>();

            data.Add("type", type.ToString());
            if (!string.IsNullOrEmpty(title))
            {
                data.Add("title", title);
            }
            if (!string.IsNullOrEmpty(artist))
            {
                data.Add("artist", artist);
            }
            data.Add("exact", exact ? "yes" : "no");
            return(webController.RequestString("search_id", data));
        }
        private void FindMissingComponents(SearchType searchType)
        {
            switch (searchType)
            {
            case SearchType.Scene:
                FindMissingComponentsInScene();
                break;

            case SearchType.Prefabs:
                FindMissingComponentsInAssets();
                break;

            default:
                throw new System.NotImplementedException(searchType.ToString());
            }
        }
        GetCollection(SearchType searchType)
        {
            var productsRepo = typeof(ProductsColection)
                               .GetFields(BindingFlags.NonPublic | BindingFlags.Instance)
                               .FirstOrDefault(f => f.Name.EndsWith(searchType.ToString()));

            if (productsRepo == null)
            {
                throw new NotImplementedException("Search type not implemented yet");
            }

            var colleciton = productsRepo.GetValue(this)
                             as Dictionary <string, OrderedDictionary <decimal, SortedSet <Product> > >;

            return(colleciton);
        }
Exemple #24
0
        public static async Task <dynamic> GetLocation(SearchType searchType, string reference)
        {
            using (var client = new HttpClient())
            {
                // NOTE: HSL endpoint is not working anymore. Use hard coded data.
                //var jsonData = await client.GetStringAsync("http://dev.hsl.fi/siriaccess/vm/json?ProducerRef=HSL");
                var jsonData = HslJsonSample.Json;

                await Task.Delay(0);

                // Json example can use either SelectToken or indexers
                var locations = JObject.Parse(jsonData)
                                .SelectToken("Siri.ServiceDelivery.VehicleMonitoringDelivery")
                                .SelectMany(s => s["VehicleActivity"])
                                .Where(s => s.SelectToken($"MonitoredVehicleJourney.{searchType.ToString()}.value").ToString() == reference)
                                .Select(s => s["MonitoredVehicleJourney"])
                                .Select(s => new
                {
                    Lon = s["VehicleLocation"]["Longitude"],
                    Lat = s["VehicleLocation"]["Latitude"]
                })
                                .FirstOrDefault();

                // Example with generated model

                var data = JsonConvert.DeserializeObject <HslSiriData>(jsonData);

                var locationsFromModel = data.Siri.ServiceDelivery.VehicleMonitoringDelivery
                                         .SelectMany(e => e.VehicleActivity)
                                         .Where(e => searchType == SearchType.VehicleRef
                                ? e.MonitoredVehicleJourney.VehicleRef.Value == reference
                                : e.MonitoredVehicleJourney.LineRef.Value == reference)
                                         .Select(e => e.MonitoredVehicleJourney)
                                         .Select(e => new
                {
                    Lon = e.VehicleLocation.Longitude,
                    Lat = e.VehicleLocation.Latitude
                })
                                         .FirstOrDefault();

                return(locations);

                // TODO: Exception handling

                // var description = infoJson["company"]?.FirstOrDefault()?["procurationAbstractDescription"]?.FirstOrDefault(e => e["language"]?.Value<string>() == "Finnish")?["description"]?.Value<string>();
            }
        }
Exemple #25
0
        /// <summary>
        /// 获取话题数据
        /// </summary>
        /// <param name="theme"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public static List <ThemeRepo> GetThemeRepos(string theme, SearchType type = SearchType.Repositories)
        {
            ATLog.Info("获取Github上关注的话题");
            List <ThemeRepo> repos = new List <ThemeRepo>();

            StringBuilder conditions = new StringBuilder();

            conditions.Append("?");
            conditions.Append(Conditions.SetQueryKeyWord(theme));

            string requestURL = Conditions.SetRequestRootURL(type.ToString()) + conditions.ToString();

            Console.WriteLine(requestURL);
            HttpWebRequest httpWebRequest = WebRequest.CreateHttp(requestURL);

            httpWebRequest.Accept    = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8";
            httpWebRequest.UserAgent = "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36";
            //httpWebRequest.ContentType = "application/json";
            httpWebRequest.Method = "GET";

            HttpWebResponse httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse();

            if (httpWebResponse.StatusCode == HttpStatusCode.OK)
            {
                //Console.WriteLine("状态返回值: success");
                Stream       stream     = (Stream)httpWebResponse.GetResponseStream();
                StreamReader sr         = new StreamReader(stream);
                string       resultJson = sr.ReadToEnd();
                resultJson = resultJson.Replace("private", "_private");
                RepositoriesEntity repositoriesResult = JsonConvert.DeserializeObject <RepositoriesEntity>(resultJson);

                RepositoriesResultItem[] items = repositoriesResult.items;
                for (int i = 0; i < items.Length; i++)
                {
                    ThemeRepo themeRepo = new ThemeRepo(items[i].full_name, items[i].html_url, items[i].description, items[i].stargazers_count, items[i].language, items[i].score, items[i].owner.login);
                    repos.Add(themeRepo);
                }
                //Console.WriteLine(repositoriesResult.total_count);
            }

            if (repos.Count != 0)
            {
                GithubOp.Instance.SaveRangeData(repos);
            }

            return(repos);
        }
 internal string CreateRequestUrl(string baseUrl)
 {
     baseUrl += $"s={Name}";
     if (SearchType != 0)
     {
         baseUrl += $"&type={SearchType.ToString()}";
     }
     if (Year != 0)
     {
         baseUrl += $"&y={Year}";
     }
     if (Page != 0)
     {
         baseUrl += $"&page={Page}";
     }
     return(baseUrl);
 }
        /// <summary>
        /// Set the state of the individual search as part of the overall search being performed
        /// </summary>
        /// <param name="token">The token that was given as part of the setup</param>
        /// <param name="searchType">The type of search element that is wanting to be modified</param>
        /// <param name="state">The new state of the search element</param>
        /// <returns>If the setting of the state was successful</returns>
        public Boolean SetState(String token, SearchType searchType, SearchState state)
        {
            // Construct the table entry for this search and insert it in to the storage account so it
            // can be retrieved by the token later
            SearchEntry searchEntry = new SearchEntry(token, searchType, state);

            searchEntry.ETag = "*";
            TableOperation insertOp = TableOperation.Replace(searchEntry);
            TableResult    result   = table.ExecuteAsync(insertOp).Result;

            // Success but no content? If not then it failed and it should be reported back to the caller
            if (result.HttpStatusCode != (int)HttpStatusCode.NoContent)
            {
                throw new Exception($"Failed to update state for '{searchType.ToString()}' - Status Code {result.HttpStatusCode.ToString()}");
            }

            return(true);
        }
 private void SetSearcher(SearchType type)
 {
     if (_searcher is not null && _searcher?.Type == type)
     {
         return;
     }
     _searcher = type switch
     {
         SearchType.Fulltext => new FullTextSearch(),
         SearchType.Errors => new ErrorsSearch(),
         SearchType.Match => new MatchSearch(),
         SearchType.Regex => new RegexSearch(),
         SearchType.Full => new AllDocSearch(),
         SearchType.Or => new AggregateSearch(),
         SearchType.Not => new NotAndSearch(),
         _ => throw new ArgumentException(type.ToString())
     };
 }
Exemple #29
0
        public static SearchResults Search(SearchType searchType, string phrase, int pageIndex)
        {
            string searchUrl = null;

            switch (searchType)
            {
            case SearchType.Web:
                searchUrl = SearchWebUrl;
                break;

            case SearchType.Video:
                searchUrl = SearchVideoUrl;
                break;

            case SearchType.Patent:
                searchUrl = SearchPatentUrl;
                break;

            case SearchType.News:
                searchUrl = SearchNewsUrl;
                break;

            case SearchType.Local:
                searchUrl = SearchLocalUrl;
                break;

            case SearchType.Image:
                searchUrl = SearchImageUrl;
                break;

            case SearchType.Book:
                searchUrl = SearchBookUrl;
                break;

            case SearchType.Blog:
                searchUrl = SearchBlogUrl;
                break;

            default:
                throw new NotSupportedException("SearchType: " + searchType.ToString());
            }

            return(DoSearch(phrase, searchUrl, pageIndex));
        }
Exemple #30
0
        /// <summary>
        /// Run a random test search with obstacles
        /// </summary>
        static void RunSearchRandomGrid()
        {
            int w = r.Next(5, 25);
            int h = r.Next(5, 25);

            int sx = r.Next(0, w / 2);
            int sy = r.Next(0, h / 2);

            int gx = r.Next(0, w);
            int gy = r.Next(0, h);

            SearchType type = SEARCH_TYPES[r.Next(0, SEARCH_TYPES.Length)];

            int[,] rgrid = GenerateGridWithObstacles(sx, sy, gx, gy, w, h);

            // Create a new search problem
            PathSearchProblem problem = new PathSearchProblem(sx, sy, gx, gy, w, h, rgrid);

            // Display problem information
            Console.WriteLine(problem.ToString());
            Console.WriteLine("Search method: " + type.ToString());

            // Run search
            var search = new UninformedSearchAlgorithm(type);
            var goal   = search.Search(problem, r.Next(1, 15));

            //Print resulting steps and cost
            if (goal == Node.FAILURE)
            {
                Console.WriteLine("No path found");
            }
            else if (goal == Node.CUTOFF)
            {
                Console.WriteLine("Cutoff occured");
            }
            else
            {
                Console.WriteLine(goal.State.ToString());
                Console.WriteLine("Goal cost: " + goal.PathCost);
            }
        }
Exemple #31
0
    public void UpdateBrowseQuery(UrlQuery urlQuery)
    {
        urlQuery.RemoveQuery("Type");
        urlQuery.RemoveQuery("FieldName");
        urlQuery.RemoveQuery("FieldValue");
        urlQuery.RemoveQuery("Value1");
        urlQuery.RemoveQuery("Value2");

        if (SearchType != SearchFilterType.None)
        {
            urlQuery.AddQuery("Type", SearchType.ToString());
            urlQuery.AddQuery("FieldName", FieldName);
            urlQuery.AddQuery("FieldValue", FieldValue);
            urlQuery.AddQuery("Value1", Value1);

            if (!String.IsNullOrEmpty(Value2))
            {
                urlQuery.AddQuery("Value2", Value2);
            }
        }
    }
Exemple #32
0
 public override List<MailHeadModel> GetMailHeaders(SearchType searchType)
 {
     return GetMailHeaders(searchType.ToString());
 }
 /// <summary>
 ///  SELECT指令查找邮件
 /// </summary>
 /// <param name="flags"></param>
 /// <returns></returns>
 public String SEARCHResponse(SearchType searchType)
 {
     streamWriter.WriteLine("A04 SEARCH " + searchType.ToString());
     streamWriter.Flush();
     response = readToEnd();
     return response;
 }
 //Attempts to enter the given text string in a specific element on the page, with specific and default exception handling
 public void TextEntry(SearchType type, string searchText, string input)
 {
     try{
         IWebElement textField;
         if (type == SearchType.Id){
             textField = WebDriver.FindElement(By.Id(searchText));
         }
         else if (type == SearchType.LinkText){
             textField = WebDriver.FindElement(By.LinkText(searchText));
         }
         else if (type == SearchType.Name){
             textField = WebDriver.FindElement(By.Name(searchText));
         }
         else if (type == SearchType.Xpath){
             textField = WebDriver.FindElement(By.XPath(searchText));
         }
         else{
             textField = null;
             System.Console.WriteLine(type.ToString() + " is an unsupported SearchType for this method.");
         }
         textField.Clear();
         textField.SendKeys(input);
         System.Console.WriteLine("Text '{0}' entered successfully in '{1}'", input, searchText);
     }
     catch (NoSuchElementException ex){
         System.Console.WriteLine("Could not successfully enter text '{0}' in '{1}'", input, searchText);
         System.Console.WriteLine(ex.ToString());
         return;
     }
     catch (Exception ex){
         System.Console.WriteLine("Unspecified exception in TextEntry().");
         System.Console.WriteLine(ex.ToString());
         return;
     }
 }
 /// <summary>
 /// starts a search with the htmlpage
 /// </summary>
 /// <param name="searchitem">the searchitem as string</param>
 /// <param name="searchtype">the type of search "album, tracks..."</param>
 /// <returns></returns>
 public XmlDocument RequestSearch(string search, SearchType searchType)
 {
     returnAction("Request Search(" + searchType.ToString() + "):" + search);
     XmlDocument doc = new XmlDocument();
     if (_serverListItem.Anonymus)
     {
         search = _serverListItem.Url + "api.php?output=xml&query=" + search + "&search_type=" + searchType.ToString().Replace("SearchType.", "");
     }
     else
     {
         search = _serverListItem.Url + "api.php?output=xml&user="******"&pass="******"&query=" + search + "&search_type=" + searchType.ToString().Replace("SearchType.", "");
     }
     //startRequest(search, "");
     if (startRequest(search, "") != null)
     {
         doc.Load(startRequest(search, ""));
     }
     stopRequest();
     returnAction("Request Search Completed");
     return doc;
 }
 //Just  object exists
 //Attempts to verify that an element exists on the page, with specific and default exception handling
 //Returns the string if found, "" if not found
 public string Validate(SearchType type, string text){
     try{
         string textString;
         if (type == SearchType.Id){
             textString = WebDriver.FindElement(By.Id(text)).Text;
         }
         else if (type == SearchType.LinkText){
             textString = WebDriver.FindElement(By.LinkText(text)).Text;
         }
         else if (type == SearchType.Name){
             textString = WebDriver.FindElement(By.Name(text)).Text;
         }
         else if (type == SearchType.Xpath){
             textString = WebDriver.FindElement(By.XPath(text)).Text;
         }
         else{
             System.Console.WriteLine(type.ToString() + " is an unsupported SearchType for this method.");
             return "";
         }
         System.Console.WriteLine("{0} '{1}' found", type.ToString(), text);
         return textString;
     }
     catch (NoSuchElementException ex) {
         System.Console.WriteLine("Could not successfully find {0} '{1}'", type.ToString(), text);
         System.Console.WriteLine(ex.ToString());
         return "";
     }
     catch (Exception ex){
         System.Console.WriteLine("Unspecified exception in Validate().");
         System.Console.WriteLine(ex.ToString());
         return "";
     }
 }
Exemple #37
0
 public MailHeadList GetMailHeads(SearchType searchType)
 {
     return new MailHeadList(imapBase, searchType.ToString());
 }