Exemple #1
0
        /// <summary>Gets the command line arguments of current settings.</summary>
        public override string GetCmdArgs()
        {
            var args = "check";                                      // set verb

            args = $"{args} -v {CurrentVersion.GetVersionString()}"; // set -v argument
            args = $"{args} -d {Path.GetFullPath(DownloadDir)}";     // set -d argument
            args = CheckOnly ? $"{args} -c" : args;                  // set -c flag
            if (UserCredentials.Length == 2 && !(UserCredentials[0] is null) && !(UserCredentials[1] is null))
            {
                args = $"{args} -u {UserCredentials[0]} {UserCredentials[1]}"; // set -u argument
            }
            args = IncludePrerelease ? $"{args} -p" : args;                    // set -p flag

            return(args);
        }
Exemple #2
0
        private static UpdateResult CheckUpdatesThread()
        {
            string cver = CurrentVersion.major + "." + CurrentVersion.minor + "." + CurrentVersion.revision;

            Console.WriteLine("Check Updates.  Current Version: " + CurrentVersion.GetVersionString());
            System.Net.WebClient client = new WebClient();
            try
            {
                string response = client.DownloadString(updateDomain + "version.txt");
                Console.WriteLine("Got most recent version of flag '" + CurrentVersion.flags + "' from server: " + response);

                if (response.Trim() != cver.Trim() + CurrentVersion.flags)
                {
                    Console.WriteLine("New update available");
                    if (callback != null)
                    {
                        callback(UpdateResult.NewUpdate, client.DownloadString(updateDomain + "updatenotes.txt"), response.Trim());
                    }
                    return(UpdateResult.NewUpdate);
                }
                else
                {
                    Console.WriteLine("No update available");
                    if (callback != null)
                    {
                        callback(UpdateResult.NoUpdates, "", "");
                    }
                    return(UpdateResult.NoUpdates);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Update Check failed");
                Console.WriteLine(e.ToString());
                if (callback != null)
                {
                    callback(UpdateResult.UnableToConnect, "", "");
                }
                return(UpdateResult.UnableToConnect);
            }
        }