public static ICollection <VisualActivity> MonthVisualActivitiesList()
        {
            ICollection <VisualActivity> activities = new List <VisualActivity>();

            for (int i = 0; i < 10; i++)
            {
                var summary = new SummaryActivity(startLatlng: new LatLng(), endLatlng: new LatLng(),
                                                  type: ActivityType.Crossfit, movingTime: 60, athlete: new MetaAthlete(123), startDate: new DateTime(2019, 09, i + 1), id: i);

                summary.StartLatlng.Add(30.0F);
                summary.StartLatlng.Add(40.0F);
                summary.EndLatlng.Add(30.0F);
                summary.EndLatlng.Add(40.0F);

                activities.Add(new VisualActivity(summary));
            }

            for (int i = 0; i < 30; i++)
            {
                var summary = new SummaryActivity(startLatlng: new LatLng(), endLatlng: new LatLng(),
                                                  type: ActivityType.Crossfit, movingTime: 60, athlete: new MetaAthlete(123), startDate: new DateTime(2019, 10, i + 1), id: 9 + i);

                summary.StartLatlng.Add(30.0F);
                summary.StartLatlng.Add(40.0F);
                summary.EndLatlng.Add(30.0F);
                summary.EndLatlng.Add(40.0F);

                activities.Add(new VisualActivity(summary));
            }

            return(activities);
        }
示例#2
0
        public Coordinates(SummaryActivity summaryActivity)
        {
            UserID       = summaryActivity.Athlete.Id;
            ActvityID    = summaryActivity.Id;
            ActivityType = summaryActivity.Type.ToString();

            if (summaryActivity.StartLatlng != null)
            {
                Latitude  = summaryActivity.StartLatlng[0];
                Longitude = summaryActivity.StartLatlng[1];
            }
        }
        public static SummaryActivity SummaryActivity3()
        {
            var summary2 = new SummaryActivity(startLatlng: new LatLng(), endLatlng: new LatLng(),
                                               type: ActivityType.Run, movingTime: 100, athlete: new MetaAthlete(123));

            summary2.StartLatlng.Add(30.6F);
            summary2.StartLatlng.Add(40.6F);

            summary2.EndLatlng.Add(30.6F);
            summary2.EndLatlng.Add(40.6F);

            return(summary2);
        }
        public static SummaryActivity SummaryActivity1()
        {
            var summary1 = new SummaryActivity(startLatlng: new LatLng(), endLatlng: new LatLng(),
                                               type: ActivityType.Crossfit, movingTime: 60, athlete: new MetaAthlete(123));

            summary1.StartLatlng.Add(30.0F);
            summary1.StartLatlng.Add(40.0F);

            summary1.EndLatlng.Add(30.0F);
            summary1.EndLatlng.Add(40.0F);


            return(summary1);
        }
示例#5
0
        private bool IsValidActivityType(SummaryActivity activity)
        {
            switch (activity.Type)
            {
            case "Run":
            case "Ride":
            case "VirtualRide":
            case "Swim":
            case "NordicSki":
                return(true);

            default:
                return(false);
            }
        }
示例#6
0
        public void Test_ConvertSummaryToActivity()
        {
            SummaryActivity summaryActivity = new SummaryActivity(type: ActivityType.Crossfit,
                                                                  startLatlng: new LatLng(), endLatlng: new LatLng(), movingTime: 60, athlete: new MetaAthlete(123));

            summaryActivity.StartLatlng.Add(30.0F);
            summaryActivity.StartLatlng.Add(40.0F);
            summaryActivity.EndLatlng.Add(30.0F);
            summaryActivity.EndLatlng.Add(40.0F);

            VisualActivity activity = new VisualActivity(summaryActivity);

            Assert.AreEqual(activity.StartLat, summaryActivity.StartLatlng[0]);
            Assert.AreEqual(activity.StartLong, summaryActivity.StartLatlng[1]);
            Assert.AreEqual(activity.EndLat, summaryActivity.EndLatlng[0]);
            Assert.AreEqual(activity.EndLong, summaryActivity.EndLatlng[1]);
        }
        public static ICollection <VisualActivity> SingleVisuActvityList()
        {
            var summary1 = new SummaryActivity(startLatlng: new LatLng(), endLatlng: new LatLng(),
                                               type: ActivityType.Crossfit, movingTime: 60, athlete: new MetaAthlete(123), id: 1);

            summary1.StartLatlng.Add(30.0F);
            summary1.StartLatlng.Add(40.0F);
            summary1.EndLatlng.Add(30.0F);
            summary1.EndLatlng.Add(40.0F);


            ICollection <VisualActivity> activities = new List <VisualActivity>
            {
                new VisualActivity(summary1),
            };

            return(activities);
        }
示例#8
0
        public VisualActivity(SummaryActivity summaryActivity) : this()
        {
            Summary    = summaryActivity;
            ActivityId = Summary.Id;

            if (Summary.StartLatlng != null)
            {
                StartLat  = Summary.StartLatlng[0];
                StartLong = Summary.StartLatlng[1];
            }

            if (Summary.EndLatlng != null)
            {
                EndLat  = Summary.EndLatlng[0];
                EndLong = Summary.EndLatlng[1];
            }

            UserId = Summary.Athlete.Id;
        }
示例#9
0
        public static IList <VisualActivity> MonthVisualActivitiesList()
        {
            IList <VisualActivity> activities = new List <VisualActivity>();
            Random gen             = new Random();
            var    firstDayOfMonth = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1);

            var firstDayOfTheWeek = MonthSummary.getCurrentWeekStartDate(DateTime.Today);
            var dates             = randomDatesThisMonth(gen, firstDayOfMonth, firstDayOfTheWeek);

            if (dates.Contains(firstDayOfTheWeek))
            {
                dates.Remove(firstDayOfTheWeek);
            }

            int id = 1;

            foreach (var date in dates)
            {
                var summary = new SummaryActivity(startLatlng: new LatLng(), endLatlng: new LatLng(),
                                                  type: ActivityType.Crossfit, movingTime: 60, distance: 3, elapsedTime: 3000, athlete: new MetaAthlete(123), startDate: date, id: id);

                summary.StartLatlng.Add(30.0F);
                summary.StartLatlng.Add(40.0F);
                summary.EndLatlng.Add(30.0F);
                summary.EndLatlng.Add(40.0F);
                activities.Add(new VisualActivity(summary));
                id++;
            }

            var summaryForCurrentDay = new SummaryActivity(name: "Morning run", startLatlng: new LatLng(), endLatlng: new LatLng(),
                                                           type: ActivityType.Run, movingTime: 60, distance: 5000, elapsedTime: 1380, athlete: new MetaAthlete(123), startDate: DateTime.Today, id: id);

            summaryForCurrentDay.StartLatlng.Add(30.0F);
            summaryForCurrentDay.StartLatlng.Add(40.0F);
            summaryForCurrentDay.EndLatlng.Add(30.0F);
            summaryForCurrentDay.EndLatlng.Add(40.0F);
            activities.Add(new VisualActivity(summaryForCurrentDay));

            return(activities);
        }
示例#10
0
        public void Test_getUniqueCoordinatesByType()
        {
            Map map     = new Map();
            var summary = new SummaryActivity(type: ActivityType.Ride, startLatlng: new LatLng(),
                                              endLatlng: new LatLng(), movingTime: 60, athlete: new MetaAthlete(123));

            summary.StartLatlng.Add(30.0F);
            summary.StartLatlng.Add(40.0F);
            summary.EndLatlng.Add(30.0F);
            summary.EndLatlng.Add(40.0F);
            visualActivities.Add(new VisualActivity(summary));


            map.getUniqueCoordinatesByType(visualActivities, ActivityType.Ride);
            var result = (List <Coordinate>)map.Coordinates;

            Assert.AreEqual(2, result.Count);
            Assert.AreEqual(30.6F, result[0].Latitude);
            Assert.AreEqual(40.6F, result[0].Longitude);
            Assert.AreEqual(30.0F, result[1].Latitude);
            Assert.AreEqual(40.0F, result[1].Longitude);
        }
示例#11
0
        public void Test_updateNumVisits()
        {
            Map map     = new Map();
            var summary = new SummaryActivity(type: ActivityType.Ride, startLatlng: new LatLng(),
                                              endLatlng: new LatLng(), movingTime: 60, athlete: new MetaAthlete(123));

            summary.StartLatlng.Add(30.0F);
            summary.StartLatlng.Add(40.0F);
            summary.EndLatlng.Add(30.0F);
            summary.EndLatlng.Add(40.0F);
            visualActivities.Add(new VisualActivity(summary));

            foreach (var activity in visualActivities)
            {
                map.updateNumVisits(activity);
            }
            var result = map.NumVisits;

            Assert.AreEqual(2, result.Count);
            result.TryGetValue(new Coordinate(30.0F, 40.0F), out var visits);
            Assert.AreEqual(2, visits);
        }
        public static ICollection <VisualActivity> NewVisualActivitiesList()
        {
            var summary1 = new SummaryActivity(startLatlng: new LatLng(), endLatlng: new LatLng(),
                                               type: ActivityType.Ride, movingTime: 60, athlete: new MetaAthlete(123), id: 2);
            var summary2 = new SummaryActivity(startLatlng: new LatLng(), endLatlng: new LatLng(),
                                               type: ActivityType.Ride, movingTime: 15, athlete: new MetaAthlete(123), id: 3);

            summary1.StartLatlng.Add(30.0F);
            summary1.StartLatlng.Add(40.0F);
            summary2.StartLatlng.Add(30.6F);
            summary2.StartLatlng.Add(40.6F);
            summary1.EndLatlng.Add(30.0F);
            summary1.EndLatlng.Add(40.0F);
            summary2.EndLatlng.Add(30.6F);
            summary2.EndLatlng.Add(40.6F);

            ICollection <VisualActivity> activities = new List <VisualActivity>
            {
                new VisualActivity(summary1),
                new VisualActivity(summary2)
            };

            return(activities);
        }
示例#13
0
        public static IList <VisualActivity> MapVisualActivitiesList()
        {
            IList <VisualActivity> activities = new List <VisualActivity>();

            int id   = 1;
            var date = new DateTime(2019, 6, 21);

            //Tiger Mountain
            for (int i = 0; i < 5; i++)
            {
                var summary = new SummaryActivity(startLatlng: new LatLng(), endLatlng: new LatLng(),
                                                  type: ActivityType.Ride, movingTime: 60, distance: 3, elapsedTime: 3000, athlete: new MetaAthlete(123), startDate: date, id: id);

                summary.StartLatlng.Add(47.47F);
                summary.StartLatlng.Add(-121.93F);
                summary.EndLatlng.Add(47.47F);
                summary.EndLatlng.Add(-121.93F);
                activities.Add(new VisualActivity(summary));
            }


            //Duthie Hill
            for (int i = 0; i < 15; i++)
            {
                var summary = new SummaryActivity(startLatlng: new LatLng(), endLatlng: new LatLng(),
                                                  type: ActivityType.Ride, movingTime: 60, distance: 3, elapsedTime: 3000, athlete: new MetaAthlete(123), startDate: date, id: id);

                summary.StartLatlng.Add(47.57F);
                summary.StartLatlng.Add(-121.98F);
                summary.EndLatlng.Add(47.57F);
                summary.EndLatlng.Add(-121.98F);
                activities.Add(new VisualActivity(summary));
            }

            //Swan creek
            for (int i = 0; i < 50; i++)
            {
                var summary = new SummaryActivity(startLatlng: new LatLng(), endLatlng: new LatLng(),
                                                  type: ActivityType.Ride, movingTime: 60, distance: 3, elapsedTime: 3000, athlete: new MetaAthlete(123), startDate: date, id: id);


                summary.StartLatlng.Add(47.21F);
                summary.StartLatlng.Add(-122.40F);
                summary.EndLatlng.Add(47.21F);
                summary.EndLatlng.Add(-122.40F);
                activities.Add(new VisualActivity(summary));
            }

            //Capital State
            for (int i = 0; i < 30; i++)
            {
                var summary = new SummaryActivity(startLatlng: new LatLng(), endLatlng: new LatLng(),
                                                  type: ActivityType.Ride, movingTime: 60, distance: 3, elapsedTime: 3000, athlete: new MetaAthlete(123), startDate: date, id: id);

                summary.StartLatlng.Add(46.94F);
                summary.StartLatlng.Add(-123.13F);
                summary.EndLatlng.Add(46.94F);
                summary.EndLatlng.Add(-123.13F);
                activities.Add(new VisualActivity(summary));
            }

            //Capital State Runs
            for (int i = 0; i < 20; i++)
            {
                var summary = new SummaryActivity(startLatlng: new LatLng(), endLatlng: new LatLng(),
                                                  type: ActivityType.Run, movingTime: 60, distance: 3, elapsedTime: 3000, athlete: new MetaAthlete(123), startDate: date, id: id);

                summary.StartLatlng.Add(46.94F);
                summary.StartLatlng.Add(-123.13F);
                summary.EndLatlng.Add(46.94F);
                summary.EndLatlng.Add(-123.13F);
                activities.Add(new VisualActivity(summary));
            }

            //Point Defiance Runs
            for (int i = 0; i < 5; i++)
            {
                var summary = new SummaryActivity(startLatlng: new LatLng(), endLatlng: new LatLng(),
                                                  type: ActivityType.Run, movingTime: 60, distance: 3, elapsedTime: 3000, athlete: new MetaAthlete(123), startDate: date, id: id);

                summary.StartLatlng.Add(47.31F);
                summary.StartLatlng.Add(-122.53F);
                summary.EndLatlng.Add(47.31F);
                summary.EndLatlng.Add(-122.53F);
                activities.Add(new VisualActivity(summary));
            }

            //Point Defiance Runs
            for (int i = 0; i < 7; i++)
            {
                var summary = new SummaryActivity(startLatlng: new LatLng(), endLatlng: new LatLng(),
                                                  type: ActivityType.Run, movingTime: 60, distance: 3, elapsedTime: 3000, athlete: new MetaAthlete(123), startDate: date, id: id);

                summary.StartLatlng.Add(47.20F);
                summary.StartLatlng.Add(-122.57F);
                summary.EndLatlng.Add(47.20F);
                summary.EndLatlng.Add(-122.57F);
                activities.Add(new VisualActivity(summary));
            }
            return(activities);
        }
示例#14
0
        public JsonResult SummaryInformationFilter(int userid, string startrange, string endrange)
        {
            DateTime start = DateTime.Parse(startrange);
            DateTime end   = DateTime.Parse(endrange);

            var activitydata = (from act in _dt.Activities
                                join em in _dt.ExerciseMachines on act.ExerciseMachineID equals em.ID
                                join tb in _dt.TargetBodyParts on em.TargetBodyPartID equals tb.ID
                                join bh in _dt.BodyHalfs on tb.BodyHalfID equals bh.ID
                                where act.UserID == userid && act.Date >= start && act.Date <= end
                                select new { act, em, tb, bh }).ToList();

            var upperbodydata = (from tb in _dt.TargetBodyParts
                                 join bh in _dt.BodyHalfs on tb.BodyHalfID equals bh.ID
                                 where bh.ID == 1
                                 select new { tb }).ToList();

            var lowerbodydata = (from tb in _dt.TargetBodyParts
                                 join bh in _dt.BodyHalfs on tb.BodyHalfID equals bh.ID
                                 where bh.ID == 2
                                 select new { tb }).ToList();

            var SummaryData = new Summary()
            {
                UpperBody = new List <string>(),
                LowerBody = new List <string>(),
                SActivity = new List <SummaryActivity>()
            };

            foreach (var a in upperbodydata)
            {
                SummaryData.UpperBody.Add(a.tb.Value);
            }

            foreach (var a in lowerbodydata)
            {
                SummaryData.LowerBody.Add(a.tb.Value);
            }

            foreach (var a in activitydata)
            {
                SummaryActivity data = new SummaryActivity()
                {
                    ExerciseMachineValue = a.em.Type,
                    Reps           = a.act.Reps,
                    Weights        = a.act.Weights,
                    Sets           = a.act.Sets,
                    Other          = a.act.Other,
                    BodyHalf       = a.bh.Value,
                    BodyPartTarget = a.tb.Value
                };
                SummaryData.SActivity.Add(data);
            }

            //piechart
            var bodyhalfs    = activitydata.Select(x => x.bh.Value).Distinct();
            var piechartlist = new List <BodyHalfPieChart>();

            foreach (var a in bodyhalfs)
            {
                BodyHalfPieChart piechartobj = new BodyHalfPieChart
                {
                    label = a,
                    value = activitydata.Where(x => x.bh.Value == a).Count()
                };
                piechartlist.Add(piechartobj);
            }

            //Check Error if only one body half has been used
            if (piechartlist.Count() == 1 && piechartlist[0].label == "Lower")
            {
                BodyHalfPieChart piecharobj = new BodyHalfPieChart
                {
                    label = "Upper",
                    value = 0
                };
                piechartlist.Add(piecharobj);
            }
            else if (piechartlist.Count() == 1 && piechartlist[0].label == "Upper")
            {
                BodyHalfPieChart piecharobj = new BodyHalfPieChart
                {
                    label = "Lower",
                    value = 0
                };
                piechartlist.Add(piecharobj);
            }

            //summary
            var summarycharts = new ChartSummary()
            {
                upperbodylabel = new List <TargetBodyPartRadarChart>(),
                upperbodycount = new List <TargetBodyPartCount>(),
                lowerbodylabel = new List <TargetBodyPartRadarChart>(),
                lowerbodycount = new List <TargetBodyPartCount>()
            };

            summarycharts.piechart = piechartlist;


            //upperbody
            foreach (var a in upperbodydata)
            {
                int count = 0;
                foreach (var b in activitydata)
                {
                    if (b.tb.Value == a.tb.Value)
                    {
                        count++;
                    }
                }
                TargetBodyPartCount frequency = new TargetBodyPartCount
                {
                    value = count
                };

                summarycharts.upperbodycount.Add(frequency);

                TargetBodyPartRadarChart upperbodylist = new TargetBodyPartRadarChart
                {
                    label = a.tb.Value
                };
                summarycharts.upperbodylabel.Add(upperbodylist);
            }


            //lowerbody
            foreach (var a in lowerbodydata)
            {
                int count = 0;
                foreach (var b in activitydata)
                {
                    if (b.tb.Value == a.tb.Value)
                    {
                        count++;
                    }
                }
                TargetBodyPartCount frequency = new TargetBodyPartCount
                {
                    value = count
                };

                summarycharts.lowerbodycount.Add(frequency);

                TargetBodyPartRadarChart lowerbodylist = new TargetBodyPartRadarChart
                {
                    label = a.tb.Value
                };
                summarycharts.lowerbodylabel.Add(lowerbodylist);
            }

            return(Json(summarycharts, JsonRequestBehavior.AllowGet));
        }
示例#15
0
 public ItemsDialog (SummaryActivity activity)
     : base (activity)
 {
     this.activity = activity;
     itemViewModel = ServiceContainer.Resolve<ItemViewModel> ();
 }
示例#16
0
 public ItemsDialog(SummaryActivity activity)
     : base(activity)
 {
     this.activity = activity;
     itemViewModel = ServiceContainer.Resolve <ItemViewModel> ();
 }
 public string GetActivityFilePath(SummaryActivity activity)
 {
     return(this.GetActivityFilePath(activity.Type, activity.Id.Value.ToString()));
 }