public override void ViewWillDisappear(bool animated)
        {
            userNameField.ResignFirstResponder();
            passwordField.ResignFirstResponder();
            GymSettingsDataSource.UserName = userNameField.Text;
            GymSettingsDataSource.Password = passwordField.Text;
            GymSettingsDataSource.Write();
            TTTHttp.LogOn();
            if (TTTHttp.isError)
            {
                UIAlertView alert = new UIAlertView();
                alert.Title   = "Påloggingsfeil";
                alert.Message = Text.getString(TTTHttp.ErrorMessage);
                alert.AddButton("OK");
                alert.Show();
            }

            base.ViewWillDisappear(animated);
        }
        public override void ViewDidAppear(bool animated)
        {
            NavigationController.NavigationBar.BackgroundColor = UIColor.FromPatternImage(UIImage.FromFile("images/blue.png"));
            float border    = 0;
            float gridHight = (View.Frame.Height - border) / elements.Count;
            float gridWidh  = View.Frame.Width;
            float ypos      = 0;
            float xpos      = 0;

            for (int i = 0; i < elements.Count; i++)
            {
                elements[i].Frame = new RectangleF(xpos + border, ypos + border, gridWidh - 2 * border, gridHight - border);
                View.AddSubview(elements[i]);

                ypos += gridHight;
            }


            if (GymSettingsDataSource.UserName == null || GymSettingsDataSource.Password == null)
            {
                NavigationController.PushViewController(new GymSettingsViewController(), true);
            }
            else
            {
                TTTHttp.LogOn();
            }

            if (TTTHttp.isError)
            {
                UIAlertView alert = new UIAlertView();
                alert.Title   = "Påloggingsfeil";
                alert.Message = Text.getString(TTTHttp.ErrorMessage);
                alert.AddButton("OK");
                alert.Show();
                NavigationController.PushViewController(new GymSettingsViewController(), true);
            }
        }
示例#3
0
文件: TTTBook.cs 项目: oddsve/TheGym
        public static void book(string gymAction)
        {
            string actionURL = "http://brp.netono.se/3t/mesh/" + gymAction;

            TTTHttp.getHTTP(actionURL);
        }
示例#4
0
        public static List <GymClass> getSchedules(DateTime scheduleDate)
        {
            string scheduleDateString = scheduleDate.Year.ToString() + "-"
                                        + scheduleDate.Month.ToString() + "-"
                                        + scheduleDate.Day.ToString();


            List <GymClass> schedules = new List <GymClass>();

            string postData = "";

            for (int i = 0; i < GymSettingsDataSource.selectedGymKeys.Count; i++)
            {
                postData += "&selectableUnits%5B"
                            + GymSettingsDataSource.selectedGymKeys[i]
                            + "%5D.chosen=true";
            }

            postData += "&group=all&date=" + scheduleDateString + " &group=all&";
            postData  = postData.Substring(1);


            string activityUrl = "http://brp.netono.se/3t/mesh/showGroupActivities.action?businessUnit=1";

            HtmlDocument document = new HtmlDocument();

            HtmlNode.ElementsFlags.Remove("option");
            document.LoadHtml(TTTHttp.PostHTTP(activityUrl, postData));


            HtmlDocument rowDocument = new HtmlDocument();

            HtmlNodeCollection tables = document.DocumentNode.SelectNodes("//table[@class='schedule']");

            if (tables != null)
            {
                foreach (HtmlNode table in tables)
                {
                    if (table.GetAttributeValue("class", "") == "schedule")
                    {
                        string             date  = "";
                        string             time  = "";
                        string             title = "";
                        HtmlNodeCollection rows  = table.SelectNodes("//tr");

                        foreach (HtmlNode row in rows)
                        {
                            HtmlNodeCollection cells;
                            HtmlNode           cell;
                            HtmlNode           link;


                            if (row.GetAttributeValue("class", "").ToString().Trim() == "date")
                            {
                                rowDocument.LoadHtml(row.OuterHtml);
                                cells = rowDocument.DocumentNode.SelectNodes("//td");
                                cell  = cells[0];
                                date  = cell.InnerText.Trim();
                            }


                            if (row.GetAttributeValue("class", "").ToString() == "row" ||
                                row.GetAttributeValue("class", "").ToString() == "row alternateRow" ||
                                row.GetAttributeValue("class", "").ToString() == "row bookedRow")
                            {
                                rowDocument.LoadHtml(row.OuterHtml);
                                cells = rowDocument.DocumentNode.SelectNodes("//td");



                                cell = cells[0];
                                time = cell.InnerText.Trim();


                                cell  = cells[2];
                                title = cell.InnerText.Trim();

                                GymClass gymClass = new GymClass(title, date, time);

                                cell         = cells[1];
                                gymClass.gym = cell.InnerText.Trim();

                                cell = cells[3];
                                gymClass.instructor = cell.InnerText.Trim();

                                cell            = cells[4];
                                gymClass.vacant = cell.InnerText.Trim();

                                cell            = cells[5];
                                gymClass.status = cell.InnerText.Trim();

                                cell = cells[6];
                                if (cell.InnerText.Trim() == "Velg")
                                {
                                    link = cell.SelectNodes("//a")[0];
                                    gymClass.bookAction = link.GetAttributeValue("href", "");
                                }

                                else if (cell.InnerText.Trim() == "Avbooke")

                                {
                                    link = cell.SelectNodes("//a")[0];
                                    string href = link.GetAttributeValue("href", "");

                                    string pattern = "bookingId=(.*?)'";
                                    // Instantiate the regular expression object.
                                    Regex r = new Regex(pattern, RegexOptions.IgnoreCase);

                                    // Match the regular expression pattern against a text string.
                                    Match m = r.Match(href);
                                    while (m.Success)
                                    {
                                        gymClass.unbookAction = "debook.action?bookingId=" + m.Groups[1].ToString();
                                        m = m.NextMatch();
                                    }
                                }

                                if (gymClass.startTime > DateTime.Now)
                                {
                                    schedules.Add(gymClass);
                                }
                            }
                        }
                    }
                }
            }


            return(schedules);
        }
示例#5
0
        public static List <GymClass> getMyBookings()
        {
            List <GymClass> myBookings = new List <GymClass>();

            HtmlDocument document = new HtmlDocument();

            HtmlNode.ElementsFlags.Remove("option");
            string html = TTTHttp.getHTTP("http://brp.netono.se/3t/mesh/showBookings.action");

            document.LoadHtml(html);



            HtmlDocument rowDocument = new HtmlDocument();

            HtmlNodeCollection tables = document.DocumentNode.SelectNodes("//table[@class='bookingsList groupActivityBookings']");

            if (tables != null)
            {
                foreach (HtmlNode table in tables)
                {
                    if (table.GetAttributeValue("class", "") == "bookingsList groupActivityBookings")
                    {
                        string             date  = "";
                        string             time  = "";
                        string             title = "";
                        HtmlNodeCollection rows  = table.SelectNodes("//tr");

                        foreach (HtmlNode row in rows)
                        {
                            HtmlNodeCollection cells;
                            HtmlNode           cell;
                            HtmlNode           link;



                            if (row.GetAttributeValue("class", "").ToString() == "normalRow" ||
                                row.GetAttributeValue("class", "").ToString() == "alternateRow")
                            {
                                rowDocument.LoadHtml(row.OuterHtml);
                                cells = rowDocument.DocumentNode.SelectNodes("//td");


                                cell = cells[0];
                                time = cell.InnerText.Trim();

                                cell  = cells[1];
                                title = cell.InnerText.Trim();

                                GymClass gymClass = new GymClass(title, date, time);

                                cell         = cells[2];
                                gymClass.gym = cell.InnerText.Trim();

                                cell = cells[3];
                                gymClass.instructor = cell.InnerText.Trim();

                                cell = cells[4];
                                if (cell.InnerText.Trim() == "Avbooke")
                                {
                                    link = cell.SelectNodes("//a")[0];
                                    string href = link.GetAttributeValue("href", "");

                                    string pattern = "bookingId=(.*?)'";
                                    // Instantiate the regular expression object.
                                    Regex r = new Regex(pattern, RegexOptions.IgnoreCase);

                                    // Match the regular expression pattern against a text string.
                                    Match m = r.Match(href);
                                    while (m.Success)
                                    {
                                        gymClass.unbookAction = "debook.action?bookingId=" + m.Groups[1].ToString();
                                        m = m.NextMatch();
                                    }
                                }
                                gymClass.status = "Booket";
                                myBookings.Add(gymClass);
                            }
                        }
                    }
                }
            }

            return(myBookings);
        }