コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }