Ejemplo n.º 1
0
        /// <summary>
        /// Does the Web Interface exist on the user's folder?
        /// If yes, check for outdated version
        /// TODO: redo update process
        /// </summary>
        public async Task <bool> CheckForUpdate()
        {
            var exists = _controller.Client.Exists("webint");

            if (exists)
            {
                try
                {
                    var lpath = Path.Combine(Common.AppdataFolder, @"version.ini");
                    await _controller.Client.Download("webint/version.ini", lpath);

                    var currentversion = "0.2.3";

                    var wc = new WebClient();
                    wc.DownloadStringCompleted += (s, e) =>
                    {
                        var vinfo = (WebInterfaceVersionInfo)JsonConvert.DeserializeObject(e.Result, typeof(WebInterfaceVersionInfo));

                        if (!vinfo.Uptodate)
                        {
                            UpdateFound.SafeInvoke(null, EventArgs.Empty);
                        }
                        else
                        {
                            Log.Write(l.Client, "Web Interface is up to date");
                        }

                        File.Delete(lpath);
                    };
                    var link = string.Format("http://ftpbox.org/webui.php?version={0}", currentversion);

                    wc.DownloadStringAsync(new Uri(link));
                }
                catch (Exception ex)
                {
                    Log.Write(l.Warning, "Error with version checking");
                    ex.LogException();
                }
            }
            return(exists);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Download the user's webUI version file, compare the version with the latest one
        /// </summary>
        private void CheckForUpdate()
        {
            try
            {
                var lpath = Path.Combine(Common.AppdataFolder, @"version.ini");
                _controller.Client.Download("webint/version.ini", lpath);

                var ini            = new IniFile(lpath);
                var currentversion = ini.ReadValue("Version", "latest");

                var wc = new WebClient();
                wc.DownloadStringCompleted += (s, e) =>
                {
                    var vinfo = (WebInterfaceVersionInfo)JsonConvert.DeserializeObject(e.Result, typeof(WebInterfaceVersionInfo));

                    if (!vinfo.Uptodate)
                    {
                        UpdateFound.SafeInvoke(null, EventArgs.Empty);
                    }
                    else
                    {
                        Log.Write(l.Client, "Web Interface is up to date");
                    }

                    File.Delete(lpath);
                };
                var link = string.Format("http://ftpbox.org/webui.php?version={0}", currentversion);

                wc.DownloadStringAsync(new Uri(link));
            }
            catch (Exception ex)
            {
                Log.Write(l.Warning, "Error with version checking");
                Common.LogError(ex);
            }
        }