Exemple #1
0
 public ListRepairs2LoadAdapter(Context context)
 {
     this.context = context;
     using (var recordset = new DynamicRS(query, Values.gDatos))
     {
         recordset.Open();
         ListElements = recordset.ToList().Select(r => new Repair()
         {
             UnitNumber = r["UnitNumber"].ToString().Trim(), RepairCode = r["RepairCode"].ToString().Trim(), Flags = r["Flags"].ToString().Trim()
         }).ToList();                                                                                                                                                                                                   //(from r in _RS.ToList() select r["RepairCode"] + "|" + r["UnitNumber"]).ToList<string>();
         recordset.Close();
     }
 }
Exemple #2
0
 public override void NotifyDataSetChanged()
 {
     base.NotifyDataSetChanged();
     LoadLabel.Text = Loads.Label;
     using (var recordset = new DynamicRS(query, Values.gDatos))
     {
         recordset.Open();
         ListElements = recordset.ToList().Select(r => new Repair()
         {
             UnitNumber = r["UnitNumber"].ToString().Trim(), RepairCode = r["RepairCode"].ToString().Trim(), Flags = r["Flags"].ToString().Trim()
         }).ToList();                                                                                                                                                                                                   //(from r in _RS.ToList() select r["RepairCode"] + "|" + r["UnitNumber"]).ToList<string>();
         recordset.Close();
     }
 }
Exemple #3
0
        public fDNS()
        {
            InitializeComponent();
            var _RS = new DynamicRS("Select server=cmp_varchar from datosEmpresa where codigo='BIND_SERVER'", Values.gDatos);

            try
            {
                _RS.Open();
            } catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            txtServerName.Value = _RS["server"];
            _RS.Close();
            _RS = null;
            txtUser.Focus();
        }
Exemple #4
0
        private async void btnProcess_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("This will update the DHCP server assignments and will restart the service.\n Are you sure? ", "Info", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes)
            {
                foreach (var server in serverList1.ListServers.Where(s => s.CheckBox.Checked == true))
                {
                    string _configFile = "";
                    //create the temp File
                    using (var _RSD = new DynamicRS("Select * from vDHCPConfig where COD3='" + server.Info.COD3 + "'", Values.gDatos))
                    {
                        await _RSD.OpenAsync();

                        string _group = "";

                        while (!_RSD.EOF)
                        {
                            if (_RSD["Group"].ToString() != _group)
                            {
                                if (_group != "")
                                {
                                    _configFile += "\t}\n";
                                }
                                _group       = _RSD["Group"].ToString();
                                _configFile += "# " + _group + '\n' + "group " + _group + "{" + '\n';
                            }
                            _configFile += "\t# " + _RSD["Comment"].ToString() + '\n';
                            _configFile += "\thost " + _RSD["Host"].ToString() + " {" + '\n';
                            _configFile += "\t\thardware ethernet " + _RSD["MAC"].ToString() + ";" + '\n';
                            _configFile += "\t\tfixed-address " + _RSD["IP"].ToString() + ";" + '\n';
                            _configFile += "\t\t}\n";
                            _RSD.MoveNext();
                        }
                        _configFile += "\t}\n";
                        _RSD.Close();
                    }
                    server.Info.FileName    = string.Format("/etc/dhcp/{0}_NET.conf", server.Info.COD3);
                    server.Info.FileContent = _configFile;
                }
                //execute tasks
                await serverList1.ExecuteCommandInServers();
            }
        }
Exemple #5
0
        private void btnProcess_Click(object sender, EventArgs e)
        {
            try
            {
                if (MessageBox.Show("This will update the DNS server assignments and will restart the service.\n Are you sure? ", "Info", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes)
                {
                    string _serverDNS = txtServerName.Text;
                    var    _SP        = new SP(Values.gDatos, "pGetContador");
                    _SP.AddParameterValue("@Contador", 0);
                    _SP.AddParameterValue("@Serv", "");
                    _SP.AddParameterValue("@Codigo", "BIND_SERIAL");
                    _SP.Execute();
                    var _serial = _SP.Parameters["@Contador"].Value.ToString();
                    _SP = null;

                    string _tmpFile    = System.IO.Path.GetTempPath() + "local.hosts";
                    string _configFile = "$ttl 38400\n";
                    _configFile += "local.	IN	SOA	valsrv02. informatica.espackeuro.com. (\n";
                    _configFile += "			"+ _serial + "\n";
                    _configFile += "			10800\n";
                    _configFile += "			3600\n";
                    _configFile += "			604800\n";
                    _configFile += "			38400 )\n";
                    _configFile += "local.	IN	NS	valsrv02.\n";
                    //create the temp File
                    var _RSD = new DynamicRS("Select entry from vDNSFile order by entry", Values.gDatos);
                    _RSD.Open();
                    while (!_RSD.EOF)
                    {
                        _configFile += _RSD["entry"] + "\n";
                        _RSD.MoveNext();
                    }
                    //_configFile += "\t}\n";
                    _RSD.Close();
                    File.WriteAllText(_tmpFile, _configFile);
                    lblMsg.Text = "File created OK.";
                    //move the file to the server
                    using (var client = new SftpClient(_serverDNS, txtUser.Text, txtPassword.Text))
                    {
                        lblMsg.Text = "Connecting the server.";
                        client.Connect();
                        lblMsg.Text = "Server Connected!";
                        client.ChangeDirectory("/var/lib/bind/");
                        using (var fileStream = new FileStream(_tmpFile, FileMode.Open))
                        {
                            client.BufferSize = 4 * 1024; // bypass Payload error large files
                            client.UploadFile(fileStream, Path.GetFileName(_tmpFile));
                        }
                        lblMsg.Text = "File updated!";
                        client.Disconnect();
                    }
                    //restart the dhcp service
                    using (var client = new SshClient(_serverDNS, txtUser.Text, txtPassword.Text))
                    {
                        client.Connect();
                        client.RunCommand("service bind9 reload");
                        lblMsg.Text = "DNS Service reloaded!";
                        client.Disconnect();
                    }
                    MessageBox.Show("The process has finished correctly.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #6
0
 private void btnProcess_Click(object sender, EventArgs e)
 {
     try
     {
         if (MessageBox.Show("This will update the DHCP server assignments and will restart the service.\n Are you sure? ", "Info", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes)
         {
             string _serverDHCP = txtServerName.Text;
             string _tmpFile    = System.IO.Path.GetTempPath() + cboCOD3.Text + "_NET.conf";
             string _configFile = "";
             //create the temp File
             var _RSD = new DynamicRS("Select * from vDHCPConfig where COD3='" + cboCOD3.Text + "'", Values.gDatos);
             _RSD.Open();
             string _group = "";
             while (!_RSD.EOF)
             {
                 if (_RSD["Group"].ToString() != _group)
                 {
                     if (_group != "")
                     {
                         _configFile += "\t}\n";
                     }
                     _group       = _RSD["Group"].ToString();
                     _configFile += "# " + _group + '\n' + "group " + _group + "{" + '\n';
                 }
                 _configFile += "\t# " + _RSD["Comment"].ToString() + '\n';
                 _configFile += "\thost " + _RSD["Host"].ToString() + " {" + '\n';
                 _configFile += "\t\thardware ethernet " + _RSD["MAC"].ToString() + ";" + '\n';
                 _configFile += "\t\tfixed-address " + _RSD["IP"].ToString() + ";" + '\n';
                 _configFile += "\t\t}\n";
                 _RSD.MoveNext();
             }
             _configFile += "\t}\n";
             _RSD.Close();
             File.WriteAllText(_tmpFile, _configFile);
             lblMsg.Text = "File created OK.";
             //move the file to the server
             using (var client = new SftpClient(_serverDHCP, txtUser.Text, txtPassword.Text))
             {
                 lblMsg.Text = "Connecting the server.";
                 client.Connect();
                 lblMsg.Text = "Server Connected!";
                 client.ChangeDirectory("/etc/dhcp/");
                 using (var fileStream = new FileStream(_tmpFile, FileMode.Open))
                 {
                     client.BufferSize = 4 * 1024; // bypass Payload error large files
                     client.UploadFile(fileStream, Path.GetFileName(_tmpFile));
                 }
                 lblMsg.Text = "File updated!";
                 client.Disconnect();
             }
             //restart the dhcp service
             using (var client = new SshClient(_serverDHCP, txtUser.Text, txtPassword.Text))
             {
                 client.Connect();
                 client.RunCommand("service isc-dhcp-server restart");
                 lblMsg.Text = "DHCP Service restarted!";
                 client.Disconnect();
             }
             MessageBox.Show("The process has finished correctly.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }