149 lines · 5.1 KB · C#
RawDownload
//******************************************************************************************************//  Nodes.cs - Gbtc////  Copyright © 2012, 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/02/2011 - Mehulbhai P Thakkar//       Generated original version of source code.//  12/20/2012 - Starlynn Danyelle Gilliam//       Modified Header.////****************************************************************************************************** using System;using System.Collections.Generic;using System.Windows;using GSF.TimeSeries.UI.DataModels; namespace GSF.TimeSeries.UI.ViewModels{    internal class Nodes : PagedViewModelBase<Node, Guid>    {        #region [ Members ]         // Fields        private Dictionary<int, string> m_companyLookupList;         #endregion         #region [ Properties ]         /// <summary>        /// Gets flag that determines if <see cref="PagedViewModelBase{T1, T2}.CurrentItem"/> is a new record.        /// </summary>        public override bool IsNewRecord        {            get            {                return (CurrentItem.ID == null || CurrentItem.ID == Guid.Empty);            }        }         public Dictionary<int, string> CompanyLookupList        {            get            {                return m_companyLookupList;            }        }         #endregion         #region [ Constructor ]         /// <summary>        /// Creates an instance of <see cref="Nodes"/> class.        /// </summary>        /// <param name="itemsPerPage">Integer value to determine number of items per page.</param>        /// <param name="autoSave">Boolean value to determine is user changes should be saved automatically.</param>        public Nodes(int itemsPerPage, bool autoSave = true)            : base(itemsPerPage, autoSave)        {        }         #endregion         #region [ Methods ]         /// <summary>        /// Gets the primary key value of the <see cref="PagedViewModelBase{T1, T2}.CurrentItem"/>.        /// </summary>        /// <returns>The primary key value of the <see cref="PagedViewModelBase{T1, T2}.CurrentItem"/>.</returns>        public override Guid GetCurrentItemKey()        {            return CurrentItem.ID;        }         /// <summary>        /// Gets the string based named identifier of the <see cref="PagedViewModelBase{T1, T2}.CurrentItem"/>.        /// </summary>        /// <returns>The string based named identifier of the <see cref="PagedViewModelBase{T1, T2}.CurrentItem"/>.</returns>        public override string GetCurrentItemName()        {            return CurrentItem.Name;        }         /// <summary>        /// Initialization to be done before the initial call to <see cref="PagedViewModelBase{T1,T2}.Load"/>.        /// </summary>        public override void Initialize()        {            base.Initialize();            m_companyLookupList = Company.GetLookupList(null, true);        }         /// <summary>        /// Saves CurrentItem information into the database.        /// </summary>        public override void Save()        {            bool reconnect = false;            if (CurrentItem.SettingsUpdated || IsNewRecord)                reconnect = true;             base.Save();             if (reconnect)                CommonFunctions.ConnectWindowsServiceClient(true);        }         public override void Delete()        {            base.Delete();            try            {                CommonFunctions.SendCommandToService("ReloadConfig");            }            catch (Exception ex)            {                if (ex.InnerException != null)                {                    Popup(ex.Message + Environment.NewLine + "Inner Exception: " + ex.InnerException.Message, "Delete " + DataModelName + " Exception:", MessageBoxImage.Error);                    CommonFunctions.LogException(null, "Delete " + DataModelName, ex.InnerException);                }                else                {                    Popup(ex.Message, "Delete " + DataModelName + " Exception:", MessageBoxImage.Error);                    CommonFunctions.LogException(null, "Delete " + DataModelName, ex);                }            }             CommonFunctions.ConnectWindowsServiceClient(true);        }         #endregion    }}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t