private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (dataGridView1.SelectedRows.Count > 0)
     {
         VpnManagerDal.DeleteExtensionObject((int)dataGridView1.SelectedRows[0].Cells[0].Value);
     }
 }
Exemple #2
0
 private void rdPlant_CheckedChanged(object sender, EventArgs e)
 {
     if (rdPlant.Checked)
     {
         extensionObjectDTOBindingSource.DataSource = VpnManagerDal.GetExtensionObjects(_plant, (int)TargetTable.Plant);
     }
 }
Exemple #3
0
 public AddConnection()
 {
     InitializeComponent();
     vpnTypeDTOBindingSource.DataSource        = VpnManagerDal.GetVpnTypes();
     connectionTypeDTOBindingSource.DataSource = VpnManagerDal.GetConnectionTypes();
     cmbCustomer.DataSource = VpnManagerDal.GetCustomersList();
 }
 private void wizardPage2_NextButtonClick(object sender, CancelEventArgs e)
 {
     try
     {
         if (Path != string.Empty)
         {
             if (CheckAssembly(Path))
             {
                 FileInfo flinfo = new FileInfo(Path);
                 FileName = flinfo.Name;
                 File.Copy(Path, Environment.CurrentDirectory + "\\" + FileName, true);
                 VpnManagerDal.InsertNewVpnType(FileName);
                 VpnManagerDAL.DTO.VpnTypeDTO VpnType = VpnManagerDal.GetVpnTypes().Where(x => x.Name.Equals(FileName)).FirstOrDefault();
                 IDConection = VpnType.Id;
             }
             else
             {
                 e.Cancel = true;
                 MessageBox.Show("File Non Valido!");
             }
         }
         else
         {
             e.Cancel = true;
             MessageBox.Show("Nessun File Selezionato!");
         }
     }
     catch (Exception ex)
     {
         e.Cancel = true;
         MessageBox.Show(ex.Message);
     }
 }
Exemple #5
0
 private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (dataGridView1.Focused)
     {
         DataGridViewRow row = dataGridView1.SelectedRows[0];
         VpnManagerDal.DeleteMachine(Convert.ToInt32(row.Cells[0].Value));
     }
     else
     {
         if (dataGridView1.SelectedRows.Count > 0)
         {
             DataGridViewRow row = dataGridView2.SelectedRows[0];
             VpnManagerDal.DeleteExtensionObject(Convert.ToInt32(row.Cells[0].Value));
             if (rdPlant.Checked)
             {
                 extensionObjectDTOBindingSource.DataSource = VpnManagerDal.GetExtensionObjects(_plant, (int)TargetTable.Plant);
             }
             else
             {
                 extensionObjectDTOBindingSource.DataSource = VpnManagerDal.GetExtensionObjects(_machineID, (int)TargetTable.Machine);
             }
         }
         else
         {
             MessageBox.Show("Select a Object before");
         }
     }
 }
Exemple #6
0
        private void cmdAddConnectionType_Click(object sender, EventArgs e)
        {
            WizardConnection wzrd = new WizardConnection();

            wzrd.ShowDialog();
            vpnTypeDTOBindingSource.DataSource = VpnManagerDal.GetVpnTypes();
        }
Exemple #7
0
        private void AddOrUpdateMachine(bool Update)
        {
            IPAddress ipadresses;

            if (IPAddress.TryParse(txtIp.Text, out ipadresses))
            {
                int i = VpnManagerDal.GetPlant(cmbCustomer.Text).Id;
                if (!Update)
                {
                    VpnManagerDAL.VpnManagerDal.InsertNewMachine(i, txtPcName.Text, txtIp.Text, txtUerMachine.Text, txtPasswordMachine.Text, Convert.ToBoolean(chkCheckEnabled.CheckState), Convert.ToInt32(cmbContype.SelectedValue));
                    machineDTOBindingSource.DataSource = VpnManagerDal.GetMachinesByPlant(i);
                }
                else
                {
                    VpnManagerDal.EditMachine(_machineID, txtPcName.Text, txtIp.Text, txtUerMachine.Text, txtPassword.Text, Convert.ToBoolean(chkCheckEnabled.CheckState), _plant, (int)cmbContype.SelectedValue);

                    cmdEdit.Enabled = false;
                }
                foreach (Control txt in grpMachine.Controls)
                {
                    if (txt.GetType() == typeof(DevComponents.DotNetBar.Controls.TextBoxX))
                    {
                        txt.Text = string.Empty;
                    }
                }
            }
            else
            {
                MessageBox.Show("Ip Not Valid");
            }
            // txtIp.Text = "";
        }
Exemple #8
0
        private void cmbType_SelectedIndexChanged(object sender, EventArgs e)
        {
            switch (cmbType.Text)
            {
            case "ConnectionType":
                dataGridView1.DataSource            = ConnTypeDto;
                ConnTypeDto.DataSource              = VpnManagerDal.GetConnectionTypes();
                sTargetTable                        = TargetTable.ConnectionType.ToString();
                dataGridView1.Columns["Id"].Visible = false;
                break;

            case "Machine":
                //dataGridView1.DataSource = MachineDto;
                //MachineDto.DataSource = VpnManagerDal.Get
                break;

            case "Plant":
                dataGridView1.DataSource         = plantDTOBindingSource;
                plantDTOBindingSource.DataSource = VpnManagerDal.GetPlants();
                sTargetTable = "Plant";
                dataGridView1.Columns["Id"].Visible = false;
                break;


            case "VpnType":
                dataGridView1.DataSource            = VpnType;
                VpnType.DataSource                  = VpnManagerDal.GetVpnTypes();
                sTargetTable                        = "VpnType";
                dataGridView1.Columns["Id"].Visible = false;
                break;

            default:
                break;
            }
        }
Exemple #9
0
 private void cmdNext_Click(object sender, EventArgs e)
 {
     if (!Modifing)
     {
         if (txtPassword.Text == txtConfrimPassword.Text)
         {
             if (VpnManagerDal.InsertNewPlant(cmbCustomer.Text, (int)cmbVpnType.SelectedValue, txtServerHost.Text, txtUser.Text, txtPassword.Text))
             {
                 grpMachine.Enabled = true;
                 grpPlant.Enabled   = false;
             }
         }
         else
         {
             MessageBox.Show("Passwords Don't Match!!'");
         }
     }
     else
     {
         if (txtPassword.Text == txtConfrimPassword.Text)
         {
             if (VpnManagerDal.EditPlant(_plant, cmbCustomer.Text, (int)cmbVpnType.SelectedValue, txtServerHost.Text, txtUser.Text, txtPassword.Text))
             {
             }
         }
         else
         {
             MessageBox.Show("Passwords Don't Match!!'");
         }
     }
 }
Exemple #10
0
 private void AddExt_Click(object sender, EventArgs e)
 {
     if (txtExtName.Text != string.Empty && txtExtValue.Text != string.Empty)
     {
         PlantDTO plant = VpnManagerDal.GetPlant(cmbCustomer.Text);
         bool     mustUpdateExtensionObj = false; //added refresh of ext objs if needed
         if (rdPlant.Checked)
         {
             if (plant.Id > 0)
             {
                 mustUpdateExtensionObj = VpnManagerDal.AddExtensionObject(plant.Id, (int)TargetTable.Plant, txtExtName.Text, txtExtValue.Text);
             }
         }
         else
         {
             if (_machineID > 0)
             {
                 mustUpdateExtensionObj = VpnManagerDal.AddExtensionObject(_machineID, (int)TargetTable.Machine, txtExtName.Text, txtExtValue.Text);
             }
         }
         if (mustUpdateExtensionObj)
         {
             extensionObjectDTOBindingSource.DataSource = VpnManagerDal.GetExtensionObjects(_plant, (int)TargetTable.Plant);
         }
     }
 }
Exemple #11
0
        public void Disconnect()
        {
            if (_Connected)
            {
                Log.ConncetionSuccesful = true;
                VpnManagerDal.UpdateLog(Log);
            }

            _connetion.Disconnect();
        }
Exemple #12
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);
            }
        }
Exemple #13
0
 private void rdExtMachine_CheckedChanged(object sender, EventArgs e)
 {
     if (rdExtMachine.Checked)
     {
         if (dataGridView1.SelectedRows.Count > 0)
         {
             extensionObjectDTOBindingSource.DataSource = VpnManagerDal.GetExtensionObjects(_machineID, (int)TargetTable.Machine);
         }
         else
         {
             MessageBox.Show("Select First a Machine!");
             rdExtMachine.Checked = false;
             rdPlant.Checked      = true;
         }
     }
 }
Exemple #14
0
 public void ReloadAll()
 {
     OnInfoFromCore("Controller: Reloading VPN", false);
     try
     {
         ListClients         = VpnManagerDal.GetCustomers().ToDictionary(x => x.Id);
         ListPlants          = VpnManagerDal.GetPlants().ToDictionary(f => f.Id);
         ListConnectionsType = VpnManagerDal.GetConnectionTypes().ToDictionary(g => g.Id);
         VpnTypes            = VpnManagerDal.GetVpnTypes().ToDictionary(j => j.Id);
         //   OnInfoFromCore("Core: Loaded Completed", false);
     }
     catch (Exception e)
     {
         OnInfoFromCore("Controller: Error in Loading  Vpn", false);
         OnInfoFromCore(e.Message, false);
     }
 }
Exemple #15
0
        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);
            }
        }
Exemple #16
0
 private void _connetion_Info(eConnectionState state)
 {
     try
     {
         ConnectionChanged(state);
         if (state == eConnectionState.Disconnected)
         {
             _connetion              = null;
             ConnectToClient         = null;
             _Connected              = false;
             Log.ConncetionSuccesful = true;
             VpnManagerDal.UpdateLog(Log);
             tTimeout.Abort();
             tTimeout = null;
         }
         else if (state == eConnectionState.Connected)
         {
             _Connected = true;
         }
     }
     catch { }
 }
Exemple #17
0
        public AddConnection(int Plant)
        {
            InitializeComponent();
            vpnTypeDTOBindingSource.DataSource        = VpnManagerDal.GetVpnTypes();
            connectionTypeDTOBindingSource.DataSource = VpnManagerDal.GetConnectionTypes();
            machineDTOBindingSource.DataSource        = VpnManagerDal.GetMachinesByPlant(Plant);
            PlantDTO plant = VpnManagerDal.GetPlant(Plant);

            cmbCustomer.DataSource = VpnManagerDal.GetCustomersList();
            cmbCustomer.Text       = plant.DisplayedName;
            //cmbCustomer.Text = plant.Name;
            txtServerHost.Text       = plant.ServerAddress;
            txtUser.Text             = plant.Username;
            txtPassword.Text         = plant.Password;
            txtConfrimPassword.Text  = plant.Password;
            cmbVpnType.SelectedValue = plant.IdConnectionType;
            Loading            = false;
            Modifing           = true;
            grpMachine.Enabled = true;
            _plant             = Plant;
            cmdNext.Text       = "Modify Plant";
            extensionObjectDTOBindingSource.DataSource = VpnManagerDal.GetExtensionObjects(_plant, (int)TargetTable.Plant);
            // cmdMachine.Text = "Edit";
        }
Exemple #18
0
 private void LoadDataExtension(int id)
 {
     extensionObjectDTOBindingSource.DataSource = VpnManagerDal.GetExtensionObjects(id, (int)VpnManagerDal.GetTargetTable(sTargetTable));
 }
 private void cmdAdd_Click(object sender, EventArgs e)
 {
     VpnManagerDal.AddExtensionObject(IDConection, VpnManagerDAL.DTO.TargetTable.VpnType, txtName.Text, txtValue.Text);
 }