Пример #1
0
        public static void Run()
        {
            // ExStart:MakeAStandardCalendar
            // Create a project instance
            Project project = new Project();

            // Define Calendar and make it standard
            Aspose.Tasks.Calendar cal1 = project.Calendars.Add("My Cal");
            Aspose.Tasks.Calendar.MakeStandardCalendar(cal1);

            // Save the Project
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName);

            project.Save(dataDir + "Project_MakeStandardCalendar_out.xml", Aspose.Tasks.Saving.SaveFileFormat.XML);
            // ExEnd:MakeAStandardCalendar
        }
        public static void Run()
        {
            // ExStart:CreatingCalendar
            // Create a project instance
            Project project = new Project();

            // New calendar can be added to a project's calendar collection using the collection's Add method.
            Aspose.Tasks.Calendar cal1 = project.Calendars.Add("New Info");
            Aspose.Tasks.Calendar cal2 = project.Calendars.Add("no name");
            Aspose.Tasks.Calendar cal3 = project.Calendars.Add("cal3");

            // Save the Project
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName);

            project.Save(dataDir + "CreatingCalendar_out.Xml", Aspose.Tasks.Saving.SaveFileFormat.XML);
            // ExEnd:CreatingCalendar
        }
        public static void Run()
        {
            // ExStart:CreatingCalendar
            // New calendar can be added to a project's calendar collection using the collection's Add method.

            // Create a project instance
            Project project = new Project();

            // Define Calendar
            Aspose.Tasks.Calendar cal1 = project.Calendars.Add("New Info");
            Aspose.Tasks.Calendar cal2 = project.Calendars.Add("no name");
            Aspose.Tasks.Calendar cal3 = project.Calendars.Add("cal3");

            // Save the Project
            string dataDir = RunExamples.GetDataDir_WorkingWithCalendars();

            project.Save(dataDir + "Project_out.xml", Aspose.Tasks.Saving.SaveFileFormat.XML);
            // ExEnd:CreatingCalendar
        }
        public static void Run()
        {
            // The path to the documents directory.
            string  dataDir = RunExamples.GetDataDir_Projects();
            Project project = new Project(dataDir + "ReplaceCalendar.mpp");

            Aspose.Tasks.Calendar cal     = new Aspose.Tasks.Calendar("New Cal");
            CalendarCollection    calColl = project.Calendars;

            foreach (Aspose.Tasks.Calendar c in calColl)
            {
                if (c.Name == "Standard")
                {
                    calColl.Remove(c);
                    calColl.Add("Standard", cal);
                    break;
                }
            }
        }
        public static void Run()
        {
            // ExStart:DefineWeekdaysForCalendar
            // This example shows how Aspose.Tasks API can be used to define a new Calendar, add week days to it and define working times for days
            // Create a project instance
            Project project = new Project();

            // Define Calendar
            Aspose.Tasks.Calendar cal = project.Calendars.Add("Calendar1");

            // Add working days monday through thursday with default timings
            cal.WeekDays.Add(WeekDay.CreateDefaultWorkingDay(DayType.Monday));
            cal.WeekDays.Add(WeekDay.CreateDefaultWorkingDay(DayType.Tuesday));
            cal.WeekDays.Add(WeekDay.CreateDefaultWorkingDay(DayType.Wednesday));
            cal.WeekDays.Add(WeekDay.CreateDefaultWorkingDay(DayType.Thursday));
            cal.WeekDays.Add(new WeekDay(DayType.Saturday));
            cal.WeekDays.Add(new WeekDay(DayType.Sunday));

            // Set friday as short working day
            WeekDay myWeekDay = new WeekDay(DayType.Friday);

            // Sets working time. Only time part of DateTime is important
            WorkingTime wt1 = new WorkingTime();

            wt1.FromTime = new DateTime(1, 1, 1, 9, 0, 0, 0);
            wt1.ToTime   = new DateTime(1, 1, 1, 12, 0, 0, 0);
            WorkingTime wt2 = new WorkingTime();

            wt2.FromTime = new DateTime(1, 1, 1, 13, 0, 0, 0);
            wt2.ToTime   = new DateTime(1, 1, 1, 16, 0, 0, 0);
            myWeekDay.WorkingTimes.Add(wt1);
            myWeekDay.WorkingTimes.Add(wt2);
            myWeekDay.DayWorking = true;
            cal.WeekDays.Add(myWeekDay);


            // Save the Project
            string dataDir = RunExamples.GetDataDir_Projects();

            project.Save("Project.xml", Aspose.Tasks.Saving.SaveFileFormat.XML);
            // ExEnd:DefineWeekdaysForCalendar
        }
        public static void Run()
        {
            // ExStart:MakeAStandardCalendar
            // The static method of Calendar class, MakeStandardCalendar can be used to make a calendar as Standard after it has been added ot the project

            // Create a project instance
            Project project = new Project();

            // Define Calendar and make it standard
            Aspose.Tasks.Calendar cal1 = project.Calendars.Add("My Cal");

            // Now make this calendar as a standard calendar
            Aspose.Tasks.Calendar.MakeStandardCalendar(cal1);

            // Save the Project
            string dataDir = RunExamples.GetDataDir_Projects();

            project.Save("Project.xml", Aspose.Tasks.Saving.SaveFileFormat.XML);
            // ExEnd:MakeAStandardCalendar
        }
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Projects();
            Project project = new Project(dataDir+ "ReplaceCalendar.mpp");

            Aspose.Tasks.Calendar cal = new Aspose.Tasks.Calendar("New Cal");
            CalendarCollection calColl = project.Calendars;
            foreach (Aspose.Tasks.Calendar c in calColl)
            {
                if (c.Name == "Standard")
                {
                    calColl.Remove(c);
                    calColl.Add("Standard", cal);
                    break;
                }
            }
            
            
        }