Пример #1
0
        public static VpnTypeDTO GetVpnType(int vpnTypeId)
        {
            VpnTypeDTO retVal = null;

            using (VpnManagerEntities entities = new VpnManagerEntities())
            {
                string tbName = TargetTable.VpnType.ToString();

                retVal = (from vpnType in entities.VpnType
                          where vpnType.Id == vpnTypeId
                          select new VpnTypeDTO
                {
                    Id = vpnType.Id,
                    Name = vpnType.Name,

                    ExtensionCollection = (from eo in entities.ExtensionObjects
                                           where eo.IdTargetElement == vpnType.Id && eo.TargetTableName == tbName
                                           select new ExtensionObjectDTO
                    {
                        Name = eo.Name,
                        Value = eo.Value
                    })
                }).FirstOrDefault();
            }

            return(retVal);
        }
Пример #2
0
 private void Connect(int IDClient)
 {
     if (_IConnection == null)
     {
         ConnectToClient = ListPlants[IDClient];
         VpnTypeDTO vpntype = VpnTypes[ConnectToClient.IdConnectionType];
         if (ConnectToClient != null)
         {
             InitializeAssmebly(vpntype.Name);
             if (_IConnection != null)
             {
                 Dictionary <string, string> temp  = new Dictionary <string, string>(vpntype.Extensions);
                 Dictionary <string, string> temp2 = new Dictionary <string, string>(ConnectToClient.Extensions);
                 _IConnection.ConnectionEntry          = ConnectToClient.Name;
                 _IConnection.Password                 = ConnectToClient.Password;
                 _IConnection.User                     = ConnectToClient.Username;
                 _IConnection.ConnectionHost           = ConnectToClient.ServerAddress;
                 _IConnection.ConnectionStatusChanged += new ConnectionStatusChange(_connetion_Info); //<--- Stato collegato o meno
                 _IConnection.Options                  = (temp.Concat(temp2)).ToDictionary(x => x.Key, x => x.Value);
                 _IConnection.CreateConnection();
                 _IConnection.Connect();
             }
         }
     }
 }
Пример #3
0
        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);
            }
        }