Пример #1
0
        protected void Button3_Click(object sender, EventArgs e)
        {
            MembershipUser user = Membership.GetUser();
            string id = user.ProviderUserKey.ToString();
            Guid g = Guid.Parse(id);

            RoutesManager rm = new RoutesManager(g);
            DateTime begindatetime = DateTime.ParseExact(TextBox1.Text,"MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture);
            DateTime enddatetime = DateTime.ParseExact(TextBox2.Text, "MM/dd/yyyy",System.Globalization.CultureInfo.InvariantCulture);

            int compare = DateTime.Compare(begindatetime,enddatetime);
            if (compare > 0)
            {
                Label3.Visible = true;
                Label3.Text = "Der Startdatum muss früher als Enddatum sein ";
            }
            else
            {
                Label3.Visible = false;
                List<Entities.Route> result;
                result = rm.GetAllRoutesForDate(begindatetime, enddatetime);
                GridView1.DataSource = result;
                GridView1.DataBind();
            }
        }
Пример #2
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            MembershipUser user = Membership.GetUser();
            string id = user.ProviderUserKey.ToString();
            Guid g = Guid.Parse(id);
            bool force;
            if (XMLUploader.HasFile)
            {
                string fileExt = System.IO.Path.GetExtension(XMLUploader.FileName);
                if (fileExt == ".gpx" || fileExt == ".xml" || fileExt == ".txt")
                {
                    RoutesManager rm = new RoutesManager(g);
                    if (TextBox3.Text == "")
                    {
                        force = false;

                    }
                    else
                    {
                        force = true;
                    }
                    rm.ImportRoute(XMLUploader.FileContent, TextBox3.Text, force);

                    //rm.ImportRoute(XMLUploader.FileContent, TextBox3.Text,false);
                    // Label2.Visible = true;
                    //Label2.Text = "the task is done !";
                    TextBox3.Text = "";
                    updategrid();
                }
                else
                {
                    //Label2.Visible = true;
                    //Label2.Text = "Only .gpx files allowed!";
                }

            }
            else
            {
                //Label2.Visible = true;
                //Label2.Text = "You have not specified a file.";
            }
        }
Пример #3
0
        protected void Button4_Click(object sender, EventArgs e)
        {
            MembershipUser user = Membership.GetUser();
            string id = user.ProviderUserKey.ToString();
            Guid g = Guid.Parse(id);
            RoutesManager rm = new RoutesManager(g);
            foreach (GridViewRow grv in GridView1.Rows)
            {

                if (((CheckBox)grv.Cells[2].FindControl("CheckBox1")).Checked==true)
                {
                    rm.DeleteRoute((int)GridView1.DataKeys[grv.RowIndex].Value);
                }
            }
            updategrid();
            LinkButton1.Visible = false;
        }
Пример #4
0
        private void updategrid()
        {
            MembershipUser user = Membership.GetUser();
            string id = user.ProviderUserKey.ToString();
            Guid g = Guid.Parse(id);
            RoutesManager rm = new RoutesManager(g);
            rm.GetAllRoutes();
            List<Entities.Route> result;
            result = rm.GetAllRoutes();
            GridView1.DataSource = result;
            GridView1.DataBind();
            Label3.Visible = false;
            for (int i = 0, checkedCount = 0; i < GridView1.Rows.Count; i++)
            {
                CheckBox chb = (CheckBox)GridView1.Rows[i].Cells[0].Controls[1];
                if (chb.Checked)
                {
                    checkedCount++;

                    if (checkedCount < 2)
                    {
                        LinkButton1.Visible = false;
                        return;
                    }
                }
            }
        }
Пример #5
0
        protected void Button5_Click(object sender, EventArgs e)
        {
            MembershipUser user = Membership.GetUser();
            string id = user.ProviderUserKey.ToString();
            Guid g = Guid.Parse(id);
            RoutesManager rm = new RoutesManager(g);
            rm.DeleteAllRoutes();

            rm.GetAllRoutes();
            List<Entities.Route> result;
            result = rm.GetAllRoutes();
            GridView1.DataSource = result;
            LinkButton1.Visible = false;
            GridView1.DataBind();
        }
        /// <summary>
        /// Occurs on the page load. Binds the data and initializes the page controls.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The event arguments.
        /// </param>
        protected void Page_Load(object sender, EventArgs e)
        {
            List<int> routeIds;
            var userGuid = (Guid)Membership.GetUser().ProviderUserKey;
            _routeManager = new RoutesManager(userGuid);

            if (BindRoutes(out routeIds))
            {
                return;
            }

            InitializeChart(chtElevationGain, "Routepunkte", "Meters");
            InitializeChart(chtSpeed, "Routepunkte", "Km/h");

            //Elevation
            for (int i = 0; i < routeIds.Count; i++)
            {
                var route = this._routeManager.GetByIdForCurrentUser(routeIds[i]);

                if (i >= chtElevationGain.Series.Count)
                {
                    var series = chtElevationGain.Series.Add(route.Id.ToString());
                    series.LegendText = route.Name;
                    series.ChartType = SeriesChartType.Spline;
                    series.Legend = chtElevationGain.Legends[0].Name;
                }
                if (i >= chtSpeed.Series.Count)
                {
                    var series = chtSpeed.Series.Add(route.Id.ToString());
                    series.LegendText = route.Name;
                    series.ChartType = SeriesChartType.Spline;
                    series.Legend = chtSpeed.Legends[0].Name;
                }

                for (var j = 0; j < route.TrackPoints.Count; j++)
                {
                    var dp = new DataPoint
                                 {
                                     Label =
                                         route.TrackPoints[j].Elevation.ToString(CultureInfo.InvariantCulture),
                                     Color = _colors[route.Id % _colors.Length],
                                     BorderWidth = 2,
                                     LabelForeColor = Color.Orange,
                                     LabelBackColor = Color.DarkBlue,
                                     IsValueShownAsLabel = true,
                                     XValue = j
                                 };

                    dp.SetValueY(route.TrackPoints[j].Elevation);
                    chtElevationGain.Series[i].Points.Add(dp);
                }

                chtElevationGain.Series[route.Id.ToString()].Color = _colors[route.Id % _colors.Length];
                chtSpeed.Series[route.Id.ToString()].Color = _colors[route.Id % _colors.Length];

                //Speed
                for (var j = 0; j < route.SpeedStages.Count; j++)
                {
                    var dp = new DataPoint
                    {
                        Label = route.SpeedStages[j].ToString("0.0", CultureInfo.InvariantCulture),
                        Color = _colors[route.Id % _colors.Length],
                        BorderWidth = 2,
                        LabelForeColor = Color.Orange,
                        LabelBackColor = Color.DarkBlue,
                        IsValueShownAsLabel = true,
                        XValue = j
                    };

                    dp.SetValueY(route.SpeedStages[j]);
                    chtSpeed.Series[i].Points.Add(dp);

                }
            }

            chtElevationGain.DataBind();
            chtSpeed.DataBind();
        }
        public void InitializeRoutesManagerTests()
        {
            // Add a route just for test purposes
            var route = new Route(1)
                            {
                                Name = "TestRoute",
                                Time = new DateTime(2012, 06, 01),
                                UserId = _userGuid,
                                TrackPoints = new List<TrackPoint>
                                                  {
                                                      new TrackPoint
                                                          {
                                                              Elevation = 2.45f,
                                                              Id = 1,
                                                              Latitude = 38.56477415,
                                                              Longitude = 40.454678457,
                                                              Time = new DateTime(2012, 06, 01)
                                                          },
                                                      new TrackPoint
                                                          {
                                                              Elevation = 1.94f,
                                                              Id = 2,
                                                              Latitude = 38.52477415,
                                                              Longitude = 41.054678457,
                                                              Time = new DateTime(2012, 06, 01)
                                                          }
                                                  }
                            };

            _routesRepositoryMock.Save(route);

            route = new Route(2)
            {
                Name = "TestRoute",
                Time = DateTime.Now,
                UserId = _userGuid,
                TrackPoints = new List<TrackPoint>
                                                  {
                                                      new TrackPoint
                                                          {
                                                              Elevation = 1.75f,
                                                              Id = 3,
                                                              Latitude = 45.457314474,
                                                              Longitude = 34.2123154,
                                                              Time = DateTime.Now
                                                          },
                                                      new TrackPoint
                                                          {
                                                              Elevation = 1.94f,
                                                              Id = 4,
                                                              Latitude = 50.4232352352,
                                                              Longitude = 32.123534523,
                                                              Time = DateTime.Now
                                                          }
                                                  }
            };

            _routesRepositoryMock.Save(route);

            _routesManager = new RoutesManager(_routesRepositoryMock, _userGuid);
        }