コード例 #1
0
ファイル: InstallWindow.cs プロジェクト: xu1u/dkim-exchange
        // ##########################################################
        // ################# Internal functions #####################
        // ##########################################################

        /// <summary>
        /// Thread safe function for the thread DkimSignerAvailable
        /// </summary>
        private async void CheckDkimSignerAvailable()
        {
            cbxPrereleases.Enabled = false;

            await Task.Run(() => versionAvailable = ApiWrapper.GetAllRelease(cbxPrereleases.Checked, new Version("2.0.0")));

            cbxPrereleases.Enabled = true;

            cbVersionWeb.Items.Clear();
            if (versionAvailable != null)
            {
                if (versionAvailable.Count > 0)
                {
                    foreach (Release oVersionAvailable in versionAvailable)
                    {
                        cbVersionWeb.Items.Add(oVersionAvailable.TagName);
                    }

                    cbVersionWeb.Enabled = true;
                }
                else
                {
                    MessageBox.Show(this, "No release information from the Web available.", "Version", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    cbVersionWeb.Enabled = false;
                }
            }
            else
            {
                MessageBox.Show(this, "Could not obtain release information from the Web. Check your Internet connection or retry later.", "Error fetching version", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                cbVersionWeb.Enabled = false;
            }

            cbxPrereleases.Enabled = true;
        }
コード例 #2
0
        /// <summary>
        /// Thread safe function for the thread DkimSignerAvailable
        /// </summary>
        private async void CheckDkimSignerAvailable()
        {
            cbxPrereleases.Enabled = false;

            List <Release> aoRelease = null;
            StringBuilder  changelog = new StringBuilder("Couldn't get current version.\r\nCheck your Internet connection or restart the application.");

            // Check the lastest Release
            Exception ex = null;
            await Task.Run(() => { try { aoRelease = ApiWrapper.GetAllRelease(cbxPrereleases.Checked); } catch (Exception e) { ex = e; } });

            if (ex != null)
            {
                changelog.Append("\r\nError: " + ex.Message);
            }

            dkimSignerAvailable = null;

            if (aoRelease != null)
            {
                changelog.Clear();

                dkimSignerAvailable = aoRelease[0];
                changelog.AppendLine(aoRelease[0].TagName + " (" + aoRelease[0].CreatedAt.Substring(0, 10) + ")\r\n\t" + aoRelease[0].Body.Replace("\r\n", "\r\n\t") + "\r\n");

                for (int i = 1; i < aoRelease.Count; i++)
                {
                    if (dkimSignerAvailable.Version < aoRelease[i].Version)
                    {
                        dkimSignerAvailable = aoRelease[i];
                    }

                    // TAG (DATE)\r\nIndented Text
                    changelog.AppendLine(aoRelease[i].TagName + " (" + aoRelease[i].CreatedAt.Substring(0, 10) + ")\r\n\t" + aoRelease[i].Body.Replace("\r\n", "\r\n\t") + "\r\n");
                }
            }

            txtDkimSignerAvailable.Text = dkimSignerAvailable != null?dkimSignerAvailable.Version.ToString() : "Unknown";

            txtChangelog.Text = changelog.ToString();
            SetUpgradeButton();

            cbxPrereleases.Enabled = true;
        }