public Ogrenci(string OgrenciNo = null, string Sifre = null) { this.OgrenciNo = OgrenciNo; this.Sifre = Sifre; this.Donemler = new HashSet <Donem>(); if (!string.IsNullOrEmpty(OgrenciNo)) { ObisisMobileServiceClient client = new ObisisMobileServiceClient(); OgrenciResult or = client.OgrenciDonemGetir(OgrenciNo); DataTable dt = or.Data.Tables[0]; foreach (DataRow item in dt.Rows) { this.Donemler.Add(new Donem(this, item["DONEM_ADI"].ToString(), item["OGRETIM_YILI"].ToString(), Convert.ToInt32(item["OGRETIM_YILI_KODU"]), Convert.ToInt32(item["DONEM_NO"]))); } HtmlDocument document = new HtmlDocument(); document.LoadHtml(Function.GetHTML("http://obisis.erciyes.edu.tr/Default.aspx?tabInd=3&tabNo=5", OgrenciNo, Sifre)); HtmlNode node = document.DocumentNode; try { this.AdSoyad = Function.TidyText(node.SelectSingleNode("//span[@id='Banner1_Kullanici1_txtAdiSoyadi']").InnerText); this.Fakulte = Function.TidyText(node.SelectSingleNode("//span[@id='Banner1_Kullanici1_txtFakulteAdi']").InnerText); this.Bolum = Function.TidyText(node.SelectSingleNode("//span[@id='Banner1_Kullanici1_txtBolumAdi']").InnerText); string SinifGano = node.SelectSingleNode("//span[@id='Banner1_Kullanici1_txtSinifSeneGano']").InnerText; this.Sinif = Convert.ToInt32(SinifGano.Split('(')[1].Split('.')[0]); this.GANO = Convert.ToDouble(SinifGano.Split(':')[1]); } catch (Exception) { } } }
public Ogrenci(string ogrNo = null, string sifre = null) { this.OgrenciNo = ogrNo; this.Sifre = sifre; this.Donemler = new HashSet <Donem>(); this.Dersler = new HashSet <Ders>(); if (!string.IsNullOrEmpty(ogrNo)) { ObisisMobileServiceClient client = new ObisisMobileServiceClient(); OgrenciResult or = client.OgrenciDonemGetir(ogrNo); DataTable dt = or.Data.Tables[0]; foreach (DataRow item in dt.Rows) { this.Donemler.Add(new Donem(this, item["DONEM_ADI"].ToString(), item["OGRETIM_YILI"].ToString(), Convert.ToInt32(item["OGRETIM_YILI_KODU"]), Convert.ToInt32(item["DONEM_NO"]))); } foreach (Donem donem in this.Donemler) { foreach (Ders ders in donem.Dersler) { this.Dersler.Add(ders); } } HtmlDocument document = new HtmlDocument(); document.LoadHtml(GetHTML("http://obisis.erciyes.edu.tr/Default.aspx?tabInd=3&tabNo=5", ogrNo, sifre)); HtmlNode node = document.DocumentNode; try { this.AdSoyad = TidyText(node.SelectSingleNode("//span[@id='Banner1_Kullanici1_txtAdiSoyadi']").InnerText); this.Fakulte = TidyText(node.SelectSingleNode("//span[@id='Banner1_Kullanici1_txtFakulteAdi']").InnerText); this.Bolum = TidyText(node.SelectSingleNode("//span[@id='Banner1_Kullanici1_txtBolumAdi']").InnerText); string SinifGano = node.SelectSingleNode("//span[@id='Banner1_Kullanici1_txtSinifSeneGano']").InnerText; this.Sinif = Convert.ToInt32(SinifGano.Split('(')[1].Split('.')[0]); this.GANO = Convert.ToDouble(SinifGano.Split(':')[1]); this.GerekenGANO = Convert.ToDouble(node.SelectSingleNode("//table[@id='ctl00_dgMezuniyetDurum']/tr[2]/td[1]").InnerText.Replace("Ortalama en az", "").Replace("olmalı", "").Trim()); this.MezuniyetKredisi = Convert.ToDouble(node.SelectSingleNode("//table[@id='ctl00_dgMezuniyetDurum']/tr[7]/td[1]").InnerText.Replace("Mezuniyet kredisi", "").Replace("olmalı", "").Trim()) / 100; this.ToplamKredi = Convert.ToDouble(node.SelectSingleNode("//table[@id='ctl00_dgMezuniyetDurum']/tr[7]/td[2]").InnerText.Replace("Toplam krediniz", "").Trim()) / 100; this.StajDurum = node.SelectSingleNode("//table[@id='ctl00_dgMezuniyetDurum']/tr[6]/td[3]").InnerHtml == "<img src=\"/images/Valid.gif\">"; } catch (Exception) { } } }
public Ogrenci(string ogrNo = "", string sifre = "") { this.OgrenciNo = ogrNo; this.Sifre = sifre; this.Donemler = new HashSet <Donem>(); this.Dersler = new HashSet <Ders>(); if (!string.IsNullOrEmpty(ogrNo)) { ObisisMobileServiceClient client = new ObisisMobileServiceClient(); OgrenciResult or = client.OgrenciDonemGetir(ogrNo); DataTable dt = or.Data.Tables[0]; foreach (DataRow item in dt.Rows) { this.Donemler.Add(new Donem(this, Convert.ToInt32(item["OGRETIM_YILI_KODU"]), Convert.ToInt32(item["DONEM_NO"])) { Adi = item["DONEM_ADI"].ToString(), OgretimYili = item["OGRETIM_YILI"].ToString() }); } foreach (Donem donem in this.Donemler) { foreach (Ders ders in donem.Dersler) { this.Dersler.Add(ders); } } HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://obisis.erciyes.edu.tr"); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); StreamReader reader = new StreamReader(response.GetResponseStream()); string strResponse = reader.ReadToEnd(); HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument(); doc.LoadHtml(strResponse); HtmlNodeCollection collection = doc.DocumentNode.SelectNodes("//input"); string getUrl = "http://obisis.erciyes.edu.tr"; string postData = string.Format("__VIEWSTATE={0}&__EVENTVALIDATION={1}&ctl00$txtboxOgrenciNo={2}&ctl00$txtBoxSifre={3}&ctl00$btnLogin={4}", HttpUtility.UrlEncode(collection[1].Attributes["value"].Value), HttpUtility.UrlEncode(collection[2].Attributes["value"].Value), ogrNo, sifre, HttpUtility.UrlEncode("Giriş")); HttpWebRequest getRequest = (HttpWebRequest)WebRequest.Create(getUrl); getRequest.CookieContainer = new CookieContainer(); getRequest.Method = "POST"; getRequest.ContentType = "application/x-www-form-urlencoded"; byte[] byteArray = Encoding.ASCII.GetBytes(postData); getRequest.ContentLength = byteArray.Length; Stream newStream = getRequest.GetRequestStream(); //open connection newStream.Write(byteArray, 0, byteArray.Length); // Send the data. newStream.Close(); HttpWebResponse getResponse = (HttpWebResponse)getRequest.GetResponse(); StreamReader sr = new StreamReader(getResponse.GetResponseStream()); HtmlAgilityPack.HtmlDocument document = new HtmlAgilityPack.HtmlDocument(); document.LoadHtml(sr.ReadToEnd()); HtmlNode node = document.DocumentNode; this.AdSoyad = node.SelectSingleNode("//span[@id='Banner1_Kullanici1_txtAdiSoyadi']").InnerText; this.Fakulte = node.SelectSingleNode("//span[@id='Banner1_Kullanici1_txtFakulteAdi']").InnerText; this.Bolum = node.SelectSingleNode("//span[@id='Banner1_Kullanici1_txtBolumAdi']").InnerText; string SinifGano = node.SelectSingleNode("//span[@id='Banner1_Kullanici1_txtSinifSeneGano']").InnerText; this.Sinif = Convert.ToInt32(SinifGano.Split('(')[1].Split('.')[0]); this.GANO = Convert.ToDouble(SinifGano.Split(':')[1]); } }