private FetchHistory GetHistory(bool forceReload) { string jsonFile = HistoryFilePath(); try { if (System.IO.File.Exists(jsonFile)) { if (History == null || forceReload) { string json = System.IO.File.ReadAllText(jsonFile); History = FetchHistory.FromJson(json); } return(History); } History = new FetchHistory(); } catch (Exception) { History = new FetchHistory(); } return(History); }
public void DoScheduledCheck() { TheConfiguration = GetConfigurationImpl(true); History = GetHistory(); DateTime now = DateTime.Now; if (TheConfiguration.OperationHourBegin != 0 && TheConfiguration.OperationHourBegin > now.Hour) { return; } if (TheConfiguration.OperationHourEnd != 0 && TheConfiguration.OperationHourEnd < now.Hour) { return; } MakeNewClient(); Dictionary <ContentType, LinkedList <KidsNoteContent> > newContents = GetNewContents(); if (newContents != null && newContents.Count > 0) { UpdateAndNotifyContents(newContents); BackupToGoogleDrive(newContents); } }
public void DoScheduledCheck(bool forceReload) { TheConfiguration = GetConfigurationImpl(forceReload); History = GetHistory(true); DateTime now = DateTime.Now; if (TheConfiguration.OperationHourBegin != 0 && TheConfiguration.OperationHourBegin > now.Hour) { return; } if (TheConfiguration.OperationHourEnd != 0 && TheConfiguration.OperationHourEnd < now.Hour) { return; } MakeNewClient(); Dictionary <ContentType, LinkedList <KidsNoteContent> > newContents = GetNewContents(); if (newContents != null && newContents.Count > 0) { // 백업은 동기적으로 동작시킬 수 있어 백업부터 하고, 이후에 텔레그램 통지한다. if (TheConfiguration.BackupToGoogleDrive) { BackupToGoogleDrive(newContents); } UpdateAndNotifyContents(newContents); if (OnGetNewContents != null) { OnGetNewContents(newContents); } } }