/// <summary>
 /// Stops the HttpListerner from Communicating with SFDC
 /// </summary>
 public void StopSFDCAdapter()
 {
     try
     {
         _logger.Info("StopSFDCAdapter : Stopping SFDC Listener....");
         SFDCHttpServer.GetInstance().StopListener();
         if (Settings.SFDCOptions.EnableAutoCloseBrowserOnAppExit)
         {
             _logger.Info("StopSFDCAdapter : Closing SFDC Browser Window....");
             if (browserProcess != null)
             {
                 if (!browserProcess.HasExited)
                 {
                     browserProcess.CloseMainWindow();
                 }
                 else
                 {
                     this._logger.Info("StopSFDCAdapter: The SFDC Browser already closed....");
                 }
             }
             else if (SFDCbrowser != null)
             {
                 SFDCbrowser.Quit();
             }
         }
         else
         {
             _logger.Info("Closing SFDC Browser Window while WDE close is disabled....");
         }
     }
     catch (Exception generalException)
     {
         this._logger.Error("StopSFDCAdapter: Error occurred " + generalException.ToString());
     }
 }
        /// <summary>
        /// Initialize SFDC Adapter
        /// </summary>
        /// <param name="agentDetails">Agent Details</param>
        /// <param name="tServer">T-Server Protocol</param>
        /// <param name="configProtocol">Config Server Protocol</param>
        private void InitializeSFDCIntegration(ISFDCListener subscirber, IAgentDetails agentDetails, IConfService confService)
        {
            try
            {
                _logger.Info("InitializeSFDCIntegration : Initializing Common Properties for SFDC Popup");

                Settings.GeneralConfigs = ReadConfiguration.GetInstance().ReadGeneralConfigurations(agentDetails.MyApplication, agentDetails.AgentGroups, agentDetails.Person);

                if (Settings.GeneralConfigs != null)
                {
                    Settings.SFDCOptions = Pointel.Salesforce.Adapter.Configurations.ReadProperties.GetInstance().GetSFDCGeneralProperties(Settings.GeneralConfigs);
                    if (Settings.SFDCOptions != null)
                    {
                        if (Settings.SFDCOptions.EnableSFDCIntegration)
                        {
                            // Initializing Common Properties in Settings
                            Settings.Initialize(subscirber, agentDetails, confService);

                            //Start SFDC Server
                            if (Settings.SFDCOptions.SFDCPopupChannels != null && Settings.SFDCOptions.SFDCConnectPort != 0)
                            {
                                SFDCHttpServer.GetInstance().StartListener(Environment.CurrentDirectory + @"\Files", Settings.SFDCOptions.SFDCConnectPort);
                                if (Settings.IsVoiceEnabled)
                                {
                                    _voicePopup = new VoiceEventHandler();
                                }
                                if (Settings.IsChatEnabled)
                                {
                                    _chatPopup = new ChatEventHandler();
                                }
                                if (Settings.IsEmailEnabled)
                                {
                                    _emailPopup = new EmailEventHandler();
                                }
                                //PopupBrowser
                                if (Settings.SFDCOptions.SFDCPopupContainer != null)
                                {
                                    if (Settings.SFDCOptions.SFDCPopupContainer.Equals("browser"))
                                    {
                                        if (Settings.SFDCOptions.SFDCLoginURL != null)
                                        {
                                            this._logger.Info("Lauching SFDC URL : " + PopupURL(Settings.SFDCOptions.SFDCLoginURL, Settings.SFDCOptions.SFDCPopupBrowserName,
                                                                                                Settings.SFDCOptions.EnableAddressbar, Settings.SFDCOptions.EnableStatusbar));
                                        }
                                        else
                                        {
                                            this._logger.Info("SFDC Login URL is null. ");
                                        }
                                    }
                                    else
                                    {
                                        Settings.SFDCListener.ReceiveSFDCWindow(new SFDCPopupWindow(Settings.SFDCOptions.SFDCLoginURL));
                                    }
                                }
                                else
                                {
                                    this._logger.Info("SFDC Popup Container is null. ");
                                }
                                if (!Settings.SFDCListener.IsSFDCConnected && Settings.SFDCOptions.AlertSFDCConnectionStatus)
                                {
                                    Settings.SFDCListener.SFDCConnectionStatus(LogMode.Error, Settings.SFDCOptions.SFDCConnectionFailureMessage);
                                }
                            }
                            else
                            {
                                this._logger.Info("SFDC Popup Aborted, because either popup channel or port number is empty ");
                                this._logger.Info("SFDC Popup Channels : " + Settings.SFDCOptions.SFDCPopupChannels);
                                this._logger.Info("SFDC Port Number : " + Settings.SFDCOptions.SFDCConnectPort);
                            }
                        }
                        else
                        {
                            _logger.Info("InitializeSFDCIntegration : SFDC Integration Disabled");
                        }
                    }
                    else
                    {
                        _logger.Info("InitializeSFDCIntegration : SFDC General Config object is null...");
                    }
                }
                else
                {
                    _logger.Info("InitializeSFDCIntegration : SFDC popup can not be started because SFDC General Configuration has is found.");
                }
            }
            catch (Exception generalException)
            {
                _logger.Error("InitializeSFDCIntegration : Error Occurred while start SFDC Popup " + generalException.ToString());
            }
        }