/// <summary>
        /// Connects the ucs.
        /// </summary>
        /// <param name="configObject">The configuration object.</param>
        /// <param name="contactAppName">Name of the application.</param>
        /// <returns></returns>
        public OutputValues ConnectUCS(ConfService configObject, NullableInt tenantDBID, string contactAppName, Func <bool, bool> contactServerNotification)
        {
            OutputValues      output            = null;
            ReadConfigObjects readConfigObjects = new ReadConfigObjects();

            try
            {
                Settings.comObject  = configObject;
                Settings.tenantDBID = tenantDBID;
                readConfigObjects.ReadApplicationObject(contactAppName);
                ContactConnectionManager createProtocol = new ContactConnectionManager();
                createProtocol.ContactServerNotificationHandler += new NotifyContactServerState(contactServerNotification);
                output = createProtocol.ConnectContactServer(Settings.PrimaryApplication, Settings.SecondaryApplication);
                if (output.MessageCode == "200")
                {
                    messageToClient.NotifyContactProtocol(Settings.UCSProtocol);
                }
                else
                {
                    messageToClient.NotifyContactProtocol(Settings.UCSProtocol);
                }
            }
            catch (Exception commonException)
            {
                logger.Error("ContactLibrary:ConnectUCS:" + commonException.ToString());
            }
            return(output);
        }
        /// <summary>
        /// Refines the place.
        /// </summary>
        /// <param name="userName">Name of the user.</param>
        /// <param name="placeName">Name of the place.</param>
        /// <param name="agentLoginID">The agent login identifier.</param>
        /// <param name="queueName">Name of the queue.</param>
        /// <param name="agentPassword">The agent password.</param>
        /// <param name="workMode">The work mode.</param>
        /// <returns></returns>
        public OutputValues RefinePlace(string userName, string placeName, string agentLoginID, string queueName, string agentPassword, string workMode)
        {
            var output = OutputValues.GetInstance();
            var read   = new ReadConfigObjects();

            try
            {
                Settings.GetInstance().PlaceName = placeName;
                output = read.ReadPlaceObject();
                if (output.MessageCode == "200")
                {
                    if (Settings.GetInstance().VoiceProtocol != null && Settings.GetInstance().VoiceProtocol.State == ChannelState.Opened)
                    {
                        output = Login(placeName, userName, workMode, queueName, agentLoginID, agentPassword);
                    }
                }
                return(output);
            }
            catch (Exception generalException)
            {
                output.MessageCode = "2001";
                output.Message     = "Error occurred in Softphone RefinePlace() : " + generalException.ToString();
                logger.Error("Softphone_RefinePlace:" + generalException.ToString());
                return(output);
            }
        }
        public OutputValues InitializeChatMedia(string userName, ConfService configObject, string applicationName)
        {
            OutputValues      output = OutputValues.GetInstance();
            ReadConfigObjects read   = new ReadConfigObjects();

            //Print DLL Info
            try
            {
                Assembly assemblyVersion = Assembly.LoadFrom(Environment.CurrentDirectory + @"\Pointel.Interactions.Chat.Core.dll");
                if (assemblyVersion != null)
                {
                    logger.Info("*********************************************");
                    logger.Info(assemblyVersion.GetName().Name + " : " + assemblyVersion.GetName().Version);
                    logger.Info("*********************************************");
                }
            }
            catch (Exception versionException)
            {
                logger.Error("Error occurred while getting the version of the chat core library " + versionException.ToString());
                output.MessageCode = "2001";
                output.Message     = "Error occurred while Initialize Chat Media : " + versionException.ToString();
            }
            try
            {
                ChatConnectionSettings.GetInstance().ComObject = configObject;
                read.ReadApplicationObject(applicationName);
                Settings.PersonID = Settings.Person.EmployeeID.ToString();
                if (Settings.NickNameFormat != null || Settings.NickNameFormat != string.Empty)
                {
                    GetNickName(Settings.NickNameFormat);
                }
                else
                {
                    if (Settings.Person != null)
                    {
                        Settings.NickName = Settings.Person.UserName;
                    }
                }
                output.MessageCode = "200";
                output.Message     = "Initialized Chat Media Successful.";
            }
            catch (Exception generalException)
            {
                logger.Error("Error occurred while Initialize Chat Media " + generalException.ToString());
                output.MessageCode = "2001";
                output.Message     = "Error occurred while Initialize Chat Media : " + generalException.ToString();
            }
            return(output);
        }
        /// <summary>
        /// Connects the interaction server.
        /// </summary>
        /// <param name="primaryServer">The primary server.</param>
        /// <param name="secondaryServer">The secondary server.</param>
        /// <param name="addpClientTimeout">The addp client timeout.</param>
        /// <param name="addpServerTimeout">The addp server timeout.</param>
        public OutputValues ConnectInteractionServer(string ixnAppName, string agentID)
        {
            OutputValues      output            = null;
            ReadConfigObjects readConfigObjects = new ReadConfigObjects();

            try
            {
                readConfigObjects.ReadApplicationObject(ixnAppName);
                InteractionConnectionManager createProtocol = new InteractionConnectionManager();
                output = createProtocol.ConnectInteractionServer(Settings.PrimaryApplication, Settings.SecondaryApplication, agentID);
                if (output.MessageCode == "200")
                {
                    messageToClient.NotifyInteractionProtocol(Settings.InteractionProtocol);
                }
                ////Passing to client
                //messageToClient.NotifyInteractionMediaStatus(output);
            }
            catch (Exception commonException)
            {
                logger.Error("InteractionLibrary:ConnectInteractionServer:" + commonException.ToString());
            }
            return(output);
        }
        public OutputValues Initialize(string place, string userName, ConfService configObject, string tServerApplicationName, string agentLoginId, string agentPassword,
                                       CfgSwitch switchType)
        {
            Settings.GetInstance().AgentLoginID   = agentLoginId;
            Settings.GetInstance().Switch         = switchType;
            Settings.GetInstance().SwitchTypeName = switchType.Type == CfgSwitchType.CFGLucentDefinityG3 ?
                                                    "avaya" :
                                                    ((switchType.Type == CfgSwitchType.CFGNortelDMS100 || switchType.Type == CfgSwitchType.CFGNortelMeridianCallCenter) ? "nortel" : "avaya");
            var output  = OutputValues.GetInstance();
            var connect = new VoiceConnectionManager();
            var read    = new ReadConfigObjects();

            //Print DLL Info
            try
            {
                Assembly assemblyVersion = Assembly.LoadFrom(Environment.CurrentDirectory + @"\Pointel.Softphone.Voice.dll");
                if (assemblyVersion != null)
                {
                    logger.Debug("*********************************************");
                    logger.Debug(assemblyVersion.GetName().Name + " : " + assemblyVersion.GetName().Version);
                    logger.Debug("*********************************************");
                }
            }
            catch (Exception versionException)
            {
                logger.Error("Error occurred while getting the version of the SoftPhone library " + versionException.ToString());
            }

            try
            {
                //ConnectionSettings.comObject = configObject;
                //Get Place details
                Settings.GetInstance().PlaceName = place;
                Settings.GetInstance().UserName  = userName;
                output = read.ReadPlaceObject();
                //Read Person Details
                //output = read.ReadPersonObject(userName);
                read.ReadApplicationObject(tServerApplicationName, agentLoginId);
            }
            catch (Exception inputException)
            {
                logger.Error("Error occurred while login into SoftPhone " + inputException);
            }

            //Input Validation
            CheckException.CheckLoginValues(place, userName);
            if (output.MessageCode == "200")
            {
                //Register with TServer
                output = connect.ConnectTServer(Settings.GetInstance().PrimaryApplication, Settings.GetInstance().SecondaryApplication);

                if (output.MessageCode != "200")
                {
                    logger.Debug("Protocol is not opened, try to connect with server config keys");
                    if (Settings.GetInstance().VoiceProtocol != null && Settings.GetInstance().VoiceProtocol.State != ChannelState.Opened)
                    {
                        if (!string.IsNullOrEmpty(Settings.GetInstance().PrimaryTServerName))
                        {
                            logger.Debug("Primary TServer name : " + Settings.GetInstance().PrimaryTServerName);
                            Settings.GetInstance().PrimaryApplication = read.ReadApplicationLevelServerDetails(Settings.GetInstance().PrimaryTServerName);
                        }
                        if (!string.IsNullOrEmpty(Settings.GetInstance().SecondaryTServerName))
                        {
                            logger.Debug("Secondary TServer name : " + Settings.GetInstance().SecondaryTServerName);
                            Settings.GetInstance().SecondaryApplication = read.ReadApplicationLevelServerDetails(Settings.GetInstance().SecondaryTServerName);

                            if (Settings.GetInstance().PrimaryApplication == null && Settings.GetInstance().SecondaryApplication != null)
                            {
                                logger.Debug("Primary server is not configured, Secondary server is assigned to Primary server");
                                Settings.GetInstance().PrimaryApplication = Settings.GetInstance().SecondaryApplication;
                            }
                        }
                        else
                        {
                            logger.Debug("secondary application name is not configured");
                            if (Settings.GetInstance().SecondaryApplication == null)
                            {
                                logger.Debug("Secondary server is not configured, primary server is assigned to secondary server");
                                Settings.GetInstance().SecondaryApplication = Settings.GetInstance().PrimaryApplication;
                            }
                        }

                        //connect with server names from options tab
                        output = connect.ConnectTServer(Settings.GetInstance().PrimaryApplication, Settings.GetInstance().SecondaryApplication);
                    }
                    else
                    {
                        return(output);
                    }
                }
            }

            return(output);
        }