public void Connect(int IDClient) { if (_connetion == null) { ConnectToClient = ListPlants[IDClient]; VpnTypeDTO vpntype = VpnTypes[ConnectToClient.IdConnectionType]; if (ConnectToClient != null) { OnInfoFromCore(String.Format("Connecting To {0}", ConnectToClient.Name), false); if (!System.Diagnostics.Debugger.IsAttached) { InitializeAssmebly(vpntype.Name); } else { _connetion = new CiscoVPN.CiscoAnyConnect(); } if (_connetion != null) { Log = new LogConenction(); Log.Id_ConnectionPlant = IDClient; Log.UserName = !_BypassMSAutantication ? Security.LoggedUser.ActualUser.user : "******"; Log.VirtualMachineName = ComputerName; Log.LastConenctionTime = DateTime.Now; VpnManagerDal.AddLog(Log); Machines = VpnManagerDAL.VpnManagerDal.GetMachinesByPlant(ConnectToClient.Name).ToDictionary(f => f.Id); Dictionary <string, string> temp = new Dictionary <string, string>(vpntype.Extensions); Dictionary <string, string> temp2 = new Dictionary <string, string>(ConnectToClient.Extensions); _connetion.ConnectionEntry = ConnectToClient.Name; _connetion.Password = ConnectToClient.Password; _connetion.User = ConnectToClient.Username; _connetion.ConnectionHost = ConnectToClient.ServerAddress; _connetion.ConnectionStatusChanged += new ConnectionStatusChange(_connetion_Info); _connetion.Options = (temp.Concat(temp2)).ToDictionary(x => x.Key, x => x.Value); _connetion.CreateConnection(); _connetion.Connect(); _Connected = false; tTimeout = new Thread(new ThreadStart(CheckTimeoutConnetcion)); tTimeout.Start(); ConnectionChanged(eConnectionState.Connecting); } } } else { OnInfoFromCore(String.Format("Controller : You are alredy Connected to {0} !!!", _connetion.ConnectionEntry), true); } }