當前位置: 首頁>>代碼示例>>C#>>正文


C# Author.setiIndex方法代碼示例

本文整理匯總了C#中Author.setiIndex方法的典型用法代碼示例。如果您正苦於以下問題:C# Author.setiIndex方法的具體用法?C# Author.setiIndex怎麽用?C# Author.setiIndex使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Author的用法示例。


在下文中一共展示了Author.setiIndex方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: MSParseProfile

        public SearchType MSParseProfile(Uri URL, String compareName, ResultType resType)
        {
            Author author = new Author();
            String type = "Author";
            if (resType == ResultType.AUTHOR)
            {
                type = "Author";
            }
            else if (resType == ResultType.JOURNAL)
            {
                type = "Journal";
            }
            WebClient wc = new WebClient();
            wc.Proxy = WebProxy.GetDefaultProxy();

            var data = wc.DownloadString(URL);
            //Console.WriteLine(data);

            JObject obj = JObject.Parse(data);
            int resultCount = 0;

            /*  while (resultCount < obj["d"]["Author"]["Result"].Count())
              {
                


                 String firstName = (String)obj["d"]["Author"]["Result"][resultCount]["FirstName"];
                  String lastName = (String)obj["d"]["Author"]["Result"][resultCount]["LastName"];
                  String middleName = (String)obj["d"]["Author"]["Result"][resultCount]["MiddleName"];

                  if (compareName.Contains(firstName) || compareName.Contains(lastName) || compareName.Contains(middleName))
                  {
                      String authorname = (String)obj["d"]["Author"]["Result"][resultCount]["FirstName"] + " " + (String)obj["d"]["Author"]["Result"][resultCount]["MiddleName"] + " " + (String)obj["d"]["Author"]["Result"][resultCount]["LastName"];

                      Console.WriteLine(authorname);
                      author.setname(authorname);

                      String hindex = (String)obj["d"]["Author"]["Result"][resultCount]["HIndex"];

                      author.sethIndex(Convert.ToInt32(hindex));

                      String iindex = (String)obj["d"]["Author"]["Result"][resultCount]["GIndex"];

                      author.setiIndex(Convert.ToInt32(iindex));

                      String count = (String)obj["d"]["Author"]["Result"][resultCount]["CitationCount"];

                      author.setnumPapers(Convert.ToInt32(count));
                  }


                
                  resultCount++;

              }*/
            int num = 5;
            if (obj["d"][type]["Result"].Count() < num)
            {
                num = obj["d"][type]["Result"].Count();
            }
            if (obj["d"][type]["Result"].Count() > 0)
            {
                String authorname = "";
                int fl = 0;
                for (int i = 0; i < num; i++)
                {
                    authorname = (String)obj["d"][type]["Result"][i]["FirstName"] + " " + (String)obj["d"][type]["Result"][i]["MiddleName"] + " " + (String)obj["d"][type]["Result"][i]["LastName"];
                    Console.WriteLine(authorname+"----====----"+compareName);
                    String[] comp;
                    char [] ch={' '};
                    comp = compareName.ToLower().Split(ch);
                    foreach (String s in comp)
                    {
                        if (authorname.ToLower().Contains(s))
                        {
                            Console.WriteLine(authorname + "----====----" + compareName);
                            resultCount = i;
                            fl=1;
                            break;
                        }
                    }
                    if (fl == 1)
                    {
                        break;
                    }

                }
                authorname = (String)obj["d"][type]["Result"][resultCount]["FirstName"] + " " + (String)obj["d"][type]["Result"][resultCount]["MiddleName"] + " " + (String)obj["d"][type]["Result"][resultCount]["LastName"];
                Console.WriteLine(authorname);
                author.setname(authorname);

                String hindex = (String)obj["d"][type]["Result"][resultCount]["HIndex"];

                author.sethIndex(Convert.ToInt32(hindex));

                String iindex = (String)obj["d"][type]["Result"][resultCount]["GIndex"];

                author.setiIndex(Convert.ToInt32(iindex));

                String count = (String)obj["d"][type]["Result"][resultCount]["CitationCount"];
//.........這裏部分代碼省略.........
開發者ID:srinivasans,項目名稱:OpenSoft2013,代碼行數:101,代碼來源:Parser.cs

示例2: GSParseProfile

        public void GSParseProfile(Uri URL)
        {

            String strResponse = this.GSTryConnect(URL);

            HtmlDocument document = new HtmlDocument();
            document.Load(new StringReader(strResponse));

            String authorName = "";
            String residence = "";
            String interest = "";
            String hindex = "";
            String iindex = "";
            String totalcitations = "";

            this.resultList.resultType = this.query.resultType;
            this.resultList.loadType();

            SearchType type;


            Author author = new Author();
            author.setresArea("");
            author.setstatsGraphUrl(new Uri("http://google.com"));
            author.setinstitute("");





            HtmlNode profileNode = document.DocumentNode.SelectSingleNode("//div[@class='g-section g-tpl-250-alt']//div[@class='g-unit']");
            if (profileNode != null)
            {
                //Console.WriteLine("hey");
                // Console.WriteLine(profileNode.InnerText);
                //   Author author = new Author();
                HtmlNode userInfoNode = profileNode.SelectSingleNode("//div[@class='cit-user-info']//div[@class='g-unit']");

                HtmlNode userNameNode = userInfoNode.SelectSingleNode("//span[@id='cit-name-read']");

                authorName = userNameNode.InnerText;
                author.setname(authorName);

                HtmlNode userResidenceNode = userInfoNode.SelectSingleNode("//span[@id='cit-affiliation-read']");

                residence = userResidenceNode.InnerText;
                author.setinstitute(residence);

                HtmlNode userInterestNode = userInfoNode.SelectSingleNode("//span[@id='cit-int-read']");

                interest = userInterestNode.InnerText;
                author.setresArea(interest);

                Console.WriteLine("Author " + authorName + residence + interest);

                HtmlNode dataNode = profileNode.SelectSingleNode("div[@class='cit-lbb']//table//tr//table[@id='stats']");

                if (dataNode != null)
                {
                    int i = 0;
                    foreach (HtmlNode hindexNode in dataNode.SelectNodes("tr//td[@class='cit-borderleft cit-data']"))
                    {
                        if (i == 0)
                        {
                            totalcitations = hindexNode.InnerText;
                            author.setnumPapers(Convert.ToInt32(totalcitations));
                        }

                        else if (i == 2)
                        {
                            hindex = hindexNode.InnerText;
                            author.sethIndex(Convert.ToInt32(hindex));
                        }

                        else if (i == 4)
                        {
                            iindex = hindexNode.InnerText;
                            author.setiIndex(Convert.ToInt32(iindex));
                        }

                        i++;
                    }

                    HtmlNode imageNode = profileNode.SelectSingleNode("div[@class='cit-lbb']//table//td[@valign='top']//img[@src]");

                    String url = imageNode.Attributes["src"].Value;
                    Console.WriteLine(hindex + "hey " + iindex + "hi" + totalcitations + " " + url);
                    url = System.Net.WebUtility.HtmlDecode(url);
                    var strUrl = new Uri(url);
                    author.setstatsGraphUrl(strUrl);
                    type = author;
                    this.resultList.type = type;



                }

            }
            else
            {
//.........這裏部分代碼省略.........
開發者ID:srinivasans,項目名稱:OpenSoft2013,代碼行數:101,代碼來源:Parser.cs


注:本文中的Author.setiIndex方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。