Skip to main content

Delete Historical Data

This actually deletes the data, and the client does not generate any audit logs

DeleteHistoryRange. Yes.Destructive Action: If the call is successful, the data within the specified range is deleted from the server. No soft delete / mark as invalid / Recycle Bin on the client side, nor is there any record of "who deleted it / when / why" — SDK just a single reply StatusCode. Compliance requirements stipulate "never delete" and "retain audit trails upon deletion."This can only be implemented on the server side., Don't assume that just because you've adjusted this, you're automatically API in compliance.

DeleteHistoryRange​

Delete data points within the specified time range.

public StatusCode DeleteHistoryRange(
string nodeId,
DateTime start,
DateTime end,
bool deleteModifiedToo = false);
ParametersTypeDefaultNote
nodeIdstring—Target; NodeId null / empty string exception ArgumentNullException
startDateTime—Interval starting at (UTC, inclusive)
endDateTime—Range Stop (UTC, inclusive)
deleteModifiedTooboolfalseChoosing which category to delete isn't just a matter of "deleting one more.": false = Delete raw history; true = Delete edit history
deleteModifiedToo is an either/or choice, not a combination.

Corresponding to OPC UA DeleteRawModifiedDetails.isDeleteModified: Pass true No"Delete the raw data and the modification log together," but ratherChange it to delete the edit history(That historical audit copy). If you want to delete both types, you'll need to run the process twice.

Returns StatusCode:Failure does not throw an exception, The status code is included directly in the return value (unlike the ReadHistory series). Good = success. The SDK does not overwrite the code given by the server — for example, if the server decides the user lacks permission, the return value contains BadUserAccessDenied.

using System;
using DarraOpcUa_Client;

using var ua = new DarraOpcUa("opc.tcp://localhost:4840");
ua.Connect();

var now = DateTime.UtcNow;
var st = ua.DeleteHistoryRange("ns=2;s=Temperature",
start: now.AddDays(-30),
end: now.AddDays(-7));

if (st != StatusCode.Good)
Console.WriteLine($"删除失败: {st}");

Deletion is not currently available​

AbilityStatus
Delete by DateNot currently available (available UpdateHistory (Implementation HistoryUpdateType.Remove )
Delete Events by List EventIdNot currently available
Soft Delete / Mark as Invalid / Recycle BinNot available —— Once you delete it, it's gone
Deletion Audit (Who deleted it / When / Why)Not available — Returns only one StatusCode

Deletion has only one entry point: "By Time Period".

Exception​

ExceptionTrigger Conditions
ArgumentNullExceptionnodeId null / empty string

Deletion Failed Without Throwing an Exception —— It will only return a Good value other than StatusCode. The caller must check the return value; failure to do so will result in a deletion failure being mistaken for a success.

Implementation Constraints​

  • None CancellationToken —— Only ReadHistoryStreamAsync Include the cancellation token.
  • Synchronous Blocking: The calling thread waits until the server returns; there are no variations Async, and the call cannot be canceled midway during the execution of a large-scale operation.
  • Session-level failures are not automatically retried。
  • The SDK performs no validation of the start / end ordering or of the interval length; it passes the data straight through to the server.

Next Step​