internal static void AssertNestedCategoriesAreOrderedRight(this HierachyCategoryPages page, List<Categories> listOfNestedCategories)
 {
     listOfNestedCategories = listOfNestedCategories.OrderBy(x => x.Order).ToList();
     for (int i = 0; i < listOfNestedCategories.Count; i++)
     {
         Assert.AreEqual(listOfNestedCategories[i].Name, page.NestedListWithCategories.ChildNodes[i].InnerText);
     }
 }
 /// <summary>
 /// Schedules the talks for the given duration.
 /// </summary>
 /// <param name="unscheduledTalks">The unscheduled talks.</param>
 /// <param name="duration">The duration.</param>
 /// <returns>
 /// List of scheduled talks.
 /// </returns>
 public List<ITalk> ScheduleTalks(List<ITalk> unscheduledTalks, int duration)
 {
     _result = null; //If a subset is found this will not be null.
     const int sum = 0;
     const int startIndex = 0;
     var talks = unscheduledTalks.OrderBy(talk => talk.Duration).ToList();
     int remainder = talks.Sum(talk => talk.Duration);
     ScheduleTalks(talks, duration, sum, startIndex, remainder);
     return _result;
 }
Exemplo n.º 3
0
        public static List<AspNetUsers> GetAllRedactors(AspNetUsers user)
        {
            List<AspNetUsers> Allredactors = new List<AspNetUsers>();
            var redactorsListFromTableRedactors = RedactorsRepository.FindAll(r => r.Administrator_Id == user.Id).GroupBy(a => a.UserId_Id).Select(g => g.First()).OrderBy(i => i.UserId_Id).ToList();

            if (redactorsListFromTableRedactors != null)
            {
                foreach (var redactor in redactorsListFromTableRedactors)
                {
                    Allredactors.Add(UsersRepository.Find(u => u.Id == redactor.UserId_Id));
                }
                return Allredactors.OrderBy(u => u.Email).ToList();
            }
            else
                return null;
        }
        public MainViewModel()
        {
            // please adjust this to meet your system layout ...
            // obviously this should be changed to load file dialog usage :)
            try
            {
                _movies = DataLoader.ReadItemLabels("u.item");
                _trainData = DataLoader.ReadTrainingData("u.data");
            }
            catch (Exception)
            {
                MessageBox.Show("Error loading data files! Please check ViewModel.cs for file location!", "Error loading files", MessageBoxButton.OK, MessageBoxImage.Error);
                Application.Current.Shutdown();
            }

            Movies = new ObservableCollection<Movie>(_movies.OrderBy(m=>m.Title));
            NewRank = 1;
            RaisePropertyChanged(() => NewRank);
            SelectedMovie = Movies.First();
            RaisePropertyChanged(() => SelectedMovie);

            Ranking = new Dictionary<int, int>();
            AddRankCommand = new RelayCommand(() => {
                if (!Ranking.ContainsKey(SelectedMovie.Id)) {
                    Log += string.Format("{0} - rank: {1}\n", SelectedMovie, NewRank);
                    RaisePropertyChanged(() => Log);
                    Ranking.Add(SelectedMovie.Id, NewRank);
                    Movies.Remove(SelectedMovie);
                    SelectedMovie = Movies.First();
                    RaisePropertyChanged(() => SelectedMovie);
                }
                var rec = Engine.GetRecommendations(_movies, Ranking, _trainData);
                var foo = rec.OrderByDescending(e => e.Rank);//.Where(e => !Ranking.ContainsKey(e.Id));
                Recomendations =new ObservableCollection<Movie>(foo);
                this.RaisePropertyChanged(() => Recomendations);
            });
        }
Exemplo n.º 5
0
        private void Carrega()
        {
            listProcedures.DataSource = _objProcBO.GetProcView("sys.procedures");
            listProcedures.DisplayMember = "name";
            listProcedures.ValueMember = "name";

            listView.DataSource = _objProcBO.GetProcView("sys.views");
            listView.DisplayMember = "name";
            listView.ValueMember = "name";

            listTriggers.DataSource = _objProcBO.GetProcView("sys.triggers");
            listTriggers.DisplayMember = "name";
            listTriggers.ValueMember = "name";

            lConstraints = new List<constraintsModel>();
            lConstraints = objConstrBo.GetAllConstraints();
            listConstraints.Items.Clear();
            foreach (var item in lConstraints.OrderBy(c => c.sConstrName))
            {
                listConstraints.Items.Add(item: item.sConstrName.ToString());
            }

            listProcedures_Click(this, null);
        }
Exemplo n.º 6
0
        public IEnumerator Load()
        {
            DebugLog("+Load()");

            var pyriteQuery = new PyriteQuery(this, SetName, ModelVersion, PyriteServer);
            yield return StartCoroutine(pyriteQuery.LoadAll());
            DebugLog("CubeQuery complete.");

            var pyriteLevel =
                pyriteQuery.DetailLevels[DetailLevel];

            var allOctCubes = pyriteQuery.DetailLevels[DetailLevel].Octree.AllItems();

            foreach (var octCube in allOctCubes)
            {
                var pCube = CreateCubeFromCubeBounds(octCube);

                var x = pCube.X;
                var y = pCube.Y;
                var z = pCube.Z;
                var cubePos = pyriteLevel.GetWorldCoordinatesForCube(pCube);

                if (UseCameraDetection)
                {
                    // Move cube to the orientation we want also move it up since the model is around -600
                    var g =
                        (GameObject)
                            //Instantiate(PlaceHolderCube, new Vector3(-cubePos.x, cubePos.z + 600, -cubePos.y),
                            //Instantiate(PlaceHolderCube, new Vector3(-cubePos.x, cubePos.z, -cubePos.y),
                            Instantiate(PlaceHolderCube, new Vector3(cubePos.x, cubePos.y, cubePos.z),
                                Quaternion.identity);

                    //var loc = Instantiate(LocatorCube, new Vector3(cubePos.x, cubePos.y, cubePos.z), Quaternion.identity) as GameObject;
                    var loc = Instantiate(LocatorCube, cubePos, Quaternion.identity) as GameObject;
                    loc.transform.parent = gameObject.transform;

                    g.transform.parent = gameObject.transform;
                    //g.GetComponent<MeshRenderer>().material.color = _colorList[_colorSelector%_colorList.Length];
                    g.GetComponent<IsRendered>().SetCubePosition(x, y, z, DetailLevel, pyriteQuery, this);

                    g.transform.localScale = new Vector3(
                        pyriteLevel.WorldCubeScale.x,
                        pyriteLevel.WorldCubeScale.z,
                        pyriteLevel.WorldCubeScale.y);
                    _colorSelector++;
                }
                else
                {
                    var loadRequest = new LoadCubeRequest(x, y, z, DetailLevel, pyriteQuery, null);
                    EnqueueLoadCubeRequest(loadRequest);
                }
            }

            if (CameraRig != null)
            {
                //DebugLog("Moving camera");
                // Hardcoding some values for now

                //var min = new Vector3(pyriteLevel.ModelBoundsMin.x, pyriteLevel.ModelBoundsMin.y,
                //    pyriteLevel.ModelBoundsMin.z);
                //var max = new Vector3(pyriteLevel.ModelBoundsMax.x, pyriteLevel.ModelBoundsMax.y,
                //    pyriteLevel.ModelBoundsMax.z);

                //min += pyriteLevel.WorldCubeScale/2;
                //max -= pyriteLevel.WorldCubeScale/2;
                //var newCameraPosition = min + (max - min)/2.0f;

                //newCameraPosition += new Vector3(0, 0, (max - min).z*1.4f);
                //CameraRig.transform.position = newCameraPosition;
                //CameraRig.transform.rotation = Quaternion.Euler(0, 180, 0);
                //DebugLog("Done moving camera");

                //var delta = pyriteLevel.ModelBoundsMax - pyriteLevel.ModelBoundsMin;
                //var center = pyriteLevel.ModelBoundsMin + new Vector3(-delta.x / 2, delta.z /2 , -delta.y);
                //CameraRig.transform.position = center;

                //var allOctCubes = pyriteQuery.DetailLevels[DetailLevel].Octree.AllItems();

                // RPL CONVERSION
                List<GridPos> gList = new List<GridPos>();
                Dictionary<string, CubeBounds> gDict = new Dictionary<string, CubeBounds>();
                foreach (var octCube in allOctCubes)
                {
                    var pCube = CreateCubeFromCubeBounds(octCube);

                    var x = pCube.X;
                    var y = pCube.Y;
                    var z = pCube.Z;
                    var gPos = new GridPos(x, y, z);
                    gList.Add(gPos);
                    gDict.Add(gPos.ToKeyString(), octCube);
                }

                int midIndex = gList.Count / 2;
                var gMid = gList.OrderBy(n => n.x).ThenBy(n => n.y).ThenBy(n => n.z).ToList()[midIndex];
                var cubeBound = CreateCubeFromCubeBounds(gDict[gMid.ToKeyString()]);
                var cubeVector3 = pyriteLevel.GetWorldCoordinatesForCube(cubeBound);
                CameraRig.transform.position = cubeVector3;

                var r = Instantiate(LocatorCube, cubeVector3, Quaternion.identity) as GameObject;
                r.GetComponent<MeshRenderer>().material.color = Color.green;
                r.transform.localScale = new Vector3(12f, 12f, 12f);

                //Instantiate(RenderCubes);
                //RenderCubes.GetComponent<RenderCubes3D>().GridMinSize = (int)(pyriteQuery.DetailLevels[DetailLevel].WorldCubeScale.x);   // World Size cut to 3x3x3 Sections
                //RenderCubes.GetComponent<RenderCubes3D>().CreateCubeLayers(CameraRig.transform.position);

            }
            DebugLog("-Load()");
        }
        /// <summary>
        /// proceed input
        /// </summary>
        /// <param name="inputList"></param>
        public List<string> ProceedInput(string[] inputList,string reportType)
        {
            //transfer input to model
            List<InputReportModel> inputRepModels = new List<InputReportModel>();
            List<OutputReportModel> outputRepModel = new List<OutputReportModel>();
            List<string> Output = new List<string>();
            int count = 1;
            foreach (var item in inputList)
            {
                string[] input = item.Split('\t');
                inputRepModels.Add(
                    new InputReportModel
                    {
                        CaseSeq = count++,
                        EditCaption = input[0],
                        DeleteCaption = input[1],
                        StartHour = Get24HourFormat(input[2]),
                        EndHour = Get24HourFormat(input[3]),
                        FBId = Int64.Parse(input[4]),
                        Description = input[5]
                    }
                    );
            }

            //process output (count man hour)
            foreach (var item in inputRepModels.OrderBy(x => x.CaseSeq))
            {
                outputRepModel.Add
                    (
                        new OutputReportModel
                        {
                            CaseSeq = item.CaseSeq,
                            FBId = item.FBId,
                            Description = item.Description,
                            ManHour = SubstractTime(item.StartHour, item.EndHour)
                        }
                    );
            }

            //group by fb id
            var groupOutput = (from O in outputRepModel
                               group O by O.FBId into G
                               select new OutputReportModel
                               {
                                   CaseSeq = G.First().CaseSeq,
                                   FBId = G.First().FBId,
                                   Description = G.First().Description,
                                   ManHour = G.Sum(x => x.ManHour)
                               }).OrderBy(x => x.CaseSeq).ToList();

            //create output
            int auto = 1;
            double totalManHour = 0;
            foreach (var item in groupOutput)
            {
                if (reportType == C.Constant.MitraisReport)
                {
                    totalManHour += item.ManHour;
                    Output.Add((auto++).ToString() + '\t' + '[' + item.FBId + "] " + item.Description + '\t' + item.ManHour + System.Environment.NewLine);
                }
                else
                {
                    string clientName = item.Description.Split(C.Constant.FbDescDelimeter)[0];
                    string fBCompleteLink = C.Constant.FBLink + item.FBId.ToString();

                    Output.Add(clientName + '\t' + fBCompleteLink + System.Environment.NewLine);
                }
            }

            Output.Add(System.Environment.NewLine + System.Environment.NewLine);
            Output.Add("Total Man Hour =" + totalManHour);

            return Output;
        }
 /// <summary>
 /// Handler for <see cref="Page.OnNavigatedTo(Windows.UI.Xaml.Navigation.NavigationEventArgs)" />.
 /// </summary>
 /// <param name="parameter"><see cref="Windows.UI.Xaml.Navigation.NavigationEventArgs.Parameter" />.</param>
 public async void Activate(object parameter)
 {
     string lsActivityID = parameter as string;
     MSHealthActivities loActivities = null;
     MSHealthSplitDistanceType loDistanceType = MSHealthSplitDistanceType.None;
     MSHealthActivityInclude loInclude = MSHealthActivityInclude.Details | MSHealthActivityInclude.MapPoints;
     IsLoaded = false;
     Activity = null;
     TotalDistance = null;
     DistanceUnitShort = null;
     Pace = null;
     Splits = null;
     HeartRateZones = null;
     MapPath = null;
     ElevationGain = null;
     ElevationLoss = null;
     MaxElevation = null;
     MinElevation = null;
     IsElevationAvailable = false;
     IsHeartRateZonesAvailable = false;
     IsNikePlusAvailable = false;
     List<HeartRateZoneItem> loHeartRateZones = null;
     // Set back button visible (for Windows app)
     SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;
     // Check parameter (Activity ID)
     if (!string.IsNullOrEmpty(lsActivityID))
     {
         IsRunningRequest = true;
         // Determine Distance Unit
         switch (Settings.MSHealthFilterDistance)
         {
             case DistanceUnit.DISTANCE_MILE:
                 loDistanceType = MSHealthSplitDistanceType.Mile;
                 DistanceUnitShort = Resources.Strings.TextDistanceUnitShortMileText;
                 break;
             case DistanceUnit.DISTANCE_KILOMETER:
                 loDistanceType = MSHealthSplitDistanceType.Kilometer;
                 DistanceUnitShort = Resources.Strings.TextDistanceUnitShortKilometerText;
                 break;
         }
         try
         {
             // Get Activity details
             loActivities = await moMSHealthClient.ListActivities(ids: lsActivityID,
                                                                  include: loInclude,
                                                                  splitDistanceType: loDistanceType);
             // Check Activity details returned
             if (loActivities.ItemCount > 0)
             {
                 // Map from derivated activities to single instance activity
                 if (loActivities.FreePlayActivities != null &&
                     loActivities.FreePlayActivities.Any())
                     Activity = loActivities.FreePlayActivities.FirstOrDefault();
                 else if (loActivities.RunActivities != null &&
                          loActivities.RunActivities.Any())
                     Activity = loActivities.RunActivities.FirstOrDefault();
                 else if (loActivities.BikeActivities != null &&
                          loActivities.BikeActivities.Any())
                     Activity = loActivities.BikeActivities.FirstOrDefault();
                 else if (loActivities.GolfActivities != null &&
                          loActivities.GolfActivities.Any())
                     Activity = loActivities.GolfActivities.FirstOrDefault();
                 else if (loActivities.GuidedWorkoutActivities != null &&
                          loActivities.GuidedWorkoutActivities.Any())
                     Activity = loActivities.GuidedWorkoutActivities.FirstOrDefault();
                 else if (loActivities.SleepActivities != null &&
                          loActivities.SleepActivities.Any())
                     Activity = loActivities.SleepActivities.FirstOrDefault();
                 else if (loActivities.HikeActivities != null &&
                          loActivities.HikeActivities.Any())
                     Activity = loActivities.HikeActivities.FirstOrDefault();
             }
             // Check current activity instance
             if (Activity != null)
             {
                 // Calculate Total Distance
                 if (Activity.SplitDistance != null &&
                     Activity.SplitDistance.HasValue &&
                     Activity.SplitDistance.Value > 0 &&
                     Activity.DistanceSummary != null &&
                     Activity.DistanceSummary.TotalDistance != null &&
                     Activity.DistanceSummary.TotalDistance.HasValue)
                 {
                     TotalDistance = (decimal)Activity.DistanceSummary.TotalDistance / (decimal)Activity.SplitDistance;
                 }
                 // Calculate Pace
                 if (Activity.DistanceSummary != null &&
                     Activity.DistanceSummary.Pace != null &&
                     Activity.DistanceSummary.Pace.HasValue)
                 {
                     Pace = TimeSpan.FromMilliseconds((double)Activity.DistanceSummary.Pace);
                 }
                 // Calculate Elevation
                 if (Activity.DistanceSummary != null)
                 {
                     // Elevation Gain
                     if (Activity.DistanceSummary.ElevationGain != null)
                     {
                         ElevationGain = (double)Activity.DistanceSummary.ElevationGain / MSHealthDistanceSummary.ELEVATION_FACTOR;
                         IsElevationAvailable = true;
                     }
                     // Elevation Loss
                     if (Activity.DistanceSummary.ElevationLoss != null)
                     {
                         ElevationLoss = (double)Activity.DistanceSummary.ElevationLoss / MSHealthDistanceSummary.ELEVATION_FACTOR;
                         IsElevationAvailable = true;
                     }
                     // Max Elevation
                     if (Activity.DistanceSummary.MaxElevation != null)
                     {
                         MaxElevation = (double)Activity.DistanceSummary.MaxElevation / MSHealthDistanceSummary.ELEVATION_FACTOR;
                         IsElevationAvailable = true;
                     }
                     // Min Elevation
                     if (Activity.DistanceSummary.MinElevation != null)
                     {
                         MinElevation = (double)Activity.DistanceSummary.MinElevation / MSHealthDistanceSummary.ELEVATION_FACTOR;
                         IsElevationAvailable = true;
                     }
                 }
                 // Heart Rate Zones
                 if (Activity.PerformanceSummary != null &&
                     Activity.PerformanceSummary.HeartRateZones != null)
                 {
                     loHeartRateZones = new List<HeartRateZoneItem>();
                     // Underhealthy
                     loHeartRateZones.Add(new HeartRateZoneItem()
                     {
                         Key = HeartRateZoneItem.HRZONE_UNDER_HEALTHY,
                         Name = Resources.Strings.TextHeartRateZoneUnderHealthyText,
                         Value = Activity.PerformanceSummary.HeartRateZones.UnderHealthyHeart ?? 0,
                     });
                     // Healthy
                     loHeartRateZones.Add(new HeartRateZoneItem()
                     {
                         Key = HeartRateZoneItem.HRZONE_HEALTHY,
                         Name = Resources.Strings.TextHeartRateZoneHealthyText,
                         Value = Activity.PerformanceSummary.HeartRateZones.HealthyHeart ?? 0,
                     });
                     // Fitness
                     loHeartRateZones.Add(new HeartRateZoneItem()
                     {
                         Key = HeartRateZoneItem.HRZONE_FITNESS,
                         Name = Resources.Strings.TextHeartRateZoneFitnessText,
                         Value = Activity.PerformanceSummary.HeartRateZones.FitnessZone ?? 0,
                     });
                     // Aerobic
                     loHeartRateZones.Add(new HeartRateZoneItem()
                     {
                         Key = HeartRateZoneItem.HRZONE_AEROBIC,
                         Name = Resources.Strings.TextHeartRateZoneAerobicText,
                         Value = Activity.PerformanceSummary.HeartRateZones.Aerobic ?? 0,
                     });
                     // Anaerobic
                     loHeartRateZones.Add(new HeartRateZoneItem()
                     {
                         Key = HeartRateZoneItem.HRZONE_ANAEROBIC,
                         Name = Resources.Strings.TextHeartRateZoneAnaerobicText,
                         Value = Activity.PerformanceSummary.HeartRateZones.Anaerobic ?? 0,
                     });
                     // Redline
                     loHeartRateZones.Add(new HeartRateZoneItem()
                     {
                         Key = HeartRateZoneItem.HRZONE_REDLINE,
                         Name = Resources.Strings.TextHeartRateZoneRedlineText,
                         Value = Activity.PerformanceSummary.HeartRateZones.Redline ?? 0,
                     });
                     // OverRedline
                     loHeartRateZones.Add(new HeartRateZoneItem()
                     {
                         Key = HeartRateZoneItem.HRZONE_OVER_REDLINE,
                         Name = Resources.Strings.TextHeartRateZoneOverRedlineText,
                         Value = Activity.PerformanceSummary.HeartRateZones.OverRedline ?? 0,
                     });
                     HeartRateZones = new ObservableCollection<HeartRateZoneItem>(loHeartRateZones);
                     IsHeartRateZonesAvailable = true;
                 }
                 // Segments (splits)
                 if (Activity.ActivitySegments != null &&
                     Activity.ActivitySegments.Any() &&
                     TotalDistance != null)
                 {
                     // ActivitySegment to Split
                     double ldSplitValue = 0;
                     List<SplitItem> loSplits = new List<SplitItem>();
                     foreach (MSHealthActivitySegment loSegment in Activity.ActivitySegments.OrderBy(loSeg => loSeg.StartTime))
                     {
                         ldSplitValue++;
                         loSplits.Add(new SplitItem()
                         {
                             Value = ldSplitValue > (double)TotalDistance.Value ? (double)TotalDistance.Value : ldSplitValue,
                             Duration = loSegment.Duration.Value,
                             AvgHeartRate = loSegment.HeartRateSummary != null ? loSegment.HeartRateSummary.AverageHeartRate.Value : 0,
                         });
                     }
                     // Get Max/Min Duration/HR, for complete splits only
                     try
                     {
                         loSplits.Where(loSplit => (loSplit.Value % 1) == 0).OrderBy(loSplit => loSplit.Duration).First().DurationMark = "↓";
                         loSplits.Where(loSplit => (loSplit.Value % 1) == 0).OrderByDescending(loSplit => loSplit.Duration).First().DurationMark = "↑";
                         loSplits.Where(loSplit => (loSplit.Value % 1) == 0).OrderBy(loSplit => loSplit.AvgHeartRate).First().HRMark = "↓";
                         loSplits.Where(loSplit => (loSplit.Value % 1) == 0).OrderByDescending(loSplit => loSplit.AvgHeartRate).First().HRMark = "↑";
                     }
                     catch { /* Do nothing */ }
                     // Sort by value and assign to instance
                     loSplits = loSplits.OrderBy(loSplit => loSplit.Value).ToList();
                     Splits = new ObservableCollection<SplitItem>(loSplits);
                 }
                 // MapPoints to MapPath
                 if (Activity.MapPoints != null &&
                     Activity.MapPoints.Any())
                 {
                     List<BasicGeoposition> loGeopositions = new List<BasicGeoposition>();
                     loGeopositions = (from loMapPoint in Activity.MapPoints
                                                                  .Where(loPoint => loPoint.Location != null &&
                                                                                    loPoint.Location.Latitude != null &&
                                                                                    loPoint.Location.Longitude != null)
                                                                  .OrderBy(loPoint => loPoint.Ordinal)
                                       select new BasicGeoposition()
                                       {
                                           Latitude = (double)loMapPoint.Location.Latitude / MSHealthGPSPoint.LATITUDE_FACTOR,
                                           Longitude = (double)loMapPoint.Location.Longitude / MSHealthGPSPoint.LONGITUDE_FACTOR,
                                           Altitude = loMapPoint.Location.ElevationFromMeanSeaLevel != null ?
                                                         ((double)loMapPoint.Location.ElevationFromMeanSeaLevel / MSHealthGPSPoint.ELEVATION_FACTOR) : 0d,
                                       }).ToList();
                     //foreach (var loMapPoint in Activity.MapPoints)
                     //{
                     //    if (loMapPoint.Location != null &&
                     //        loMapPoint.Location.Latitude != null &&
                     //        loMapPoint.Location.Longitude != null)
                     //    {
                     //        loGeopositions.Add(new BasicGeoposition()
                     //        {
                     //            Latitude = (double)loMapPoint.Location.Latitude / 10000000d,
                     //            Longitude = (double)loMapPoint.Location.Longitude / 10000000d,
                     //        });
                     //    }
                     //}
                     if (loGeopositions.Any())
                     {
                         MapPath = new Geopath(loGeopositions);
                     }
                 }
             }
         }
         catch (Exception loException)
         {
             // Handle exceptions (just for debugging purposes)
             if (System.Diagnostics.Debugger.IsAttached)
                 System.Diagnostics.Debug.WriteLine(loException.StackTrace);
             await moDialogService.ShowError(Resources.Strings.MessageContentErrorOperation,
                                             Resources.Strings.MessageTitleError,
                                             Resources.Strings.MessageButtonOK,
                                             null);
             // Return to main page
             moNavigationService.GoBack();
         }
         finally
         {
             Messenger.Default.Send<Geopath>(MapPath);
             IsRunningRequest = false;
         }
         // Check for Nike+ Credentials
         if (Settings.NikePlusCredential != null)
         {
             if (!System.Text.RegularExpressions.Regex.IsMatch(Settings.NikePlusCredential.Password, "[\"&`'<>]"))
             {
                 try
                 {
                     // Check for GPS data
                     if (Activity.MapPoints == null ||
                         !Activity.MapPoints.Any())
                     {
                         // Get Minute Summaries
                         loActivities = await moMSHealthClient.ListActivities(ids: lsActivityID,
                                                                      include: MSHealthActivityInclude.MinuteSummaries,
                                                                      splitDistanceType: loDistanceType);
                         // Check Activity details returned
                         if (loActivities.ItemCount > 0)
                         {
                             // Map from derivated activities to single instance activity
                             if (loActivities.FreePlayActivities != null &&
                                 loActivities.FreePlayActivities.Any())
                                 Activity.MinuteSummaries = loActivities.FreePlayActivities.FirstOrDefault().MinuteSummaries;
                             else if (loActivities.RunActivities != null &&
                                      loActivities.RunActivities.Any())
                                 Activity.MinuteSummaries = loActivities.RunActivities.FirstOrDefault().MinuteSummaries;
                             else if (loActivities.BikeActivities != null &&
                                      loActivities.BikeActivities.Any())
                                 Activity.MinuteSummaries = loActivities.BikeActivities.FirstOrDefault().MinuteSummaries;
                             else if (loActivities.GolfActivities != null &&
                                      loActivities.GolfActivities.Any())
                                 Activity.MinuteSummaries = loActivities.GolfActivities.FirstOrDefault().MinuteSummaries;
                             else if (loActivities.GuidedWorkoutActivities != null &&
                                      loActivities.GuidedWorkoutActivities.Any())
                                 Activity.MinuteSummaries = loActivities.GuidedWorkoutActivities.FirstOrDefault().MinuteSummaries;
                             else if (loActivities.SleepActivities != null &&
                                      loActivities.SleepActivities.Any())
                                 Activity.MinuteSummaries = loActivities.SleepActivities.FirstOrDefault().MinuteSummaries;
                         }
                     }
                 }
                 catch (Exception loException)
                 {
                     // Handle exceptions (just for debugging purposes)
                     if (System.Diagnostics.Debugger.IsAttached)
                         System.Diagnostics.Debug.WriteLine(loException.StackTrace);
                 }
                 // Ensure Activity either has GPS or MinuteSummaries data
                 if ((Activity.MapPoints != null &&
                      Activity.MapPoints.Any()) ||
                      (Activity.MinuteSummaries != null &&
                       Activity.MinuteSummaries.Any()))
                 {
                     moNikePlusClient.SetCredentials(Settings.NikePlusCredential.UserName, Settings.NikePlusCredential.Password);
                     IsNikePlusAvailable = true;
                 }
             }
         }
         IsLoaded = true;
     }
 }
Exemplo n.º 9
0
		/// <summary>
		/// Gets a list of all available languages.
		/// </summary>
		/// <param name="mirror">Mirror to use.</param>
		/// <returns>Collection of all available languages.</returns>
		/// <example>Shows how to get all languages.
		/// <code>
		/// namespace Docunamespace
		/// {
		/// 	/// <summary>
		/// 	/// Class for the docu.
		/// 	/// </summary>
		/// 	class DocuClass
		/// 	{
		/// 		/// <summary>
		/// 		/// Gets all mirrors that are available.
		/// 		/// </summary>
		/// 		public List&#60;Language&#62; GetAllLanguages(Mirror mirror)
		/// 		{
		///				string apiKey = "ABCD12345";
		/// 			TVDB.Web.ITvDb instance = new TVDB.Web.WebInterface(apiKey);
		/// 			List&#60;Language&#62; languages = await instance.GetLanguages(mirror);
		/// 
		/// 			return languages
		/// 		}
		/// 	}
		/// }
		/// </code>
		/// </example>
		public async Task<List<Language>> GetLanguages(Mirror mirror)
		{
			if (mirror == null)
			{
				return null;
			}

			string url = "{0}/api/{1}/languages.xml";

            byte[] result = await this.client.DownloadDataTaskAsync(string.Format(url, mirror.Address, APIKey)).ConfigureAwait(continueOnCapturedContext: false);
			MemoryStream resultStream = new MemoryStream(result);

			XmlDocument doc = new XmlDocument();
			doc.Load(resultStream);
			XmlNode dataNode = doc.ChildNodes[1];

			List<Language> receivedLanguages = new List<Language>();

			foreach (XmlNode currentNode in dataNode.ChildNodes)
			{
				Language deserialized = new Language();
				deserialized.Deserialize(currentNode);

				receivedLanguages.Add(deserialized);
			}

			return receivedLanguages.OrderBy(x => x.Name).ToList<Language>();
		}
Exemplo n.º 10
0
 private void SelectDay()
 {
     DateTime now = new DateTime(int.Parse(this.YearDropDownList.SelectedValue), int.Parse(this.MonthDropDownList.SelectedValue), 1);
     List<int> days = new List<int>(31);
     for (int i = 1; i <= DateTime.DaysInMonth(now.Year, now.Month); i++)
     {
         days.Add(i);
     }
     this.DayDropDownList.DataSource = days.OrderBy(d => d);
     this.DayDropDownList.DataBind();
 }