Exemplo n.º 1
0
 public Customer(Session Session, string Name)
 {
     _Name = Name;
     HtmlDocument Doc = Session.GetDocument("/");
     foreach (var v in Doc.DocumentNode.Descendants("option"))
     {
         if (v.ParentNode.GetAttributeValue("id", "") != "ctl00_ContentPlaceHolder1_LoginSection1_ChooseSite_site_input") continue;
         if (_Name == v.NextSibling.InnerHtml) _Id = (uint)v.GetAttributeValue("value", 0);
     }
     if ((_Name == null) || (_Name == "")) throw new ArgumentException("No customer found", "Id");
 }
Exemplo n.º 2
0
 public static List<Bulletin> inCP(Session Session, ICourseProjectCommons Parent)
 {
     string path = Parent.getDashboardPath();
     HtmlDocument Document = Session.GetDocument(path);
     var nodesWithHrefToBulletin = from node in Document.DocumentNode.DescendantNodes() where node.Name == "a" && node.GetAttributeValue("href", "").Contains("/Bulletin/View") select node.GetAttributeValue("href", "");
     List<Bulletin> Bulletins = new List<Bulletin>(nodesWithHrefToBulletin.Count());
     int i = 0;
     foreach (string uri_string in nodesWithHrefToBulletin)
     {
         Uri uri = uri_string.StartsWith("/") ? new Uri(Properties.Settings.Default.urlBase + uri_string) : new Uri(uri_string);
         Bulletins[i++] = new Bulletin(Session, Parent, uint.Parse(HttpUtility.ParseQueryString(uri.Query).Get("BulletinId")));
     }
     return Bulletins;
 }
Exemplo n.º 3
0
 public static Person Me(Session sess)
 {
     uint Uid = 0;
     HtmlDocument top_menu = sess.GetDocument("/TopMenu.aspx?Course=&CPHFrame=1&item=menu_intranet");
     var e = from element in top_menu.DocumentNode.Descendants("a") where element.GetAttributeValue("class", "") == "user_name" select element.GetAttributeValue("href", "");
     Uri user_info_Uri = new Uri(Properties.Settings.Default.urlBase + e.First());
     Uid = uint.Parse(HttpUtility.ParseQueryString(user_info_Uri.Query).Get("PersonId"));
     return new Person(sess, Uid);
 }