コード例 #1
0
 public BookingViewController( GymClass gymClass, UITableView tableView, NSIndexPath indexPath )
 {
     Title = gymClass.title;
     this. gymClass = gymClass;
     this.tableView = tableView;
     this.indexPath = indexPath;
 }
コード例 #2
0
        public override void ViewDidLoad()
        {
            View.BackgroundColor = UIColor.Black;
            bookButton = new UIButton( new RectangleF(10,100,this.View.Frame.Width-10 ,40) );

            bookButton.BackgroundColor = UIColor.Clear;
            setButton();

            bookButton.TouchUpInside += delegate {
                gymClass.book();
                System.Console.WriteLine( gymClass.unbookAction);
                ScheduleTableViewDataSource ds = ( ScheduleTableViewDataSource ) tableView.DataSource;
                ds.force = true;
                ds.ReloadData();
                tableView.ReloadData();

                if ( ! ds.isMyBookings )
                {
                    gymClass = ds.getGymClass( indexPath );
                    setButton();
                }

            };

            this.View.AddSubview( bookButton );
        }
コード例 #3
0
 public void ReloadData( )
 {
     if ( isMyBookings )
     {
         if ( !GymSettingsDataSource.isLogedOn )
         {
             GymClass notLoggedIn = new GymClass("Ikke logget inn", "Gå til settings" , "");
             _gyms = new List<GymClass>();
             _gyms.Add( notLoggedIn );
         }
         else
         {
             this._gyms = TTTBookings.getMyBookings();
         }
     }
     else
         if ( needToReload() )
         {
             gymKeys = GymSettingsDataSource.gymKeyString;
             this._gyms = TTTSchedules.getSchedules( scheduleDate );
             reloadTimeStamp = DateTime.Now;
             force= false;
         }
 }
コード例 #4
0
 public void ReloadData( )
 {
     if (isMyBookings)
     {
         if (!GymSettingsDataSource.isLogedOn)
         {
             GymClass notLoggedIn = new GymClass("Ikke logget inn", "Gå til settings", "");
             _gyms = new List <GymClass>();
             _gyms.Add(notLoggedIn);
         }
         else
         {
             this._gyms = TTTBookings.getMyBookings();
         }
     }
     else
     if (needToReload())
     {
         gymKeys         = GymSettingsDataSource.gymKeyString;
         this._gyms      = TTTSchedules.getSchedules(scheduleDate);
         reloadTimeStamp = DateTime.Now;
         force           = false;
     }
 }
コード例 #5
0
ファイル: TTTSchedules.cs プロジェクト: oddsve/TheGym
        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);
        }
コード例 #6
0
ファイル: TTTBookings.cs プロジェクト: oddsve/TheGym
        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;
        }
コード例 #7
0
        public GymClassTableViewCell( GymClass gymClass )
        {
            _gymClass = gymClass;

            classTitle = new UILabel();
            instructor = new UILabel(  );
            classTime = new UILabel();
            gym = new UILabel();
            vacant = new UILabel();

            classTitle.BackgroundColor = UIColor.Clear;
            instructor.BackgroundColor = UIColor.Clear;
            classTime.BackgroundColor = UIColor.Clear;
            gym.BackgroundColor = UIColor.Clear;
            vacant.BackgroundColor = UIColor.Clear;

            classTitle.Text = _gymClass.title;
            instructor.Text = _gymClass.instructor ;
            classTime.Text= _gymClass.time;
            gym.Text = _gymClass.gym;

            if ( _gymClass.fullt )
                vacant.Text = "Fullt";
            else if ( _gymClass.vacant == null )
                vacant.Text ="";
            else
                vacant.Text = _gymClass.vacant + " ledig" ;

            UIView backGround = new UIView( new RectangleF( 0,0,Frame.Width ,Frame.Height ) );
            UIColor textColor = UIColor.White;
            backGround.BackgroundColor = UIColor.FromPatternImage( UIImage.FromFile ("images/violet.png") );

            if ( _gymClass.fullt )
            {
                backGround.BackgroundColor = UIColor.FromPatternImage( UIImage.FromFile ("images/grey.png") );
            } else if ( _gymClass.booked )
            {
                backGround.BackgroundColor = UIColor.FromPatternImage( UIImage.FromFile ("images/green.png") );
                textColor = UIColor.Black;
            }

            BackgroundView = backGround;

            float leftColumn = 5;
            float upperMargin = 1;
            float verticalSpace= 1;
            float horisontalSpace = 5;
            float leftLength = 200;
            float heigth = 22;
            float smallHeight = 14;

            classTitle.Frame = new RectangleF( 	leftColumn,
                                     		    upperMargin,
                                          		leftLength,
                                          		heigth );
            classTitle.TextColor = textColor;
            AddSubview( classTitle );

            gym.Frame = new RectangleF( 	leftColumn + horisontalSpace + leftLength,
                                            upperMargin ,
                                            leftLength ,
                                            smallHeight );
            gym.TextColor = textColor;
            gym.Font = UIFont.FromName("Arial",10);
            AddSubview( gym  );

            instructor.Frame = new RectangleF(	leftColumn,
                                          		upperMargin+heigth+verticalSpace,
                                          		leftLength,
                                          		smallHeight );
            instructor.Font = UIFont.FromName("Arial",10);
            instructor.TextColor = textColor;
            AddSubview( instructor );

            classTime.Frame = new RectangleF( 	leftColumn + horisontalSpace+ leftLength,
                                         		upperMargin + smallHeight ,
                                         		leftLength ,
                                         		smallHeight );
            classTime.TextColor = textColor;
            classTime.Font = UIFont.FromName("Arial",10);
            AddSubview( classTime );

            vacant.Frame = new RectangleF( 	leftColumn + horisontalSpace+ leftLength,
                                         		upperMargin + smallHeight * 2 ,
                                         		leftLength ,
                                         		smallHeight );
            vacant.TextColor = textColor;
            vacant.Font = UIFont.FromName("Arial",10);
            AddSubview( vacant );
        }
コード例 #8
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);
        }
コード例 #9
0
        public GymClassTableViewCell(GymClass gymClass)
        {
            _gymClass = gymClass;


            classTitle = new UILabel();
            instructor = new UILabel(  );
            classTime  = new UILabel();
            gym        = new UILabel();
            vacant     = new UILabel();

            classTitle.BackgroundColor = UIColor.Clear;
            instructor.BackgroundColor = UIColor.Clear;
            classTime.BackgroundColor  = UIColor.Clear;
            gym.BackgroundColor        = UIColor.Clear;
            vacant.BackgroundColor     = UIColor.Clear;


            classTitle.Text = _gymClass.title;
            instructor.Text = _gymClass.instructor;
            classTime.Text  = _gymClass.time;
            gym.Text        = _gymClass.gym;

            if (_gymClass.fullt)
            {
                vacant.Text = "Fullt";
            }
            else if (_gymClass.vacant == null)
            {
                vacant.Text = "";
            }
            else
            {
                vacant.Text = _gymClass.vacant + " ledig";
            }


            UIView  backGround = new UIView(new RectangleF(0, 0, Frame.Width, Frame.Height));
            UIColor textColor  = UIColor.White;

            backGround.BackgroundColor = UIColor.FromPatternImage(UIImage.FromFile("images/violet.png"));

            if (_gymClass.fullt)
            {
                backGround.BackgroundColor = UIColor.FromPatternImage(UIImage.FromFile("images/grey.png"));
            }
            else if (_gymClass.booked)
            {
                backGround.BackgroundColor = UIColor.FromPatternImage(UIImage.FromFile("images/green.png"));
                textColor = UIColor.Black;
            }

            BackgroundView = backGround;

            float leftColumn      = 5;
            float upperMargin     = 1;
            float verticalSpace   = 1;
            float horisontalSpace = 5;
            float leftLength      = 200;
            float heigth          = 22;
            float smallHeight     = 14;


            classTitle.Frame = new RectangleF(leftColumn,
                                              upperMargin,
                                              leftLength,
                                              heigth);
            classTitle.TextColor = textColor;
            AddSubview(classTitle);

            gym.Frame = new RectangleF(leftColumn + horisontalSpace + leftLength,
                                       upperMargin,
                                       leftLength,
                                       smallHeight);
            gym.TextColor = textColor;
            gym.Font      = UIFont.FromName("Arial", 10);
            AddSubview(gym);

            instructor.Frame = new RectangleF(leftColumn,
                                              upperMargin + heigth + verticalSpace,
                                              leftLength,
                                              smallHeight);
            instructor.Font      = UIFont.FromName("Arial", 10);
            instructor.TextColor = textColor;
            AddSubview(instructor);


            classTime.Frame = new RectangleF(leftColumn + horisontalSpace + leftLength,
                                             upperMargin + smallHeight,
                                             leftLength,
                                             smallHeight);
            classTime.TextColor = textColor;
            classTime.Font      = UIFont.FromName("Arial", 10);
            AddSubview(classTime);

            vacant.Frame = new RectangleF(leftColumn + horisontalSpace + leftLength,
                                          upperMargin + smallHeight * 2,
                                          leftLength,
                                          smallHeight);
            vacant.TextColor = textColor;
            vacant.Font      = UIFont.FromName("Arial", 10);
            AddSubview(vacant);
        }
コード例 #10
0
ファイル: TTTSchedules.cs プロジェクト: oddsve/TheGym
        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;
        }