/// <summary> /// Validates the nodes and updates the history. /// </summary> protected virtual void HistoryUpdate( ServerSystemContext context, Type detailsType, IList<HistoryUpdateDetails> nodesToUpdate, IList<HistoryUpdateResult> results, IList<ServiceResult> errors, List<NodeHandle> nodesToProcess, IDictionary<NodeId, NodeState> cache) { // handle update data request. if (detailsType == typeof(UpdateDataDetails)) { UpdateDataDetails[] details = new UpdateDataDetails[nodesToUpdate.Count]; for (int ii = 0; ii < details.Length; ii++) { details[ii] = (UpdateDataDetails)nodesToUpdate[ii]; } HistoryUpdateData( context, details, results, errors, nodesToProcess, cache); return; } // handle update structure data request. if (detailsType == typeof(UpdateStructureDataDetails)) { UpdateStructureDataDetails[] details = new UpdateStructureDataDetails[nodesToUpdate.Count]; for (int ii = 0; ii < details.Length; ii++) { details[ii] = (UpdateStructureDataDetails)nodesToUpdate[ii]; } HistoryUpdateStructureData( context, details, results, errors, nodesToProcess, cache); return; } // handle update events request. if (detailsType == typeof(UpdateEventDetails)) { UpdateEventDetails[] details = new UpdateEventDetails[nodesToUpdate.Count]; for (int ii = 0; ii < details.Length; ii++) { details[ii] = (UpdateEventDetails)nodesToUpdate[ii]; } HistoryUpdateEvents( context, details, results, errors, nodesToProcess, cache); return; } // handle delete raw data request. if (detailsType == typeof(DeleteRawModifiedDetails)) { DeleteRawModifiedDetails[] details = new DeleteRawModifiedDetails[nodesToUpdate.Count]; for (int ii = 0; ii < details.Length; ii++) { details[ii] = (DeleteRawModifiedDetails)nodesToUpdate[ii]; } HistoryDeleteRawModified( context, details, results, errors, nodesToProcess, cache); return; } // handle delete at time request. if (detailsType == typeof(DeleteAtTimeDetails)) { DeleteAtTimeDetails[] details = new DeleteAtTimeDetails[nodesToUpdate.Count]; for (int ii = 0; ii < details.Length; ii++) { details[ii] = (DeleteAtTimeDetails)nodesToUpdate[ii]; } HistoryDeleteAtTime( context, details, results, errors, nodesToProcess, cache); return; } // handle delete at time request. if (detailsType == typeof(DeleteEventDetails)) { DeleteEventDetails[] details = new DeleteEventDetails[nodesToUpdate.Count]; for (int ii = 0; ii < details.Length; ii++) { details[ii] = (DeleteEventDetails)nodesToUpdate[ii]; } HistoryDeleteEvents( context, details, results, errors, nodesToProcess, cache); return; } }
/// <summary> /// Updates the history. /// </summary> private HistoryUpdateResultCollection InsertReplace(NodeId nodeId, PerformUpdateType updateType, bool isStructure, IList<DataValue> values) { HistoryUpdateDetails details = null; if (isStructure) { UpdateStructureDataDetails details2 = new UpdateStructureDataDetails(); details2.NodeId = nodeId; details2.PerformInsertReplace = updateType; details2.UpdateValues.AddRange(values); details = details2; } else { UpdateDataDetails details2 = new UpdateDataDetails(); details2.NodeId = nodeId; details2.PerformInsertReplace = updateType; details2.UpdateValues.AddRange(values); details = details2; } ExtensionObjectCollection nodesToUpdate = new ExtensionObjectCollection(); nodesToUpdate.Add(new ExtensionObject(details)); HistoryUpdateResultCollection results = null; DiagnosticInfoCollection diagnosticInfos = null; m_session.HistoryUpdate( null, nodesToUpdate, out results, out diagnosticInfos); ClientBase.ValidateResponse(results, nodesToUpdate); ClientBase.ValidateDiagnosticInfos(diagnosticInfos, nodesToUpdate); if (StatusCode.IsBad(results[0].StatusCode)) { throw new ServiceResultException(results[0].StatusCode); } return results; }