コード例 #1
0
ファイル: PersonSearch.cs プロジェクト: sundhaug92/itsCon
        public PersonSearch(Session Session, string Forname, string Surname, int HierarchyId, Course Course, PersonType PersonType)
        {
            HttpWebRequest InitialLoginRequest = Session.GetHttpWebRequest("/search/search_person.aspx");
            HtmlDocument initialLoginScreen = new HtmlDocument();
            HttpWebResponse FirstResponse = (HttpWebResponse)InitialLoginRequest.GetResponse();
            initialLoginScreen.Load(FirstResponse.GetResponseStream());

            Dictionary<string, string> LoginFormData = new Dictionary<string, string>();

            LoginFormData.Add("FirstName", Forname);
            LoginFormData.Add("Lastname", Surname);
            LoginFormData.Add("CourseID", Course.Id.ToString());
            LoginFormData.Add("HierarchyId", HierarchyId.ToString());

            LoginFormData.Add("idProfileID_7", (((PersonType & PersonType.sysadmin) > 0) ? 7 : 0).ToString());
            LoginFormData.Add("idProfileID_14", (((PersonType & PersonType.examinator) > 0) ? 14 : 0).ToString());
            LoginFormData.Add("idProfileID_8", (((PersonType & PersonType.administrator) > 0) ? 8 : 0).ToString());
            LoginFormData.Add("idProfileID_9", (((PersonType & PersonType.employee) > 0) ? 9 : 0).ToString());
            LoginFormData.Add("idProfileID_10", (((PersonType & PersonType.student) > 0) ? 10 : 0).ToString());
            LoginFormData.Add("idProfileID_62007", (((PersonType & PersonType.parent) > 0) ? 62007 : 0).ToString());
            LoginFormData.Add("idProfileID_11", (((PersonType & PersonType.guest) > 0) ? 11 : 0).ToString());

            LoginFormData.Add("Search", "Søk");
            LoginFormData.Add("Advanced", "0");

            foreach (var Form in initialLoginScreen.DocumentNode.Descendants("form"))
            {
                if (Form.GetAttributeValue("name", "") == "form")
                {
                    foreach (var inp in initialLoginScreen.DocumentNode.Descendants("input"))
                    {
                        if (!LoginFormData.ContainsKey(inp.GetAttributeValue("name", ""))) LoginFormData.Add(inp.GetAttributeValue("name", ""), inp.GetAttributeValue("value", ""));
                    }
                    HtmlDocument doc = Session.PostData("/search/search_person.aspx", LoginFormData);
                    _Result = new List<Person>(10);
                    foreach (var row in (from element in doc.DocumentNode.DescendantNodes() where element.GetAttributeValue("id", "").StartsWith("row_") select element))
                    {
                        string href = row.ChildNodes[1].FirstChild.GetAttributeValue("href", "");
                        _Result.Add(new Person(Session, uint.Parse(HttpUtility.ParseQueryString(new Uri(Properties.Settings.Default.urlBase + href.Substring(href.IndexOf('/'))).Query).Get("PersonID"))));
                    }
                }
            }
        }
コード例 #2
0
ファイル: MailCreator.cs プロジェクト: sundhaug92/itsCon
        public void SendMessage(Session Session)
        {
            /*
             * /XmlHttp/Api.aspx?Function=MessagingValidateRecipients
             * operationId: 1000
             * to:
             * cc:
             * bcc:
             * subject:
             * text:
             * files:
             * id: 0
             * messageMeasurement: 2
             * _:
            */
            Dictionary<string, string> MailData = new Dictionary<string, string>(5);
            string Persons = "";
            foreach (Person Person in To)
            {
                Persons += Person.Username + ";";
            }
            MailData.Add("to", Persons);

            Persons = "";
            foreach (Person Person in Cc)
            {
                Persons += Person.Username + ";";
            }
            MailData.Add("cc", Persons);

            Persons = "";
            foreach (Person Person in Bcc)
            {
                Persons += Person.Username + ";";
            }
            MailData.Add("bcc", Persons);

            MailData.Add("operationId", (1000).ToString());
            MailData.Add("id", (0).ToString());
            MailData.Add("text", Text);
            MailData.Add("subject", Text);
            MailData.Add("files", "");
            MailData.Add("messageMeasurement", (2).ToString());
            MailData.Add("_", "");
            Session.PostData("/XmlHttp/Api.aspx?Function=MessagingValidateRecipients", MailData);
            Session.PostData("/XmlHttp/Api.aspx?Function=MessagingSendMessage&MessageOperationID=" + (1000).ToString(), MailData);
        }