public IDataProividerResultDayBase getDayData(IDataSourceConfiguration configuration) { IDataProividerResultDayBase result = new DataProviderResultDay(); IsConfigurationValid(configuration); try { using (StreamReader r = new StreamReader(configuration.File.File)) { string json = r.ReadToEnd(); result.data = JsonConvert.DeserializeObject <DayFollowed>(json, new JsonSerializerSettings { DateFormatString = "yyyyMMddTHH:mm:ssZ" }); } } catch (Exception error) { result.sucess = false; result.error = error.Message; return(result); } result.sucess = true; return(result); }
private IDataProividerResultDayBase WriteDayToFile(IDataSourceConfiguration configuration, DayFollowed day) { IDataProividerResultDayBase result = new DataProviderResultDay(); try { using (StreamWriter r = new StreamWriter(configuration.File.File)) { string data = JsonConvert.SerializeObject(day, new JsonSerializerSettings { DateFormatString = "yyyyMMddTHH:mm:ssZ" }); r.Write(data); } } catch (Exception error) { result.sucess = false; result.error = error.Message; } return(result); }