Пример #1
0
        /// <summary>
        /// ReRun a scheduled Advertisement
        /// </summary>
        /// <param name="ADV_AdvertisementID">Advertisement ID</param>
        /// <param name="PKG_PackageID">Package ID</param>
        /// <param name="PRG_ProgramID">Program ID (Program Name)</param>
        /// <param name="UserSID">User Security Identifier (SID) or null for Machine</param>
        /// <returns>The restarted ScheduleID or NULL if the Advertisement does not have a valid ScheduleID</returns>
        /// <remarks>Only scheduled Advertisements (DateTime/As soon as possible/..) which are assigned to a Client can be restarted</remarks>
        public string RerunAdv(string ADV_AdvertisementID, string PKG_PackageID, string PRG_ProgramID, string UserSID)
        {
            WMI.Provider oProv = new WMI.Provider(oWMIProvider.mScope.Clone());

            //Chekc if User or Machine is requested
            if (string.IsNullOrEmpty(UserSID))
                UserSID = "Machine";
            else
                UserSID = UserSID.Replace('-', '_');

            oProv.mScope.Path.NamespacePath = string.Format(@"root\ccm\Policy\{0}\ActualConfig", UserSID);
            ManagementObject oAdv = oProv.GetObject(@"CCM_SoftwareDistribution.ADV_AdvertisementID='" + ADV_AdvertisementID + "',PKG_PackageID='" + PKG_PackageID + "',PRG_ProgramID='" + PRG_ProgramID + "'");

            oAdv.SetPropertyValue("ADV_MandatoryAssignments", "True");
            oAdv.SetPropertyValue("ADV_RepeatRunBehavior", "RerunAlways");
            oAdv.Put();

            ArrayList ScheduleIDs = new ArrayList();
            ScheduleIDs.AddRange(GetSchedulIDs(ADV_AdvertisementID, PKG_PackageID, PRG_ProgramID, UserSID));
            SMS.Schedules SMSSched = new SMS.Schedules(oProv);
            foreach (string sID in ScheduleIDs)
            {
                try
                {
                    SMSSched.TriggerScheduleID(sID, false);
                    return sID;
                }
                catch
                {
                }
            }
            return null;

        }
Пример #2
0
        /// <summary>
        /// ReRun a failed Advertisement
        /// </summary>
        /// <param name="ADV_AdvertisementID">Advertisement ID</param>
        /// <param name="PKG_PackageID">Package ID</param>
        /// <param name="PRG_ProgramID">Program ID (Program Name)</param>
        /// <remarks>Rerun an Advertisement only if Adv. is not installed or was previously failed</remarks>
        public void RerunAdvIfMissing(string ADV_AdvertisementID, string PKG_PackageID, string PRG_ProgramID)
        {
            ArrayList ScheduleIDs = new ArrayList();
            ScheduleIDs.AddRange(GetSchedulIDs(ADV_AdvertisementID, PKG_PackageID, PRG_ProgramID));
            SMS.Schedules SMSSched = new SMS.Schedules(oWMIProvider);
            foreach (string sID in ScheduleIDs)
            {
                try
                {
                    SMSSched.TriggerScheduleID(sID);
                }
                catch { }
            }

        }