Beispiel #1
0
 public void OnTimedEvent(object source, ElapsedEventArgs e)
 {
     Searcher.CancelAsync();
     aTimer.Enabled = false;
     aTimer.Stop();
     TabPage.displayError("Connection Timed Out. Please Check your Internet Connection.");
 }
Beispiel #2
0
        private void export(object sender, RoutedEventArgs e)
        {
            var fileDialog = new System.Windows.Forms.SaveFileDialog();

            fileDialog.Title    = "Export Results file";
            fileDialog.FileName = "Export";
            fileDialog.Filter   = "Tab separated values|*.tsv";

            if (fileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK && fileDialog.FileName != "")
            {
                if (Exporter.exportResults(this.resultList, fileDialog.FileName))
                {
                    TabPage.displayError("Export Success !!");
                    updateStatusBar("Export Success !!!");
                }
                else
                {
                    TabPage.displayError("Export Failed !!");
                    updateStatusBar("Export Failed !!!");
                }
            }
        }
Beispiel #3
0
        public ResultList initiateSearch(data d)
        {
            String queryString = d.qs;

            //tab.getSearchBoxText();
            if (d.b.CancellationPending)
            {
                return(null);
            }
            if (queryString == null || queryString == "")
            {
                TabPage.displayError("Please Enter a Query");
                return(null);
            }

            d.b.ReportProgress(0, null);
            int        ylo = d.yl;
            int        yhi = d.yh;              //tab.getYhi();
            Boolean    includeCitations = d.ic; // tab.getIncludePatents();
            SortOrder  sortOrder        = d.so; //tab.getSortOrder();
            ResultType resultType       = d.rt; // tab.getResultType();

            d.b.ReportProgress(10, null);
            Query query = new Query();

            query.setqueryString(queryString);
            if (ylo != 0)
            {
                query.setylo(ylo);
            }
            if (yhi != 0)
            {
                query.setyhi(yhi);
            }
            query.setincludePatents(includeCitations);
            query.sortOrder  = sortOrder;
            query.resultType = resultType;
            query.setpageid(d.pageId);

            if (d.b.CancellationPending)
            {
                return(null);
            }

            //bool networkUp = System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable();
            bool networkUp = Controller.CheckForInternetConnection();

            Console.WriteLine(networkUp);
            if (networkUp)
            {
                Searcher   searcher     = new Searcher();
                ResultList resultListGS = new ResultList();

                ResultList resultListMS = new ResultList();

                ResultList resultList = new ResultList();


                SearchType type;
                d.b.ReportProgress(20, null);
                resultListGS = searcher.GSsearch(query);
                if (d.b.CancellationPending)
                {
                    return(null);
                }
                d.b.ReportProgress(50, null);
                resultListMS = searcher.MSASsearch(query);
                if (d.b.CancellationPending)
                {
                    return(null);
                }
                d.b.ReportProgress(70, null);

                if (resultListMS != null)
                {
                    resultList = resultListMS;
                }
                else if (resultListMS == null && resultListGS != null)
                {
                    resultList = resultListGS;
                }
                else
                {
                    TabPage.displayError("Cannot connect to Data Sources.");
                    return(null);
                }
                if (d.b.CancellationPending)
                {
                    return(null);
                }

                d.b.ReportProgress(85, null);

                if (resultListGS != null)
                {
                    if (resultListGS.type != null)
                    {
                        resultList.type = resultListGS.type;
                    }
                }
                else
                {
                    MSASQueryURLBuilder MSQ = new MSASQueryURLBuilder();
                    String URL = "";
                    if (resultType == ResultType.AUTHOR)
                    {
                        URL = MSQ.buildAuthorUrl(queryString);
                    }
                    else if (resultType == ResultType.JOURNAL)
                    {
                        URL = MSQ.buildJournalUrl(queryString);
                    }

                    Uri url = new Uri(URL);
                    Console.WriteLine(url.ToString());
                    MSASParser parser = new MSASParser();
                    if (resultType == ResultType.AUTHOR)
                    {
                        resultList.resultType = ResultType.AUTHOR;
                        resultList.type       = parser.MSParseProfile(url, queryString, resultType);
                    }
                    else
                    {
                        resultList.resultType = ResultType.JOURNAL;
                        resultList.loadType();
                        Console.WriteLine("Reached");
                        resultList.type = (Journal)parser.MSParseJournal(queryString);
                        Console.WriteLine(";;;;;" + resultList.type);
                    }
                    if (d.b.CancellationPending)
                    {
                        return(null);
                    }
                }

                //      tab.setResult(resultList);

                if (d.b.CancellationPending)
                {
                    return(null);
                }

                d.b.ReportProgress(100, null);
                return(resultList);
            }

            else
            {
                TabPage.displayError("Oops !! No Internet Connection !!!");

                return(null);
            }
        }
Beispiel #4
0
        public Result GSConnect(Uri URL)
        {
            //Console.WriteLine(URL.ToString());


            String       strResponse = this.GSTryConnect(URL);
            HtmlDocument document    = new HtmlDocument();

            document.Load(new StringReader(strResponse));

            String resTitle     = "";
            String resAuthor    = "";
            String resContent   = "";
            String resCite      = "";
            String resLink      = "";
            String profileLink  = "";
            String resTitleLink = "";

            Result result = new Result();



            HtmlNode testNode = document.DocumentNode.SelectSingleNode("//div[@id='gs_ccl']/p[@class='gs_med']");

            if (testNode != null)
            {
                TabPage.displayError("No Results Found ! Please Try Again!!!");
                return(null);
            }



            testNode = document.DocumentNode.SelectSingleNode("//div[@class='gs_r']/div[@class='gs_ri']");
            if (testNode != null)
            {
                foreach (HtmlNode startNode in document.DocumentNode.SelectNodes("//div[@class='gs_r']/div[@class='gs_ri']"))
                {
                    Paper paper = new Paper();

                    HtmlNode titleNode = startNode.SelectSingleNode("h3[@class='gs_rt']");

                    resTitle = titleNode.InnerText;
                    paper.settitle(resTitle);

                    HtmlNode authorLinkNode = titleNode.SelectSingleNode("a[@href]");

                    resTitleLink = authorLinkNode.Attributes["href"].Value;

                    paper.seturl(new Uri(resTitleLink));

                    HtmlNode authorNode = startNode.SelectSingleNode("div[@class='gs_a']");


                    resAuthor = authorNode.InnerText;
                    paper.setauthors(resAuthor);


                    HtmlNode contentNode = startNode.SelectSingleNode("div[@class='gs_rs']");

                    if (contentNode != null)
                    {
                        resContent = contentNode.InnerText;
                        if (resContent != null)
                        {
                            paper.setdescription(resContent);
                        }
                    }


                    HtmlNode citeNode = startNode.SelectSingleNode("div[@class='gs_fl']");

                    int numCite;
                    if (citeNode != null)
                    {
                        HtmlNode citeInfoNode = citeNode.SelectSingleNode("a[@href]");

                        resCite = citeInfoNode.InnerText;
                        if (resCite.Contains("Cited by"))
                        {
                            resCite = resCite.Replace("Cited by ", "");
                            numCite = Convert.ToInt32(resCite);
                            paper.setnumCitations(numCite);
                            resLink = citeInfoNode.Attributes["href"].Value;

                            paper.setcitationsUrl(resLink);
                        }
                        else
                        {
                            numCite = 0;
                            paper.setnumCitations(numCite);
                        }
                    }
                    else
                    {
                        numCite = 0;
                        paper.setnumCitations(numCite);
                    }


                    result.addPaper(paper);
                }
                return(result);
            }

            else
            {
                //TabPage.displayError("GS Blocking!!!");
                return(null);
            }
        }