예제 #1
0
파일: MtClient.cs 프로젝트: zhao0876/mtapi
        /// <exception cref="CommunicationException">Thrown when connection failed</exception>
        public MtResponse SendCommand(int commandType, ArrayList parameters, Dictionary <string, object> namedParams, int expertHandle)
        {
            Log.DebugFormat("SendCommand: begin. commandType = {0}, parameters count = {1}", commandType, parameters?.Count);

            if (IsConnected == false)
            {
                Log.Error("SendCommand: Client is not connected.");
                throw new CommunicationException("Client is not connected.");
            }

            MtResponse result;

            try
            {
                result = _proxy.SendCommand(new MtCommand {
                    CommandType  = commandType,
                    Parameters   = parameters,
                    NamedParams  = namedParams,
                    ExpertHandle = expertHandle
                });
            }
            catch (Exception ex)
            {
                Log.ErrorFormat("SendCommand: Exception - {0}", ex.Message);

                throw new CommunicationException("Service connection failed! " + ex.Message);
            }

            Log.DebugFormat("SendCommand: end. result = {0}", result);

            return(result);
        }
예제 #2
0
        /// <exception cref="CommunicationException">Thrown when connection failed</exception>
        public MtResponse SendCommand(int commandType, ArrayList parameters)
        {
            Log.DebugFormat("SendCommand: begin. commandType = {0}, parameters count = {1}", commandType, parameters?.Count);

            MtResponse result;

            if (_isConnected == false)
            {
                Log.Error("SendCommand: Client is not connected.");
                throw new CommunicationException("Client is not connected.");
            }

            if (_proxy == null)
            {
                Log.Error("SendCommand: Proxy is not defined.");
                throw new CommunicationException("Proxy is not defined.");
            }

            try
            {
                result = _proxy.SendCommand(new MtCommand(commandType, parameters));
            }
            catch (Exception ex)
            {
                Log.ErrorFormat("SendCommand: Exception - {0}", ex.Message);

                Close();

                throw new CommunicationException("Service connection failed! " + ex.Message);
            }

            return(result);
        }