Beispiel #1
0
        void DownloadsFinished(object sender, UpdateDownloader.FinishedEventArgs args)
        {
            if (mCurOperation == AgentOperation.PreparingCheck)
            {
                AppLog.Line("wsusscn2.cab downloaded");

                ClearOffline();
                SetupOffline();

                SearchForUpdates();
            }
            else
            {
                MultiValueDictionary <string, string> AllFiles = new MultiValueDictionary <string, string>();
                foreach (UpdateDownloader.Task task in args.Downloads)
                {
                    AllFiles.Add(task.KB, task.Path + @"\" + task.FileName);
                }

                // TODO

                /*string INIPath = dlPath + @"\updates.ini";
                 * foreach (string KB in AllFiles.Keys)
                 * {
                 *  string Files = "";
                 *  foreach (string FileName in AllFiles.GetValues(KB))
                 *  {
                 *      if (Files.Length > 0)
                 *          Files += "|";
                 *      Files += FileName;
                 *  }
                 *  Program.IniWriteValue(KB, "Files", Files, INIPath);
                 * }*/

                if (mCurOperation != AgentOperation.PreparingUpdates)
                {
                    AppLog.Line("Updates downloaded to {0}", dlPath);
                }
                else if (InstallUpdatesOffline(args.Updates, AllFiles))
                {
                    return;
                }

                OnFinished(args.Success);
            }
        }
Beispiel #2
0
        void DownloadsFinished(object sender, UpdateDownloader.FinishedEventArgs args) // "manuall" mode
        {
            if (mCurOperation == AgentOperation.PreparingCheck)
            {
                AppLog.Line("wsusscn2.cab downloaded");

                RetCodes ret = ClearOffline();
                if (ret == RetCodes.Success)
                {
                    ret = SetupOffline();
                }
                if (ret == RetCodes.Success)
                {
                    ret = SearchForUpdates();
                }
                if (ret <= 0)
                {
                    OnFinished(ret);
                }
            }
            else
            {
                MultiValueDictionary <string, string> AllFiles = new MultiValueDictionary <string, string>();
                foreach (UpdateDownloader.Task task in args.Downloads)
                {
                    if (task.Failed && task.FileName != null)
                    {
                        continue;
                    }
                    AllFiles.Add(task.KB, task.Path + @"\" + task.FileName);
                }

                // TODO

                /*string INIPath = dlPath + @"\updates.ini";
                 * foreach (string KB in AllFiles.Keys)
                 * {
                 *  string Files = "";
                 *  foreach (string FileName in AllFiles.GetValues(KB))
                 *  {
                 *      if (Files.Length > 0)
                 *          Files += "|";
                 *      Files += FileName;
                 *  }
                 *  Program.IniWriteValue(KB, "Files", Files, INIPath);
                 * }*/

                AppLog.Line("Downloaded {0} out of {1} to {2}", AllFiles.GetCount(), args.Downloads.Count, dlPath);

                if (mCurOperation == AgentOperation.PreparingUpdates)
                {
                    RetCodes ret = InstallUpdatesManually(args.Updates, AllFiles);
                    if (ret <= 0)
                    {
                        OnFinished(ret);
                    }
                }
                else
                {
                    RetCodes ret = AllFiles.GetCount() == args.Downloads.Count ? RetCodes.Success : RetCodes.DownloadFailed;
                    if (mCurOperation == AgentOperation.CancelingOperation)
                    {
                        ret = RetCodes.Abborted;
                    }
                    OnFinished(ret);
                }
            }
        }