/// <summary>
        /// Loads <see cref="CompressionSetting"/> information as an <see cref="ObservableCollection{T}"/> style list.
        /// </summary>
        /// <param name="database"><see cref="AdoDataConnection"/> to connection to database.</param>
        /// <param name="keys">Keys of the compression settings to be loaded from the database.</param>
        /// <returns>Collection of <see cref="CompressionSetting"/>.</returns>
        public static ObservableCollection <CompressionSetting> Load(AdoDataConnection database, IList <int> keys)
        {
            bool createdConnection = false;

            try
            {
                createdConnection = CreateConnection(ref database);

                string commaSeparatedKeys;

                CompressionSetting[] compressionSettingList = null;
                DataTable            compressionSettingTable;
                int pointID;

                if ((object)keys != null && keys.Count > 0)
                {
                    commaSeparatedKeys = keys.Select(key => "" + key.ToString() + "").Aggregate((str1, str2) => str1 + "," + str2);

                    compressionSettingTable = database.RetrieveData(
                        $"SELECT PointID, CompressionMinTime, CompressionMaxTime, CompressionLimit " +
                        $"FROM CompressionSetting WHERE PointID IN ({commaSeparatedKeys})");

                    compressionSettingList = new CompressionSetting[compressionSettingTable.Rows.Count];

                    foreach (DataRow row in compressionSettingTable.Rows)
                    {
                        pointID = row.ConvertField <int>(nameof(PointID));

                        compressionSettingList[keys.IndexOf(pointID)] = new CompressionSetting()
                        {
                            PointID            = pointID,
                            CompressionMinTime = row.ConvertField <ulong>(nameof(CompressionMinTime)),
                            CompressionMaxTime = row.ConvertField <ulong>(nameof(CompressionMaxTime)),
                            CompressionLimit   = row.ConvertField <double>(nameof(CompressionLimit)),
                            IsNew = false
                        };
                    }
                }

                return(new ObservableCollection <CompressionSetting>(compressionSettingList ?? new CompressionSetting[0]));
            }
            finally
            {
                if (createdConnection && database != null)
                {
                    database.Dispose();
                }
            }
        }
        /// <summary>
        /// Saves <see cref="CompressionSetting"/> information to database.
        /// </summary>
        /// <param name="database"><see cref="AdoDataConnection"/> to connection to database.</param>
        /// <param name="compressionSetting">Information about <see cref="CompressionSetting"/>.</param>
        /// <returns>String, for display use, indicating success.</returns>
        public static string Save(AdoDataConnection database, CompressionSetting compressionSetting)
        {
            bool createdConnection = false;

            try
            {
                createdConnection = CreateConnection(ref database);

                string successMessage = "CompressionSetting information saved successfully";

                if (compressionSetting.IsNew)
                {
                    database.ExecuteNonQuery(
                        $"INSERT INTO CompressionSetting ({nameof(PointID)}, {nameof(CompressionMinTime)}, {nameof(CompressionMaxTime)}, {nameof(CompressionLimit)}) " +
                        $"VALUES({{0}}, {{1}}, {{2}}, {{3}})", compressionSetting.PointID, compressionSetting.CompressionMinTime, compressionSetting.CompressionMaxTime, compressionSetting.CompressionLimit);

                    compressionSetting.IsNew = false;
                }
                else
                {
                    database.ExecuteNonQuery(
                        $"UPDATE CompressionSetting SET " +
                        $"    {nameof(CompressionMinTime)} = {{0}}, " +
                        $"    {nameof(CompressionMaxTime)} = {{1}}, " +
                        $"    {nameof(CompressionLimit)} = {{2}} " +
                        $"WHERE {nameof(PointID)} = {{3}}",
                        compressionSetting.CompressionMinTime, compressionSetting.CompressionMaxTime, compressionSetting.CompressionLimit, compressionSetting.PointID);
                }

                try
                {
                    CommonFunctions.SendCommandToService("ReloadConfig");
                }
                catch (Exception ex)
                {
                    CommonFunctions.LogException(database, "CompressionSetting Save", ex);
                }

                return(successMessage);
            }
            finally
            {
                if (createdConnection && database != null)
                {
                    database.Dispose();
                }
            }
        }