public override async Task <Empty> DeleteSocket(CustomSocketIdentity request, ServerCallContext context)
        {
            DebugWrite($"RpcCall 'DeleteSocket': '{request}' from {context.Peer}");

            if (!_socketCache.EntityExists(request.SocketName))
            {
                throw new RpcException(new Status(StatusCode.NotFound, $"Socket {request.SocketName} not found"));
            }
            await _client.DeleteSocketAsync(new CustomSocketIdentity { SocketName = request.SocketName });

            SyncProcessors(SyncProcessorsAction.Remove, _socketCache.Get(request.SocketName));
            _socketCache.Remove(request.SocketName);
            return(new Empty());
        }
        /// <summary>Вызов процедуры удаления</summary>
        /// <param name="request">Запрос</param>
        /// <param name="context">Контекст</param>
        /// <returns>Завершённая задача после того, как были написаны заголовки ответов</returns>
        public override Task <Empty> DeleteSocket(CustomSocketIdentity request, ServerCallContext context)
        {
            DebugWrite($"RpcCall 'DeleteSocket': '{request}' from {context.Peer}");

            var socket = _socketService.GetSocket(request.SocketName);

            if (socket == null)
            {
                throw new RpcException(new Status(StatusCode.NotFound,
                                                  $"Socket {request.SocketName} not found"));
            }
            _socketService.DeleteSocket(request.SocketName);
            return(Task.FromResult(new Empty()));
        }
示例#3
0
        private async Task DeleteSocketByName(string socketName)
        {
            var socketIdentity = new CustomSocketIdentity {
                SocketName = socketName
            };

            try
            {
                await Client.DeleteSocketAsync(socketIdentity);

                Console.WriteLine($"Разъем: {socketName} был успешно удалён.");
            }
            catch (Exception e)
            {
                WritePaddedTop(e.Message);
            }
        }
示例#4
0
        private async Task BackProcessing(string socketName)
        {
            WritePaddedBottom($"Обратный продукционный вывод для {socketName}");
            try
            {
                var socketIdentity = new CustomSocketIdentity {
                    SocketName = socketName
                };
                var socket = await Client.FindSocketByIdentityAsync(socketIdentity);

                WritePaddedTop($"Результат для {socketName}: {socket}");
            }
            catch (Exception ex)
            {
                WritePaddedTop(ex.Message);
            }
        }
        public override Task <CustomSocket> FindSocketByIdentity(CustomSocketIdentity request, ServerCallContext context)
        {
            DebugWrite($"RpcCall 'FindSocketByIdentity': '{request}' from {context.Peer}");

            try
            {
                var factSet = _productionProcessor.BackProcessing(request.SocketName);
                return(Task.FromResult(FactSetToSocket(factSet)));
            }
            catch (Exception exception)
            {
                if (exception is EntityNotFoundException)
                {
                    throw new RpcException(new Status(StatusCode.NotFound, exception.Message));
                }
                throw new RpcException(new Status(StatusCode.Aborted, "BackProcessing throws unhandled exception"));
            }
        }