コード例 #1
0
        public static void Run()
        {
            //ExStart:ReplaceCalendar
            // The path to the documents directory.
            string  dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName);
            Project project = new Project(dataDir + "ReplaceCalendar.mpp");

            // Add a new calendar to the project's calendars collection
            project.Calendars.Add("New cal1", project.Get(Prj.Calendar));

            // Now traverse through project calendars and replace the already added calendar with a new one
            CalendarCollection calColl = project.Calendars;

            foreach (Calendar c in calColl)
            {
                if (c.Name != "New cal1")
                {
                    continue;
                }

                calColl.Remove(c);
                calColl.Add("New cal2", project.Get(Prj.Calendar));
                break;
            }
            //ExEnd:ReplaceCalendar
        }
コード例 #2
0
        private async Task <CalendarCollection> FetchCalendarsAsync()
        {
            var result = new CalendarCollection();

            if (!_appSettings.CalendarSources.Any())
            {
                return(await Task.FromResult(result));
            }

            _appSettings.CalendarSources.ForEach(url =>
            {
                try
                {
                    using (var client = new HttpClient())
                    {
                        var response = client.GetStringAsync(url).Result;

                        var calendar = Calendar.Load(response);
                        calendar.Properties.Add(new CalendarProperty("Url", url));

                        result.Add(calendar);
                    }
                }
                catch (Exception ex)
                {
                    _logger.LogError($"Can not retrieve calendar data for the Url: {url}", ex);
                }
            });

            return(await Task.FromResult(result));
        }
コード例 #3
0
        public static void Run()
        {
            try
            {
                // The path to the documents directory.
                string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName);

                //ExStart:ReplaceCalendarWithNewCalendar
                // Create project
                Project project = new Project(dataDir + "Project5.mpp");

                // Access project calendars
                CalendarCollection calColl = project.Calendars;
                foreach (Calendar myCalendar in calColl)
                {
                    if (myCalendar.Name == "TestCalendar")
                    {
                        // Remove calendar
                        calColl.Remove(myCalendar);
                    }
                }

                // Add new calendar
                Calendar newCalendar = calColl.Add("TestCalendar");
                project.Save(dataDir + "ReplaceCalendar_out.mpp", SaveFileFormat.MPP);
                //ExEnd:ReplaceCalendarWithNewCalendar
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message + "\nThis example will only work if you apply a valid Aspose License. You can purchase full license or get 30 day temporary license from http://www.aspose.com/purchase/default.aspx.");
            }
        }
コード例 #4
0
        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;
                }
            }
        }
コード例 #5
0
        public static void Run()
        {
            // ExStart:ReplaceCalendarWithNewCalendar
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_CustomizingCreatedProject();

            Project            project  = new Project(dataDir + "Project5.mpp");
            Calendar           calendar = new Calendar("New Cal");
            CalendarCollection calColl  = project.Calendars;

            foreach (Calendar getcalendar in calColl)
            {
                if (getcalendar.Name == "Standard")
                {
                    calColl.Remove(getcalendar);
                    calColl.Add("Standard", getcalendar);
                    break;
                }
            }
            // ExEnd:ReplaceCalendarWithNewCalendar
        }
コード例 #6
0
        public static void Run()
        {
            // ExStart:ReplaceCalendar
            // The path to the documents directory.
            string  dataDir = RunExamples.GetDataDir_WorkingWithProjects();
            Project project = new Project(dataDir + "ReplaceCalendar.mpp");

            // Add a new calendar to the project's calendars collection
            project.Calendars.Add("New cal1", project.Get(Prj.Calendar));

            // Now traverse through project calendars and replace the already added calendar with a new one
            CalendarCollection calColl = project.Calendars;

            foreach (Calendar c in calColl)
            {
                if (c.Name == "New cal1")
                {
                    calColl.Remove(c);
                    calColl.Add("New cal2", project.Get(Prj.Calendar));
                    break;
                }
            }
            // ExEnd:ReplaceCalendar
        }
コード例 #7
0
ファイル: iCalParser.cs プロジェクト: thomsonreuters/ical.net
        public CalendarCollection icalendar(SerializationContext ctx)
        {
            CalendarCollection iCalendars = new CalendarCollection();


            SerializationUtil.OnDeserializing(iCalendars);

            Calendar cal = null;

            ctx.GetService <ISerializationSettings>();

            { // ( ... )*
                for (;;)
                {
                    if ((LA(1) == CRLF || LA(1) == BEGIN))
                    {
                        { // ( ... )*
                            for (;;)
                            {
                                if ((LA(1) == CRLF))
                                {
                                    match(CRLF);
                                }
                                else
                                {
                                    goto _loop4_breakloop;
                                }
                            }
_loop4_breakloop:
                            ;
                        } // ( ... )*
                        match(BEGIN);
                        match(COLON);
                        match(VCALENDAR);
                        { // ( ... )*
                            for (;;)
                            {
                                if ((LA(1) == CRLF))
                                {
                                    match(CRLF);
                                }
                                else
                                {
                                    goto _loop6_breakloop;
                                }
                            }
_loop6_breakloop:
                            ;
                        } // ( ... )*

                        var processor = ctx.GetService(typeof(CompositeProcessor <Calendar>)) as CompositeProcessor <Calendar>;

                        // Do some pre-processing on the calendar:
                        processor?.PreDeserialization(cal);

                        cal = new Calendar();
                        SerializationUtil.OnDeserializing(cal);

                        // Push the iCalendar onto the serialization context stack
                        ctx.Push(cal);

                        icalbody(ctx, cal);
                        match(END);
                        match(COLON);
                        match(VCALENDAR);
                        { // ( ... )*
                            for (;;)
                            {
                                if ((LA(1) == CRLF) && (LA(2) == EOF || LA(2) == CRLF || LA(2) == BEGIN) && (tokenSet_0_.member(LA(3))))
                                {
                                    match(CRLF);
                                }
                                else
                                {
                                    goto _loop8_breakloop;
                                }
                            }
_loop8_breakloop:
                            ;
                        } // ( ... )*

                        // Do some final processing on the calendar:
                        processor?.PostDeserialization(cal);

                        // Notify that the iCalendar has been loaded
                        cal.OnLoaded();
                        iCalendars.Add(cal);

                        SerializationUtil.OnDeserialized(cal);

                        // Pop the iCalendar off the serialization context stack
                        ctx.Pop();
                    }
                    else
                    {
                        goto _loop9_breakloop;
                    }
                }
_loop9_breakloop:
                ;
            } // ( ... )*

            SerializationUtil.OnDeserialized(iCalendars);

            return(iCalendars);
        }