コード例 #1
0
ファイル: Program.cs プロジェクト: nus-ii/Jason3
        /// <summary>
        /// Пункт меню анализа данных
        /// </summary>
        /// <param name="property"></param>
        public static void AnalizeData(CommonProperty property)
        {
            MenuMasterFunc <List <StepAtDay>, List <string> > aMenu = new MenuMasterFunc <List <StepAtDay>, List <string> >();

            aMenu.AddItem("Ghost Race Calendar", DataAnalizer.GhostRaceCalendar);
            aMenu.AddItem("Series", DataAnalizer.GetSeriesRating);
            aMenu.AddItem("Steps in Month", DataAnalizer.StepsInMonth);
            aMenu.AddItem("New target", ReTergetCover);

            var data   = property._repository.GetAll();
            var result = aMenu.PrintAndWait(data);

            foreach (var s in result)
            {
                Console.WriteLine(s);
            }

            Console.WriteLine("Input file name:");
            var fileName = Console.ReadLine();

            if (!string.IsNullOrEmpty(fileName))
            {
                File.WriteAllLines(fileName, result);
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: nus-ii/Jason3
 public static void PrintForDay(CommonProperty property)
 {
     while (DateTime.TryParse(Console.ReadLine(), out DateTime date))
     {
         var value = property._repository.Get(date);
         if (value != null)
         {
             Console.WriteLine($" {value.Value}");
             Console.WriteLine("_________________________________________________________");
         }
     }
 }
コード例 #3
0
ファイル: Program.cs プロジェクト: nus-ii/Jason3
        public static void EmptyData(CommonProperty property)
        {
            var data = property._repository.GetAll();

            var from = data.Select(i => i.TargetDate).Min();

            var to = data.Select(i => i.TargetDate).Max();

            var cart = from;

            while (cart <= to)
            {
                var val = data.FirstOrDefault(v => v.TargetDate.Date == cart);
                if (val == null)
                {
                    Console.WriteLine(cart.ToString("dd.MM.yyy"));
                }
                cart = cart.AddDays(1);
            }
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: nus-ii/Jason3
        static void Main(string[] args)
        {
            Console.ForegroundColor = ConsoleColor.Green;
            StepRepository.StepRepositoryFile stepRepository = new StepRepository.StepRepositoryFile(@"C:\stepsDataClean\cleanDataString.csv");
            CommonProperty CommonProperty = new CommonProperty(stepRepository, new LobalugSettings());

            MenuMasterAction <CommonProperty> mainMenu = new MenuMasterAction <CommonProperty>();

            mainMenu.AddItem("Print Summary", SummaryPrinter.Print);

            mainMenu.AddItem("Empty Data", SummaryPrinter.EmptyData);

            mainMenu.AddItem("Print for day", SummaryPrinter.PrintForDay);

            mainMenu.AddItem("Input step`s data", StepsInserter.StepInsertMain);

            mainMenu.AddItem("Analize data", SummaryPrinter.AnalizeData);

            mainMenu.PrintAndWait(CommonProperty);
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: nus-ii/Jason3
        public static void Print(CommonProperty property)
        {
            var data = property._repository.GetAll();

            var from = data.Select(i => i.TargetDate).Min();

            var to = data.Select(i => i.TargetDate).Max();

            Console.WriteLine($"From: {from.ToString("dd.MM.yyy")} To: {to.ToString("dd.MM.yyy")}");

            int allStep = data.Select(i => i.Value).Sum();

            Console.WriteLine($"All steps: {allStep}");

            int max = data.Select(i => i.Value).Max();

            Console.WriteLine($"Max steps: {max}");

            double avg = Math.Round(data.Select(i => i.Value).Average());

            Console.WriteLine($"Average steps: {avg}");
        }
コード例 #6
0
ファイル: StepsInserter.cs プロジェクト: nus-ii/Jason3
        public static void StepInsertMain(CommonProperty commonProperty)
        {
            string fileId = Guid.NewGuid().ToString().Split('-')[0];

            DateTime         lastDate = InputLastDate();
            int              steps    = 0;
            List <StepAtDay> data     = new List <StepAtDay>();

            for (; ;)
            {
                Console.Write("Input steps at " + lastDate.ToString("dd.MM.yyyy") + " ");

                if (ReadSteps(ref steps))
                {
                    data.Add(new StepAtDay(lastDate, steps));
                    lastDate = lastDate.AddDays(-1);
                }
                else
                {
                    commonProperty._repository.Insert(data);
                }
            }
        }