The following is a C# code example that adds a new schedule called "Extended Work Hours," which includes all hours on all days. This code was written as a Windows Console Application. To use this code:
using System; using System.Collections.Generic; using System.Runtime.InteropServices; using Microsoft.Isa.Interop; namespace CsAddSchedule { class AddSchedule { const string ScheduleName = "Extended Work Hours"; const Int32 Error_AlreadyExists = -2147024713; // 0x800700B7 private static FPC m_Root; private static FPCSchedules m_Schedules; private static FPCSchedule m_Schedule; static void Main(string[] args) { m_Root = new FPC(); // Retrieve the schedules collection. m_Schedules = m_Root.GetContainingArray().RuleElements.Schedules; // Create the new schedule. try { m_Schedule = m_Schedules.Add(ScheduleName); } catch (COMException comEx) { if (comEx.ErrorCode == Error_AlreadyExists) { m_Schedule = m_Schedules.Item(ScheduleName); Console.WriteLine("Using the existing schedule"); } } // Set the schedule. m_Schedule.Set(FpcScheduleDays.fpcALL_WEEK, FpcScheduleHours.fpcALL_DAY); // Save the changes. m_Schedules.Save(false, true); Console.WriteLine("\r\nDone!"); } } }
Send comments about this topic to Microsoft
Build date: 11/30/2009
© 2008 Microsoft Corporation. All rights reserved.