예제 #1
0
        public OutputValues ConnectInteractionServer(CfgApplication primaryServer, CfgApplication secondayServer, string clientName)
        {
            OutputValues output = OutputValues.GetInstance();
            var          ixnserverconfProperties = new IxnServerConfProperties();

            try
            {
                if (Settings.InteractionProtocol == null)
                {
                    _logger.Debug("ConnectInteractionServer : Connecting to the Ixn server with the details of " +
                                  primaryServer.ServerInfo.Host.IPaddress + ":" + primaryServer.ServerInfo.Port + " backup server " +
                                  secondayServer.ServerInfo.Port + ":" + secondayServer.ServerInfo.Port);

                    ProtocolManagers.Instance().DisConnectServer(ServerType.Ixnserver);
                    Settings.InteractionProtocol = null;
                    ixnserverconfProperties.Create(new Uri("tcp://" + primaryServer.ServerInfo.Host.IPaddress + ":" + primaryServer.ServerInfo.Port),
                                                   clientName, InteractionClient.Proxy, new Uri("tcp://" + secondayServer.ServerInfo.Host.IPaddress + ":" + secondayServer.ServerInfo.Port),
                                                   Convert.ToInt32(primaryServer.ServerInfo.Timeout), Convert.ToInt16(primaryServer.ServerInfo.Attempts),
                                                   Convert.ToInt32(Settings.AddpServerTimeout), Convert.ToInt32(Settings.AddpClientTimeout), Genesyslab.Platform.Commons.Connection.Configuration.AddpTraceMode.Both);

                    var ixnProtocolConfiguration = ixnserverconfProperties.Protocolconfiguration;

                    string error = "";
                    if (!ProtocolManagers.Instance().ConnectServer(ixnProtocolConfiguration, out error))
                    {
                        _logger.Error("Interaction protocol is not opened due to, " + error);
                        output.MessageCode = "2001";
                        output.Message     = error;
                        return(output);
                    }
                    Settings.InteractionProtocol           = ProtocolManagers.Instance().ProtocolManager[ixnProtocolConfiguration.Name] as InteractionServerProtocol;
                    InteractionManager.EventCreated        = false;
                    Settings.InteractionProtocol.Received += InteractionManager.InteractionEvents;

                    if (Settings.InteractionProtocol.State == ChannelState.Opened)
                    {
                        InteractionManager.isAfterConnect = true;
                        _logger.Debug("ConnectInteractionServer : Interaction protocol is opened ");
                        _logger.Info("ConnectInteractionServer : Interaction Protocol object id is " + Settings.InteractionProtocol.GetHashCode().ToString());
                        output.MessageCode = "200";
                        output.Message     = "InteractionServer Connected";
                    }
                    else
                    {
                        _logger.Warn("CreateInteractionConnection : Interaction protocol is closed ");
                    }
                }
                else
                {
                    _logger.Warn("Interaction Protocol status is " + Settings.InteractionProtocol.State.ToString());
                }
            }

            catch (Exception commonException)
            {
                Settings.InteractionProtocol = null;
                _logger.Error("ConnectInteractionServer :" + commonException.ToString());
                output.MessageCode = "2001";
                output.Message     = commonException.Message;
            }
            return(output);
        }
        public OutputValues ConnectTServer(CfgApplication primaryServer, CfgApplication secondaryServer, bool switchoverServer = true)
        {
            OutputValues output = OutputValues.GetInstance();
            var          tServerConfProperties = new TServerConfProperties();

            try
            {
                if (primaryServer != null)
                {
                    ProtocolManagers.Instance().DisConnectServer(ServerType.Tserver);
                    Settings.GetInstance().VoiceProtocol = null;
                    logger.Debug("ConnectTServer : Applied primary server properties to Voice protocol");

                    logger.Debug("ConnectTServer : Primary server uri " + "tcp://" + primaryServer.ServerInfo.Host.IPaddress
                                 + ":" + primaryServer.ServerInfo.Port);
                    if (secondaryServer != null)
                    {
                        logger.Debug("ConnectTServer : Applied secondary server properties to Voice protocol");
                        logger.Debug("ConnectTServer : Secondary server uri " + "tcp://" + secondaryServer.ServerInfo.Host.IPaddress
                                     + ":" + secondaryServer.ServerInfo.Port);
                    }
                    else
                    {
                        logger.Warn("ConnectTServer : Secondary server is not mentioned");
                        logger.Info("ConnectTServer : Application has no backup servers");
                    }

                    tServerConfProperties.Create(new Uri("tcp://" + primaryServer.ServerInfo.Host.IPaddress + ":" + primaryServer.ServerInfo.Port),
                                                 Settings.GetInstance().UserName, new Uri("tcp://" + secondaryServer.ServerInfo.Host.IPaddress + ":" + secondaryServer.ServerInfo.Port),
                                                 Convert.ToInt32(primaryServer.ServerInfo.Timeout), Convert.ToInt16(primaryServer.ServerInfo.Attempts),
                                                 Convert.ToInt32(Settings.GetInstance().AddpServerTimeout), Convert.ToInt32(Settings.GetInstance().AddpClientTimeout),
                                                 Genesyslab.Platform.Commons.Connection.Configuration.AddpTraceMode.Both);
                    var    TserverProtocolConfiguration = tServerConfProperties.Protocolconfiguration;
                    string error = "";
                    if (!ProtocolManagers.Instance().ConnectServer(TserverProtocolConfiguration, out error))
                    {
                        logger.Error("Tserver protocol is not opened due to, " + error);
                        output.MessageCode = "2001";
                        output.Message     = error;
                        return(output);
                    }
                    Settings.GetInstance().VoiceProtocol = ProtocolManagers.Instance().ProtocolManager[TserverProtocolConfiguration.Name] as TServerProtocol;
                    VoiceManager.EventCreated = false;
                    Settings.GetInstance().VoiceProtocol.Received += VoiceManager.GetInstance().ReportingVoiceMessage;

                    if (Settings.GetInstance().VoiceProtocol.State == ChannelState.Opened)
                    {
                        logger.Debug("ConnectTServer : Voice protocol is opened ");
                        logger.Info("ConnectTServer : Voice Protocol object id is "
                                    + Settings.GetInstance().VoiceProtocol.GetHashCode().ToString());
                        output.MessageCode = "200";
                        output.Message     = "TServer Connected";
                    }
                    else
                    {
                        logger.Debug("CreateVoiceConnection : Voice protocol is closed ");
                    }
                }
                else
                {
                    Settings.GetInstance().VoiceProtocol = null;
                    if (switchoverServer)
                    {
                        output = ConnectTServer(secondaryServer, primaryServer, false);
                    }
                    else
                    {
                        logger.Error("ConnectTServer : No primary server configured.");
                        output.MessageCode = "2002";
                        output.Message     = "No primary server configured. Could not able to connect T-server";
                    }
                }
            }

            catch (Exception CommonException)
            {
                Settings.GetInstance().VoiceProtocol = null;
                if (switchoverServer)
                {
                    output = ConnectTServer(secondaryServer, primaryServer, false);
                }
                else
                {
                    logger.Error("ConnectTServer :" + CommonException.ToString());
                    output.MessageCode = "2001";
                    output.Message     = CommonException.Message;
                }
            }
            return(output);
        }
        /// <summary>
        /// Opens the chat protocol.
        /// </summary>
        /// <param name="nickName">Name of the nick.</param>
        /// <param name="personId">The person identifier.</param>
        /// <param name="host">The host.</param>
        /// <param name="port">The port.</param>
        /// <returns></returns>
        public Pointel.Interactions.Chat.Core.General.OutputValues OpenChatProtocol(string nickName, string personId,
                                                                                    Genesyslab.Platform.ApplicationBlocks.ConfigurationObjectModel.CfgObjects.CfgApplication primaryServer,
                                                                                    Genesyslab.Platform.ApplicationBlocks.ConfigurationObjectModel.CfgObjects.CfgApplication secondaryServer, bool switchoverServer = true)
        {
            var output = new Pointel.Interactions.Chat.Core.General.OutputValues();

            var chatServerConfProperties = new BasicChatServerConfProperties();

            try
            {
                if (primaryServer != null)
                {
                    logger.Debug("OpenChatProtocol : Applied primary server properties to Chat protocol");
                    logger.Debug("OpenChatProtocol : Primary server uri " + "tcp://" + primaryServer.ServerInfo.Host.IPaddress
                                 + ":" + primaryServer.ServerInfo.Port);
                    if (secondaryServer != null)
                    {
                        logger.Debug("OpenChatProtocol : Applied secondary server properties to Chst protocol");
                        logger.Debug("OpenChatProtocol : Secondary server uri " + "tcp://" + secondaryServer.ServerInfo.Host.IPaddress
                                     + ":" + secondaryServer.ServerInfo.Port);
                    }
                    else
                    {
                        logger.Warn("OpenChatProtocol : Secondary server is not mentioned");
                        logger.Info("OpenChatProtocol : Application has no backup servers");
                    }
                    ProtocolManagers.Instance().DisConnectServer(ServerType.Chatserver);
                    chatServerConfProperties.Create(new Uri("tcp://" + primaryServer.ServerInfo.Host.IPaddress + ":" + primaryServer.ServerInfo.Port),
                                                    nickName, Genesyslab.Platform.WebMedia.Protocols.BasicChat.UserType.Agent, personId,
                                                    new Uri("tcp://" + secondaryServer.ServerInfo.Host.IPaddress + ":" + secondaryServer.ServerInfo.Port),
                                                    Convert.ToInt32(primaryServer.ServerInfo.Timeout), Convert.ToInt16(primaryServer.ServerInfo.Attempts),
                                                    Convert.ToInt32(Pointel.Interactions.Chat.Core.Util.Settings.AddpServerTimeout),
                                                    Convert.ToInt32(Pointel.Interactions.Chat.Core.Util.Settings.AddpClientTimeout),
                                                    Genesyslab.Platform.Commons.Connection.Configuration.AddpTraceMode.Both);
                    var    ChatserverProtocolConfiguration = chatServerConfProperties.Protocolconfiguration;
                    string error = "";
                    if (!ProtocolManagers.Instance().ConnectServer(ChatserverProtocolConfiguration, out error))
                    {
                        logger.Error("Chat protocol is not opened due to, " + error);
                        output.MessageCode = "2001";
                        output.Message     = error;
                        return(output);
                    }
                    Pointel.Interactions.Chat.Core.Util.Settings.ChatProtocol =
                        ProtocolManagers.Instance().ProtocolManager[ChatserverProtocolConfiguration.Name] as Genesyslab.Platform.WebMedia.Protocols.BasicChatProtocol;

                    Pointel.Interactions.Chat.Core.Util.Settings.ChatProtocol.Received += Pointel.Interactions.Chat.Core.Listener.BasicChatListener.GetInstance().BasicExtractor;
                    #region Old code
                    //if (Pointel.Interactions.Chat.Core.Util.Settings.ChatProtocol == null)
                    //{
                    //    logger.Debug("ConnectBasicChatServer : Applied primary server properties to Basic Chat protocol");

                    //    //Primary Server settings
                    //    logger.Debug("OpenChatProtocol : Primary server uri " + "tcp://" + primaryServer.ServerInfo.Host.IPaddress
                    //                                                              + ":" + primaryServer.ServerInfo.Port);
                    //    ChatConnectionSettings.GetInstance().ChatProtocolProperties.Uri = new Uri("tcp://" + primaryServer.ServerInfo.Host.IPaddress
                    //                                                              + ":" + primaryServer.ServerInfo.Port);

                    //    if (secondaryServer != null)
                    //    {
                    //        logger.Debug("OpenChatProtocol : Applied secondary server properties to Basic Chat protocol");
                    //        //Backup Server settings
                    //        ChatConnectionSettings.GetInstance().ChatProtocolProperties.FaultTolerance = Genesyslab.Platform.ApplicationBlocks.Commons.Protocols.FaultToleranceMode.WarmStandby;
                    //        //HardCoded Values
                    //        ChatConnectionSettings.GetInstance().ChatProtocolProperties.WarmStandbyTimeout = Convert.ToInt32(primaryServer.ServerInfo.Timeout);
                    //        ChatConnectionSettings.GetInstance().ChatProtocolProperties.WarmStandbyAttempts = Convert.ToInt16(primaryServer.ServerInfo.Attempts);
                    //        //End

                    //        ChatConnectionSettings.GetInstance().ChatProtocolProperties.WarmStandbyUri = new Uri("tcp://" + secondaryServer.ServerInfo.Host.IPaddress +
                    //                                                                            ":" + secondaryServer.ServerInfo.Port);
                    //        logger.Debug("OpenChatProtocol : Secondary server uri " + "tcp://" + secondaryServer.ServerInfo.Host.IPaddress
                    //                                                                  + ":" + secondaryServer.ServerInfo.Port);
                    //    }
                    //    else
                    //    {
                    //        logger.Warn("OpenChatProtocol : Secondary server is not mentioned");
                    //        logger.Warn("OpenChatProtocol : Application has no backup servers");
                    //    }
                    //    //Set ADDP
                    //    ChatConnectionSettings.GetInstance().ChatProtocolProperties.UseAddp = true;

                    //    ChatConnectionSettings.GetInstance().ChatProtocolProperties.AddpServerTimeout = Convert.ToInt32(Pointel.Interactions.Chat.Core.Util.Settings.AddpServerTimeout);
                    //    ChatConnectionSettings.GetInstance().ChatProtocolProperties.AddpClientTimeout = Convert.ToInt32(Pointel.Interactions.Chat.Core.Util.Settings.AddpClientTimeout);

                    //    ChatConnectionSettings.GetInstance().ChatProtocolProperties.AddpTrace = "both";

                    //    ChatConnectionSettings.GetInstance().ChatProtocolProperties.UserNickname = nickName;
                    //    ChatConnectionSettings.GetInstance().ChatProtocolProperties.UserType = Genesyslab.Platform.WebMedia.Protocols.BasicChat.UserType.Agent;
                    //    ChatConnectionSettings.GetInstance().ChatProtocolProperties.PersonId = personId;

                    //    logger.Debug("OpenChatProtocol : Trying to register protocol manger for Basic Chat protocol");
                    //    if (ChatConnectionSettings.GetInstance().ChatProtocolManager == null)
                    //    {
                    //        ChatConnectionSettings.GetInstance().ChatProtocolManager = new Genesyslab.Platform.ApplicationBlocks.Commons.Protocols.ProtocolManagementService();
                    //        ChatConnectionSettings.GetInstance().ChatProtocolManager.Register(ChatConnectionSettings.GetInstance().ChatProtocolProperties);
                    //        logger.Debug("OpenChatProtocol : Registered protocol manager");
                    //    }
                    //    else
                    //    {
                    //        ChatConnectionSettings.GetInstance().ChatProtocolManager.Register(ChatConnectionSettings.GetInstance().ChatProtocolProperties);
                    //        logger.Debug("OpenChatProtocol : Registered protocol manager");
                    //    }
                    //    //Open the connection
                    //    ChatConnectionSettings.GetInstance().ChatProtocolManager[ChatConnectionSettings.ChatServer].Open();
                    //    Pointel.Interactions.Chat.Core.Util.Settings.ChatProtocol = (Genesyslab.Platform.WebMedia.Protocols.BasicChatProtocol)ChatConnectionSettings.GetInstance().ChatProtocolManager[ChatConnectionSettings.ChatServer];

                    //    ChatConnectionSettings.GetInstance().ChatEventBroker[0] = Genesyslab.Platform.ApplicationBlocks.Commons.Broker.BrokerServiceFactory.CreateEventBroker(ChatConnectionSettings.GetInstance().ChatProtocolManager.Receiver);
                    //    ChatConnectionSettings.GetInstance().ChatEventBroker[0].Activate();

                    //    ChatConnectionSettings.GetInstance().ChatEventBroker[0].Register(Pointel.Interactions.Chat.Core.Listener.BasicChatListener.GetInstance().BasicExtractor);

                    #endregion

                    if (Pointel.Interactions.Chat.Core.Util.Settings.ChatProtocol.State == Genesyslab.Platform.Commons.Protocols.ChannelState.Opened)
                    {
                        Pointel.Interactions.Chat.Core.Util.Settings.ChatProtocol.Opened += new EventHandler(ChatConnectionManager_Opened);
                        Pointel.Interactions.Chat.Core.Util.Settings.ChatProtocol.Closed += new EventHandler(ChatConnectionManager_Closed);
                        logger.Debug("OpenChatProtocol : Basic Chat protocol is opened ");
                        logger.Debug("OpenChatProtocol : Basic Chat protocol object id is "
                                     + Pointel.Interactions.Chat.Core.Util.Settings.ChatProtocol.GetHashCode().ToString());
                        output.MessageCode = "200";
                        output.Message     = "Chat Server Connected";
                    }
                    else
                    {
                        logger.Warn("OpenChatProtocol : Basic Chat protocol is closed ");
                    }
                }
                else
                {
                    logger.Error("OpenChatProtocol : No primary server configured.");
                    output.MessageCode = "2002";
                    output.Message     = "No primary server configured. Could not able to connect Chat server";
                }
            }
            catch (Exception generalException)
            {
                if (switchoverServer)
                {
                    output = OpenChatProtocol(nickName, personId, secondaryServer, primaryServer, false);
                }
                else
                {
                    logger.Error("OpenChatProtocol :" + generalException.ToString());
                    output.MessageCode = "2001";
                    output.Message     = generalException.Message;
                }
            }
            return(output);
        }
예제 #4
0
        /// <summary>
        /// Connects the contact server.
        /// </summary>
        /// <param name="primaryServer">The primary server.</param>
        /// <param name="secondaryServer">The secondary server.</param>
        /// <returns></returns>
        public OutputValues ConnectContactServer(CfgApplication primaryServer, CfgApplication secondaryServer, bool switchoverServer = true)
        {
            OutputValues output = OutputValues.GetInstance();
            var          ucsServerConfProperties = new UcsServerConfProperties();

            try
            {
                if (Settings.UCSProtocol == null)
                {
                    logger.Debug("ConnectContactServer : Applied primary server properties to UCS protocol");
                    logger.Debug("ConnectContactServer : Primary server uri " + "tcp://" + primaryServer.ServerInfo.Host.IPaddress
                                 + ":" + primaryServer.ServerInfo.Port);
                    if (secondaryServer != null)
                    {
                        logger.Debug("ConnectContactServer : Applied secondary server properties to UCS protocol");
                        logger.Debug("ConnectContactServer : Secondary server uri " + "tcp://" + secondaryServer.ServerInfo.Host.IPaddress
                                     + ":" + secondaryServer.ServerInfo.Port);
                    }
                    else
                    {
                        logger.Warn("ConnectContactServer : Secondary server is not mentioned");
                        logger.Info("ConnectContactServer : Application has no backup servers");
                    }

                    ProtocolManagers.Instance().DisConnectServer(ServerType.Ucserver);

                    ucsServerConfProperties.Create(new Uri("tcp://" + primaryServer.ServerInfo.Host.IPaddress + ":" + primaryServer.ServerInfo.Port),
                                                   "", new Uri("tcp://" + secondaryServer.ServerInfo.Host.IPaddress + ":" + secondaryServer.ServerInfo.Port),
                                                   Convert.ToInt32(primaryServer.ServerInfo.Timeout), Convert.ToInt16(primaryServer.ServerInfo.Attempts),
                                                   Convert.ToInt32(Settings.AddpServerTimeout), Convert.ToInt32(Settings.AddpClientTimeout),
                                                   Genesyslab.Platform.Commons.Connection.Configuration.AddpTraceMode.Both);
                    var    USCserverProtocolConfiguration = ucsServerConfProperties.Protocolconfiguration;
                    string error = "";
                    if (!ProtocolManagers.Instance().ConnectServer(USCserverProtocolConfiguration, out error))
                    {
                        logger.Error("Ucs protocol is not opened due to, " + error);
                        output.MessageCode = "2001";
                        output.Message     = error;
                        return(output);
                    }
                    Settings.UCSProtocol         = ProtocolManagers.Instance().ProtocolManager[USCserverProtocolConfiguration.Name] as UniversalContactServerProtocol;
                    Settings.UCSProtocol.Opened += ContactConnectionManager_Opened;
                    Settings.UCSProtocol.Closed += ContactConnectionManager_Closed;
                    if (Settings.UCSProtocol.State == ChannelState.Opened)
                    {
                        ContactConnectionManager_Opened(null, null);
                        logger.Warn("ConnectContactServer : Contact protocol is opened ");
                        logger.Info("ConnectContactServer : Contact Protocol object id is " + Settings.UCSProtocol.GetHashCode().ToString());
                        output.MessageCode = "200";
                        output.Message     = "ConnectContactServer Connected";
                    }
                    else
                    {
                        logger.Warn("ConnectContactServer : Contact protocol is closed ");
                    }
                }
                else
                {
                    logger.Info("Contact Protocol status is " + Settings.UCSProtocol.State.ToString());
                }
            }
            catch (Exception commonException)
            {
                Settings.UCSProtocol = null;
                if (switchoverServer)
                {
                    output = ConnectContactServer(secondaryServer, primaryServer, false);
                }
                else
                {
                    logger.Error("ConnectContactServer :" + commonException.ToString());
                    output.MessageCode = "2001";
                    output.Message     = commonException.Message;
                }
            }
            return(output);
        }
        public static void RequestTeamCommunicatorStatistics(string businessAttributeName, string dynamicStatName, string[] objectIds, StatisticObjectType statObjectType,
                                                             int seconds, int insensitivity)
        {
            _logger.Info("Request Statistics Entry");
            try
            {
                if (objectIds == null || objectIds.Length <= 0)
                {
                    _logger.Warn("object ids for requesting statistics is null or empty");
                    return;
                }

                System.Collections.Generic.Dictionary <string, string> dictionary = new System.Collections.Generic.Dictionary <string, string>();
                dictionary = GetDynamicStatsConfiguration(businessAttributeName, dynamicStatName);
                if (dictionary == null || dictionary.Count <= 0)
                {
                    _logger.Warn("Dynamic teamcommunicator statistics configuration throws null or empty collection");
                    return;
                }
                string tenantName = string.Empty;
                if (ConfigContainer.Instance().AllKeys.Contains("tenant-name"))
                {
                    tenantName = (string)ConfigContainer.Instance().GetValue("tenant-name");
                }

                int refID = 5000;
                for (int index = 0; index < objectIds.Length; index++)
                {
                    if (string.IsNullOrEmpty(objectIds[index]))
                    {
                        continue;
                    }

                    var requestStat = RequestOpenStatisticEx.Create();

                    requestStat.StatisticObject            = StatisticObject.Create();
                    requestStat.StatisticObject.ObjectId   = objectIds[index];
                    requestStat.StatisticObject.ObjectType = statObjectType;
                    if (!string.IsNullOrEmpty(tenantName))
                    {
                        requestStat.StatisticObject.TenantName = tenantName;
                    }

                    requestStat.Notification           = Notification.Create();
                    requestStat.Notification.Mode      = NotificationMode.Immediate;
                    requestStat.Notification.Frequency = seconds;

                    DnActionMask mainMask = null;
                    DnActionMask relMask  = null;

                    requestStat.StatisticMetricEx = StatisticMetricEx.Create();

                    if (dictionary.ContainsKey("Category"))
                    {
                        var values = Enum.GetValues(typeof(StatisticCategory));
                        foreach (StatisticCategory categoryItem in values)
                        {
                            if (string.Compare(categoryItem.ToString(), dictionary["Category"], true) == 0)
                            {
                                requestStat.StatisticMetricEx.Category = categoryItem;
                            }
                        }
                    }
                    if (dictionary.ContainsKey("MainMask"))
                    {
                        mainMask = ActionsMask.CreateDnActionMask();

                        string[] actions = dictionary["MainMask"].ToString().Split(',');

                        foreach (string customAction in actions)
                        {
                            string myAction = string.Empty;
                            if (customAction.Contains('~'))
                            {
                                myAction = customAction.Substring(1, customAction.Length - 1);
                                var values = Enum.GetValues(typeof(DnActions));
                                foreach (DnActions action in values)
                                {
                                    if (string.Compare(action.ToString(), myAction, true) == 0)
                                    {
                                        mainMask.ClearBit(action);
                                    }
                                }
                            }
                            else if (customAction.Contains('*'))
                            {
                                var values = Enum.GetValues(typeof(DnActions));
                                foreach (DnActions action in values)
                                {
                                    mainMask.SetBit(action);
                                }
                            }
                            else
                            {
                                var values = Enum.GetValues(typeof(DnActions));
                                foreach (DnActions action in values)
                                {
                                    if (string.Compare(action.ToString(), customAction.Trim().ToString(), true) == 0)
                                    {
                                        mainMask.SetBit(action);
                                    }
                                }
                            }
                        }
                    }

                    if (dictionary.ContainsKey("RelMask"))
                    {
                        relMask = ActionsMask.CreateDnActionMask();

                        string[] actions = dictionary["RelMask"].ToString().Split(',');

                        foreach (string customAction in actions)
                        {
                            string myAction = string.Empty;
                            if (customAction.Contains('~'))
                            {
                                myAction = customAction.Substring(1, customAction.Length - 1);
                                var values = Enum.GetValues(typeof(DnActions));
                                foreach (DnActions action in values)
                                {
                                    if (string.Compare(action.ToString(), myAction, true) == 0)
                                    {
                                        mainMask.ClearBit(action);
                                    }
                                }
                            }
                            else
                            {
                                var values = Enum.GetValues(typeof(DnActions));
                                foreach (DnActions action in values)
                                {
                                    if (string.Compare(action.ToString(), customAction.Trim().ToString(), true) == 0)
                                    {
                                        relMask.SetBit(action);
                                    }
                                }
                            }
                        }
                    }
                    if (dictionary.ContainsKey("Subject"))
                    {
                        if (dictionary["Subject"] != null)
                        {
                            var values = Enum.GetValues(typeof(StatisticSubject));
                            foreach (StatisticSubject subjectItem in values)
                            {
                                if (string.Compare(subjectItem.ToString(), dictionary["Subject"], true) == 0)
                                {
                                    requestStat.StatisticMetricEx.Subject = subjectItem;
                                }
                            }
                        }
                    }
                    if (dictionary.ContainsKey("Filter"))
                    {
                        if (dictionary["Filter"] != null)
                        {
                            requestStat.StatisticMetricEx.Filter = dictionary["Filter"].ToString();
                        }
                        else
                        {
                            requestStat.StatisticMetricEx.Filter = string.Empty;
                        }
                    }

                    requestStat.StatisticMetricEx.IntervalType   = StatisticInterval.GrowingWindow;
                    requestStat.StatisticMetricEx.IntervalLength = 0;
                    requestStat.StatisticMetricEx.MainMask       = mainMask;
                    requestStat.StatisticMetricEx.RelativeMask   = relMask;
                    requestStat.ReferenceId = refID;
                    _logger.Info("Request Team Communicator statistics : " + requestStat.ToString());
                    IMessage response = ((StatServerProtocol)ProtocolManagers.Instance().ProtocolManager[ServerType.Statisticsserver.ToString()]).Request(requestStat);
                    if (response != null)
                    {
                        switch (response.Id)
                        {
                        case EventStatisticOpened.MessageId:
                            EventStatisticOpened info;
                            info = (EventStatisticOpened)response;
                            _logger.Trace("RequestStatistics Method : EventStatisticsOpened : " + info.Name);
                            break;

                        case EventError.MessageId:
                            EventError eventError = (EventError)response;
                            _logger.Trace("RequestStatistics Method : EventError : " + eventError.StringValue);
                            break;
                        }
                    }
                    refID++;
                }
            }
            catch (Exception generalException)
            {
                _logger.Error("Error while requesting statistics : " + ((generalException.InnerException == null) ? generalException.Message : generalException.InnerException.ToString()));
            }
        }
        public OutputValues ConnectConfigServer(string pri_ConfigServerHost, string pri_ConfigServerPort,
                                                string applicationName, string userName, string password, string sec_ConfigServerHost,
                                                string sec_ConfigServerPort, bool switchoverServer = true)
        {
            var output = new OutputValues();
            var confServerProperties = new ConfigurationServerConfProperties();

            try
            {
                _logger.Debug("ConnectTServer : Applied primary server properties to Voice protocol");
                _logger.Debug("ConnectTServer : Primary server uri " + "tcp://" + pri_ConfigServerHost
                              + ":" + pri_ConfigServerPort);
                if (sec_ConfigServerHost != null)
                {
                    _logger.Debug("ConnectTServer : Applied secondary server properties to Voice protocol");
                    _logger.Debug("ConnectTServer : Secondary server uri " + "tcp://" + sec_ConfigServerHost
                                  + ":" + sec_ConfigServerPort);
                }
                else
                {
                    _logger.Warn("ConnectTServer : Secondary server is not mentioned");
                    _logger.Info("ConnectTServer : Application has no backup servers");
                }

                if (ConfigContainer.Instance().ConfServiceObject != null)
                {
                    ConfServiceFactory.ReleaseConfService(ConfigContainer.Instance().ConfServiceObject);
                }

                ProtocolManagers.Instance().DisConnectServer(ServerType.Configserver);

                confServerProperties.Create(new Uri("tcp://" + pri_ConfigServerHost + ":" + pri_ConfigServerPort), CfgAppType.CFGAgentDesktop, applicationName,
                                            userName, password, new Uri("tcp://" + (sec_ConfigServerHost == "optional" ? pri_ConfigServerHost : sec_ConfigServerHost) +
                                                                        ":" + (sec_ConfigServerPort == "optional" ? pri_ConfigServerPort : sec_ConfigServerPort)),
                                            10, 5, 60, 60, Genesyslab.Platform.Commons.Connection.Configuration.AddpTraceMode.Both);
                var    cfgProtocolConfiguration = confServerProperties.Protocolconfiguration;
                string error = "";
                if (!ProtocolManagers.Instance().ConnectServer(cfgProtocolConfiguration, out error))
                {
                    _logger.Error("Configuration protocol is not opened due to, " + error);
                    output.MessageCode = "2001";
                    output.Message     = error;
                    return(output);
                }
                ConfigContainer.Instance().ConfServiceObject = (ConfService)ConfServiceFactory.CreateConfService(
                    ProtocolManagers.Instance().ProtocolManager[cfgProtocolConfiguration.Name] as ConfServerProtocol);
                if (ProtocolManagers.Instance().ProtocolManager[cfgProtocolConfiguration.Name].State == ChannelState.Opened)
                {
                    _logger.Debug("getProtocol : Configuration protocol is opened ");
                    _logger.Info("getProtocol : Configuration Protocol object id is "
                                 + ProtocolManagers.Instance().ProtocolManager[cfgProtocolConfiguration.Name].GetHashCode().ToString());

                    output.MessageCode = "200";
                    output.Message     = "Config Server Protocol Opened";
                }
                else
                {
                    _logger.Debug("getProtocol : Configuration protocol is closed ");
                    output.MessageCode = "2001";
                    output.Message     = "Config Server Connection not Established";
                }

                #region Old Code
                //catch (Exception generalException)
                //{
                //    _logger.Info("Configuration protocol already opened " + generalException.ToString());
                //    output.MessageCode = "2001";
                //    output.Message = (generalException.InnerException == null ? generalException.Message : generalException.InnerException.Message);
                //    return output;
                //}

                //_logger.Debug("getProtocol : Registered protocol manager ");
                ////Open the connection
                //ConnectionSettings.protocolManager[ConnectionSettings.ConfServer].Open();

                //comEventBrokerService = new EventBrokerService(ConnectionSettings.protocolManager.Receiver);
                ////Subscription of CFGObjects
                ////    Register(new Action<ConfEvent>(ReadApplicationObject.GetInstance().ConfigServiceHandler), new MessageIdFilter(EventObjectUpdated.MessageId));
                ////comEventBrokerService.Register(ReadApplicationObject.GetInstance().OnCMEObjectUpdated, new MessageIdFilter(EventObjectUpdated.MessageId));

                ////if (ConnectionSettings.comObject != null)
                ////    ConfServiceFactory.ReleaseConfService(ConnectionSettings.comObject);
                //if (ConfigContainer.Instance().ConfServiceObject != null)
                //    ConfServiceFactory.ReleaseConfService(ConfigContainer.Instance().ConfServiceObject);

                //ConfigContainer.Instance().ConfServiceObject = (ConfService)ConfServiceFactory.CreateConfService(
                //                  ConnectionSettings.protocolManager[ConnectionSettings.ConfServer] as ConfServerProtocol,
                //                  comEventBrokerService, true);
                //comEventBrokerService.Activate();

                //_logger.Debug("Trying to open the connection");
                //if (ConnectionSettings.protocolManager[ConnectionSettings.ConfServer].State == ChannelState.Opened)
                //{
                //    _logger.Debug("getProtocol : Configuration protocol is opened ");
                //    _logger.Info("getProtocol : Configuration Protocol object id is "
                //        + ConnectionSettings.protocolManager[ConnectionSettings.ConfServer].GetHashCode().ToString());

                //    output.MessageCode = "200";
                //    output.Message = "Config Server Protocol Opened";
                //}
                //else
                //{
                //    _logger.Debug("getProtocol : Configuration protocol is closed ");
                //    output.MessageCode = "2001";
                //    output.Message = "Config Server Connection Established";
                //}
                #endregion old code
            }
            catch (Exception connectionException)
            {
                if (switchoverServer)
                {
                    output = ConnectConfigServer(sec_ConfigServerHost, sec_ConfigServerPort,
                                                 applicationName, userName, password, pri_ConfigServerHost,
                                                 pri_ConfigServerPort, false);
                }
                else
                {
                    output.MessageCode = "2001";
                    output.Message     = (connectionException.InnerException == null ? connectionException.Message : connectionException.InnerException.Message);
                }
            }
            return(output);
        }