Exemplo n.º 1
0
        private void addFav(object sender, RoutedEventArgs e)
        {
            btnAddFav.Background      = new SolidColorBrush(Color.FromRgb(71, 135, 237));
            btnAddFav.BorderBrush     = new SolidColorBrush(Colors.DarkGray);
            btnAddFav.BorderThickness = new Thickness(1);
            btnAddFav.Content         = "Favourite";
            btnAddFav.Foreground      = new SolidColorBrush(Colors.White);
            Query q = new Query();

            q.setqueryString(this.getSearchBoxText());
            q.setyhi(this.getYhi());
            q.setylo(this.getYlo());
            if (this.getSortOrder() == SortOrder.DATE)
            {
                q.sortOrder = SortOrder.DATE;
            }
            else
            {
                q.sortOrder = SortOrder.CITATIONS;
            }
            if (this.getResultType() == ResultType.AUTHOR)
            {
                q.resultType = ResultType.AUTHOR;
            }
            else
            {
                q.resultType = ResultType.JOURNAL;
            }
            q.setpageid(currentPageSelected);
            fav.addFavourite(q);
        }
Exemplo n.º 2
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);
            }
        }
Exemplo n.º 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;

                   }
        }
Exemplo n.º 4
0
 private void addFav(object sender, RoutedEventArgs e)
 {
     btnAddFav.Background = new SolidColorBrush(Color.FromRgb(71, 135, 237));
     btnAddFav.BorderBrush = new SolidColorBrush(Colors.DarkGray);
     btnAddFav.BorderThickness = new Thickness(1);
     btnAddFav.Content = "Favourite";
     btnAddFav.Foreground = new SolidColorBrush(Colors.White);
     Query q = new Query();
     q.setqueryString(this.getSearchBoxText());
     q.setyhi(this.getYhi());
     q.setylo(this.getYlo());
     if (this.getSortOrder() == SortOrder.DATE)
         q.sortOrder = SortOrder.DATE;
     else
         q.sortOrder = SortOrder.CITATIONS;
     if (this.getResultType() == ResultType.AUTHOR)
         q.resultType = ResultType.AUTHOR;
     else
         q.resultType = ResultType.JOURNAL;
     q.setpageid(currentPageSelected);
     fav.addFavourite(q);
 }