Esempio n. 1
0
        private void CreateActivity()
        {
            var startString = EditableString.Input("Activity start", null).Value;

            if (!DateTime.TryParse(startString, out var start))
            {
                Console.WriteLine("Wrong date format, aborting!");
                return;
            }

            var endString = EditableString.Input("Activity end", null).Value;

            if (!DateTime.TryParse(endString, out var end) || end < start)
            {
                Console.WriteLine("Wrong activity end time, aborting!");
                return;
            }

            var activity = new Activity
            {
                Start  = start,
                End    = end,
                Source = Source.Manual,
                Value  = EditableString.Input("Activity name", "Manual Activity").Value
            };

            _data.Activities.Add(activity);
        }
Esempio n. 2
0
        private void DetectActivity()
        {
            var lats    = _data.Latitudes.OrderByDescending(a => a.Key).ToList();
            var actEnd  = DateTime.Now;
            var prevLat = actEnd;

            for (int i = 0; i < lats.Count; i++)
            {
                var curLat = lats[i].Key;

                if (i == 0)
                {
                    actEnd  = curLat;
                    prevLat = curLat;
                    continue;
                }

                if (curLat.AddMinutes(5) > prevLat)
                {
                    prevLat = curLat;
                    continue;
                }

                var activity = new Activity
                {
                    End    = actEnd,
                    Start  = curLat,
                    Source = Source.Other,
                    Value  = "Detected"
                };

                if (EditableString
                    .Input($"Activity {activity.Start} - {actEnd} detected, add to Activities? [yes]/no", "yes")
                    .Value == "yes")
                {
                    _data.Activities.Add(activity);
                    if (lats.Count > i)
                    {
                        actEnd  = lats[i + 1].Key;
                        prevLat = actEnd;
                    }
                }

                if (EditableString
                    .Input("Detect next? yes/[no]", "no")
                    .Value == "no")
                {
                    return;
                }
            }
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            var config = Loader.Load() ?? new Config();

            var path = new EditableString
            {
                Value = config.LastPath ?? string.Empty
            };

            path.Input("Enter path to data");

            config.LastPath = path.Value;
            Loader.Save(config);

            var logic = new CommandLineLogic(config, path.Value);

            logic.Run();
        }