Delete Historical Data
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);
| Parameters | Type | Default | Note |
|---|---|---|---|
| nodeId | string | — | Target; NodeId null / empty string exception ArgumentNullException |
| start | DateTime | — | Interval starting at (UTC, inclusive) |
| end | DateTime | — | Range Stop (UTC, inclusive) |
| deleteModifiedToo | bool | false | Choosing which category to delete isn't just a matter of "deleting one more.": false = Delete raw history; true = Delete edit history |
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
| Ability | Status |
|---|---|
| Delete by Date | Not currently available (available UpdateHistory (Implementation HistoryUpdateType.Remove ) |
| Delete Events by List EventId | Not currently available |
| Soft Delete / Mark as Invalid / Recycle Bin | Not 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
| Exception | Trigger Conditions |
|---|---|
ArgumentNullException | nodeId 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/endordering or of the interval length; it passes the data straight through to the server.