Exemple #1
0
        public static int SaveValueWhenConditionsAreMet(MeasuredValue currentValue, CompressionCondition condition)
        {
            if (currentValue == null)
            {
                throw new ArgumentNullException("currentValue");
            }
            if (condition == null)
            {
                throw new ArgumentNullException("condition");
            }

            // if the current value has the OPCQuality of "NoValue"
            // return without writting the value
            if (currentValue.Quality == OPCQuality.NoValue)
            {
                _logger.DebugFormat("current value {0} has the OPCQuality of \"NoValue\"", currentValue.Name);
                return(0);
            }

            TypeCode      typeCode      = currentValue.GetTypeCode();
            MeasuredValue previousValue = ReadLastMeasuredValueFromLocalDB(currentValue.Name, typeCode);

            if (false == condition.ShouldCurrentValueBeWritten(currentValue, previousValue))
            {
                return(0);
            }
            int rowAffected = InsertIntoDatabase(currentValue, typeCode);

            return(rowAffected);
        }