//******************************************************************************************************
// MeasuremnetGroup.cs - Gbtc
//
// Copyright © 2010, Grid Protection Alliance. All Rights Reserved.
//
// Licensed to the Grid Protection Alliance (GPA) under one or more contributor license agreements. See
// the NOTICE file distributed with this work for additional information regarding copyright ownership.
// The GPA licenses this file to you under the MIT License (MIT), the "License"; you may
// not use this file except in compliance with the License. You may obtain a copy of the License at:
//
// http://www.opensource.org/licenses/MIT
//
// Unless agreed to in writing, the subject software distributed under the License is distributed on an
// "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Refer to the
// License for the specific language governing permissions and limitations.
//
// Code Modification History:
// ----------------------------------------------------------------------------------------------------
// 05/11/2011 - Aniket Salver
// Generated original version of source code.
//
//******************************************************************************************************
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Data;
using GSF.Data;
using GSF.TimeSeries.UI;
using GSF.TimeSeries.UI.DataModels;
namespace GSF.TimeSeries.Transport.UI.DataModels
{
///
/// Represents a record of information as defined in the database.
///
public class MeasurementGroup : DataModelBase
{
#region [ Members ]
//Fields
private Guid m_nodeID;
private int m_id;
private string m_name;
private string m_description;
private string m_filterExpression;
private DateTime m_createdOn;
private string m_createdBy;
private DateTime m_updatedOn;
private string m_updatedBy;
#endregion
#region [ Properties ]
///
/// Gets or sets the NodeID.
///
// Field is populated by database via auto-increment, so no validation attributes are applied.
public Guid NodeID
{
get
{
return m_nodeID;
}
set
{
m_nodeID = value;
OnPropertyChanged("NodeID");
}
}
///
/// Gets or sets the ID.
///
// Field is populated by database via auto-increment, so no validation attributes are applied.
public int ID
{
get
{
return m_id;
}
set
{
m_id = value;
OnPropertyChanged("ID");
}
}
///
/// Gets or sets Name.
///
[Required(ErrorMessage = "MeasurementGroup name is a required field, please provide value.")]
[StringLength(200, ErrorMessage = "MeasurementGroup Name cannot exceed 200 characters.")]
[DefaultValue("Add New Group")]
public string Name
{
get
{
return m_name;
}
set
{
m_name = value;
OnPropertyChanged("Name");
}
}
///
/// Gets or sets DescriptionText.
///
// Field is populated by database via trigger and has no screen interaction, so no validation attributes are applied
public string Description
{
get
{
return m_description;
}
set
{
m_description = value;
OnPropertyChanged("Description");
}
}
///
/// Gets or sets FilterExpression text.
///
public string FilterExpression
{
get
{
return m_filterExpression;
}
set
{
m_filterExpression = value;
OnPropertyChanged("FilterExpression");
}
}
///
/// Gets or sets CreatedOn.
///
// Field is populated by database via trigger and has no screen interaction, so no validation attributes are applied
public DateTime CreatedOn
{
get
{
return m_createdOn;
}
set
{
m_createdOn = value;
}
}
///
/// Gets or sets CreatedBy.
///
// Field is populated by database via trigger and has no screen interaction, so no validation attributes are applied
public string CreatedBy
{
get
{
return m_createdBy;
}
set
{
m_createdBy = value;
}
}
///
/// Gets or sets UpdatedOn.
///
// Field is populated by database via trigger and has no screen interaction, so no validation attributes are applied
public DateTime UpdatedOn
{
get
{
return m_updatedOn;
}
set
{
m_updatedOn = value;
}
}
///
/// Gets or sets UpdatedBy.
///
// Field is populated by database via trigger and has no screen interaction, so no validation attributes are applied
public string UpdatedBy
{
get
{
return m_updatedBy;
}
set
{
m_updatedBy = value;
}
}
#endregion
#region [ Static ]
// Static Methods
///
/// Loads information as an style list.
///
/// to connection to database.
/// Collection of .
public static ObservableCollection Load(AdoDataConnection database)
{
ObservableCollection measurementGroupList;
DataTable measurementGroupTable;
bool createdConnection = false;
string query;
try
{
createdConnection = CreateConnection(ref database);
measurementGroupList = new ObservableCollection();
query = database.ParameterizedQueryString("SELECT NodeID, ID, Name, Description, FilterExpression FROM MeasurementGroup WHERE NodeID = {0} ORDER BY Name", "nodeID");
measurementGroupTable = database.Connection.RetrieveData(database.AdapterType, query, DefaultTimeout, database.CurrentNodeID());
foreach (DataRow row in measurementGroupTable.Rows)
{
measurementGroupList.Add(new MeasurementGroup()
{
NodeID = database.Guid(row, "NodeID"),
ID = row.ConvertField("ID"),
Name = row.Field("Name"),
Description = row.Field