Exemplo n.º 1
0
        private void DoStartupCheck(Action callbackWhenAvailable)
        {
            try
            {
                Repo2SoapClient server = new Repo2SoapClient("Repo2Soap", Server.TechURL + "repo2.asmx");
                string          latest = server.LastVersionB(Server.Software, Server.PRODUCT, SoftwareVersion.VersionString, "", false, Server.Language2, GetNetVersion(), GetMachineID());
                if (latest.StartsWith("w"))
                {
                    latest = latest.Substring(1);                     // ignore update-via-download flag;  all that's important is what version is available
                }
                // run the rest on UI thread
                Menu.Invoke(new Action(() =>
                {
                    var parts = latest.Split('#');
#if !DEBUG
                    for (int index = 1; index < parts.Length; index++)
                    {
                        // process any directives.They are in form "1.2.3#warn" - where each item between # is a command
                        switch (parts[index].ToLower())
                        {
                        case "warn":
                            const string SkipKey = "Skip_Upgrade_Message";
                            var skip             = Config.SystemConfig.ReadInteger(SkipKey, 0);
                            if (skip > 0)
                            {
                                Config.SystemConfig.Write(SkipKey, skip - 1);
                            }
                            else
                            {
                                Config.SystemConfig.Write(SkipKey, 10);
                                MessageBox.Show(Strings.Item("Update_Warn"));
                            }
                            SaveSystemConfig();
                            break;
                        }
                    }
#endif
                    latest = parts[0];

                    if (string.IsNullOrEmpty(latest))
                    {
                        return;
                    }
                    float asNumber  = SoftwareVersion.VersionNumberFromString(latest);
                    UpdateAvailable = asNumber > SoftwareVersion.Version + 0.001;                     // see frmUpdate

                    Config.SystemConfig.Write(CONFIG_UPDATECHECK_STATE, (int)StartState.Complete);
                    Globals.Root.SaveSystemConfig();
                    if (UpdateAvailable)
                    {
                        callbackWhenAvailable.Invoke();
                    }
                }));
            }
            catch (Exception ex)
            {
                try
                {
#if !DEBUG
                    Utilities.LogSubError(ex);
#endif
                }
                catch
                {
                }
            }
        }
Exemplo n.º 2
0
        public void tmrStart_Tick(object sender, EventArgs e)
        {
            // finds which is the latest version available, and gets the index file for it
            tmrStart.Enabled = false;
            this.Cursor      = Cursors.WaitCursor;
            string errorAction = "Update_Contact_Failed";             // first part of error message - changes throughout function

            try
            {
                txtLatest.Text = "?";                 // will be left in place if fn fails early
                m_Server       = new Repo2SoapClient("Repo2Soap", Server.TechURL + "repo2.asmx");
                string latest = m_Server.LastVersionB(Server.Software, Server.PRODUCT, SoftwareVersion.VersionString, "", false, Server.Language2, RootApplication.GetNetVersion(), RootApplication.GetMachineID());
                // if it is prefixed with "w", then it needs to be downloaded from the website
                m_RequiresWeb = false;
                if (latest.StartsWith("w", StringComparison.InvariantCultureIgnoreCase))
                {
                    m_RequiresWeb = true;
                    latest        = latest.Substring(1);
                }
                latest = latest.Split('#')[0];
                // other info can be appended after #.  Not used here
                txtLatest.Text = latest;
                m_LatestNumber = SoftwareVersion.VersionNumberFromString(latest);
                errorAction    = "Update_Version_Fetch_Failed";
                m_Latest       = null;
                if (!m_RequiresWeb)
                {
                    m_Latest = GetVersionIndex(latest);
                }
                errorAction = "Update_Check_Failed";
                //MessageBox.Show("m_LatestNumber=" + m_LatestNumber + ", SoftwareVersion.Version=" + SoftwareVersion.Version);
                if (m_LatestNumber <= SoftwareVersion.Version + 0.001)                 // the +0.001 added as bizarrely this condition was failing on 32 bit machines when both were "700.7"
                {
                    lblStatus.Text      = Strings.Item("Update_Latest_Installed");
                    btnDownload.Visible = false;
                    int errors = 0;
                    System.Text.StringBuilder sb = new System.Text.StringBuilder();
                    VerifyVersion(m_Latest, false, ref sb, ref errors);
                    //Clipboard.SetText(sb.ToString());
                    if (errors > 0)
                    {
                        lblStatus.Text      = Strings.Item("Update_Installation_Damaged");
                        btnDownload.Text    = Strings.Item("Update_Reinstall");
                        btnDownload.Visible = true;
                    }
                }
                else if (m_RequiresWeb)
                {
                    lblStatus.Text      = Strings.Item("Update_Newer_Manual");
                    btnDownload.Text    = Strings.Item("Update_Show_Website");
                    btnDownload.Visible = true;
                }
                else
                {
                    lblStatus.Text      = Strings.Item("Update_Newer_Available");
                    btnDownload.Text    = Strings.Item("Update_Download_Install").Replace("%0", latest);
                    btnDownload.Visible = true;
                }
            }
            catch (Exception ex)
            {
                lblStatus.Text = Strings.Item(errorAction).Trim() + " " + ex.Message;
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
Exemplo n.º 3
0
        public static Document Display(string file)
        {
            frmShowErrorReport frmNew = new frmShowErrorReport();

            frmNew.Text += " " + System.IO.Path.GetFileName(file);
            DataReader reader = new DataReader(file, FileMarkers.ErrorReport);
            //reader.ReadByte() ' Shouldn't be needed.  In versions 2.03.n if it failed to save the document it added an extra byte here (followed by a blank document)
            Document document = (Document)reader.ReadData(FileMarkers.Document);

            frmNew.txtError.Text   = reader.ReadString();
            frmNew.txtMessage.Text = reader.ReadString();
            List <string> colSubErrors = reader.ReadListString();

            System.Text.StringBuilder sub = new System.Text.StringBuilder();
            for (int index = 0; index <= colSubErrors.Count - 1; index++)
            {
                sub.Append("(").Append(index.ToString()).Append(") ").AppendLine(colSubErrors[index]);
            }
            frmNew.m_SubErrors      = sub.ToString();
            frmNew.txtErrorLog.Text = frmNew.m_SubErrors;
            // some of this extra information is not displayed yet, but is included in later reports
            reader.ReadByte();             //Dim eUser As Users =
            Guid idActivity = reader.ReadGuid();

            frmNew.m_UserConfig = (Config)reader.ReadData();
            reader.ReadData();             // will be null - UserEditor in Splash
            reader.ReadString();
            frmNew.m_Log          = reader.ReadString();
            frmNew.m_LogPermanent = reader.ReadString();
            if (reader.Version >= 108)
            {
                frmNew.m_Events = Globals.ReadDiagnosticEvents(reader);
            }
            reader.ReadOptionalPNG();             // never used
            reader.Close();
            document.UpdateReferencesObjectsCreated(document, reader);

            frmNew.lblVersion.Text = "Binary data version: " + reader.Version + "; Software version: " + SoftwareVersion.VersionStringFromNumber(reader.SoftwareVersion);
            if (document.Count == 0)
            {
                frmNew.lblWarning.Text = "SAW6Doc contained no pages - blank page created";
                document.AddPage(new Page(), new Transaction(), false);
            }
            frmNew.lblActivity.Text = "Activity: " + idActivity;
            try             // Error handler in case the activity is not present on this machine
            {
                frmNew.lblActivity.Text += " (" + Activities.GetActivityText(idActivity, false, false) + ")";
            }
            catch
            {
            }
            frmNew.TopMost = true;
            frmNew.Show();
            return(document);
        }