} // QueryHour // ---------------------------------------------------------------------- public bool QueryMinute() { int?minute = ConsoleTool.QueryNumber("Minute (0..59) [enter=" + Minute + "]: ", Minute, 0, TimeSpec.MinutesPerHour - 1); if (!minute.HasValue) { return(false); } Minute = minute.Value; return(true); } // QueryMinute
} // QueryYearWeekType // ---------------------------------------------------------------------- public bool QueryDay() { int?day = ConsoleTool.QueryNumber("Day (1..31) [enter=" + Day + "]: ", Day, 1, 31); if (!day.HasValue) { return(false); } Day = day.Value; return(true); } // QueryDay
} // QueryDay // ---------------------------------------------------------------------- public bool QueryHour() { int?hour = ConsoleTool.QueryNumber("Hour (0..23) [enter=" + Hour + "]: ", Hour, 0, TimeSpec.HoursPerDay - 1); if (!hour.HasValue) { return(false); } Hour = hour.Value; return(true); } // QueryHour
} // QueryYearMonth // ---------------------------------------------------------------------- public bool QueryWeek() { int?week = ConsoleTool.QueryNumber("Week (1..53) [enter=" + Week + "]: ", Week, 1, 53); if (!week.HasValue) { return(false); } Week = week.Value; return(true); } // QueryWeek
} // QueryCulture // ---------------------------------------------------------------------- public bool QueryPeriodCount() { int?periodCount = ConsoleTool.QueryNumber("Period count [enter=" + PeriodCount + "]: ", PeriodCount, 1, 10000); if (!periodCount.HasValue) { return(false); } PeriodCount = periodCount.Value; return(true); } // QueryPeriodCount
} // QueryPeriodCount // ---------------------------------------------------------------------- public bool QueryYear() { int?year = ConsoleTool.QueryNumber("Year [enter=" + Year + "]: ", Year, DateTime.MinValue.Year, DateTime.MaxValue.Year); if (!year.HasValue) { return(false); } Year = year.Value; return(true); } // QueryYear
} // QueryWeek // ---------------------------------------------------------------------- public bool QueryYearWeekType() { int?weekType = ConsoleTool.QueryNumber("Week type (0..1) [enter=" + (int)YearWeekType + "/" + YearWeekType + "]: ", (int)YearWeekType, 0, 2); if (!weekType.HasValue) { return(false); } YearWeekType = (YearWeekType)weekType.Value; return(true); } // QueryYearWeekType
} // QueryYearQuarter // ---------------------------------------------------------------------- public bool QueryYearMonth() { int?yearMonth = ConsoleTool.QueryNumber("Month (1..12) [enter=" + (int)Month + "/" + Month + "]: ", (int)Month, 1, TimeSpec.QuartersPerYear); if (!yearMonth.HasValue) { return(false); } Month = (YearMonth)yearMonth.Value; return(true); } // QueryYearMonth
} // QueryYearBaseMonth // ---------------------------------------------------------------------- public bool QueryYearHalfyear() { int?halfyear = ConsoleTool.QueryNumber("Halfyear (1..2) [enter=" + (int)Halfyear + "/" + Halfyear + "]: ", (int)Halfyear, 1, TimeSpec.HalfyearsPerYear); if (!halfyear.HasValue) { return(false); } Halfyear = (YearHalfyear)halfyear.Value; return(true); } // QueryYearHalfyear
} // QueryYear // ---------------------------------------------------------------------- public bool QueryYearBaseMonth() { int?yearStartMonth = ConsoleTool.QueryNumber("Year start month (1..12) [enter=" + (int)YearBaseMonth + "/" + YearBaseMonth + "]: ", (int)YearBaseMonth, 1, TimeSpec.MonthsPerYear); if (!yearStartMonth.HasValue) { return(false); } YearBaseMonth = (YearMonth)yearStartMonth.Value; return(true); } // QueryYearBaseMonth
} // QueryYearHalfyear // ---------------------------------------------------------------------- public bool QueryYearQuarter() { int?yearQuarter = ConsoleTool.QueryNumber("Quarter (1..4) [enter=" + (int)Quarter + "/" + Quarter + "]: ", (int)Quarter, 1, TimeSpec.QuartersPerYear); if (!yearQuarter.HasValue) { return(false); } Quarter = (YearQuarter)yearQuarter.Value; return(true); } // QueryYearQuarter
// ---------------------------------------------------------------------- public bool QueryCulture() { string cultureName = ConsoleTool.QueryText("Culture [enter=" + CultureInfo.CurrentCulture.Name + "]: ", CultureInfo.CurrentCulture.Name); if (cultureName == null) { return(false); } if (UpdateCulture(cultureName) == false) { return(false); } return(true); } // QueryCulture
} // Reset // ---------------------------------------------------------------------- private bool UpdateCulture(string cultureName) { try { culture = new CultureInfo(cultureName); } catch (Exception e) { ConsoleTool.WriteLine(e.Message); return(false); } CultureName = cultureName; return(true); } // UpdateCulture
} // WriteLine // ---------------------------------------------------------------------- protected static void WriteIndentLine(string text) { ConsoleTool.WriteIndentLine(text); } // WriteIndentLine
} // WriteIndentLine // ---------------------------------------------------------------------- protected static string Format(DateTime dateTime, bool compact = true) { return(ConsoleTool.Format(dateTime, compact)); } // Format
} // WriteIndentLine // ---------------------------------------------------------------------- protected static void WriteIndentLine(string format, params object[] args) { ConsoleTool.WriteIndentLine(format, args); } // WriteIndentLine
} // Main // ---------------------------------------------------------------------- private static bool QueryPeriodData(ref string periodType, TimePeriodDemoData demoData) { ConsoleTool.WriteSeparatorLine(); do { string input = ConsoleTool.QueryText("Period type (y/by/hy/q/m/bm/w/bw/d/h/min) [enter=" + periodType + "]: ", periodType); if (string.IsNullOrEmpty(input)) { return(false); } switch (input) { case "Y": Console.Clear(); goto case "y"; case "y": periodType = input; return (demoData.QueryPeriodCount() && demoData.QueryYear() && demoData.QueryYearBaseMonth()); case "BY": Console.Clear(); goto case "by"; case "by": periodType = input; return (demoData.QueryYear()); case "HY": Console.Clear(); goto case "hy"; case "hy": periodType = input; return (demoData.QueryPeriodCount() && demoData.QueryYear() && demoData.QueryYearBaseMonth() && demoData.QueryYearHalfyear()); case "Q": Console.Clear(); goto case "q"; case "q": periodType = input; return (demoData.QueryPeriodCount() && demoData.QueryYear() && demoData.QueryYearBaseMonth() && demoData.QueryYearQuarter()); case "M": Console.Clear(); goto case "m"; case "m": periodType = input; return (demoData.QueryPeriodCount() && demoData.QueryYear() && demoData.QueryYearMonth()); case "BM": Console.Clear(); goto case "bm"; case "bm": periodType = input; return (demoData.QueryYear() && demoData.QueryYearMonth()); case "W": Console.Clear(); goto case "w"; case "w": periodType = input; return (demoData.QueryPeriodCount() && demoData.QueryYear() && demoData.QueryYearWeekType() && demoData.QueryWeek()); case "BW": Console.Clear(); goto case "bw"; case "bw": periodType = input; return (demoData.QueryYear() && demoData.QueryWeek()); case "D": Console.Clear(); goto case "d"; case "d": periodType = input; return (demoData.QueryPeriodCount() && demoData.QueryYear() && demoData.QueryYearMonth() && demoData.QueryDay()); case "H": Console.Clear(); goto case "h"; case "h": periodType = input; return (demoData.QueryPeriodCount() && demoData.QueryYear() && demoData.QueryYearMonth() && demoData.QueryDay() && demoData.QueryHour()); case "Min": Console.Clear(); goto case "min"; case "min": periodType = input; return (demoData.QueryPeriodCount() && demoData.QueryYear() && demoData.QueryYearMonth() & demoData.QueryDay() && demoData.QueryHour() && demoData.QueryMinute()); } } while (true); } // QueryPeriodData
} // WriteLine // ---------------------------------------------------------------------- protected static void WriteLine() { ConsoleTool.WriteLine(); } // WriteLine