public List <SearchResult> getResults(String query, int itemsPerPage, int page)
        {
            const string        apiKey         = "AIzaSyCbwi1U_KFwou26QLz1 - K8P5y0pJRwQm30";
            const string        searchEngineId = "006347468050510818806:bdoeuah7j4m";
            CustomsearchService service        = new CustomsearchService(new BaseClientService.Initializer {
                ApiKey = apiKey
            });
            ListRequest request = service.Cse.List(query);

            request.Cx    = searchEngineId;
            request.Num   = itemsPerPage;
            request.Start = itemsPerPage * page;

            List <SearchResult> results = new List <SearchResult>();

            foreach (var item in request.Execute().Items)
            {
                results.Add(
                    new SearchResult {
                    Title = item.Title, Link = item.Link
                }
                    );
            }
            return(results);
        }
Esempio n. 2
0
        private Google.Apis.Customsearch.v1.Data.Search HandleSearchRequest(CustomsearchService service, string[] args)
        {
            string      query_input = PrepareInput(args);
            ListRequest listRequest = service.Cse.List(query_input);

            listRequest.Cx   = Program.config.GoogleSearchEngineID;
            listRequest.Safe = this.SafeSearch;
            Google.Apis.Customsearch.v1.Data.Search search = listRequest.Execute();
            return(search);
        }
Esempio n. 3
0
        public static string translate(string english, string language)
        {
            string[]    srcText = new[] { english };
            ListRequest request = service.Translations.List(srcText, language);

            request.Source = "en";
            TranslationsListResponse response = request.Execute();
            String translated_text            = response.Translations[0].TranslatedText;

            return(switchSingleQuoteToCurlyClosingQuote(translated_text));
        }
        private IEnumerable <Firewall> GetProjectFirewalls()
        {
            string pageToken = null;

            do
            {
                ListRequest request = Service.Firewalls.List(Project);
                request.PageToken = pageToken;
                FirewallList response = request.Execute();
                if (response.Items != null)
                {
                    foreach (Firewall firewall in response.Items)
                    {
                        yield return(firewall);
                    }
                }
                pageToken = response.NextPageToken;
            } while (pageToken != null);
        }
        public async virtual Task <List <SearchResult> > GetSearchResultsAsync(string query)
        {
            //TODO: Need to add a logger, NLog for example
            try
            {
                if (string.IsNullOrEmpty(query))
                {
                    return(null);
                }

                ListRequest listRequest = CreateListRequest(query);

                return(await Task.Run(() => { return Map(listRequest.Execute()); }));
            }
            catch (Exception ex)
            {
                await Task.Delay(10000);

                return(null);
            }
        }
        public static Google.Apis.Drive.v3.Data.File FindFirstFolder(string FolderName, string ParentID = null)
        {
            ParentID = ParentID ?? ParentDrive;
            ListRequest listRequest = new ListRequest(driveService)
            {
                Q                         = "name = '" + FolderName + "' and mimeType = 'application/vnd.google-apps.folder' and '" + ParentID + "' in parents and trashed = false",
                Spaces                    = "drive",
                Fields                    = "files(id)",
                SupportsAllDrives         = true,
                IncludeItemsFromAllDrives = true,
            };
            FileList result = listRequest.Execute();

            if (result.Files.Count == 0)
            {
                return(null);
            }
            else
            {
                return(result.Files[0]);
            }
        }
Esempio n. 7
0
        public void UpList()
        {
            Xamarin.Forms.Application.Current.Properties["Boff"] = "Uploading Files, Please Wait.";
            FilesResource bung = new FilesResource(driver);
            ListRequest   req  = bung.List();

            req.Q = "'root' in parents and trashed=false";
            FileList jonny = req.Execute();

            // try{
            (bool, bool, bool)set = (false, false, false);
            foreach (Google.Apis.Drive.v3.Data.File x in jonny.Files)
            {
                if (x.MimeType == "application/vnd.ms-excel")
                {
                    if (x.Name == "Pricings.xls")
                    {
                        Xamarin.Forms.Application.Current.Properties["Boff"] += "\nUploading: " + x.Name;
                        set.Item1 = true;
                        FiletoStream(x, "Pricings.xls");
                    }
                    else if (x.Name == "Plots.xls")
                    {
                        Xamarin.Forms.Application.Current.Properties["Boff"] += "\nUploading: " + x.Name;
                        set.Item2 = true;
                        FiletoStream(x, "Plots.xls");
                    }
                    else if (x.Name == "trees.xls")
                    {
                        Xamarin.Forms.Application.Current.Properties["Boff"] += "\nUploading: " + x.Name;
                        set.Item3 = true;
                        FiletoStream(x, "trees.xls");
                    }
                }
            }
            CreateFiles(set);
        }
Esempio n. 8
0
        private void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            try
            {
                if (ListRequest != null)
                {
                    IList <Message> messages = ListRequest.Execute().Messages;

                    if (messages != null && messages.Count > 0)
                    {
                        foreach (var msgItem in messages)
                        {
                            var emailInfoRequest  = GmailService.Users.Messages.Get("me", msgItem.Id);
                            var emailInfoResponse = emailInfoRequest.Execute();

                            if (emailInfoResponse != null)
                            {
                                string   date     = emailInfoResponse.Payload.Headers.First(x => x.Name == "Date").Value;
                                DateTime exitDate = DateTime.Parse(date);
                                if (exitDate.Day == DateTime.Now.Day)
                                {
                                    timer.Stop();
                                    if (!isExited)
                                    {
                                        isExited = true;
                                        OnUniversalCondition(null, null);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }