/// <summary> /// Decode an SMS ScheduleID string /// </summary> /// <param name="ScheduleID">SMS encoded 64bit ScheduleID string</param> /// <returns>object of type: SMS_ST_NonRecurring, SMS_ST_RecurInterval, SMS_ST_RecurWeekly, SMS_ST_RecurMonthlyByWeekday or SMS_ST_RecurMonthlyByDate</returns> public static object DecodeScheduleID(string ScheduleID) { try { int year = startyear(ScheduleID); int month = startmonth(ScheduleID); int day = startday(ScheduleID); int hour = starthour(ScheduleID); int minute = startminute(ScheduleID); if (isNonRecurring(ScheduleID)) { SMS_ST_NonRecurring oRes = new SMS_ST_NonRecurring(); oRes.IsGMT = isgmt(ScheduleID); oRes.StartTime = new DateTime(year, month, day, hour, minute, 0); oRes.DayDuration = dayduration(ScheduleID); oRes.HourDuration = hourduration(ScheduleID); oRes.MinuteDuration = minuteduration(ScheduleID); return(oRes); } if (isRecurInterval(ScheduleID)) { SMS_ST_RecurInterval oRes = new SMS_ST_RecurInterval(); oRes.IsGMT = isgmt(ScheduleID); oRes.StartTime = new DateTime(year, month, day, hour, minute, 0); oRes.DayDuration = dayduration(ScheduleID); oRes.DaySpan = dayspan(ScheduleID); oRes.HourDuration = hourduration(ScheduleID); oRes.HourSpan = hourpan(ScheduleID); oRes.MinuteDuration = minuteduration(ScheduleID); oRes.MinuteSpan = minutespan(ScheduleID); return(oRes); } if (isRecurWeekly(ScheduleID)) { SMS_ST_RecurWeekly oRes = new SMS_ST_RecurWeekly(); oRes.IsGMT = isgmt(ScheduleID); oRes.StartTime = new DateTime(year, month, day, hour, minute, 0); oRes.Day = iDay(ScheduleID); oRes.ForNumberOfWeeks = fornumberofweeks(ScheduleID); oRes.DayDuration = dayduration(ScheduleID); oRes.HourDuration = hourduration(ScheduleID); oRes.MinuteDuration = minuteduration(ScheduleID); return(oRes); } if (isRecurMonthlyByWeekday(ScheduleID)) { SMS_ST_RecurMonthlyByWeekday oRes = new SMS_ST_RecurMonthlyByWeekday(); oRes.IsGMT = isgmt(ScheduleID); oRes.StartTime = new DateTime(year, month, day, hour, minute, 0); oRes.WeekOrder = weekorder(ScheduleID); oRes.Day = iDay(ScheduleID); oRes.ForNumberOfMonths = fornumberofmonths(ScheduleID); oRes.DayDuration = dayduration(ScheduleID); oRes.HourDuration = hourduration(ScheduleID); oRes.MinuteDuration = minuteduration(ScheduleID); return(oRes); } if (isRecurMonthlyByDate(ScheduleID)) { SMS_ST_RecurMonthlyByDate oRes = new SMS_ST_RecurMonthlyByDate(); oRes.IsGMT = isgmt(ScheduleID); oRes.StartTime = new DateTime(year, month, day, hour, minute, 0); oRes.ForNumberOfMonths = fornumberofmonths2(ScheduleID); oRes.MonthDay = monthday(ScheduleID); oRes.DayDuration = dayduration(ScheduleID); oRes.HourDuration = hourduration(ScheduleID); oRes.MinuteDuration = minuteduration(ScheduleID); return(oRes); } } catch { } return(null); }
internal static string encodeID(object Schedule) { long lSchedID = new long(); int lo = 0; int hi = 0; SMS_ST_NonRecurring oSched = Schedule as SMS_ST_NonRecurring; #region BaseSchedule //IsGMT Flag if (oSched.IsGMT) { lo |= 1; } //StartTime Year (check if in a valid range) if ((oSched.StartTime.Year > 1970) & (oSched.StartTime.Year < 2033)) { hi |= (oSched.StartTime.Year - 1970) << 6; } else { hi |= 63 << 6; } //StartTime Month hi |= oSched.StartTime.Month << 12; //StartTime Day hi |= oSched.StartTime.Day << 16; //StartTime Hour hi |= oSched.StartTime.Hour << 21; //StartTime Minute hi |= oSched.StartTime.Minute << 26; //Day duration lo |= oSched.DayDuration << 22; //hourduration duration lo |= oSched.HourDuration << 27; //Minute duration hi |= oSched.MinuteDuration; #endregion switch (Schedule.GetType().Name) { case ("SMS_ST_NonRecurring"): //Set type to SMS_ST_NonRecurring lo |= 1 << 19; break; case ("SMS_ST_RecurInterval"): SMS_ST_RecurInterval oSchedRI = oSched as SMS_ST_RecurInterval; //DaySpan lo |= oSchedRI.DaySpan << 3; //HourSpan lo |= oSchedRI.HourSpan << 8; //MinuteSpan lo |= oSchedRI.MinuteSpan << 13; //Set type to SMS_ST_RecurInterval lo |= 2 << 19; break; } //Convert to HEX lSchedID = (((long)hi) << 32) | ((uint)lo); string sResult = lSchedID.ToString("X"); //Result must always have 16 Characters, otherwise ConfigMgr does not understand the Format ! while (sResult.Length < 16) { sResult = '0' + sResult; } return(sResult); }