public void DeleteNodesAsync()
        {
            var nodesTDelete    = new DeleteNodesItemCollection();
            var deleteNodesItem = new DeleteNodesItem()
            {
            };

            for (int ii = 0; ii < kOperationLimit * 2; ii++)
            {
                nodesTDelete.Add(deleteNodesItem);
            }

            var requestHeader = new RequestHeader();
            var sre           = Assert.ThrowsAsync <ServiceResultException>(async() => {
                var response = await Session.DeleteNodesAsync(requestHeader,
                                                              nodesTDelete, CancellationToken.None).ConfigureAwait(false);

                StatusCodeCollection results             = response.Results;
                DiagnosticInfoCollection diagnosticInfos = response.DiagnosticInfos;

                Assert.NotNull(response.ResponseHeader);
                Assert.AreEqual(nodesTDelete.Count, results.Count);
                Assert.AreEqual(diagnosticInfos.Count, diagnosticInfos.Count);
            });

            Assert.AreEqual(StatusCodes.BadServiceUnsupported, sre.StatusCode);
        }
        public void DeleteNodes()
        {
            var nodesTDelete    = new DeleteNodesItemCollection();
            var deleteNodesItem = new DeleteNodesItem()
            {
            };

            for (int ii = 0; ii < kOperationLimit * 2; ii++)
            {
                nodesTDelete.Add(deleteNodesItem);
            }

            var requestHeader = new RequestHeader();
            var sre           = Assert.Throws <ServiceResultException>(() => {
                var responseHeader = Session.DeleteNodes(requestHeader,
                                                         nodesTDelete,
                                                         out StatusCodeCollection results,
                                                         out DiagnosticInfoCollection diagnosticInfos);

                Assert.NotNull(responseHeader);
                Assert.AreEqual(nodesTDelete.Count, results.Count);
                Assert.AreEqual(diagnosticInfos.Count, diagnosticInfos.Count);
            });

            Assert.AreEqual(StatusCodes.BadServiceUnsupported, sre.StatusCode);
        }
示例#3
0
        /// <summary>
        /// 删除一个节点的操作,除非服务器配置允许,否则引发异常,成功返回<c>True</c>,否则返回<c>False</c>
        /// </summary>
        /// <param name="tag">节点文本描述</param>
        /// <returns></returns>
        public bool DeleteExsistNode(string tag)
        {
            DeleteNodesItemCollection nodesToDelete = new DeleteNodesItemCollection();

            new DeleteNodesItem().NodeId = new NodeId(tag);
            StatusCodeCollection     results;
            DiagnosticInfoCollection diagnosticInfos;

            this.m_session.DeleteNodes((RequestHeader)null, nodesToDelete, out results, out diagnosticInfos);
            ClientBase.ValidateResponse((IList)results, (IList)nodesToDelete);
            ClientBase.ValidateDiagnosticInfos(diagnosticInfos, (IList)nodesToDelete);
            return(!StatusCode.IsBad(results[0]));
        }
示例#4
0
        /// <summary>
        /// Invokes the DeleteNodes service.
        /// </summary>
        public virtual ResponseHeader DeleteNodes(
            RequestHeader requestHeader,
            DeleteNodesItemCollection nodesToDelete,
            out StatusCodeCollection results,
            out DiagnosticInfoCollection diagnosticInfos)
        {
            results         = null;
            diagnosticInfos = null;

            ValidateRequest(requestHeader);

            // Insert implementation.

            return(CreateResponse(requestHeader, StatusCodes.BadServiceUnsupported));
        }
示例#5
0
        /// <summary>
        /// 删除一个节点的操作,除非服务器配置允许,否则引发异常,成功返回<c>True</c>,否则返回<c>False</c>
        /// </summary>
        /// <param name="tag">节点文本描述</param>
        /// <returns></returns>
        public bool DeleteExsistNode(string tag)
        {
            DeleteNodesItemCollection waitDelete = new DeleteNodesItemCollection( );

            DeleteNodesItem nodesItem = new DeleteNodesItem( )
            {
                NodeId = new NodeId(tag),
            };

            m_session.DeleteNodes(
                null,
                waitDelete,
                out StatusCodeCollection results,
                out DiagnosticInfoCollection diagnosticInfos);

            ClientBase.ValidateResponse(results, waitDelete);
            ClientBase.ValidateDiagnosticInfos(diagnosticInfos, waitDelete);

            return(!StatusCode.IsBad(results[0]));
        }
示例#6
0
 public static Entry For(DeleteNodesItemCollection nodesToDelete)
 {
     if (nodesToDelete == null)
     {
         return(new NullEntry());
     }
     else
     {
         ArrayEntry entry = new ArrayEntry();
         DeleteNodesItemCollection.Enumerator e = nodesToDelete.GetEnumerator();
         while (e.MoveNext())
         {
             ObjectEntry node = new ObjectEntry();
             node.Add("NodeId", For(e.Current.NodeId));
             node.Add("DeleteTargetReferences", For(e.Current.DeleteTargetReferences));
             entry.Add(node);
         }
         return(entry);
     }
 }
        /// <summary>
        /// Invokes the DeleteNodes service.
        /// </summary>
        public virtual ResponseHeader DeleteNodes(
            RequestHeader                requestHeader,
            DeleteNodesItemCollection    nodesToDelete,
            out StatusCodeCollection     results,
            out DiagnosticInfoCollection diagnosticInfos)
        {
            results = null;
            diagnosticInfos = null;

            ValidateRequest(requestHeader);

            // Insert implementation.

            return CreateResponse(requestHeader, StatusCodes.BadServiceUnsupported);
        }
示例#8
0
        /// <summary>
        /// Begins an asynchronous invocation of the DeleteNodes service.
        /// </summary>
        public IAsyncResult BeginDeleteNodes(
            RequestHeader             requestHeader,
            DeleteNodesItemCollection nodesToDelete,
            AsyncCallback             callback,
            object                    asyncState)
        {
            DeleteNodesRequest request = new DeleteNodesRequest();

            request.RequestHeader = requestHeader;
            request.NodesToDelete = nodesToDelete;

            UpdateRequestHeader(request, requestHeader == null, "DeleteNodes");

            if (UseTransportChannel)
            {
                return TransportChannel.BeginSendRequest(request, callback, asyncState);
            }

            return InnerChannel.BeginDeleteNodes(new DeleteNodesMessage(request), callback, asyncState);
        }
示例#9
0
        /// <summary>
        /// Invokes the DeleteNodes service.
        /// </summary>
        public virtual ResponseHeader DeleteNodes(
            RequestHeader                requestHeader,
            DeleteNodesItemCollection    nodesToDelete,
            out StatusCodeCollection     results,
            out DiagnosticInfoCollection diagnosticInfos)
        {
            DeleteNodesRequest request = new DeleteNodesRequest();
            DeleteNodesResponse response = null;

            request.RequestHeader = requestHeader;
            request.NodesToDelete = nodesToDelete;

            UpdateRequestHeader(request, requestHeader == null, "DeleteNodes");

            try
            {
                if (UseTransportChannel)
                {
                    IServiceResponse genericResponse = TransportChannel.SendRequest(request);

                    if (genericResponse == null)
                    {
                        throw new ServiceResultException(StatusCodes.BadUnknownResponse);
                    }

                    ValidateResponse(genericResponse.ResponseHeader);
                    response = (DeleteNodesResponse)genericResponse;
                }
                else
                {
                    DeleteNodesResponseMessage responseMessage = InnerChannel.DeleteNodes(new DeleteNodesMessage(request));

                    if (responseMessage == null || responseMessage.DeleteNodesResponse == null)
                    {
                        throw new ServiceResultException(StatusCodes.BadUnknownResponse);
                    }

                    response = responseMessage.DeleteNodesResponse;
                    ValidateResponse(response.ResponseHeader);
                }

                results         = response.Results;
                diagnosticInfos = response.DiagnosticInfos;
            }
            finally
            {
                RequestCompleted(request, response, "DeleteNodes");
            }

            return response.ResponseHeader;
        }