/// <summary> /// This method is used to create a DataGrpc List of one of the four supported list types. /// Which are: /// 1) ElementValueList - used to maintain a list of active process values. /// 2) ElementValuesJournalList - used to obtain a historical list of process values. /// 3) EventList - used to obtain process events as they occur. /// 4) EventJournalList - used to obtain a historical list of process events. /// </summary> /// <param name="dataGrpcList"></param> /// <param name="listParams"></param> public void DefineList(ClientListRoot dataGrpcList, CaseInsensitiveDictionary <string>?listParams) { if (_disposed) { throw new ObjectDisposedException("Cannot access a disposed ClientContext."); } if (!ServerContextIsOperational) { throw new InvalidOperationException(); } uint listClientAlias = _lists.Add(dataGrpcList); try { var request = new DefineListRequest { ContextId = this.ServerContextId, ListClientAlias = listClientAlias, ListType = dataGrpcList.ListType }; if (listParams is not null) { request.ListParams.Add(listParams); } var reply = _resourceManagementClient.DefineList(request); SetResourceManagementLastCallUtc(); if ((StatusCode)reply.Result.StatusCode == StatusCode.OK) { dataGrpcList.ListClientAlias = listClientAlias; dataGrpcList.ListServerAlias = reply.Result.ServerAlias; dataGrpcList.IsInServerContext = true; } } catch (Exception ex) { _lists.Remove(listClientAlias); ProcessRemoteMethodCallException(ex); throw; } }
/// <summary> /// This method deletes a list from the DataGrpc Server. /// </summary> /// <param name="dataGrpcList"> The list to deleted </param> /// <returns> The results of the deletion. </returns> public AliasResult?RemoveList(ClientListRoot dataGrpcList) { if (_disposed) { throw new ObjectDisposedException("Cannot access a disposed ClientContext."); } if (!ServerContextIsOperational) { throw new InvalidOperationException(); } // Only do the delete of this list from the server // if the context dispose is not running and the // list has list attributes. if (dataGrpcList.IsInServerContext) { try { var request = new DeleteListsRequest { ContextId = _serverContextId }; request.ListServerAliases.Add(dataGrpcList.ListServerAlias); DeleteListsReply reply = _resourceManagementClient.DeleteLists(request); SetResourceManagementLastCallUtc(); _lists.Remove(dataGrpcList.ListClientAlias); dataGrpcList.IsInServerContext = false; return(reply.Results.FirstOrDefault()); } catch (Exception ex) { ProcessRemoteMethodCallException(ex); throw; } } return(null); }