protected virtual ServiceResult OnOneShotShelve(
ISystemContext context,
MethodState method,
IList<object> inputArguments,
IList<object> outputArguments)
{
ServiceResult error = null;
try
{
if (!this.EnabledState.Id.Value)
{
return error = StatusCodes.BadConditionDisabled;
}
if (!this.ShelvingState.IsCausePermitted(context, Methods.ShelvedStateMachineType_OneShotShelve, false))
{
return error = StatusCodes.BadConditionAlreadyShelved;
}
if (OnShelve == null)
{
return error = StatusCodes.BadNotSupported;
}
error = OnShelve(context, this, true, true, 0);
// report a state change event.
if (ServiceResult.IsGood(error))
{
ReportStateChange(context, false);
}
}
finally
{
if (this.AreEventsMonitored)
{
AuditConditionShelvingEventState e = new AuditConditionShelvingEventState(null);
TranslationInfo info = new TranslationInfo(
"AuditConditionOneShotShelve",
"en-US",
"The OneShotShelve method was called.");
e.Initialize(
context,
this,
EventSeverity.Low,
new LocalizedText(info),
ServiceResult.IsGood(error),
DateTime.UtcNow);
e.SourceName.Value = "Attribute/Call";
e.MethodId = new PropertyState<NodeId>(e);
e.MethodId.Value = method.NodeId;
ReportEvent(context, e);
}
}
return error;
}