private void RemoveStates() { log.Clear(); LastRecord = null; if (Settings["WriteInDatabase"].Value == "true") RemoveAllNodeData(); }
public override void OnInputChange(Input input) { if (input.Value == null) return; LastRecordCached = new NodeData(Id, input.Value); LastRecordUpdated = true; }
private void UpdateTaskInDb(UITimerTask task) { NodeData data = new NodeData { DateTime = DateTime.Now, Id = task.Id, NodeId = Id, Value = JsonConvert.SerializeObject(task) }; UpdateNodeData(data); }
public override void OnInputChange(Input input) { int max = (int)double.Parse(Settings["MaxRecords"].Value); if (max < 0) max = 0; LastRecord = new NodeData(Id, input.Value); log.Add(LastRecord); while (log.Count > max) log.Remove(log.First()); UpdateMeOnDashboard(); if (Settings["WriteInDatabase"].Value == "true") AddNodeData(input.Value, max); }
public override bool SetSettings(Dictionary<string, string> data) { if (data["WriteInDatabase"] == "false" && Settings["WriteInDatabase"].Value == "true") { log.Clear(); LastRecord = null; } else if (data["WriteInDatabase"] == "true" && Settings["WriteInDatabase"].Value == "false") GetStatesFromRepository(); return base.SetSettings(data); }
public override string GetValue(string name) { if (log == null || !log.Any()) return null; //copy to array to prevent changing data error NodeData[] nodeDatasArray = new NodeData[log.Count]; log.CopyTo(nodeDatasArray); List<ChartData> chartData = nodeDatasArray.Select( state => new ChartData(state.DateTime, state.Value)).ToList(); return JsonConvert.SerializeObject(chartData); }
public void UpdateNodeDataImmediately(NodeData nodeData) { NodeData old = GetNodeData(nodeData.Id); if (old == null) { LogError("Cant update node data. Does not exist."); return; } old.Value = nodeData.Value; old.DateTime = nodeData.DateTime; //db.Update(old); db.SaveChanges(); }
public void UpdateNodeData(NodeData nodeData) { if (writeInterval != 0) { cachedUpdatedData.RemoveAll(x => x.Id == nodeData.Id); cachedUpdatedData.Add(nodeData); return; } UpdateNodeDataImmediately(nodeData); }
public int AddNodeDataImmediately(NodeData nodeData, int? maxDbRecords = null) { db.NodesData.Add(nodeData); //remove extra data if (maxDbRecords != null) { int count = db.NodesData.Count(x => x.NodeId == nodeData.NodeId); int more = count - maxDbRecords.Value + 1; if (more > 0) { List<NodeData> removeList = db.NodesData .Where(x => x.NodeId == nodeData.NodeId) .OrderBy(x => x.DateTime) .Take(more) .ToList(); db.NodesData.RemoveRange(removeList); } } db.SaveChanges(); return nodeData.Id; }
public void AddNodeData(NodeData nodeData, int? maxDbRecords) { if (writeInterval != 0) { maxRecords[nodeData.NodeId] = maxDbRecords; cachedNewData.Add(nodeData); return; } AddNodeDataImmediately(nodeData, maxDbRecords); }
public void UpdateNodeDataImmediately(NodeData nodeData) { engine?.dataDb?.UpdateNodeDataImmediately(nodeData); }
public void UpdateNodeData(NodeData nodeData) { engine?.dataDb?.UpdateNodeData(nodeData); }