public override void Run(List <AntminerStatus> antminerStatuses)
        {
            foreach (var ant in antminerStatuses.Where(x => x.Status.Equals("Alive") && x.AsicStatus.Contains("x") && !AlertedAntIds.Contains(x.Id)))
            {
                var restartMessage = "Miner was successfully restarted. You will be notified if restart removes Xs.";
                try
                {
                    AntminerConnector.Restart(IPAddress.Parse(ant.IpAddress));
                }
                catch (Exception ex)
                {
                    restartMessage = string.Format("An error occured while attempting to restart miner: {0}", ex.Message);
                }

                EmailService.SendAlertEmail(string.Format(EmailSubject, ant.Name, ant.IpAddress),
                                            string.Format(EmailMessage, ant.Name, ant.IpAddress, DateTime.Now.ToString("h:mm:ss tt"), restartMessage));
                AlertedAntIds.Add(ant.Id);
            }

            foreach (var ant in antminerStatuses.Where(ant => ant.Status.Equals("Alive") && AlertedAntIds.Contains(ant.Id) && !ant.AsicStatus.Contains("x")))
            {
                EmailService.SendAlertEmail(string.Format(UpEmailSubject, ant.Name, ant.IpAddress), string.Format(UpEmailMessage, ant.Name, ant.IpAddress, DateTime.Now.ToString("h:mm:ss tt")));
                AlertedAntIds.Remove(ant.Id);
            }
        }
Exemple #2
0
        void restart_Click(object sender, EventArgs e)
        {
            var id       = (Guid)grdAntminers.CurrentRow.Tag;
            var antminer = _antminers.Antminer.SingleOrDefault(x => x.Id.Equals(id));

            if (antminer == null)
            {
                return;
            }

            try
            {
                AntminerConnector.Restart(IPAddress.Parse(antminer.IpAddress));
                new InfoDialog {
                    InfoSubject = "Restarting...", InfoMessage = "Restart Successful"
                }.ShowDialog();
            }
            catch (Exception ex)
            {
                new ErrorDialog {
                    ErrorMessage = ex.Message, ErrorSubject = "Error restarting miner"
                }.ShowDialog();
            }
        }
Exemple #3
0
        void massRebootToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var result = new ConfirmDialog {
                ConfirmSubject = "Mass Restart", ConfirmMessage = "Are you sure you want to restart all miners?"
            }.ShowDialog();

            if (!result.Equals(DialogResult.OK))
            {
                return;
            }

            var errors = new List <string>();

            _antminers = AntminerService.GetAntminers();
            foreach (var ant in _antminers.Antminer)
            {
                try
                {
                    AntminerConnector.Restart(IPAddress.Parse(ant.IpAddress));
                }
                catch (Exception ex)
                {
                    errors.Add(string.Format("{0}: {1}", ant.IpAddress, ex.Message));
                }
            }

            if (errors.Count > 0)
            {
                new ErrorDialog
                {
                    ErrorSubject     = "Error restarting miner(s)",
                    ErrorMessage     = "Some miners error when trying to restart. Hover to see error messages.",
                    LongErrorMessage = errors.Aggregate((w, j) => string.Format("{0}\r\n{1}", w, j))
                }.ShowDialog();
            }
        }