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); } }
private void treeClienti_NodeClick(object sender, DevComponents.AdvTree.TreeNodeMouseEventArgs e) { try { if (!connected) { if (treeClienti.SelectedNode.Index > 0 || treeClienti.SelectedNode.Parent != null) { VpnManagerDAL.DTO.ExtensionObjectDTO ext = VpnManagerDAL.VpnManagerDal.GetExtensionObject(_controller.GetCLient[Convert.ToInt32(treeClienti.SelectedNode.Tag)].Id, VpnManagerDAL.DTO.TargetTable.Plant, "Note"); if (ext != null && !string.IsNullOrEmpty(ext.Value)) { txtNote.Text = ext.Value; } else { txtNote.Text = string.Empty; //reset info previously charged } LogConenction LastConenction = VpnManagerDal.GetLogForPlant(Convert.ToInt32(treeClienti.SelectedNode.Tag)); if (LastConenction != null) { string temp = @"Last Connection : {0}" + Environment.NewLine + "User : {1}" + Environment.NewLine + "Connection Succesful : {2}" + Environment.NewLine + "Virtual Machine : {3}"; txtLastConnectionInfo.Text = string.Format(temp, LastConenction.LastConenctionTime, LastConenction.UserName, LastConenction.ConncetionSuccesful.ToString(), LastConenction.VirtualMachineName); } else { txtLastConnectionInfo.Text = ""; } } if (treeClienti.SelectedNode.Tag != null && treeClienti.SelectedNode.Parent == null) { plantDTOBindingSource.DataSource = _controller.GetCLient[Convert.ToInt32(treeClienti.SelectedNode.Tag)]; } } else { } } catch (Exception d) { WriteInfo(d.Message, true); } }