Exemplo n.º 1
1
        private void btnAdd_Click(object sender, System.EventArgs e)
        {
            if (Antminers.Antminer.Select(x => x.IpAddress).Contains(txtIpAddress.Text))
            {
                new ErrorDialog
                {
                    ErrorSubject = "Error adding Antminer",
                    ErrorMessage = string.Format("Antminer with Ip {0} already has been added.", txtIpAddress.Text)
                }.ShowDialog();

                return;
            }

            var antminer = new API.Antminer.Antminer
            {
                Id          = Guid.NewGuid(),
                Name        = txtName.Text,
                IpAddress   = txtIpAddress.Text,
                SshUsername = txtSshUsername.Text,
                SshPassword = txtSshPassword.Text
            };

            Antminers.Antminer.Add(antminer);

            SaveAntminers();
            PopulateAntminers();

            txtName.Text = "";
        }
Exemplo n.º 2
0
        void _scanBackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            var sn = ddlScanIpRange.SelectedItem.Value;

            for (var i = 1; i < 255; i++)
            {
                var ipAddress = IPAddress.Parse(string.Format("192.168.{0}.{1}", sn, i));

                pgbScan.Text = ipAddress.ToString();

                try
                {
                    if (AntminerConnector.Exists(ipAddress))
                    {
                        var antminer = new API.Antminer.Antminer
                        {
                            Id          = Guid.NewGuid(),
                            Name        = ipAddress.ToString(),
                            IpAddress   = ipAddress.ToString(),
                            SshUsername = txtSshUsername.Text,
                            SshPassword = txtSshPassword.Text
                        };

                        Antminers.Antminer.Add(antminer);
                    }
                }
                catch (Exception)
                {
                }

                var progress = (((double)i) / 255) * 100;

                var backgroundWorker = sender as BackgroundWorker;
                if (backgroundWorker != null)
                {
                    backgroundWorker.ReportProgress((int)progress);
                }
            }

            PopulateAntminers();
        }
Exemplo n.º 3
0
        void _scanBackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            var sn = ddlScanIpRange.SelectedItem.Value;

            for (var i = 1; i < 255; i++)
            {
                var ipAddress = IPAddress.Parse(string.Format("192.168.{0}.{1}", sn, i));

                pgbScan.Text = ipAddress.ToString();

                try
                {
                    if (AntminerConnector.Exists(ipAddress))
                    {
                        var antminer = new API.Antminer.Antminer
                        {
                            Id = Guid.NewGuid(),
                            Name = ipAddress.ToString(),
                            IpAddress = ipAddress.ToString(),
                            SshUsername = txtSshUsername.Text,
                            SshPassword = txtSshPassword.Text
                        };

                        Antminers.Antminer.Add(antminer);
                    }
                }
                catch (Exception)
                {
                    
                }

                var progress = (((double) i)/255)*100;
                
                var backgroundWorker = sender as BackgroundWorker;
                if (backgroundWorker != null) backgroundWorker.ReportProgress((int)progress);
            }

            PopulateAntminers();
        }
Exemplo n.º 4
0
        private void btnAdd_Click(object sender, System.EventArgs e)
        {
            if (Antminers.Antminer.Select(x => x.IpAddress).Contains(txtIpAddress.Text))
            {
                new ErrorDialog
                {
                    ErrorSubject = "Error adding Antminer",
                    ErrorMessage = string.Format("Antminer with Ip {0} already has been added.", txtIpAddress.Text)
                }.ShowDialog();

                return;
            }

            var antminer = new API.Antminer.Antminer
            {
                Id = Guid.NewGuid(),
                Name = txtName.Text,
                IpAddress = txtIpAddress.Text,
                SshUsername = txtSshUsername.Text,
                SshPassword = txtSshPassword.Text
            };

            Antminers.Antminer.Add(antminer);
            
            SaveAntminers();
            PopulateAntminers();

            txtName.Text = "";
        }