本文整理汇总了C#中StatusCodeCollection.Add方法的典型用法代码示例。如果您正苦于以下问题:C# StatusCodeCollection.Add方法的具体用法?C# StatusCodeCollection.Add怎么用?C# StatusCodeCollection.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StatusCodeCollection
的用法示例。
在下文中一共展示了StatusCodeCollection.Add方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetMonitoringMode
/// <summary>
/// Changes the monitoring mode for a set of items.
/// </summary>
public void SetMonitoringMode(
OperationContext context,
MonitoringMode monitoringMode,
UInt32Collection monitoredItemIds,
out StatusCodeCollection results,
out DiagnosticInfoCollection diagnosticInfos)
{
if (context == null) throw new ArgumentNullException("context");
if (monitoredItemIds == null) throw new ArgumentNullException("monitoredItemIds");
int count = monitoredItemIds.Count;
bool diagnosticsExist = false;
results = new StatusCodeCollection(count);
diagnosticInfos = null;
if ((context.DiagnosticsMask & DiagnosticsMasks.OperationAll) != 0)
{
diagnosticInfos = new DiagnosticInfoCollection(count);
}
// build list of items to modify.
List<IMonitoredItem> monitoredItems = new List<IMonitoredItem>(count);
List<ServiceResult> errors = new List<ServiceResult>(count);
MonitoringMode[] originalMonitoringModes = new MonitoringMode[count];
bool validItems = false;
lock (m_lock)
{
// check session.
VerifySession(context);
// clear lifetime counter.
ResetLifetimeCount();
for (int ii = 0; ii < count; ii++)
{
LinkedListNode<IMonitoredItem> node = null;
if (!m_monitoredItems.TryGetValue(monitoredItemIds[ii], out node))
{
monitoredItems.Add(null);
errors.Add(StatusCodes.BadMonitoredItemIdInvalid);
// update diagnostics.
if ((context.DiagnosticsMask & DiagnosticsMasks.OperationAll) != 0)
{
DiagnosticInfo diagnosticInfo = ServerUtils.CreateDiagnosticInfo(m_server, context, errors[ii]);
diagnosticsExist = true;
diagnosticInfos.Add(diagnosticInfo);
}
continue;
}
IMonitoredItem monitoredItem = node.Value;
monitoredItems.Add(monitoredItem);
originalMonitoringModes[ii] = monitoredItem.MonitoringMode;
errors.Add(null);
validItems = true;
// update diagnostics.
if ((context.DiagnosticsMask & DiagnosticsMasks.OperationAll) != 0)
{
diagnosticInfos.Add(null);
}
}
}
// update items.
if (validItems)
{
m_server.NodeManager.SetMonitoringMode(
context,
monitoringMode,
monitoredItems,
errors);
}
lock (m_lock)
{
// update diagnostics.
for (int ii = 0; ii < errors.Count; ii++)
{
ServiceResult error = errors[ii];
if (error == null)
{
results.Add(StatusCodes.Good);
}
else
{
results.Add(error.StatusCode);
}
//.........这里部分代码省略.........
示例2: SetTriggering
/// <summary>
/// Updates the triggers for the monitored item.
/// </summary>
public void SetTriggering(
OperationContext context,
uint triggeringItemId,
UInt32Collection linksToAdd,
UInt32Collection linksToRemove,
out StatusCodeCollection addResults,
out DiagnosticInfoCollection addDiagnosticInfos,
out StatusCodeCollection removeResults,
out DiagnosticInfoCollection removeDiagnosticInfos)
{
if (context == null) throw new ArgumentNullException("context");
if (linksToAdd == null) throw new ArgumentNullException("linksToAdd");
if (linksToRemove == null) throw new ArgumentNullException("linksToRemove");
// allocate results.
bool diagnosticsExist = false;
addResults = new StatusCodeCollection();
addDiagnosticInfos = null;
removeResults = new StatusCodeCollection();
removeDiagnosticInfos = null;
if ((context.DiagnosticsMask & DiagnosticsMasks.OperationAll) != 0)
{
addDiagnosticInfos = new DiagnosticInfoCollection();
removeDiagnosticInfos = new DiagnosticInfoCollection();
}
// build list of items to modify.
lock (m_lock)
{
// check session.
VerifySession(context);
// clear lifetime counter.
ResetLifetimeCount();
// look up triggering item.
LinkedListNode<IMonitoredItem> triggerNode = null;
if (!m_monitoredItems.TryGetValue(triggeringItemId, out triggerNode))
{
throw new ServiceResultException(StatusCodes.BadMonitoredItemIdInvalid);
}
// lookup existing list.
List<ITriggeredMonitoredItem> triggeredItems = null;
if (!m_itemsToTrigger.TryGetValue(triggeringItemId, out triggeredItems))
{
m_itemsToTrigger[triggeringItemId] = triggeredItems = new List<ITriggeredMonitoredItem>();
}
// remove old links.
for (int ii = 0; ii < linksToRemove.Count; ii++)
{
removeResults.Add(StatusCodes.Good);
bool found = false;
for (int jj = 0; jj < triggeredItems.Count; jj++)
{
if (triggeredItems[jj].Id == linksToRemove[ii])
{
found = true;
triggeredItems.RemoveAt(jj);
break;
}
}
if (!found)
{
removeResults[ii] = StatusCodes.BadMonitoredItemIdInvalid;
// update diagnostics.
if ((context.DiagnosticsMask & DiagnosticsMasks.OperationAll) != 0)
{
DiagnosticInfo diagnosticInfo = ServerUtils.CreateDiagnosticInfo(m_server, context, removeResults[ii]);
diagnosticsExist = true;
removeDiagnosticInfos.Add(diagnosticInfo);
}
continue;
}
// update diagnostics.
if ((context.DiagnosticsMask & DiagnosticsMasks.OperationAll) != 0)
{
removeDiagnosticInfos.Add(null);
}
}
// add new links.
for (int ii = 0; ii < linksToAdd.Count; ii++)
{
addResults.Add(StatusCodes.Good);
LinkedListNode<IMonitoredItem> node = null;
//.........这里部分代码省略.........
示例3: DeleteMonitoredItems
/// <summary>
/// Deletes the monitored items in a subscription.
/// </summary>
private void DeleteMonitoredItems(
OperationContext context,
UInt32Collection monitoredItemIds,
bool doNotCheckSession,
out StatusCodeCollection results,
out DiagnosticInfoCollection diagnosticInfos)
{
if (context == null) throw new ArgumentNullException("context");
if (monitoredItemIds == null) throw new ArgumentNullException("monitoredItemIds");
int count = monitoredItemIds.Count;
bool diagnosticsExist = false;
results = new StatusCodeCollection(count);
diagnosticInfos = null;
if ((context.DiagnosticsMask & DiagnosticsMasks.OperationAll) != 0)
{
diagnosticInfos = new DiagnosticInfoCollection(count);
}
// build list of items to modify.
List<IMonitoredItem> monitoredItems = new List<IMonitoredItem>(count);
List<ServiceResult> errors = new List<ServiceResult>(count);
double[] originalSamplingIntervals = new double[count];
MonitoringMode[] originalMonitoringModes = new MonitoringMode[count];
bool validItems = false;
lock (m_lock)
{
// check session.
if (!doNotCheckSession)
{
VerifySession(context);
}
// clear lifetime counter.
ResetLifetimeCount();
for (int ii = 0; ii < count; ii++)
{
LinkedListNode<IMonitoredItem> node = null;
if (!m_monitoredItems.TryGetValue(monitoredItemIds[ii], out node))
{
monitoredItems.Add(null);
errors.Add(StatusCodes.BadMonitoredItemIdInvalid);
// update diagnostics.
if ((context.DiagnosticsMask & DiagnosticsMasks.OperationAll) != 0)
{
DiagnosticInfo diagnosticInfo = ServerUtils.CreateDiagnosticInfo(m_server, context, errors[ii]);
diagnosticsExist = true;
diagnosticInfos.Add(diagnosticInfo);
}
continue;
}
IMonitoredItem monitoredItem = node.Value;
monitoredItems.Add(monitoredItem);
// remove the item from the internal lists.
m_monitoredItems.Remove(monitoredItemIds[ii]);
m_itemsToTrigger.Remove(monitoredItemIds[ii]);
//remove the links towards the deleted monitored item
List<ITriggeredMonitoredItem> triggeredItems = null;
foreach (KeyValuePair<uint, List<ITriggeredMonitoredItem>> item in m_itemsToTrigger)
{
triggeredItems = item.Value;
for (int jj = 0; jj < triggeredItems.Count; jj++)
{
if (triggeredItems[jj].Id == monitoredItemIds[ii])
{
triggeredItems.RemoveAt(jj);
break;
}
}
}
if (node.List != null)
{
node.List.Remove(node);
}
originalSamplingIntervals[ii] = monitoredItem.SamplingInterval;
originalMonitoringModes[ii] = monitoredItem.MonitoringMode;
errors.Add(null);
validItems = true;
// update diagnostics.
if ((context.DiagnosticsMask & DiagnosticsMasks.OperationAll) != 0)
{
diagnosticInfos.Add(null);
//.........这里部分代码省略.........
示例4: ReadStatusCodeArray
/// <summary>
/// Reads an StatusCode array from the stream.
/// </summary>
public StatusCodeCollection ReadStatusCodeArray(string fieldName)
{
bool isNil = false;
StatusCodeCollection values = new StatusCodeCollection();
if (BeginField(fieldName, true, out isNil))
{
PushNamespace(Namespaces.OpcUaXsd);
while (MoveToElement("StatusCode"))
{
values.Add(ReadStatusCode("StatusCode"));
}
// check the length.
if (m_context.MaxArrayLength > 0 && m_context.MaxArrayLength < values.Count)
{
throw new ServiceResultException(StatusCodes.BadEncodingLimitsExceeded);
}
PopNamespace();
EndField(fieldName);
return values;
}
if (isNil)
{
return null;
}
return values;
}
示例5: Acknowledge
/// <summary>
/// Processes acknowledgements for previously published messages.
/// </summary>
public void Acknowledge(
OperationContext context,
SubscriptionAcknowledgementCollection subscriptionAcknowledgements,
out StatusCodeCollection acknowledgeResults,
out DiagnosticInfoCollection acknowledgeDiagnosticInfos)
{
if (context == null) throw new ArgumentNullException("context");
if (subscriptionAcknowledgements == null) throw new ArgumentNullException("subscriptionAcknowledgements");
lock (m_lock)
{
bool diagnosticsExist = false;
acknowledgeResults = new StatusCodeCollection(subscriptionAcknowledgements.Count);
acknowledgeDiagnosticInfos = new DiagnosticInfoCollection(subscriptionAcknowledgements.Count);
for (int ii = 0; ii < subscriptionAcknowledgements.Count; ii++)
{
SubscriptionAcknowledgement acknowledgement = subscriptionAcknowledgements[ii];
bool found = false;
for (int jj = 0; jj < m_queuedSubscriptions.Count; jj++)
{
QueuedSubscription subscription = m_queuedSubscriptions[jj];
if (subscription.Subscription.Id == acknowledgement.SubscriptionId)
{
ServiceResult result = subscription.Subscription.Acknowledge(context, acknowledgement.SequenceNumber);
if (ServiceResult.IsGood(result))
{
acknowledgeResults.Add(StatusCodes.Good);
if ((context.DiagnosticsMask & DiagnosticsMasks.OperationAll) != 0)
{
acknowledgeDiagnosticInfos.Add(null);
}
}
else
{
acknowledgeResults.Add(result.Code);
if ((context.DiagnosticsMask & DiagnosticsMasks.OperationAll) != 0)
{
DiagnosticInfo diagnosticInfo = ServerUtils.CreateDiagnosticInfo(m_server, context, result);
acknowledgeDiagnosticInfos.Add(diagnosticInfo);
diagnosticsExist = true;
}
}
found = true;
break;
}
}
if (!found)
{
ServiceResult result = new ServiceResult(StatusCodes.BadSubscriptionIdInvalid);
acknowledgeResults.Add(result.Code);
if ((context.DiagnosticsMask & DiagnosticsMasks.OperationAll) != 0)
{
DiagnosticInfo diagnosticInfo = ServerUtils.CreateDiagnosticInfo(m_server, context, result);
acknowledgeDiagnosticInfos.Add(diagnosticInfo);
diagnosticsExist = true;
}
}
}
if (!diagnosticsExist)
{
acknowledgeDiagnosticInfos.Clear();
}
}
}
示例6: CreateStatusCodeCollection
/// <summary>
/// Creates a collection of status codes and diagnostics from a set of errors.
/// </summary>
public static StatusCodeCollection CreateStatusCodeCollection(
OperationContext context,
IList<ServiceResult> errors,
out DiagnosticInfoCollection diagnosticInfos)
{
diagnosticInfos = null;
bool noErrors = true;
StatusCodeCollection results = new StatusCodeCollection(errors.Count);
foreach (ServiceResult error in errors)
{
if (ServiceResult.IsBad(error))
{
results.Add(error.Code);
noErrors = false;
}
else
{
results.Add(StatusCodes.Good);
}
}
// only generate diagnostics if errors exist.
if (noErrors)
{
diagnosticInfos = CreateDiagnosticInfoCollection(context, errors);
}
return results;
}
示例7: ActivateSession
/// <summary>
/// Invokes the ActivateSession service.
/// </summary>
/// <param name="requestHeader">The request header.</param>
/// <param name="clientSignature">The client signature.</param>
/// <param name="clientSoftwareCertificates">The client software certificates.</param>
/// <param name="localeIds">The locale ids.</param>
/// <param name="userIdentityToken">The user identity token.</param>
/// <param name="userTokenSignature">The user token signature.</param>
/// <param name="serverNonce">The server nonce.</param>
/// <param name="results">The results.</param>
/// <param name="diagnosticInfos">The diagnostic infos.</param>
/// <returns>
/// Returns a <see cref="ResponseHeader"/> object
/// </returns>
public override ResponseHeader ActivateSession(
RequestHeader requestHeader,
SignatureData clientSignature,
SignedSoftwareCertificateCollection clientSoftwareCertificates,
StringCollection localeIds,
ExtensionObject userIdentityToken,
SignatureData userTokenSignature,
out byte[] serverNonce,
out StatusCodeCollection results,
out DiagnosticInfoCollection diagnosticInfos)
{
serverNonce = null;
results = null;
diagnosticInfos = null;
OperationContext context = ValidateRequest(requestHeader, RequestType.ActivateSession);
try
{
// validate client's software certificates.
List<SoftwareCertificate> softwareCertificates = new List<SoftwareCertificate>();
if (context.SecurityPolicyUri != SecurityPolicies.None)
{
bool diagnosticsExist = false;
if ((context.DiagnosticsMask & DiagnosticsMasks.OperationAll) != 0)
{
diagnosticInfos = new DiagnosticInfoCollection();
}
results = new StatusCodeCollection();
diagnosticInfos = new DiagnosticInfoCollection();
foreach (SignedSoftwareCertificate signedCertificate in clientSoftwareCertificates)
{
SoftwareCertificate softwareCertificate = null;
ServiceResult result = SoftwareCertificate.Validate(
new CertificateValidator(),
signedCertificate.CertificateData,
out softwareCertificate);
if (ServiceResult.IsBad(result))
{
results.Add(result.Code);
// add diagnostics if requested.
if ((context.DiagnosticsMask & DiagnosticsMasks.OperationAll) != 0)
{
DiagnosticInfo diagnosticInfo = ServerUtils.CreateDiagnosticInfo(ServerInternal, context, result);
diagnosticInfos.Add(diagnosticInfo);
diagnosticsExist = true;
}
}
else
{
softwareCertificates.Add(softwareCertificate);
results.Add(StatusCodes.Good);
// add diagnostics if requested.
if ((context.DiagnosticsMask & DiagnosticsMasks.OperationAll) != 0)
{
diagnosticInfos.Add(null);
}
}
}
if (!diagnosticsExist && diagnosticInfos != null)
{
diagnosticInfos.Clear();
}
}
// check if certificates meet the server's requirements.
ValidateSoftwareCertificates(softwareCertificates);
// activate the session.
bool identityChanged = ServerInternal.SessionManager.ActivateSession(
context,
requestHeader.AuthenticationToken,
clientSignature,
softwareCertificates,
userIdentityToken,
userTokenSignature,
//.........这里部分代码省略.........
示例8: CreateError
/// <summary>
/// Fills in the diagnostic information after an error.
/// </summary>
public static bool CreateError(
uint code,
StatusCodeCollection results,
DiagnosticInfoCollection diagnosticInfos,
OperationContext context)
{
ServiceResult error = new ServiceResult(code);
results.Add(error.Code);
if ((context.DiagnosticsMask & DiagnosticsMasks.OperationAll) != 0)
{
diagnosticInfos.Add(new DiagnosticInfo(error, context.DiagnosticsMask, false, context.StringTable));
return true;
}
return false;
}
示例9: CreateSuccess
/// <summary>
/// Creates a place holder in the lists for the results.
/// </summary>
public static void CreateSuccess(
StatusCodeCollection results,
DiagnosticInfoCollection diagnosticInfos,
OperationContext context)
{
results.Add(StatusCodes.Good);
if ((context.DiagnosticsMask & DiagnosticsMasks.OperationAll) != 0)
{
diagnosticInfos.Add(null);
}
}
示例10: Write
/// <summary>
/// Writes a set of values.
/// </summary>
public virtual void Write(
OperationContext context,
WriteValueCollection nodesToWrite,
out StatusCodeCollection results,
out DiagnosticInfoCollection diagnosticInfos)
{
if (context == null) throw new ArgumentNullException("context");
if (nodesToWrite == null) throw new ArgumentNullException("nodesToWrite");
int count = nodesToWrite.Count;
bool diagnosticsExist = false;
results = new StatusCodeCollection(count);
diagnosticInfos = new DiagnosticInfoCollection(count);
// add placeholder for each result.
bool validItems = false;
for (int ii = 0; ii < count; ii++)
{
StatusCode result = StatusCodes.Good;
DiagnosticInfo diagnosticInfo = null;
// pre-validate and pre-parse parameter.
ServiceResult error = WriteValue.Validate(nodesToWrite[ii]);
// return error status.
if (ServiceResult.IsBad(error))
{
nodesToWrite[ii].Processed = true;
result = error.Code;
// add diagnostics if requested.
if ((context.DiagnosticsMask & DiagnosticsMasks.OperationAll) != 0)
{
diagnosticInfo = ServerUtils.CreateDiagnosticInfo(m_server, context, error);
diagnosticsExist = true;
}
}
// found at least one valid item.
else
{
nodesToWrite[ii].Processed = false;
validItems = true;
}
results.Add(result);
diagnosticInfos.Add(diagnosticInfo);
}
// call each node manager.
if (validItems)
{
List<ServiceResult> errors = new List<ServiceResult>(count);
errors.AddRange(new ServiceResult[count]);
foreach (INodeManager nodeManager in m_nodeManagers)
{
nodeManager.Write(
context,
nodesToWrite,
errors);
}
for (int ii = 0; ii < nodesToWrite.Count; ii++)
{
if (!nodesToWrite[ii].Processed)
{
errors[ii] = StatusCodes.BadNodeIdUnknown;
}
if (errors[ii] != null && errors[ii].Code != StatusCodes.Good)
{
results[ii] = errors[ii].Code;
// add diagnostics if requested.
if ((context.DiagnosticsMask & DiagnosticsMasks.OperationAll) != 0)
{
diagnosticInfos[ii] = ServerUtils.CreateDiagnosticInfo(m_server, context, errors[ii]);
diagnosticsExist = true;
}
}
ServerUtils.ReportWriteValue(nodesToWrite[ii].NodeId, nodesToWrite[ii].Value, results[ii]);
}
}
// clear the diagnostics array if no diagnostics requested or no errors occurred.
UpdateDiagnostics(context, diagnosticsExist, ref diagnosticInfos);
}
示例11: ReadStatusCodeArray
/// <summary>
/// Reads an StatusCode array from the stream.
/// </summary>
public StatusCodeCollection ReadStatusCodeArray(string fieldName)
{
int length = ReadArrayLength();
if (length == -1)
{
return null;
}
StatusCodeCollection values = new StatusCodeCollection(length);
for (int ii = 0; ii < length; ii++)
{
values.Add(ReadStatusCode(null));
}
return values;
}
示例12: DeleteSubscriptions
/// <summary>
/// Deletes group of subscriptions.
/// </summary>
public void DeleteSubscriptions(
OperationContext context,
UInt32Collection subscriptionIds,
out StatusCodeCollection results,
out DiagnosticInfoCollection diagnosticInfos)
{
bool diagnosticsExist = false;
results = new StatusCodeCollection(subscriptionIds.Count);
diagnosticInfos = new DiagnosticInfoCollection(subscriptionIds.Count);
foreach (uint subscriptionId in subscriptionIds)
{
try
{
StatusCode result = DeleteSubscription(context, subscriptionId);
results.Add(result);
if ((context.DiagnosticsMask & DiagnosticsMasks.OperationAll) != 0)
{
diagnosticInfos.Add(null);
}
}
catch (Exception e)
{
ServiceResult result = ServiceResult.Create(e, StatusCodes.BadUnexpectedError, String.Empty);
results.Add(result.Code);
if ((context.DiagnosticsMask & DiagnosticsMasks.OperationAll) != 0)
{
DiagnosticInfo diagnosticInfo = ServerUtils.CreateDiagnosticInfo(m_server, context, result);
diagnosticInfos.Add(diagnosticInfo);
diagnosticsExist = true;
}
}
}
if (!diagnosticsExist)
{
diagnosticInfos.Clear();
}
}
示例13: SetPublishingMode
/// <summary>
/// Sets the publishing mode for a set of subscriptions.
/// </summary>
public void SetPublishingMode(
OperationContext context,
bool publishingEnabled,
UInt32Collection subscriptionIds,
out StatusCodeCollection results,
out DiagnosticInfoCollection diagnosticInfos)
{
bool diagnosticsExist = false;
results = new StatusCodeCollection(subscriptionIds.Count);
diagnosticInfos = new DiagnosticInfoCollection(subscriptionIds.Count);
for (int ii = 0; ii < subscriptionIds.Count; ii++)
{
try
{
// find subscription.
Subscription subscription = null;
lock (m_lock)
{
if (!m_subscriptions.TryGetValue(subscriptionIds[ii], out subscription))
{
throw new ServiceResultException(StatusCodes.BadSubscriptionIdInvalid);
}
}
// update the subscription.
subscription.SetPublishingMode(context, publishingEnabled);
// save results.
results.Add(StatusCodes.Good);
if ((context.DiagnosticsMask & DiagnosticsMasks.OperationAll) != 0)
{
diagnosticInfos.Add(null);
}
}
catch (Exception e)
{
ServiceResult result = ServiceResult.Create(e, StatusCodes.BadUnexpectedError, String.Empty);
results.Add(result.Code);
if ((context.DiagnosticsMask & DiagnosticsMasks.OperationAll) != 0)
{
DiagnosticInfo diagnosticInfo = ServerUtils.CreateDiagnosticInfo(m_server, context, result);
diagnosticInfos.Add(diagnosticInfo);
diagnosticsExist = true;
}
}
if (!diagnosticsExist)
{
diagnosticInfos.Clear();
}
}
}
示例14: ReadStatusCodeArray
/// <summary>
/// Reads an StatusCode array from the stream.
/// </summary>
public StatusCodeCollection ReadStatusCodeArray(string fieldName)
{
var values = new StatusCodeCollection();
List<object> token = null;
if (!ReadArrayField(fieldName, out token))
{
return values;
}
for (int ii = 0; ii < token.Count; ii++)
{
try
{
m_stack.Push(token[ii]);
var element = ReadStatusCode(null);
values.Add(element);
}
finally
{
m_stack.Pop();
}
}
return values;
}