public void LoadDatapointByID(Int64 nodeID, DatabaseFacade database) { this.Database = database; this.Database.OpenConnection(); DatapointNode datapoint = this.Database.GetDatapointNodeByID(nodeID); FolderNode parent = this.Database.GetFolderNodeByID(datapoint.GetParentID()); this.Database.CloseConnection(); this.DatapointID = datapoint.GetID(); this.LabelDatapointName.Text = datapoint.GetName(); this.AnalyseDatapointName.Text = datapoint.GetName(); this.AnalyseDatapointDescription.Text = datapoint.GetDescription(); this.LabelDatapointDescription.Text = datapoint.GetDescription(); this.LabelDatapointID.Text = datapoint.GetID().ToString(); this.LabelDatapointParent.Text = parent.GetName(); if (datapoint.GetDatapointType() == DatapointNode.TYPE_BOOL) { this.LabelDatapointType.Text = "Bool (Wahr/Falsch)"; } if (datapoint.GetDatapointType() == DatapointNode.TYPE_FLOATING_POINT) { this.LabelDatapointType.Text = "Fließkommazahl"; } if (datapoint.GetDatapointType() == DatapointNode.TYPE_INTEGER) { this.LabelDatapointType.Text = "Ganzzahl"; } if (datapoint.GetDatapointType() == DatapointNode.TYPE_TEXT) { this.LabelDatapointType.Text = "Text"; } this.LabelDatapointUnit.Text = datapoint.GetUnit(); this.LabelDatapointLastValue.Text = datapoint.GetLastValue() + " (" + datapoint.GetLastValueUpdate() + ")"; this.LabelDatapointLastUpdate.Text = datapoint.GetLastUpdated().ToString(); DateTime From = DateTime.Now; TimeSpan FromTime = new TimeSpan(0, 0, 0); From = From.Date + FromTime; DateTime To = DateTime.Now; TimeSpan ToTime = new TimeSpan(23, 59, 59); To = To.Date + ToTime; DrawDatapointChart(ChartDatapoint, From, To); }
public Boolean DeleteNode(DatapointNode Node) { return(this.DatabaseConnector.DeleteNodeByID(Node.GetID())); }
/// <summary> /// Update a DatapointNode in the database /// </summary> /// <param name="Node"> /// DatapointNode that should be updated /// </param> /// <returns> /// true, if the node is updated /// false, if no node is updated /// </returns> public Boolean UpdateNode(DatapointNode Node) { // Command that will be send to the databse MySqlCommand Command = this.Connection.CreateCommand(); // Update a row in the databse with the given node id // UPDATE > Update rows of a table // SET [colum name] = [value], > Set a column to the given value // [colum name] = [value] > Set a column to the given value // WHERE object_id = {0} > Update all rows where the column object_id matches the given id Command.CommandText = String.Format( "UPDATE object_tree SET object_parent_id={0}, object_name='{1}', object_description='{2}', object_last_updated='{3}', datapoint_type={4}, datapoint_unit='{5}', datapoint_last_value='{6}', datapoint_last_updated='{7}' WHERE object_id={8}", Node.GetParentID(), Node.GetName(), Node.GetDescription(), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Node.GetDatapointType(), Node.GetUnit(), Node.GetLastValue(), Node.GetLastValueUpdate().ToString("yyyy-MM-dd HH:mm:ss"), Node.GetID() ); Command.Connection = this.Connection; // Execute the command and get the number of rows that are affected by the command Int32 AffectedRows = Command.ExecuteNonQuery(); // If no rows where affected return false if (AffectedRows == 0) { return(false); } // Row successfully updated return(true); }