public void RegisterationSetup()
 {
     _homePage     = new HomePage(ActiveBrowser.WebDriverInstance);
     _registerPage = new RegisterPage(ActiveBrowser.WebDriverInstance);
     _searchAPI    = new SearchAPI();
     password      = "******";
 }
Example #2
0
        public async Task <Embed> GetMount(string search)
        {
            List <SearchAPI.Result> results = await SearchAPI.Search(SearchAPI.SearchType.Mounts, search);

            if (results.Count <= 0)
            {
                throw new UserException("I couldn't find any mounts that match that search.");
            }

            if (results.Count > 1)
            {
                EmbedBuilder embed = new EmbedBuilder();

                StringBuilder description = new StringBuilder();
                for (int i = 0; i < Math.Min(results.Count, 10); i++)
                {
                    description.AppendLine(results[i].ID + " - " + results[i].Name);
                }

                embed.Title       = results.Count + " results found";
                embed.Description = description.ToString();
                return(embed.Build());
            }

            ulong?id = results[0].ID;

            if (id == null)
            {
                throw new Exception("No Id in mount");
            }

            return(await this.GetMount(id.Value));
        }
Example #3
0
        public static async Task SearchByKeywordMfrRequestAsync(ApplicationContext context, Proxy proxy, ApiRegInfo apiRegInfo, string keyword, Manufacturer manufacturer, int records, int startingRecord)
        {
            using (var searchAPI = new SearchAPI())
            {
                var header = new MouserHeader();
                header.AccountInfo           = new AccountInfo();
                header.AccountInfo.PartnerID = apiRegInfo.PartnerId;
                searchAPI.MouserHeaderValue  = header;

                WebProxy wp = new WebProxy(proxy.IPAddress, true);
                if (proxy.UserName != "")
                {
                    ICredentials credentials = new NetworkCredential(proxy.UserName, proxy.Password);
                    wp.Credentials = credentials;
                }
                searchAPI.Proxy = wp;

                ResultParts resultParts = searchAPI.SearchByKeywordAndManufacturer(keyword, manufacturer.MouserID, records, startingRecord, String.Empty, String.Empty);

                EFManufacturer eFManufacturer = new EFManufacturer(context);
                manufacturer.StartingRecord = startingRecord;
                manufacturer.NumberOfResult = resultParts.NumberOfResult;
                await eFManufacturer.AddOrUpdateAsync(manufacturer, manufacturer.Id);

                foreach (var resultPart in resultParts.Parts.ToList())
                {
                    await SaveGoodAsync(context, resultPart, manufacturer);
                }
            }
        }
Example #4
0
        public ActionResult Test1(string querytxt)
        {
            IEnumerable <Sitecore.Data.Items.Item> datamodel;
            SearchAPI searchapi = new SearchAPI();

            datamodel = searchapi.BasicSearch(querytxt);
            return(View(datamodel));
        }
Example #5
0
        //
        // GET: /SearchAutoComplete/
        public ActionResult AutoComplete(string querytxt)
        {
            string    datamodel;
            SearchAPI searchapi = new SearchAPI();

            datamodel = searchapi.AutoComplete("New");

            return(View("AutoComplete", model: datamodel));
        }
        public override void Execute(Message message, TelegramBotClient client)
        {
            List <YouTubeSearchResult> searchResults = SearchAPI.YouTubeSearch(message.Text, BotSettings.GoogleApiKey);
            string msg = null;

            foreach (var result in searchResults)
            {
                msg = "*Title:* " + result.Title + '\n' +
                      "*Link:* " + result.Link;

                client.SendTextMessageAsync(message.Chat.Id, msg, ParseMode.Markdown);
            }
        }
        public async Task <ActionResult> Search(SearchDocModel searchmodel)
        {
            AzSearchModel azSearchModel = new AzSearchModel {
                search = searchmodel.search, skip = searchmodel.pageNo * pageSize, top = pageSize
            };

            var items = await SearchAPI.GetDocListAsync(azSearchModel);

            ViewData["pageNo"]                 = searchmodel.pageNo;
            ViewData["IsSearchQuery"]          = (searchmodel.search == null) ? string.Empty : searchmodel.search;
            ViewData["pageSize"]               = pageSize;
            ViewData["totalRemainingPageSize"] = (int)Math.Ceiling((double)items.odatacount / pageSize) - searchmodel.pageNo;

            return(View(items.value));
        }
 public SpotifyController(ILogger <SpotifyController> logger,
                          HttpClient httpClient,
                          SpotifyClient spotifyClient,
                          HelperMethods helperMethods,
                          ComputerVisionAPI computerVisionAPI,
                          CosmosAPI cosmosAPI,
                          SearchAPI searchAPI)
 {
     this.logger            = logger;
     this.httpClient        = httpClient;
     this.spotifyClient     = spotifyClient;
     this.helperMethods     = helperMethods;
     this.computerVisionAPI = computerVisionAPI;
     this.cosmosAPI         = cosmosAPI;
     this.searchAPI         = searchAPI;
 }
Example #9
0
        public async Task GetMarketBoardItem(CommandMessage message, string search)
        {
            List <SearchAPI.Result> results = await SearchAPI.Search(search, "Item");

            if (results.Count <= 0)
            {
                throw new UserException("I couldn't find any items that match that search.");
            }

            ulong?id;

            SearchAPI.Result exactMatch = results.FirstOrDefault(x => search.Equals(x.Name, StringComparison.InvariantCultureIgnoreCase));
            if (exactMatch != null)
            {
                id = exactMatch.ID;
            }
            else if (results.Count > 1)
            {
                EmbedBuilder embed = new EmbedBuilder();

                StringBuilder description = new StringBuilder();
                for (int i = 0; i < Math.Min(results.Count, 10); i++)
                {
                    description.AppendLine(results[i].ID + " - " + results[i].Name);
                }

                embed.Title       = results.Count + " results found";
                embed.Description = description.ToString();

                await message.Channel.SendMessageAsync(embed: embed.Build());

                return;
            }
            else
            {
                id = results[0].ID;
            }

            if (id == null)
            {
                throw new Exception("No Id in item");
            }

            await this.GetMarketBoardItem(message, id.Value);

            return;
        }
Example #10
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.Configure <SpotifyOptions>(Configuration.GetSection(SpotifyOptions.SectionName));
            services.Configure <ComputerVisionOptions>(Configuration.GetSection(ComputerVisionOptions.SectionName));
            services.Configure <CosmosOptions>(Configuration.GetSection(CosmosOptions.SectionName));
            services.Configure <SearchOptions>(Configuration.GetSection(SearchOptions.SectionName));

            services.AddScoped <SpotifyClient>(s =>
            {
                IOptions <SpotifyOptions> spotifyOptions = s.GetRequiredService <IOptions <SpotifyOptions> >();
                return(new SpotifyClient(spotifyOptions.Value.ClientId, spotifyOptions.Value.ClientSecret, spotifyOptions.Value.RedirectUrl));
            });
            services.AddSingleton <HttpClient>();
            services.AddSingleton <ComputerVisionAPI>(s =>
            {
                IOptions <ComputerVisionOptions> computerVisionOptions = s.GetRequiredService <IOptions <ComputerVisionOptions> >();
                HttpClient httpClient = s.GetRequiredService <HttpClient>();
                return(new ComputerVisionAPI(computerVisionOptions, httpClient));
            });
            services.AddSingleton <CosmosAPI>(s =>
            {
                IOptions <CosmosOptions> cosmosOptions = s.GetRequiredService <IOptions <CosmosOptions> >();
                CosmosAPI cosmosAPI = new CosmosAPI(cosmosOptions);
                // ensure CosmosAPI is setup before startup
                // Service setup can't be async so use this...
                cosmosAPI.Setup().GetAwaiter().GetResult();
                return(cosmosAPI);
            });
            services.AddSingleton <SearchAPI>(s =>
            {
                IOptions <SearchOptions> searchOptions = s.GetRequiredService <IOptions <SearchOptions> >();
                SearchAPI searchAPI = new SearchAPI(searchOptions);
                return(searchAPI);
            });
            services.AddSingleton <HelperMethods>();

            services.AddControllers();
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo {
                    Title = "AlbumImageSearch", Version = "v1"
                });
            });
        }
Example #11
0
        public void SearchCatalogAsAssets()
        {
            Task.Run(async() =>
            {
                Asset[] results = await SearchAPI.SearchAssets(TestConstants.TestSearchKeyword, ESearchCategory.AllInCatalog);

                Assert.IsNotNull(results);

                Assert.IsTrue(results.Length > 0);

                Type ty = typeof(Asset);
                foreach (Asset res in results)
                {
                    foreach (PropertyInfo info in ty.GetProperties())
                    {
                        Console.WriteLine("{0} = {1}", info.Name, info.GetGetMethod().Invoke(res, new object[] { }));
                    }
                    Console.WriteLine("---");
                }
            }).Wait(TestConstants.MaxMilisecondTimeout);
        }
		/// <summary>
		/// 构造函数
		/// </summary>
		/// <param name="client">操作类</param>
		public SearchInterface(Client client)
			: base(client)
		{
			api = new SearchAPI(client);
		}
Example #13
0
 /// <summary>
 ///     构造函数
 /// </summary>
 /// <param name="client">操作类</param>
 public SearchInterface(Client client)
     : base(client)
 {
     api = new SearchAPI(client);
 }