public static ToolkitVersionOnline Load()
        {
            var url = String.Format("{0}/{1}", GetFileUrl(), ToolkitVersion.commit);

            // GET ONLINE VERSION
            var tvo = new ToolkitVersionOnline();
            var wc = new WebClient();
            var versionJson = wc.DownloadString(url);
            tvo = JsonConvert.DeserializeObject<ToolkitVersionOnline>(versionJson);

            return tvo;
        }
 private void CheckForUpdate(object sender, DoWorkEventArgs e)
 {
     try
     {// CHECK FOR NEW AVAILABLE VERSION AND ENABLE UPDATE
         onlineVersion = ToolkitVersionOnline.Load();
     }
     catch (WebException) { /* Do nothing on 404 */ }
     catch (Exception)
     {
         throw;
     }
 }
Ejemplo n.º 3
0
        public static ToolkitVersionOnline Load()
        {
            var url = String.Format("{0}/{1}", GetFileUrl(), ToolkitVersion.commit);

            // GET ONLINE VERSION
            var tvo         = new ToolkitVersionOnline();
            var wc          = new WebClient();
            var versionJson = wc.DownloadString(url);

            tvo = JsonConvert.DeserializeObject <ToolkitVersionOnline>(versionJson);

            return(tvo);
        }
        /// <summary>
        /// based on current installed revision get the latest online revision
        /// <para>server will determine if local revision should be updated</para>
        /// </summary>
        /// <returns></returns>
        public static ToolkitVersionOnline Load(string versionInfoUrl = "")
        {
            // No TLS 1.2 in WinXp, or before IE8 browser if OS is newer than WinXP
            // Automatic updates do not work in WinXP (Win10 TLS 1.2 must be manually activated)

            var versionInfoJson      = String.Empty;
            var toolkitVersionOnline = new ToolkitVersionOnline();

            if (String.IsNullOrEmpty(versionInfoUrl))
            {
                versionInfoUrl = String.Format("{0}/{1}", GetFileUrl(), ToolkitVersion.AssemblyInformationVersion);
            }

            try
            {
                if (GeneralExtensions.IsInDesignMode)
                {
                    // for debugging dumby JSON data
                    versionInfoJson      = "{\"version\":\"2.7.1.0\",\"date\":1470934174,\"update\":true,\"commits\":[\"2016-08-11:AppVeyour build failed so recommitting\",\"2016-08-11: Commit for Beta Version 2.7.1.0\"],\"revision\":\"7f8f5233\"}";
                    toolkitVersionOnline = JsonConvert.DeserializeObject <ToolkitVersionOnline>(versionInfoJson);
                }
                else
                {
                    versionInfoJson      = new WebClient().DownloadString(versionInfoUrl);
                    toolkitVersionOnline = JsonConvert.DeserializeObject <ToolkitVersionOnline>(versionInfoJson);

                    //  recommend update to latest revision under special conditions
                    var useBeta = ConfigRepository.Instance().GetBoolean("general_usebeta");

                    if ((!useBeta && ToolkitVersion.AssemblyConfiguration == "BETA") ||
                        (useBeta && ToolkitVersion.AssemblyConfiguration != "BETA") ||
                        (String.IsNullOrEmpty(toolkitVersionOnline.Revision) &&
                         !toolkitVersionOnline.UpdateAvailable))
                    {
                        versionInfoJson      = new WebClient().DownloadString(GetFileUrl());
                        toolkitVersionOnline = JsonConvert.DeserializeObject <ToolkitVersionOnline>(versionInfoJson);
                        toolkitVersionOnline.CommitMessages    = new string[2];
                        toolkitVersionOnline.CommitMessages[0] = "<WARNING>: Special conditions were detected ...";
                        toolkitVersionOnline.CommitMessages[1] = "Recommend installing the latest online version.";
                        toolkitVersionOnline.UpdateAvailable   = true;
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("VersionInfoUrl Load Error: " + ex.Message);
            }

            return(toolkitVersionOnline);
        }
        public void Init(ToolkitVersionOnline onlineVersion)
        {            
            // DELETE OLD UPDATER APP IF EXISTS
            var updatingApp = Path.Combine(RootDirectory, APP_UPDATING);
            if (File.Exists(updatingApp))
                File.Delete(updatingApp);

            currentVersionLabel.Text = ToolkitVersion.version;
            newVersionLabel.Text = String.Format("{0}-{1}", onlineVersion.Version, onlineVersion.Revision);
            dateLabel.Text = onlineVersion.Date.ToShortDateString();

            if (onlineVersion.CommitMessages != null)
            {
                commitMessageDataGrid.Visible = true;
                commitMessageDataGrid.Rows.Clear();
                for (var i = 0; i < onlineVersion.CommitMessages.Length; i++)
                {
                    commitMessageDataGrid.Rows.Add();
                    commitMessageDataGrid.Rows[i].Cells["Message"].Value = onlineVersion.CommitMessages[i];
                }
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Get the latest online version info
        /// </summary>
        /// <param name="gitSubversion">Get specified version info and force rollback</param>
        /// <returns></returns>
        public static ToolkitVersionOnline GetVersionInfo(string gitSubversion = "") // fe47c38
        {
            // TODO: impliment TLS check (see way below)
            // No TLS 1.2 in WinXp, or before IE8 browser if OS is newer than WinXP
            // Automatic updates do not work in WinXP (Win10 TLS 1.2 must be manually activated)
            var versionOnline  = new ToolkitVersionOnline();
            var versionInfoUrl = String.Empty;

            if (!String.IsNullOrEmpty(gitSubversion))
            {
                versionInfoUrl = String.Format("{0}/{1}", GetFileUrl(), gitSubversion);
            }
            else
            {
                versionInfoUrl = GetFileUrl(); // latest online version (default)
            }
            var versionInfoJson = String.Empty;

            if (!GeneralExtension.IsInDesignMode)
            {
                try
                {
                    versionInfoJson = new WebClient().DownloadString(versionInfoUrl);
                }
                catch (Exception ex)
                {
                    versionOnline.CommitMessages    = new string[3];
                    versionOnline.CommitMessages[0] = "<WARNING> Could not retreive online version info ...";
                    versionOnline.CommitMessages[1] = "<WARNING> Check your internet connection ...";
                    versionOnline.CommitMessages[2] = " - " + ex.Message;
                    versionOnline.UpdateAvailable   = true;
                    return(versionOnline);
                }
            }
            else // use some dumby JSON data for debugging
            {
                versionInfoJson = "{\"version\":\"2.7.1.0\",\"date\":1470934174,\"update\":true,\"commits\":[\"<README> For Developer Use Only ...\",\"<README> This is dumby data for debugging ...\",\"2016-08-11:AppVeyour build failed so recommitting\",\"2016-08-11: Commit for Beta Version 2.7.1.0\"],\"revision\":\"7f8f5233\"}";
            }

            versionOnline = JsonConvert.DeserializeObject <ToolkitVersionOnline>(versionInfoJson);

            var commitMessagesList = new List <string>();

            if (String.IsNullOrEmpty(gitSubversion))
            {
                // update if git subversions are different
                var versionInstalled = ToolkitVersion.AssemblyInformationVersion;
                if (!versionInstalled.Equals(versionOnline.Revision, StringComparison.OrdinalIgnoreCase))
                {
                    if (!GeneralExtension.IsInDesignMode)
                    {
                        commitMessagesList.Add("<README> Sucessfully retrieved latest online version info  ...");
                        commitMessagesList.Add("<README> An update is ready for download and installation  ...");
                    }

                    versionOnline.UpdateAvailable = true;
                }
                else
                {
                    versionOnline.UpdateAvailable = false;
                }
            }
            else // forced update (custom rollback) to a specific version
            {
                commitMessagesList.Add("<README> This is a custom rollback installation ...");
                versionOnline.UpdateAvailable = true;
            }

            if (versionOnline.CommitMessages != null)
            {
                for (int i = 0; i < versionOnline.CommitMessages.Length; i++)
                {
                    commitMessagesList.Add(versionOnline.CommitMessages[i]);
                }
            }

            versionOnline.CommitMessages = commitMessagesList.ToArray();
            return(versionOnline);
        }