Beispiel #1
0
 public GFUTaskProgress(GFUTaskProgress other)
 {
     _percentComplete = other.PercentComplete;
     _message         = other.Message;
     _state           = other.State;
     _exception       = other.Exception;
 }
Beispiel #2
0
        private bool Reboot(IProgress <GFUTaskProgress> progress = null)
        {
            bool            result = false;
            GFUTaskProgress st     = new GFUTaskProgress(10, "Issuing reboot command...", GFUTaskState.Running);

            progress?.Report(new GFUTaskProgress(st));
            try
            {
                Submit("firmware.cgi", "bC=Cold Reboot");
            }
            catch (Exception ex)
            {
                st.Message += $"\nIgnoring request error:{ex.Message}\n";
            }
            st.Message         = "\nReboot in progress...";
            st.PercentComplete = 50;
            progress?.Report(new GFUTaskProgress(st));

            result      = WaitForGemini("Reboot");
            st.State    = result ? GFUTaskState.Success : GFUTaskState.Failed;
            st.Message += result ? "\nReboot successful" : "\nReboot failed";
            progress?.Report(new GFUTaskProgress(st));
            return(result);
        }
Beispiel #3
0
        private bool CheckVersion(IProgress <GFUTaskProgress> progress = null)
        {
            GFUTaskProgress prg = new GFUTaskProgress(5, "Initializing...", GFUTaskState.Running);

            if (progress != null)
            {
                progress.Report(new GFUTaskProgress(prg));
            }
            try
            {
                string s = "";
                try
                {
                    prg.Message = "Sending controller request...";
                    if (progress != null)
                    {
                        progress.Report(new GFUTaskProgress(prg));
                    }
                    s = HttpGet("firmware.cgi", "");
                }
                catch (WebException ex)
                {
                    // if file not found, perhaps it's just a clean SD card
                    if (!ex.Message.Contains("404"))
                    {
                        throw ex;
                    }
                }

                int idx = s.IndexOf("Build date:");
                if (idx < 0)
                {
                    //DialogResult res = MessageBox.Show(this, "Please note that if your current Gemini firmware version is earlier than Dec 18, 2012, you should first upgrade to Dec 18, 2012 firmware before proceeding!\n\nDo you want to continue anyway (not recommended)?", "Version check", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
                    //if (res != DialogResult.Yes)
                    //{
                    //    return false;
                    //}
                    //else
                    prg.Message = "No build date found, ok";
                    if (progress != null)
                    {
                        progress.Report(new GFUTaskProgress(prg));
                    }
                    return(true);
                }

                try
                {
                    string[] sa = (s.Substring(idx)).Split(new string[] { "<BR>" }, StringSplitOptions.RemoveEmptyEntries);
                    string   v  = "Build date:";
                    s = sa[0].Trim().Substring(v.Length);
                    s = s.Trim();
                    DateTime dt = new DateTime();

                    if (DateTime.TryParse(s, out dt))
                    {
                        _previousDateTime = dt.ToLongDateString();

                        //if (dt < new DateTime(2012, 12, 17))
                        //{

                        //    DialogResult res = MessageBox.Show(this, "Your firmware version (" + previousDateTime + ") is earlier than\nDecember 18, 2012.\n\nYou should first upgrade to December 18, 2012 firmware before proceeding!\n\nDo you want to continue anyway (not recommended)?", "Version check", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button2);
                        //    if (res != DialogResult.Yes)
                        //    {
                        //        return false;
                        //    }
                        //}
                        prg.Message          = $"Build date: {_previousDateTime}";
                        prg.PercentComplete += 5;
                        if (progress != null)
                        {
                            progress.Report(new GFUTaskProgress(prg));
                        }
                    }
                }
                catch (Exception ex)
                {
                    //DialogResult res = MessageBox.Show(this, "Please note that if your firmware version is earlier than December 18, 2012, you should first upgrade to Dec 18, 2012 firmware before proceeding!\n\nDo you want to continue anyway (not recommended)?", "Version check", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
                    //if (res != DialogResult.Yes)
                    //{
                    //    return false;
                    //}
                    prg.Message = $"Ignoring error: {ex.Message}";
                    if (progress != null)
                    {
                        progress.Report(new GFUTaskProgress(prg));
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                prg.Exception = ex;
                prg.Message   = "Failed to connect to Gemini. Please check that it's connected, turned ON, and at the correct IP address.\n"
                                + prg.Message;
                if (progress != null)
                {
                    progress.Report(new GFUTaskProgress(prg));
                }
                return(false);
            }
        }