Example #1
0
        public static ConfigJson Load()
        {
            var configJson = new ConfigJson();

            configJson.LoadJson();
            return(configJson);
        }
Example #2
0
        /// <summary>
        /// Checks for newer version and prints response accordingly.
        /// </summary>
        public void Checkupdate()
        {
            var configJson = ConfigJson.Load();

            Console.WriteLine(configJson.CurrentVersionCode < _project.GetLatestVersion().VersionCode
                ? $"New version {_project.GetLatestVersion()} is available."
                : "Version is up to date.");
        }
Example #3
0
        /// <summary>
        /// Install the version specified by code or name,
        /// if both are null latest version is installed
        /// </summary>
        /// <param name="code">Target version code to be installed.</param>
        /// <param name="name">Target version name to be installed.</param>
        public void Install(int code, string name)
        {
            Version version = null;

            if (code > 0)
            {
                version = _project.GetVersion(code);
            }
            else if (!string.IsNullOrEmpty(name))
            {
                version = _project.GetVersion(name);
            }
            else
            {
                version = _project.GetLatestVersion();
            }

            if (version == null)
            {
                Console.WriteLine("Version could not be found.");
                return;
            }

            Console.WriteLine("Starting Download...");

            if (!DriveUtils.DownloadFile(FilePath.TempZipFile, version.FileId))
            {
                Console.WriteLine("Downloding updated failed.");
                return;
            }

            UnzipFiles();

            var configJson = new ConfigJson(_project.SoftwareName, version.VersionCode);

            configJson.SaveJson();

            Console.WriteLine($"Updated to version code {version.VersionName}");
        }