示例#1
0
        /// <summary>
        /// The is update marked for uninstall.
        /// </summary>
        /// <param name="update">
        /// The update.
        /// </param>
        /// <param name="targetGroup">
        /// The target group.
        /// </param>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        private static bool IsUpdateMarkedForUninstall(IUpdate update, IComputerTargetGroup targetGroup)
        {
            UpdateApprovalCollection approvals = update.GetUpdateApprovals(targetGroup);

            foreach (IUpdateApproval approval in approvals)
            {
                if (approval.Action == UpdateApprovalAction.Uninstall)
                {
                    return(true);
                }
            }

            return(false);
        }
示例#2
0
        /// <summary>
        /// Approves a superseded update
        ///     Using previous approval settings
        /// </summary>
        /// <param name="newUpdate">
        /// The new update
        /// </param>
        /// <param name="previousUpdate">
        /// The previously approved update
        /// </param>
        /// <param name="isTest">
        /// Whether we are in test mode
        /// </param>
        /// <param name="recentlyApproved">
        /// List of recently approved updates
        /// </param>
        /// <param name="shouldApproveUninstalledSupersededUpdate">
        /// Whether an update that has been uninstalled should be approved if superseded.
        /// </param>
        private static void ApproveSupersededUpdate(
            IUpdate newUpdate,
            IUpdate previousUpdate,
            bool isTest,
            List <Guid> recentlyApproved,
            bool shouldApproveUninstalledSupersededUpdate)
        {
            if (isTest)
            {
                Console.Out.Write("(TEST) ");
            }

            Console.Out.WriteLine(newUpdate.Title);
            recentlyApproved.Add(newUpdate.Id.UpdateId);

            if (isTest)
            {
                return;
            }

            UpdateApprovalCollection approvals = previousUpdate.GetUpdateApprovals();

            foreach (IUpdateApproval approval in approvals)
            {
                IComputerTargetGroup ctg = approval.GetComputerTargetGroup();

                if (approval.Action == UpdateApprovalAction.Uninstall && !shouldApproveUninstalledSupersededUpdate)
                {
                    // this update has been marked for removal
                    Console.WriteLine(
                        " WARNING: Superseded update is marked for uninstall and settings don't allow it to be automatically approved. Target group: "
                        + ctg.Name);

                    continue;
                }

                newUpdate.Approve(UpdateApprovalAction.Install, ctg);

                Console.Out.WriteLine(" " + ctg.Name);
            }
        }
示例#3
0
        /// <summary>
        /// Approves a superseded update
        ///     Using previous approval settings
        /// </summary>
        /// <param name="newUpdate">
        /// The new update
        /// </param>
        /// <param name="previousUpdate">
        /// The previously approved update
        /// </param>
        /// <param name="isTest">
        /// Whether we are in test mode
        /// </param>
        /// <param name="recentlyApproved">
        /// List of recently approved updates
        /// </param>
        /// <param name="shouldApproveUninstalledSupersededUpdate">
        /// Whether an update that has been uninstalled should be approved if superseded.
        /// </param>
        private static void ApproveSupersededUpdate(
            IUpdate newUpdate,
            IUpdate previousUpdate,
            bool isTest,
            List<Guid> recentlyApproved,
            bool shouldApproveUninstalledSupersededUpdate)
        {
            if (isTest)
            {
                Console.Out.Write("(TEST) ");
            }

            Console.Out.WriteLine(newUpdate.Title);
            recentlyApproved.Add(newUpdate.Id.UpdateId);

            if (isTest)
            {
                return;
            }

            UpdateApprovalCollection approvals = previousUpdate.GetUpdateApprovals();

            foreach (IUpdateApproval approval in approvals)
            {
                IComputerTargetGroup ctg = approval.GetComputerTargetGroup();

                if (approval.Action == UpdateApprovalAction.Uninstall && !shouldApproveUninstalledSupersededUpdate)
                {
                    // this update has been marked for removal
                    Console.WriteLine(
                        " WARNING: Superseded update is marked for uninstall and settings don't allow it to be automatically approved. Target group: "
                        + ctg.Name);

                    continue;
                }

                newUpdate.Approve(UpdateApprovalAction.Install, ctg);

                Console.Out.WriteLine(" " + ctg.Name);
            }
        }
示例#4
0
        /// <summary>
        /// The is update marked for uninstall.
        /// </summary>
        /// <param name="update">
        /// The update.
        /// </param>
        /// <param name="targetGroup">
        /// The target group.
        /// </param>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        private static bool IsUpdateMarkedForUninstall(IUpdate update, IComputerTargetGroup targetGroup)
        {
            UpdateApprovalCollection approvals = update.GetUpdateApprovals(targetGroup);
            foreach (IUpdateApproval approval in approvals)
            {
                if (approval.Action == UpdateApprovalAction.Uninstall)
                {
                    return true;
                }
            }

            return false;
        }