Example #1
0
        private int CheckPrinterStatus(DatDeviceReboot ddr, DateTime startDt)
        {
            int exe;

            int    rebootTime = 0;
            string state      = string.Empty;

            DateTime dt = DateTime.Now.AddSeconds(240);

            while (state != "Ready" && (dt > DateTime.Now))
            {
                state = ddr.GetSNMPData(out exe, _deviceStatus);
                TimeSpan span = DateTime.Now.Subtract(startDt);

                rebootTime = (span.Minutes * 60) + span.Seconds;

                if (state.Equals("04 00"))
                {
                    state = "Still in the process of rebooting: " + rebootTime + " seconds passed.";
                }
                else if (string.IsNullOrWhiteSpace(state))
                {
                    state = "Still in the process of rebooting:" + rebootTime + " seconds passed.";
                }
                else if (state.ToLower().Contains("error:") && state.ToLower().Contains("did not respond to snmp"))
                {
                    state = "Beginning of power cycle process. Printer is unable to respond.";
                }
                RlblRebootMessage.Text = state;
                RlblRebootMessage.Update();

                this.Refresh();
            }
            return(rebootTime);
        }
Example #2
0
 private void RebootDevice(DatDeviceReboot ddr, ref int exeTime, ref int rebootTime)
 {
     ddr.RebootDevice(_rebootOid, out exeTime);
     if (exeTime > 0)
     {
         RlblRebootMessage.Text = "Starting the power cycle process";
         RlblRebootMessage.Update();
         DateTime startDt = DateTime.Now;
         Thread.Sleep(5000);
         rebootTime = CheckPrinterStatus(ddr, startDt);
     }
 }
Example #3
0
        private void SetLabel()
        {
            string msg = "Rebooting " + PrinterName;

            switch (RebootStyle)
            {
            case 4: msg += " with normal power cycle.";
                break;

            case 5: msg += " and resetting to NTRAM";
                break;

            case 6: msg += " with NVRAM and factory restore.";
                break;
            }

            RlblFieldName.Text     = PrinterName;
            RlblRebootMessage.Text = msg;

            RlblFieldName.Update();
            RlblRebootMessage.Update();
        }
Example #4
0
        private void WakeDevice(DatDeviceReboot ddr)
        {
            int    exeTime = 0;
            string status  = ddr.SetDeviceValue(_wakeDevice, 1, out exeTime);

            if (!ddr.IsError)
            {
                status = ddr.GetSNMPData(out exeTime, _deviceStatus);

                while (status.ToLower().Contains("sleep") || status.ToLower().Contains("initializing"))
                {
                    RlblRebootMessage.Text = status + "...Waking device " + RtxtIpAddress.Text;
                    RlblRebootMessage.Update();

                    exeTime = 0;
                    Thread.Sleep(5000);
                    status = ddr.GetSNMPData(out exeTime, _deviceStatus);
                }
            }
            else
            {
                RlblRebootMessage.Text = "Issue waking device. Reboot may still work. " + ddr.GetLastError;
            }
        }