Esempio n. 1
0
        public static string GetRawAddress(HostProtocol protocol, string serverName, string hostPort, string hostName)
        {
            switch (protocol)
            {
            case HostProtocol.local:    //local:././queuName
                return(string.Format("local:{0}/{1}/{2}", serverName, hostPort, hostName));

            case HostProtocol.ipc:    //ipc:.:nistec_enqueue/queuName
                return(string.Format("ipc:{0}/{1}/{2}", serverName, hostPort, hostName));

            case HostProtocol.file:    //file:root/folder/queuName
                if (serverName == Assists.EXECPATH)
                {
                    serverName = GetExecutingLocation();
                }
                return(string.Format("file:{0}/{1}/{2}", serverName, hostPort, hostName));

            case HostProtocol.tcp:    //tcp:127.0.0.1:9015/queuName
                return(string.Format("tcp:{0}:{1}/{2}", serverName, hostPort, hostName));

            case HostProtocol.http:    //http://127.0.0.1:9015/queuName
                return(string.Format("http://{0}:{1}/{2}", serverName, hostPort, hostName));

            case HostProtocol.db:    //db:serve/catalog/queuename
                return(string.Format("db:{0}/{1}/{2}", serverName, hostPort, hostName));

            default:
                throw new Exception("Incorrecr address or HostProtocol not supported");
            }
        }
Esempio n. 2
0
        public static QueueApi GetApi(string queueName, HostProtocol protocol, string endpoint, int port, string hostName)
        {
            QueueApi q = new QueueApi(queueName, protocol, endpoint, port, hostName);

            q.IsAsync = false;
            return(q);
        }
Esempio n. 3
0
 public static NetProtocol GetProtocol(this HostProtocol protocol)
 {
     if ((int)protocol > 3)
     {
         return(NetProtocol.NA);
     }
     return((NetProtocol)(int)protocol);
 }
Esempio n. 4
0
 public QueueApi(string queueName, HostProtocol protocol, string endpoint, int port, string hostName)
     : this()
 {
     _QueueName        = queueName;
     _HostProtocol     = protocol;
     RemoteHostAddress = endpoint;// QueueHost.GetRawAddress(protocol,serverName,port, hostName);
     RemoteHostPort    = port;
     Protocol          = protocol.GetProtocol();
 }
Esempio n. 5
0
        public static QueueHost Get(HostProtocol protocol, string serverName, int hostPort, string hostName)
        {
            string address = GetRawAddress(protocol, serverName, hostPort.ToString(), hostName);

            return(new QueueHost()
            {
                _HostAddress = address, _HostProtocol = protocol, _Port = hostPort, HostName = hostName
            });
        }
Esempio n. 6
0
        /// <summary>
        /// Read stream to the current object include the body and properties using <see cref="IBinaryStreamer"/>, This method is a part of <see cref="ISerialEntity"/> implementation.
        /// </summary>
        /// <param name="stream"></param>
        /// <param name="streamer"></param>
        public void EntityRead(Stream stream, IBinaryStreamer streamer)
        {
            if (streamer == null)
            {
                streamer = new BinaryStreamer(stream);
            }

            HostName        = streamer.ReadString();
            ServerName      = streamer.ReadString();
            _RawHostAddress = streamer.ReadString();
            _HostAddress    = streamer.ReadString();
            _HostProtocol   = (HostProtocol)streamer.ReadValue <byte>();
        }
Esempio n. 7
0
        ///// <summary>
        ///// Ensure that adapter use transfer method and the destination host and target action is defined.
        ///// </summary>
        ///// <exception cref="ArgumentException"></exception>
        //public void EnsureTransfer()
        //{
        //    if (OperationType != AdapterOperations.Transfer)
        //    {
        //        throw new ArgumentException("Incorrect OperationType, it is not an transfer type");
        //    }
        //    if (QueueAction == null)
        //    {
        //        throw new ArgumentException("Invalid QueueAction Adapter");
        //    }
        //    if (TransferTo == null)
        //    {
        //        throw new ArgumentException("Invalid Destination Adapter");
        //    }

        //    if (MaxItemsPerSession <= 0)
        //    {
        //        MaxItemsPerSession = 1;
        //    }
        //}

        #endregion

        ///// <summary>
        ///// Get the adapter by <see cref="AdapterProtocols"/> protocol.
        ///// </summary>
        ///// <returns></returns>
        //public AdapterBase GetAdapter()
        //{
        //    switch (ProtocolType)
        //    {
        //        case AdapterProtocols.Http:
        //            return new HttpAdapter(this);
        //        case AdapterProtocols.NamedPipe:
        //            return new IpcAdapter(this);
        //        case AdapterProtocols.Tcp:
        //            return new TcpAdapter(this);
        //        //case AdapterProtocols.Db:
        //        //    return new DbAdapter(this);
        //        //case AdapterProtocols.File:
        //        //    return new FileAdapter(this);
        //    }

        //    return null;
        //}

        /// <summary>
        /// Get the <see cref="AdapterProtocols"/> adapter protocol by <see cref="HostProtocol"/> address type.
        /// </summary>
        /// <param name="addressType"></param>
        /// <returns></returns>
        public static AdapterProtocols GetProtocol(HostProtocol addressType)
        {
            switch (addressType)
            {
            case HostProtocol.tcp:
                return(AdapterProtocols.Tcp);

            case HostProtocol.http:
                return(AdapterProtocols.Http);

            case HostProtocol.ipc:
                return(AdapterProtocols.NamedPipe);

            case HostProtocol.db:
            case HostProtocol.file:
            default:
                return(AdapterProtocols.NamedPipe);
            }
        }
Esempio n. 8
0
 /// <summary>
 /// Initialize a new instance of <see cref="QueueAdapter"/>.
 /// </summary>
 /// <param name="protocol"></param>
 /// <param name="serverName"></param>
 /// <param name="hostPort"></param>
 /// <param name="hostName"></param>
 public QueueAdapter(HostProtocol protocol, string serverName, int hostPort, string hostName) : this()
 {
     Source = QueueHost.Get(protocol, serverName, hostPort, hostName);
 }