LaunchUrl() public static method

Launch the specified URL in the user's browser, with added tracking parameters if the URL to be launched is part of nerdoftheherd.com.
public static LaunchUrl ( Uri url, string action ) : void
url System.Uri The URL to open.
action string The action which caused the URL to be launched, which will be set as the 'campaign'.
return void
Example #1
0
 private void LinkUpdate_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     using (UpdateNotify showUpdate = new UpdateNotify())
     {
         if (showUpdate.ShowDialog(this) == DialogResult.Yes)
         {
             OsUtils.LaunchUrl(new Uri("https://nerdoftheherd.com/tools/radiodld/"), "Download Update (About)");
             this.Close();
         }
     }
 }
        public bool SendReport()
        {
            try
            {
                WebClient sendClient = new WebClient();
                sendClient.Headers.Add("Content-Type", "application/x-www-form-urlencoded");

                string postData = string.Empty;

                foreach (KeyValuePair <string, string> reportField in this.fields)
                {
                    postData += "&" + HttpUtility.UrlEncode(reportField.Key) + "=" + HttpUtility.UrlEncode(reportField.Value);
                }

                postData = postData.Substring(1);

                byte[]   result      = sendClient.UploadData(SendReportUrl, "POST", System.Text.Encoding.ASCII.GetBytes(postData));
                string[] returnLines = System.Text.Encoding.ASCII.GetString(result).Split('\n');

                if (returnLines[0] == "success")
                {
                    string successMessage = "Your error report was sent successfully.";

                    if (returnLines.Length > 1)
                    {
                        int reportNum;

                        if (int.TryParse(returnLines[1], NumberStyles.Integer, CultureInfo.InvariantCulture, out reportNum))
                        {
                            successMessage += Environment.NewLine + Environment.NewLine + "The report number is " + reportNum.ToString(CultureInfo.CurrentCulture) + ".";
                        }
                    }

                    MessageBox.Show(successMessage, Application.ProductName);

                    Uri moreInfo;

                    if (Uri.TryCreate(returnLines[1], UriKind.Absolute, out moreInfo))
                    {
                        OsUtils.LaunchUrl(moreInfo, "Error Report");
                    }

                    return(true);
                }
            }
            catch
            {
                // No way of reporting errors that have happened here, so just give up
            }

            return(false);
        }
Example #3
0
        public static bool Startup()
        {
            const string DbFileName = "store.db";
            string       specDbPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, DbFileName);
            string       appDbPath  = Path.Combine(FileUtils.GetAppDataFolder(), DbFileName);

            // Ensure that the template database exists
            if (!File.Exists(specDbPath))
            {
                MessageBox.Show("The Radio Downloader template database was not found at '" + specDbPath + "'." + Environment.NewLine + Environment.NewLine + "Try repairing the Radio Downloader installation or installing the latest version from nerdoftheherd.com", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return(false);
            }

            using (SQLiteConnection specConn = new SQLiteConnection("Data Source=" + specDbPath + ";Version=3;New=False;Read Only=True"))
            {
                specConn.Open();

                using (SQLiteCommand command = new SQLiteCommand("pragma integrity_check(1)", specConn))
                {
                    string result = (string)command.ExecuteScalar();

                    if (result.ToUpperInvariant() != "OK")
                    {
                        MessageBox.Show("The Radio Downloader template database at '" + specDbPath + "' appears to be corrupted." + Environment.NewLine + Environment.NewLine + "Try repairing the Radio Downloader installation or installing the latest version from nerdoftheherd.com", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                        return(false);
                    }
                }

                // Migrate old (pre 0.26) version databases from www.nerdoftheherd.com -> NerdoftheHerd.com
                string oldDbPath = Path.Combine(Path.Combine(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "www.nerdoftheherd.com"), Application.ProductName), DbFileName);

                if (File.Exists(oldDbPath) && !File.Exists(appDbPath))
                {
                    File.Move(oldDbPath, appDbPath);
                }

                // Test if there is an existing application database
                if (!File.Exists(appDbPath))
                {
                    // Start with a copy of the template database
                    File.Copy(specDbPath, appDbPath);

                    // Set the current database version in the new database
                    Settings.DatabaseVersion = Database.CurrentDbVersion;
                }
                else
                {
                    using (SQLiteCommand command = new SQLiteCommand("pragma integrity_check(1)", FetchDbConn()))
                    {
                        string result = (string)command.ExecuteScalar();

                        if (result.ToUpperInvariant() != "OK")
                        {
                            if (MessageBox.Show("Unfortunately Radio Downloader cannot start because your database has become corrupted." + Environment.NewLine + Environment.NewLine + "Would you like to view some help about resolving this issue?", Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Stop) == DialogResult.Yes)
                            {
                                OsUtils.LaunchUrl(new Uri("https://nerdoftheherd.com/tools/radiodld/help/corrupt-database"), "corruptdb");
                            }

                            return(false);
                        }
                    }

                    // Start a transaction so we can roll back a half-completed upgrade on error
                    using (SQLiteMonTransaction transMon = new SQLiteMonTransaction(FetchDbConn().BeginTransaction()))
                    {
                        try
                        {
                            // Perform a check and automatic update of the database table structure
                            UpdateStructure(specConn, Database.FetchDbConn());

                            // Perform any updates required which were not handled by UpdateStructure
                            switch (Settings.DatabaseVersion)
                            {
                            case 4:
                                // Clear error details previously serialised as XML
                                using (SQLiteCommand command = new SQLiteCommand("update downloads set errordetails=null where errortype=@errortype", FetchDbConn()))
                                {
                                    command.Parameters.Add(new SQLiteParameter("errortype", ErrorType.UnknownError));
                                    command.ExecuteNonQuery();
                                }

                                break;

                            case Database.CurrentDbVersion:
                                // Nothing to do, this is the current version.
                                break;
                            }

                            // Set the current database version
                            Settings.DatabaseVersion = Database.CurrentDbVersion;
                        }
                        catch (SQLiteException)
                        {
                            transMon.Trans.Rollback();
                            throw;
                        }

                        transMon.Trans.Commit();
                    }
                }
            }

            // Prune the database once a week
            if (Settings.LastPrune.AddDays(7) < DateTime.Now)
            {
                using (Status status = new Status())
                {
                    status.ShowDialog(delegate
                    {
                        Prune(status);
                    });
                }
            }

            // Vacuum the database every three months
            if (Settings.LastVacuum.AddMonths(3) < DateTime.Now)
            {
                using (Status status = new Status())
                {
                    status.ShowDialog(delegate
                    {
                        Vacuum(status);
                    });
                }
            }

            return(true);
        }
Example #4
0
 private void ShowHelp()
 {
     OsUtils.LaunchUrl(new Uri("https://nerdoftheherd.com/tools/radiodld/help/dialogs.clean-up-downloads/"), "Context Help");
 }
Example #5
0
 private void LinkHomepage_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     OsUtils.LaunchUrl(new Uri(this.LinkHomepage.Text), "About Dialog Link");
 }
Example #6
0
 private void ShowHelp()
 {
     OsUtils.LaunchUrl(new Uri("http://www.nerdoftheherd.com/tools/radiodld/help/dialogs.options/"), "Context Help");
 }