示例#1
0
        public static void StoreDailyData(DailyData data, DateTime today, Location location)
        {
            if (GetDailyData(today, location) != null)
            {
                return;
            }
            try
            {
                string path     = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
                string filename = Path.Combine(path, getDocId(today, location));

                if (File.Exists(filename))
                {
                    File.Delete(filename);
                }

                using (var streamWriter = new StreamWriter(filename, true))
                {
                    streamWriter.Write(JsonConvert.SerializeObject(data));
                }
            }
            catch (Exception ex)
            {
                //var alert = await Xamarin.Forms.Page.
            }
        }
示例#2
0
 public static void StoreDailyData(DailyData data, DateTime today, Location location)
 {
     //var doc = DB.CreateDocument();
     //string docId = getDocId(today, location);
     //var props = new Dictionary<string, object>();
     //var serializedData = JsonConvert.SerializeObject(data);
     //props.Add("data", serializedData);
     //doc.PutProperties(props);
 }
示例#3
0
        public static DailyData GetDailyData(DateTime today, Location location)
        {
            DailyData data = null;

            try
            {
                string path     = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
                string filename = Path.Combine(path, getDocId(today, location));

                using (var streamReader = new StreamReader(filename))
                {
                    string content = streamReader.ReadToEnd();
                    data = JsonConvert.DeserializeObject <DailyData>(content);
                }
            }
            catch { }
            return(data);
        }