Exemplo n.º 1
0
        /// <summary>Downloads updates.</summary>
        static void DownloadInstallUpdates()
        {
            for (int x = 0; x < Core.Applications.Count; x++)
            {
                for (int y = 0; y < Core.Applications[x].Updates.Count; y++)
                {
                    if (Core.Applications[x].Updates[y].Selected)
                    {
                        continue;
                    }

                    Core.Applications[x].Updates.RemoveAt(y);
                    y--;
                }

                if (Core.Applications[x].Updates.Count != 0)
                {
                    continue;
                }

                Core.Applications.RemoveAt(x);
                x--;
            }

            if (Core.Applications.Count > 0)
            {
                var sla = new LicenseAgreement();
                if (sla.LoadLicenses() == false)
                {
                    Core.Instance.UpdateAction = UpdateAction.Canceled;
                    return;
                }

                if (WcfService.Install())
                {
                    try
                    {
                        File.Delete(Path.Combine(App.AllUserStore, @"updates.sui"));
                    }
                    catch (Exception e)
                    {
                        if (!(e is UnauthorizedAccessException || e is IOException))
                        {
                            Utilities.ReportError(e, ErrorType.GeneralError);
                        }
                    }

                    Core.Instance.UpdateAction   = isInstallOnly ? UpdateAction.Installing : UpdateAction.Downloading;
                    Settings.Default.LastInstall = DateTime.Now;
                }
                else
                {
                    Core.Instance.UpdateAction = UpdateAction.Canceled;
                }
            }
            else
            {
                Core.Instance.UpdateAction = UpdateAction.Canceled;
            }
        }