public OpcStatusCollection DeleteHistory(
            OpcContext context,
            OpcHistoryModificationInfo modificationInfo,
            OpcValueCollection values)
        {
            var results = OpcStatusCollection.Create(OpcStatusCode.Good, values.Count);

            lock (this.syncRoot) {
                for (int index = 0; index < values.Count; index++)
                {
                    var timestamp = OpcHistoryValue.Create(values[index]).Timestamp;
                    var result    = results[index];

                    if (this.History.Contains(timestamp))
                    {
                        var value = this.History[timestamp];
                        this.History.RemoveAt(timestamp);

                        var modifiedValue = value.CreateModified(modificationInfo);
                        this.ModifiedHistory.Add(modifiedValue);
                    }
                    else
                    {
                        result.Update(OpcStatusCode.BadNoEntryExists);
                    }
                }
            }

            return(results);
        }
        public OpcStatusCollection DeleteHistory(
            OpcContext context,
            OpcHistoryModificationInfo modificationInfo,
            DateTime?startTime,
            DateTime?endTime,
            OpcDeleteHistoryOptions options)
        {
            var results = new OpcStatusCollection();

            lock (this.syncRoot) {
                if (options.HasFlag(OpcDeleteHistoryOptions.Modified))
                {
                    this.ModifiedHistory.RemoveRange(startTime, endTime);
                }
                else
                {
                    var values = this.History.Enumerate(startTime, endTime).ToArray();
                    this.History.RemoveRange(startTime, endTime);

                    for (int index = 0; index < values.Length; index++)
                    {
                        var value = values[index];
                        this.ModifiedHistory.Add(value.CreateModified(modificationInfo));

                        results.Add(OpcStatusCode.Good);
                    }
                }
            }

            return(results);
        }
        public OpcStatusCollection DeleteHistory(
            OpcContext context,
            OpcHistoryModificationInfo modificationInfo,
            IEnumerable <DateTime> times)
        {
            var results = OpcStatusCollection.Create(OpcStatusCode.Good, times.Count());

            lock (this.syncRoot) {
                int index = 0;

                foreach (var time in times)
                {
                    var result = results[index++];

                    if (this.History.Contains(time))
                    {
                        var value = this.History[time];
                        this.History.RemoveAt(time);

                        var modifiedValue = value.CreateModified(modificationInfo);
                        this.ModifiedHistory.Add(modifiedValue);
                    }
                    else
                    {
                        result.Update(OpcStatusCode.BadNoEntryExists);
                    }
                }
            }

            return(results);
        }
        public OpcStatusCollection UpdateHistory(
            OpcContext context,
            OpcHistoryModificationInfo modificationInfo,
            OpcValueCollection values)
        {
            var results = OpcStatusCollection.Create(OpcStatusCode.Good, values.Count);

            lock (this.syncRoot) {
                var expectedDataTypeId = this.Node.DataTypeId;

                for (int index = 0; index < values.Count; index++)
                {
                    var result = results[index];
                    var value  = OpcHistoryValue.Create(values[index]);

                    if (value.DataTypeId == expectedDataTypeId)
                    {
                        if (this.History.Contains(value.Timestamp))
                        {
                            var oldValue = this.History[value.Timestamp];
                            this.History.Replace(value);

                            var modifiedValue = oldValue.CreateModified(modificationInfo);
                            this.ModifiedHistory.Add(modifiedValue);

                            result.Update(OpcStatusCode.GoodEntryReplaced);
                        }
                        else
                        {
                            this.History.Add(value);

                            var modifiedValue = value.CreateModified(modificationInfo);
                            this.ModifiedHistory.Add(modifiedValue);

                            result.Update(OpcStatusCode.GoodEntryInserted);
                        }
                    }
                    else
                    {
                        result.Update(OpcStatusCode.BadTypeMismatch);
                    }
                }
            }

            return(results);
        }