Esempio n. 1
0
        public async Task ImportWorkingHourByApi(YearMonth yearMonth, string param)
        {
            SnackbarService.Current.ShowMessage("勤務時間取込処理を開始します");

            var requestUri = $"{WorkingHourImportUrl}?key={param}";
            var response   = await client.GetAsync(requestUri);

            if (response.IsSuccessStatusCode)
            {
                // JSONを受け取るにはSpreadSheetのAPIをanyoneで公開する必要がある
                var json = await response.Content.ReadAsStringAsync();

                _Logger.Info("GET JSON" + Environment.NewLine + json);

                var result = JsonSerializer.Deserialize <WorkingHourJson>(json, JsonSerializerHelper.DefaultOptions);

                if (result?.records.Any() == true)
                {
                    var targetData = result.records.Select(r => r.ConvertToDomainModel())
                                     .Where(r => yearMonth.Contains(r.Ymd))
                                     .ToArray();

                    _WorkingHourUseCase.Import(targetData);

                    //SnackbarService.Current.ShowMessage($"{targetData.Count(t => t.IsEmpty == false)}件の勤務時間を取り込みました");
                    _Logger.Info($"{targetData.Count(t => t.IsEmpty == false)}件の勤務時間を取り込みました");
                }
            }
            else
            {
                _Logger.Error("Api実行に失敗 code=" + response.StatusCode);
            }
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            var ym1 = new YearMonth(2019, 2);
            var ym2 = new YearMonth(2017, 12);
            var ym3 = new YearMonth(2016, 2);
            var ym4 = new YearMonth(2013, 11);
            var ym5 = new YearMonth(2019, 12);
            var ym  = new YearMonth[] { ym1, ym2, ym3, ym4, ym5 };

            for (int i = 0; i < ym.Length; i++)
            {
                Console.WriteLine(ym[i]);
            }

            string a = ym.Contains(Is21(ym)) ? Is21(ym).Year.ToString(): "21世紀のデータがありません";

            Console.WriteLine(a);


            var years = ym.Select(s => s.AddOneMonth()).OrderBy(y => y.Year);

            foreach (var b in years)
            {
                Console.WriteLine(b);
            }
        }