public override void DoLog() { newValue = (int.Parse(getFromWebService(url))); Database.Instance.setCounter(newValue, name); int difference = newValue - oldValue; if (difference < 0) { difference = 0; } LogValue newLog = new LogValue(difference); oldValue = newValue; //newValue.value = difference; logList.Add(newLog); LastLog = newLog.value; while (logList.Count > maxLog) { logList.RemoveAt(0); } string json = JsonConvert.SerializeObject(logList); DirectoryInfo di = Directory.CreateDirectory(path); File.WriteAllText(path + name + ".json", json); }
public virtual void DoLog() { try { // logList.Add(new Datalogger.Log("123")); LogValue newValue = new LogValue(int.Parse(getFromWebService(url))); Database.Instance.setValue(newValue.value, name); logList.Add(newValue); LastLog = newValue.value; while (logList.Count > maxLog) { logList.RemoveAt(0); } string json = JsonConvert.SerializeObject(logList); DirectoryInfo di = Directory.CreateDirectory(path); File.WriteAllText(path + name + ".json", json); } catch (Exception e) { /*MessageBox.Show("Log failed " + e.ToString());*/ Console.WriteLine(e.ToString()); } }