void OnCommServerCallbackHelper_AfterUnsubscribed(IExMonServer4CommsServerCallback callback, object state)
 {
     ExCommsServerSubscribeEntityBase callbackEntity = state as ExCommsServerSubscribeEntityBase;
     if (callbackEntity != null)
     {
         string ipAddress = callbackEntity.Entity.IPAddress;
         if (_commsServerCallbacks.ContainsKey(ipAddress))
         {
             _commsServerCallbacks[ipAddress] = null;
         }
     }
 }
        void OnCommServerCallbackHelper_AfterUnsubscribed(IExMonServer4CommsServerCallback callback, object state)
        {
            ExCommsServerSubscribeEntityBase callbackEntity = state as ExCommsServerSubscribeEntityBase;

            if (callbackEntity != null)
            {
                string ipAddress = callbackEntity.Entity.IPAddress;
                if (_commsServerCallbacks.ContainsKey(ipAddress))
                {
                    _commsServerCallbacks[ipAddress] = null;
                }
            }
        }
        bool IExMonServer4CommsServer2.ProcessH2GMessage(ExComms.Contracts.DTO.Monitor.MonMsg_H2G request)
        {
            using (ILogMethod method = Log.LogMethod(this.DYN_MODULE_NAME, "ProcessG2HMessage"))
            {
                bool result = default(bool);

                try
                {
                    // unable to get the instllation no
                    if (request.InstallationNo <= 0)
                    {
                        Log.Info("Unable to get the installation no.");
                        return(false);
                    }

                    // find the host by installation no or ip address
                    string hostIpAddress = string.Empty;
                    if (_commsServersMapByInsno.ContainsKey(request.InstallationNo))
                    {
                        _commsServersMapByInsno.TryGetValue(request.InstallationNo, out hostIpAddress);
                    }
                    else if (!request.IpAddress.IsEmpty() &&
                             _commsServersMapByIp.ContainsKey(request.IpAddress))
                    {
                        _commsServersMapByIp.TryGetValue(request.IpAddress, out hostIpAddress);
                        _commsServersMapByInsno.GetOrAdd(request.InstallationNo, hostIpAddress);
                    }

                    // get the callback by host ip address
                    if (!hostIpAddress.IsEmpty() &&
                        _commsServerCallbacks.ContainsKey(hostIpAddress))
                    {
                        IExMonServer4CommsServerCallback callback = _commsServerCallbacks[hostIpAddress];
                        if (callback != null)
                        {
                            request.HostIpAddress = hostIpAddress;
                            result = callback.ProcessH2GMessage(request);
                        }
                    }
                }
                catch (Exception ex)
                {
                    method.Exception(ex);
                }

                return(result);
            }
        }
        public static ExMonServer4CommsServerProxy Get(IExMonServer4CommsServerCallback callbackInstance)
        {
            using (ILogMethod method = Log.LogMethod("ExMonServer4CommsServerProxyFactory", "Get"))
            {
                ExMonServer4CommsServerProxy result = default(ExMonServer4CommsServerProxy);
                Binding binding = ExCommServerWcfHelper.CreateTcpBinding();
                string  uri     = "net.tcp://lt-in224:8880/BMC/Exchange";

                try
                {
                    result = ExCommsGenericProxy.GetService <ExMonServer4CommsServerProxy, IExMonServer4CommsServer>(
                        (i) =>
                    {
                        if (callbackInstance != null)
                        {
                            return(new ExMonServer4CommsServerProxy(i, callbackInstance));
                        }
                        else
                        {
                            return(new ExMonServer4CommsServerProxy(i));
                        }
                    },
                        (b, u) =>
                    {
                        b = binding;
                        u = uri;

                        if (callbackInstance != null)
                        {
                            return(new ExMonServer4CommsServerProxy(callbackInstance, b, u, null));
                        }
                        else
                        {
                            return(new ExMonServer4CommsServerProxy(b, u));
                        }
                    });
                }
                catch (Exception ex)
                {
                    method.Exception(ex);
                }

                return(result);
            }
        }
        public static ExMonServer4CommsServerCallbackProxy Get(IExecutorService executorService,
                                                               ExMonServer4CommsServerCallbackTypes callbackType,
                                                               IExMonServer4CommsServerCallback callbackInstance,
                                                               int timeoutInMilliseconds, WaitHandle canListen)
        {
            using (ILogMethod method = Log.LogMethod("ExMonServer4CommsServerProxyFactory", "Get"))
            {
                ExMonServer4CommsServerCallbackProxy result = default(ExMonServer4CommsServerCallbackProxy);

                try
                {
                    result = new ExMonServer4CommsServerCallbackProxy(executorService, callbackType, callbackInstance, timeoutInMilliseconds, canListen);
                }
                catch (Exception ex)
                {
                    method.Exception(ex);
                }

                return(result);
            }
        }
 public ExCommsMonitorProcessor(IExMonServer4CommsServerCallback callback)
 {
     exMonProxy = ExMonServer4CommsServerProxyFactory.Get(callback);
 }
 public ExCommsMonitorProcessor(IExMonServer4CommsServerCallback callback)
 {
     exMonProxy = ExMonServer4CommsServerProxyFactory.Get(callback);
 }