Exemplo n.º 1
0
        private static String GetHTMLString(String username, String password, String code, WebProxy proxy)
        {
            String          result = "";
            CookieContainer Cc     = new CookieContainer();
            HttpWebRequest  req    = HTTPUtil.GetHttpRequest("http://uis2.fudan.edu.cn:82/amserver/UI/Login?Login.Token2=" + password + "&Login.code=" + code + "&Login.Token1=" + username, "GET", Cc, 15000, 15000, proxy, true);

            using (WebResponse wr = req.GetResponse())
            {
            }
            req = HTTPUtil.GetHttpRequest("http://www.urp.fudan.edu.cn:84/epstar/app/fudan/ScoreManger/ScoreViewer/Student/Course.jsp", "GET", Cc, 15000, 15000, proxy, true);
            using (WebResponse wr = req.GetResponse())
            {
                result = HTTPUtil.GetStringFromStream(wr.GetResponseStream(), Encoding.GetEncoding("GB2312"));
            }
            req = HTTPUtil.GetHttpRequest("http://www.urp.fudan.edu.cn/logout.jsp", "GET", Cc, 15000, 15000, proxy, true);
            using (WebResponse wr = req.GetResponse())
            {
            }
            return(result);
        }
Exemplo n.º 2
0
 public static void CheckUpdate()
 {
     try
     {
         XmlDocument doc = new XmlDocument();
         doc.XmlResolver = null;
         doc.Load("http://wiki.hackerzhou.me/GPATool");
         XmlNodeList list         = doc.SelectNodes("//table[@id='updateData']/tr");
         double      versionValue = 0;
         String      downloadUrl  = null;
         foreach (XmlNode n in list)
         {
             String version      = n.ChildNodes[0].InnerText.Replace("v", "");
             String downloadTemp = n.ChildNodes[1].InnerText;
             double versionTemp  = 0;
             double.TryParse(version, out versionTemp);
             if (versionTemp > versionValue)
             {
                 versionValue = versionTemp;
                 downloadUrl  = HttpUtility.UrlDecode(downloadTemp);
             }
         }
         if (versionValue > currentVersion && downloadUrl != null && downloadUrl.StartsWith("http://hackerzhou.googlecode.com"))
         {
             String upgradeFile = HTTPUtil.GetFileNameFromUrl(downloadUrl);
             String filePath    = Environment.CurrentDirectory + "\\" + upgradeFile;
             bool   success     = HTTPUtil.SaveUrlContentToFile(downloadUrl, filePath);
             if (success)
             {
                 MessageBox.Show("已下载更新版 v" + versionValue.ToString("0.00") + " 到 " + upgradeFile + "\n请解压覆盖旧版本应用更新", "更新");
             }
         }
     }
     catch
     {
     }
 }