Exemplo n.º 1
0
        private void MoniClick(object sender, RoutedEventArgs e)
        {
            GradeModel model = ((FrameworkElement)sender).Tag as GradeModel;
            MoniWindow moni  = new MoniWindow(model.Grade);

            if (moni.ShowDialog() == true)
            {
                model.Grade = moni.Result;
                if (double.TryParse(moni.Result, out double g))
                {
                    model.GradePoint = (g / 10.0d - 5.0d).ToString();
                }
                else
                {
                    var val = gradeKeyValues.FirstOrDefault(x => string.Equals(x.Key, moni.Result));
                    if (val == null)
                    {
                        model.GradePoint = "0";
                    }
                    else
                    {
                        model.GradePoint = (val.Value / 10.0d - 5.0d).ToString();
                    }
                }
                model.ExaminationGrade = "";
                model.ReworkGrade      = "";
                Cal();
            }
        }
Exemplo n.º 2
0
        private void CancelClick(object sender, RoutedEventArgs e)
        {
            GradeModel model = ((FrameworkElement)sender).Tag as GradeModel;

            model.Cut = false;
            Cal();
        }
Exemplo n.º 3
0
 private List <GradeModel> GetGradeDetail(string viewState)
 {
     try
     {
         string         post         = url_code + "xscj_gc.aspx?" + string.Format("xh={0}&xm={1}&gnmkdm=N121605", HttpUtility.UrlEncode(username), HttpUtility.UrlEncode(name));
         string         postdata     = string.Format("__VIEWSTATE={0}&ddlXN=&ddlXQ=&Button2=%D4%DA%D0%A3%D1%A7%CF%B0%B3%C9%BC%A8%B2%E9%D1%AF", HttpUtility.UrlEncode(viewState));
         byte[]         postdatabyte = Encoding.GetEncoding("GB2312").GetBytes(postdata);
         HttpWebRequest request      = (HttpWebRequest)WebRequest.Create(post);
         request.ServicePoint.Expect100Continue = false;
         request.Method = "POST";
         request.Headers.Add("Cache-Control", "max-age=0");
         request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36";
         request.Accept    = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8";
         request.Headers.Add("Accept-Encoding", "gzip, deflate");
         request.Headers.Add("Accept-Language", "zh-CN,zh;q=0.8");
         request.Referer       = post;
         request.ContentLength = postdatabyte.Length;
         request.KeepAlive     = true;
         request.ContentType   = "application/x-www-form-urlencoded";
         request.Headers.Add("Upgrade-Insecure-Requests", "1");
         request.CookieContainer   = cookie;
         request.AllowAutoRedirect = false;
         using (Stream stream = request.GetRequestStream())
         {
             stream.Write(postdatabyte, 0, postdatabyte.Length);
         }
         HttpWebResponse response = (HttpWebResponse)request.GetResponse();
         string          str      = string.Empty;
         bool            gzip     = string.Equals(response.Headers["Vary"], "Accept-Encoding", StringComparison.OrdinalIgnoreCase);
         str = DecompressGzip(response.GetResponseStream(), gzip);
         response.Close();
         if (string.IsNullOrWhiteSpace(str) || !str.Contains("__VIEWSTATE"))
         {
             return(null);
         }
         List <string> tab = GetReg("<table", "</table>", str);
         if (tab.Count <= 0)
         {
             return(null);
         }
         List <string>     trs  = GetReg("<tr", "</tr>", tab[0]);
         List <GradeModel> list = new List <GradeModel>();
         foreach (string tr in trs.Skip(1))
         {
             List <string> tds   = GetReg("<td", "</td>", tr);
             GradeModel    model = new GradeModel();
             model.Year             = HttpUtility.HtmlDecode(GetContent(tds[0])).Trim();
             model.Semester         = HttpUtility.HtmlDecode(GetContent(tds[1])).Trim();
             model.ClassCode        = HttpUtility.HtmlDecode(GetContent(tds[2])).Trim();
             model.ClassName        = HttpUtility.HtmlDecode(GetContent(tds[3])).Trim();
             model.ClassNature      = HttpUtility.HtmlDecode(GetContent(tds[4])).Trim();
             model.ClassOwnership   = HttpUtility.HtmlDecode(GetContent(tds[5])).Trim();
             model.Credit           = HttpUtility.HtmlDecode(GetContent(tds[6])).Trim();
             model.GradePoint       = HttpUtility.HtmlDecode(GetContent(tds[7])).Trim();
             model.Grade            = HttpUtility.HtmlDecode(GetContent(tds[8])).Trim();
             model.MinorFlag        = HttpUtility.HtmlDecode(GetContent(tds[9])).Trim();
             model.ExaminationGrade = HttpUtility.HtmlDecode(GetContent(tds[10])).Trim();
             model.ReworkGrade      = HttpUtility.HtmlDecode(GetContent(tds[11])).Trim();
             model.CollegeName      = HttpUtility.HtmlDecode(GetContent(tds[12])).Trim();
             model.Note             = HttpUtility.HtmlDecode(GetContent(tds[13])).Trim();
             model.ReworkFlag       = HttpUtility.HtmlDecode(GetContent(tds[14])).Trim();
             model.ClassEnglishName = HttpUtility.HtmlDecode(GetContent(tds[15])).Trim();
             list.Add(model);
         }
         return(list);
     }
     catch (Exception ex)
     {
         LogUtils.Write(ex);
         return(null);
     }
 }