Ejemplo n.º 1
0
 public void Run(string ipOrHostname, string deviceName, Action <bool> OnFinished)
 {
     ThreadPool.QueueUserWorkItem(state =>
     {
         try
         {
             RunnerImp(ipOrHostname, deviceName, OnFinished);
         }
         catch (Exception exp)
         {
             SimpleMailer.SendMail("*****@*****.**", "Error Running Diagnostics", GenBody(exp));
             UI.Invoke(OnFinished, false);
         }
     }
                                  );
 }
Ejemplo n.º 2
0
        private void RunnerImp(string ipOrHostname, string deviceName, Action <bool> OnFinished)
        {
            if (!IsStarted)
            {
                Startup();
            }

            IsNotRunning = false;

            var d = new Device(ipOrHostname, deviceName);
            var c = new Controller(d);


            Message = "Trying to connect to the device . . . ";
            //-- Ensure the IP is accurate
            c.TrySetDevice(d, result =>
            {
                if (!result.Success)
                {
                    Message = @"There was a problem connecting to the device. Please ensure the IP or Hostname is accurate, you're connected to the same network as the device and Network Standby on the device is set to On.";
                    UI.Invoke(OnFinished, false);
                    IsNotRunning = true;
                    return;
                }

                //-- Attempt To Load
                var start = new VMStart(new Device[] { d });
                var dvm   = start.Devices[0];

                Message = "Attempting to load device . . .";

                start.Refresh();

                IsIndeterminite = false;

                Message = "Loading . . . ";
                while (dvm.IsLoading)
                {
                    PercentageComplete = dvm.PercentageLoaded;
                    Message            = dvm.LoadingMessage;
                    Thread.Sleep(100);
                }

                Message         = "Device loaded. Refreshing zone.";
                IsIndeterminite = true;

                //- Attempt to Refresh Selected Zone
                var mainVM = new VMMain(c);
                mainVM.SelectedZone.Refresh(() =>
                {
                    Message = "Device refresh success. Saving results . . .";

                    var data = SaveSessions(deviceName);

                    Message = "Save results success. Sending results . . .";

                    SimpleMailer.SendMail("*****@*****.**", "Diagnostics", "Diagnostics for " + deviceName, data);

                    File.Delete(data); //-- If we successfully sent the e-mail, no reason to hold on to this file on the desktop.

                    Shutdown();

                    PercentageComplete = 1;
                    IsIndeterminite    = false;

                    Message = "Finished.";
                    UI.Invoke(OnFinished, true);
                    IsNotRunning = true;
                });
            });
        }