コード例 #1
0
ファイル: Schedule.cs プロジェクト: MaitreDede/dday-ical
 private void Schedule_Load(object sender, EventArgs e)
 {
     iCal = iCalendar.LoadFromFile(@"Calendars\USHolidays.ics");
     iCal.MergeWith(iCalendar.LoadFromFile(@"Calendars\lotr.ics"));
     iCal.MergeWith(iCalendar.LoadFromFile(@"Calendars\To-do.ics"));
     //iCal.MergeWith(iCalendar.LoadFromFile("Barça 2006 - 2007.ics"));
     if (iCal == null)
     {
         throw new ApplicationException("iCalendar could not be loaded.");
     }
 }
コード例 #2
0
ファイル: ProgramTest.cs プロジェクト: MaitreDede/dday-ical
        public void MERGE3()
        {
            iCalendar iCal1 = iCalendar.LoadFromFile(@"Calendars\Recurrence\RRULE21.ics");
            iCalendar iCal2 = iCalendar.LoadFromFile(@"Calendars\Recurrence\RRULE23.ics");

            iCal1.MergeWith(iCal2);

            Assert.AreEqual(1, iCal1.Events.Count);
        }
コード例 #3
0
        public void Merge2()
        {
            iCalendar  iCal    = new iCalendar();
            IICalendar tmp_cal = iCalendar.LoadFromFile(@"Calendars\Serialization\TimeZone3.ics")[0];

            iCal.MergeWith(tmp_cal);

            tmp_cal = iCalendar.LoadFromFile(@"Calendars\Serialization\TimeZone3.ics")[0];

            // Compare the two calendars -- they should match exactly
            SerializationTest.CompareCalendars(iCal, tmp_cal);
        }
コード例 #4
0
ファイル: ProgramTest.cs プロジェクト: MaitreDede/dday-ical
        public void MERGE2()
        {
            iCalendar iCal    = new iCalendar();
            iCalendar tmp_cal = iCalendar.LoadFromFile(@"Calendars\General\MERGE2.ics");

            iCal.MergeWith(tmp_cal);

            tmp_cal = iCalendar.LoadFromFile(@"Calendars\General\MERGE2.ics");

            // Compare the two calendars -- they should match exactly
            SerializationTest.CompareCalendars(iCal, tmp_cal);
        }
コード例 #5
0
        public void TIMEZONE3()
        {
            SerializeTest("TIMEZONE3.ics", typeof(iCalendarSerializer));

            iCalendar iCal    = new iCalendar();
            iCalendar tmp_cal = iCalendar.LoadFromFile(@"Calendars\Serialization\TIMEZONE3.ics");

            iCal.MergeWith(tmp_cal);

            iCalendarSerializer serializer = new iCalendarSerializer(iCal);

            serializer.Serialize(@"Calendars\Serialization\testMeOut.ics");
        }
コード例 #6
0
ファイル: WorkerRole.cs プロジェクト: mikesavior/elmcity
		public static void MergeIcs(Calinfo calinfo)
		{
			var id = calinfo.id;
			GenUtils.LogMsg("status", "MergeIcs: " + id, null);
			List<string> suffixes = new List<string>() { "ical" };
			if (calinfo.hub_enum == HubType.where)
				foreach (NonIcalType type in Enum.GetValues(typeof(CalendarAggregator.NonIcalType)))
				{
					if (Utils.UseNonIcalService(type, settings, calinfo) == true)
						suffixes.Add(type.ToString());
				}
			try
			{
				var all_ical = new iCalendar();
				Collector.AddTimezoneToDDayICal(all_ical, calinfo.tzinfo);

				foreach (var suffix in suffixes)  // todo: skip if disabled in settings
				{
					var url = MakeIcsUrl(id, suffix);
					try
					{
						var feedtext = HttpUtils.FetchUrl(url).DataAsString();
						var sr = new StringReader(feedtext);
						var ical = iCalendar.LoadFromStream(sr).First().Calendar;
						all_ical.MergeWith(ical);
					}
					catch (Exception e)
					{
						GenUtils.LogMsg("warning", "MergeICS: " + url, e.Message);
					}
				}

				var serializer = new DDay.iCal.Serialization.iCalendar.iCalendarSerializer(all_ical);
				var icsbytes = Encoding.UTF8.GetBytes(serializer.SerializeToString(all_ical));
				bs.PutBlob(id, id + ".ics", new Hashtable(), icsbytes, "text/calendar");
			}
			catch (Exception e)
			{
				GenUtils.LogMsg("exception", "MergeIcs: " + id, e.Message + e.StackTrace);
			}
		}
コード例 #7
0
ファイル: Program.cs プロジェクト: MaitreDede/dday-ical
        public void MERGE()
        {
            iCalendar iCal1 = iCalendar.LoadFromFile(@"Calendars\Recurrence\RRULE21.ics");
            iCalendar iCal2 = iCalendar.LoadFromFile(@"Calendars\Recurrence\RRULE22.ics");

            // Change the UID of the 2nd event to make sure it's different
            iCal2.Events[iCal1.Events[0].UID].UID = "1234567890";
            iCal1.MergeWith(iCal2);

            Event evt1 = iCal1.Events[0];
            Event evt2 = iCal1.Events[1];

            evt1.Evaluate(new Date_Time(1996, 1, 1, tzid, iCal1), new Date_Time(2000, 1, 1, tzid, iCal1));

            Date_Time[] DateTimes = new Date_Time[]
            {
                new Date_Time(1997, 9, 10, 9, 0, 0, tzid, iCal1),
                new Date_Time(1997, 9, 11, 9, 0, 0, tzid, iCal1),
                new Date_Time(1997, 9, 12, 9, 0, 0, tzid, iCal1),
                new Date_Time(1997, 9, 13, 9, 0, 0, tzid, iCal1),
                new Date_Time(1997, 9, 14, 9, 0, 0, tzid, iCal1),
                new Date_Time(1997, 9, 15, 9, 0, 0, tzid, iCal1),
                new Date_Time(1999, 3, 10, 9, 0, 0, tzid, iCal1),
                new Date_Time(1999, 3, 11, 9, 0, 0, tzid, iCal1),
                new Date_Time(1999, 3, 12, 9, 0, 0, tzid, iCal1),
                new Date_Time(1999, 3, 13, 9, 0, 0, tzid, iCal1),
            };

            string[] TimeZones = new string[]
            {
                "EDT",
                "EDT",
                "EDT",
                "EDT",
                "EDT",
                "EDT",
                "EST",
                "EST",
                "EST",
                "EST"
            };

            for (int i = 0; i < DateTimes.Length; i++)
            {
                Date_Time dt = (Date_Time)DateTimes[i];
                Assert.IsTrue(evt1.OccursAt(dt), "Event should occur on " + dt);
                Assert.IsTrue(dt.TimeZoneInfo.TimeZoneName == TimeZones[i], "Event " + dt + " should occur in the " + TimeZones[i] + " timezone");
            }

            Assert.IsTrue(evt1.Periods.Count == DateTimes.Length, "There should be exactly " + DateTimes.Length + " occurrences; there were " + evt1.Periods.Count);

            evt2.Evaluate(new Date_Time(1996, 1, 1, tzid, iCal1), new Date_Time(1998, 4, 1, tzid, iCal1));

            Date_Time[] DateTimes1 = new Date_Time[]
            {
                new Date_Time(1997, 9, 2, 9, 0, 0, tzid, iCal1),
                new Date_Time(1997, 9, 9, 9, 0, 0, tzid, iCal1),
                new Date_Time(1997, 9, 16, 9, 0, 0, tzid, iCal1),
                new Date_Time(1997, 9, 23, 9, 0, 0, tzid, iCal1),
                new Date_Time(1997, 9, 30, 9, 0, 0, tzid, iCal1),
                new Date_Time(1997, 11, 4, 9, 0, 0, tzid, iCal1),
                new Date_Time(1997, 11, 11, 9, 0, 0, tzid, iCal1),
                new Date_Time(1997, 11, 18, 9, 0, 0, tzid, iCal1),
                new Date_Time(1997, 11, 25, 9, 0, 0, tzid, iCal1),
                new Date_Time(1998, 1, 6, 9, 0, 0, tzid, iCal1),
                new Date_Time(1998, 1, 13, 9, 0, 0, tzid, iCal1),
                new Date_Time(1998, 1, 20, 9, 0, 0, tzid, iCal1),
                new Date_Time(1998, 1, 27, 9, 0, 0, tzid, iCal1),
                new Date_Time(1998, 3, 3, 9, 0, 0, tzid, iCal1),
                new Date_Time(1998, 3, 10, 9, 0, 0, tzid, iCal1),
                new Date_Time(1998, 3, 17, 9, 0, 0, tzid, iCal1),
                new Date_Time(1998, 3, 24, 9, 0, 0, tzid, iCal1),
                new Date_Time(1998, 3, 31, 9, 0, 0, tzid, iCal1)
            };

            string[] TimeZones1 = new string[]
            {
                "EDT",
                "EDT",
                "EDT",
                "EDT",
                "EDT",
                "EST",
                "EST",
                "EST",
                "EST",
                "EST",
                "EST",
                "EST",
                "EST",
                "EST",
                "EST",
                "EST",
                "EST",
                "EST"
            };

            for (int i = 0; i < DateTimes1.Length; i++)
            {
                Date_Time dt = (Date_Time)DateTimes1[i];
                Assert.IsTrue(evt2.OccursAt(dt), "Event should occur on " + dt);
                Assert.IsTrue(dt.TimeZoneInfo.TimeZoneName == TimeZones1[i], "Event " + dt + " should occur in the " + TimeZones1[i] + " timezone");
            }

            Assert.IsTrue(evt2.Periods.Count == DateTimes1.Length, "There should be exactly " + DateTimes1.Length + " occurrences; there were " + evt2.Periods.Count);
        }
コード例 #8
0
ファイル: Serialize.cs プロジェクト: MaitreDede/dday-ical
        public void TIMEZONE3()
        {
            SerializeTest("TIMEZONE3.ics", typeof(iCalendarSerializer));

            iCalendar iCal = new iCalendar();
            iCalendar tmp_cal = iCalendar.LoadFromFile(@"Calendars\Serialization\TIMEZONE3.ics");
            iCal.MergeWith(tmp_cal);

            iCalendarSerializer serializer = new iCalendarSerializer(iCal);
            serializer.Serialize(@"Calendars\Serialization\testMeOut.ics");
        }
コード例 #9
0
        public void TimeZone3()
        {
            SerializeTest("TimeZone3.ics", typeof(iCalendarSerializer));

            iCalendar iCal = new iCalendar();
            IICalendar tmp_cal = iCalendar.LoadFromFile(@"Calendars/Serialization/TimeZone3.ics")[0];
            iCal.MergeWith(tmp_cal);

            iCalendarSerializer serializer = new iCalendarSerializer();
            serializer.Serialize(iCal, @"Calendars/Serialization/Temp/TimeZone3.ics");
        }
コード例 #10
0
ファイル: ProgramTest.cs プロジェクト: MaitreDede/dday-ical
        public void MERGE1()
        {
            iCalendar iCal1 = iCalendar.LoadFromFile(@"Calendars\Recurrence\RRULE21.ics");
            iCalendar iCal2 = iCalendar.LoadFromFile(@"Calendars\Recurrence\RRULE22.ics");

            // Change the UID of the 2nd event to make sure it's different
            iCal2.Events[iCal1.Events[0].UID].UID = "1234567890";
            iCal1.MergeWith(iCal2);

            Event evt1 = iCal1.Events[0];
            Event evt2 = iCal1.Events[1];

            // Get occurrences for the first event
            List <Occurrence> occurrences = evt1.GetOccurrences(
                new iCalDateTime(1996, 1, 1, tzid, iCal1),
                new iCalDateTime(2000, 1, 1, tzid, iCal1));

            iCalDateTime[] DateTimes = new iCalDateTime[]
            {
                new iCalDateTime(1997, 9, 10, 9, 0, 0, tzid, iCal1),
                new iCalDateTime(1997, 9, 11, 9, 0, 0, tzid, iCal1),
                new iCalDateTime(1997, 9, 12, 9, 0, 0, tzid, iCal1),
                new iCalDateTime(1997, 9, 13, 9, 0, 0, tzid, iCal1),
                new iCalDateTime(1997, 9, 14, 9, 0, 0, tzid, iCal1),
                new iCalDateTime(1997, 9, 15, 9, 0, 0, tzid, iCal1),
                new iCalDateTime(1999, 3, 10, 9, 0, 0, tzid, iCal1),
                new iCalDateTime(1999, 3, 11, 9, 0, 0, tzid, iCal1),
                new iCalDateTime(1999, 3, 12, 9, 0, 0, tzid, iCal1),
                new iCalDateTime(1999, 3, 13, 9, 0, 0, tzid, iCal1),
            };

            string[] TimeZones = new string[]
            {
                "EDT",
                "EDT",
                "EDT",
                "EDT",
                "EDT",
                "EDT",
                "EST",
                "EST",
                "EST",
                "EST"
            };

            for (int i = 0; i < DateTimes.Length; i++)
            {
                iCalDateTime dt    = (iCalDateTime)DateTimes[i];
                iCalDateTime start = occurrences[i].Period.StartTime;
                Assert.AreEqual(dt.Local, start.Local);
                Assert.IsTrue(dt.TimeZoneInfo.TimeZoneName == TimeZones[i], "Event " + dt + " should occur in the " + TimeZones[i] + " timezone");
            }

            Assert.IsTrue(occurrences.Count == DateTimes.Length, "There should be exactly " + DateTimes.Length + " occurrences; there were " + occurrences.Count);

            // Get occurrences for the 2nd event
            occurrences = evt2.GetOccurrences(
                new iCalDateTime(1996, 1, 1, tzid, iCal1),
                new iCalDateTime(1998, 4, 1, tzid, iCal1));

            iCalDateTime[] DateTimes1 = new iCalDateTime[]
            {
                new iCalDateTime(1997, 9, 2, 9, 0, 0, tzid, iCal1),
                new iCalDateTime(1997, 9, 9, 9, 0, 0, tzid, iCal1),
                new iCalDateTime(1997, 9, 16, 9, 0, 0, tzid, iCal1),
                new iCalDateTime(1997, 9, 23, 9, 0, 0, tzid, iCal1),
                new iCalDateTime(1997, 9, 30, 9, 0, 0, tzid, iCal1),
                new iCalDateTime(1997, 11, 4, 9, 0, 0, tzid, iCal1),
                new iCalDateTime(1997, 11, 11, 9, 0, 0, tzid, iCal1),
                new iCalDateTime(1997, 11, 18, 9, 0, 0, tzid, iCal1),
                new iCalDateTime(1997, 11, 25, 9, 0, 0, tzid, iCal1),
                new iCalDateTime(1998, 1, 6, 9, 0, 0, tzid, iCal1),
                new iCalDateTime(1998, 1, 13, 9, 0, 0, tzid, iCal1),
                new iCalDateTime(1998, 1, 20, 9, 0, 0, tzid, iCal1),
                new iCalDateTime(1998, 1, 27, 9, 0, 0, tzid, iCal1),
                new iCalDateTime(1998, 3, 3, 9, 0, 0, tzid, iCal1),
                new iCalDateTime(1998, 3, 10, 9, 0, 0, tzid, iCal1),
                new iCalDateTime(1998, 3, 17, 9, 0, 0, tzid, iCal1),
                new iCalDateTime(1998, 3, 24, 9, 0, 0, tzid, iCal1),
                new iCalDateTime(1998, 3, 31, 9, 0, 0, tzid, iCal1)
            };

            string[] TimeZones1 = new string[]
            {
                "EDT",
                "EDT",
                "EDT",
                "EDT",
                "EDT",
                "EST",
                "EST",
                "EST",
                "EST",
                "EST",
                "EST",
                "EST",
                "EST",
                "EST",
                "EST",
                "EST",
                "EST",
                "EST"
            };

            for (int i = 0; i < DateTimes1.Length; i++)
            {
                iCalDateTime dt    = (iCalDateTime)DateTimes1[i];
                iCalDateTime start = occurrences[i].Period.StartTime;
                Assert.AreEqual(dt.Local, start.Local);
                Assert.IsTrue(dt.TimeZoneInfo.TimeZoneName == TimeZones1[i], "Event " + dt + " should occur in the " + TimeZones1[i] + " timezone");
            }

            Assert.AreEqual(DateTimes1.Length, occurrences.Count, "There should be exactly " + DateTimes1.Length + " occurrences; there were " + occurrences.Count);
        }
コード例 #11
0
ファイル: ProgramTest.cs プロジェクト: xxjeng/nuxleus
        public void MERGE2()
        {
            iCalendar iCal = new iCalendar();
            iCalendar tmp_cal = iCalendar.LoadFromFile(@"Calendars\General\MERGE2.ics");
            iCal.MergeWith(tmp_cal);

            tmp_cal = iCalendar.LoadFromFile(@"Calendars\General\MERGE2.ics");

            // Compare the two calendars -- they should match exactly
            SerializationTest.CompareCalendars(iCal, tmp_cal);
        }
コード例 #12
0
ファイル: ProgramTest.cs プロジェクト: Guymestef/DDay.iCal
        public void Merge2()
        {
            iCalendar iCal = new iCalendar();
            IICalendar tmp_cal = iCalendar.LoadFromFile(@"Calendars\Serialization\TimeZone3.ics")[0];
            iCal.MergeWith(tmp_cal);

            tmp_cal = iCalendar.LoadFromFile(@"Calendars\Serialization\TimeZone3.ics")[0];

            // Compare the two calendars -- they should match exactly
            SerializationTest.CompareCalendars(iCal, tmp_cal);
        }