コード例 #1
0
 public object OnRequest(IRequest request)
 {
     if (request.Message is ManagementCommand)
     {
         ManagementCommand command = request.Message as ManagementCommand;
         if (command == null)
         {
             return(null);
         }
         ManagementResponse response = new ManagementResponse();
         response.MethodName = command.MethodName;
         response.Version    = command.CommandVersion;
         response.RequestId  = command.RequestId;
         byte[] arguments = CompactBinaryFormatter.ToByteBuffer(command.Parameters, null);
         try
         {
             response.ResponseMessage = _rpcService.InvokeMethodOnTarget(command.MethodName,
                                                                         command.Overload, GetTargetMethodParameters(arguments));
         }
         catch (System.Exception ex)
         {
             response.Exception = ex;
         }
         return(response);
     }
     else
     {
         return(null);
     }
 }
コード例 #2
0
        protected object ExecuteCommandOnMgtServer(object message, bool Response)
        {
            ManagementResponse managementResponse = null;

            if (_channel != null)
            {
                try
                {
                    managementResponse = _channel.SendMessage(message, !Response) as ManagementResponse;
                }
                catch (System.Exception e)
                {
                    throw new System.Exception(e.Message, e);
                }
                if (managementResponse != null && managementResponse.Exception != null)
                {
                    throw new System.Exception(managementResponse.Exception.Message);
                }
            }
            if (managementResponse != null)
            {
                return(managementResponse.ResponseMessage);
            }

            return(null);
        }
コード例 #3
0
        protected object ExecuteCommandOnCacehServer(Alachisoft.NCache.Common.Protobuf.ManagementCommand command)
        {
            ManagementResponse response = null;
            if (_requestManager != null)
            {
                try
                {
                    response = _requestManager.SendRequest(command) as ManagementResponse;
                }
                catch (System.Exception e)
                {
                    throw new ManagementException(e.Message,e);
                }

                if (response != null && response.exception != null)
                {
                    throw new ManagementException(response.exception.message);
                }
            }

            if (response != null)
                return response.ReturnValue;

            return null;
        }
コード例 #4
0
        protected object ExecuteCommandOnCacehServer(Alachisoft.NCache.Common.Protobuf.ManagementCommand command)
        {
            ManagementResponse response = null;

            if (_requestManager != null)
            {
                try
                {
                    response = _requestManager.SendRequest(command) as ManagementResponse;
                }
                catch (System.Exception e)
                {
                    throw new ManagementException(e.Message, e);
                }

                if (response != null && response.exception != null)
                {
                    if (response.exception.type == Alachisoft.NCache.Common.Protobuf.Exception.Type.CONFIGURATON_EXCEPTION)
                    {
                        throw new VersionException(response.exception.message, response.exception.errorCode);
                    }

                    throw new ManagementException(response.exception.message);
                }
            }

            if (response != null)
            {
                return(response.ReturnValue);
            }

            return(null);
        }
コード例 #5
0
        protected object  ExecuteCommandOnConfigurationServer(Alachisoft.NosDB.Common.Protobuf.ManagementCommands.ManagementCommand command, bool response)
        {
            ManagementResponse managementResponse = null;

            if (_channel != null)
            {
                try
                {
                    managementResponse = _channel.SendMessage(command, response) as ManagementResponse;
                }
                catch (System.Exception e)
                {
                    throw e;
                }

                if (managementResponse != null && managementResponse.Exception != null)
                {
                    throw new System.Exception(managementResponse.Exception.Message);
                }
            }

            if (managementResponse != null)
            {
                return(managementResponse.ReturnVal);
            }

            return(null);
        }
コード例 #6
0
        public object GetErrorResponse(System.Exception e)
        {
            ManagementResponse response = new ManagementResponse();

            response.exception           = new Common.Protobuf.Exception();
            response.exception.exception = e.Message;
            return(response);
        }
コード例 #7
0
        public async Task <int> insert(ManagementResponse managementResponse) //opis do TypOferty
        {
            TypOferty typ = new TypOferty()
            {
                Opis = managementResponse.Opis
            };
            await _managementRep.InsertAsync(typ);

            return((int)typ.IdTypu);
        }
コード例 #8
0
        public static byte[] SerializeManagementExceptionResponse(Exception exc, long requestId)
        {
            Alachisoft.NCache.Common.Protobuf.Exception ex = GetExceptionResponse(exc);

            Alachisoft.NCache.Common.Protobuf.ManagementResponse response = new ManagementResponse();
            response.requestId = requestId;
            response.exception = ex;

            return(SerializeResponse(response));
        }
コード例 #9
0
        public async Task <ActionResult> CreateAsync([FromBody] ManagementResponse managementResponse)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var ret = await _magagementServ.insert(managementResponse);

            return(Ok(ret));
        }
コード例 #10
0
        public async Task <int> UpdateType(int id, ManagementResponse types)
        {
            TypOferty typ = new TypOferty
            {
                Opis = types.Opis
            };

            try
            {
                await _managementRep.UpdateType(id, typ);
            }
            catch (Exception e)
            {
                return(-1);
            }
            return(id);
        }
コード例 #11
0
        public object Deserialize(byte[] buffer)
        {
            ManagementResponse response = null;

            using (MemoryStream stream = new MemoryStream(buffer))
            {
                response = ProtoBuf.Serializer.Deserialize <ManagementResponse>(stream);
            }

            if (response != null)
            {
                if (response.returnVal != null)
                {
                    response.ReturnValue = CompactBinaryFormatter.FromByteBuffer(response.returnVal, null);
                }
            }
            return(response);
        }
コード例 #12
0
        public object OnRequest(IRequest request)
        {
            if (request.Message is ManagementCommand)
            {
                //ConfigurationProvider.Provider = service;
                ManagementCommand command = (ManagementCommand)request.Message;

                ManagementResponse response = new ManagementResponse();
                response.MethodName = command.MethodName;
                response.Version    = command.CommandVersion;
                response.RequestId  = command.RequestId;
                response.ReturnVal  = CompactBinaryFormatter.ToByteBuffer(this.ConfigurationProvider.ManagementRpcService.InvokeMethodOnTarget(command.MethodName,
                                                                                                                                               command.Overload,
                                                                                                                                               GetTargetMethodParameters(CompactBinaryFormatter.ToByteBuffer(command.Parameters, null))), null);

                return(response);
            }
            else
            {
                return(new object());
            }
        }
コード例 #13
0
        public object OnRequest(IRequest request)
        {
            if (request.Message is ManagementCommand)
            {
                ManagementCommand command = request.Message as ManagementCommand;

                if (command == null)
                {
                    return(null);
                }
                ManagementResponse response = new ManagementResponse();
                response.MethodName = command.MethodName;
                response.Version    = command.CommandVersion;
                response.RequestId  = command.RequestId;

                // LoggerManager.Instance.SetThreadContext(new LoggerContext() { ShardName = "shard1", DatabaseName = "database" });
                try
                {
                    byte[] arguements = CompactBinaryFormatter.ToByteBuffer(command.Parameters, null);
                    response.ResponseMessage = ManagementProvider.ManagementRpcService.InvokeMethodOnTarget(command.MethodName,
                                                                                                            command.Overload,
                                                                                                            GetTargetMethodParameters(arguements)
                                                                                                            );
                    _channel.GetType();
                }
                catch (System.Exception ex)
                {
                    response.Exception = ex;
                }
                return(response);
            }
            else
            {
                return(null);
            }
        }
コード例 #14
0
        public async Task <ActionResult> Put(int id, [FromBody] ManagementResponse types)
        {
            var ret = await _magagementServ.UpdateType(id, types);

            return(Ok(ret));
        }