コード例 #1
0
ファイル: MainWindow.xaml.cs プロジェクト: maxpiva/jmmclient
        public void CheckForUpdatesNew(bool forceShowForm)
        {
            try
            {
                long verCurrent = 0;
                long verNew = 0;

                // get the latest version as according to the release
                if (!forceShowForm)
                {
                    AutoUpdates.JMMVersions verInfo = AutoUpdates.JMMAutoUpdatesHelper.GetLatestVersionInfo();
                    if (verInfo == null) return;

                    // get the user's version
                    System.Reflection.Assembly a = System.Reflection.Assembly.GetExecutingAssembly();
                    if (a == null)
                    {
                        logger.Error("Could not get current version");
                        return;
                    }
                    System.Reflection.AssemblyName an = a.GetName();

                    verNew = verInfo.versions.DesktopVersionAbs;

                    verCurrent = (an.Version.Revision * 100) +
                        (an.Version.Build * 100 * 100) +
                        (an.Version.Minor * 100 * 100 * 100) +
                        (an.Version.Major * 100 * 100 * 100 * 100);
                }

                if (forceShowForm || verNew > verCurrent)
                {
                    UpdateForm frm = new UpdateForm();
                    frm.Owner = this;
                    frm.ShowDialog();
                }

            }
            catch (Exception ex)
            {
                logger.ErrorException(ex.ToString(), ex);
            }
        }
コード例 #2
0
        public void CheckForUpdatesNew(bool forceShowForm)
        {
            try
            {
                long verCurrent = 0;
                long verNew = 0;

                // get the latest version as according to the release
                if (!forceShowForm)
                {
                    //AutoUpdates.JMMVersions verInfo = AutoUpdates.JMMAutoUpdatesHelper.GetLatestVersionInfo();
                    //if (verInfo == null) return;

                    // get the user's version
                    System.Reflection.Assembly a = System.Reflection.Assembly.GetExecutingAssembly();
                    if (a == null)
                    {
                        logger.Error("Could not get current version");
                        return;
                    }
                    System.Reflection.AssemblyName an = a.GetName();

                    verNew =
                        JMMAutoUpdatesHelper.ConvertToAbsoluteVersion(
                            JMMAutoUpdatesHelper.GetLatestVersionNumber(AppSettings.UpdateChannel));

                    //verNew = verInfo.versions.DesktopVersionAbs;
                    verCurrent = (an.Version.Revision * 100) +
                        (an.Version.Build * 100 * 100) +
                        (an.Version.Minor * 100 * 100 * 100) +
                        (an.Version.Major * 100 * 100 * 100 * 100);

                    //string compareMessage = string.Format("Current version: {0} / new version:{1}", verCurrent, verNew);
                    //MessageBox.Show(compareMessage);
                }

                if (forceShowForm || verNew > verCurrent)
                {
                    UpdateForm frm = new UpdateForm();
                    frm.Owner = this;
                    frm.ShowDialog();
                }

            }
            catch (Exception ex)
            {
                logger.Error(ex, ex.ToString());
            }
        }