public void RELATED_TO1() { iCalendar iCal = new iCalendar(); // Create a test event Event evt1 = iCal.Create <Event>(); evt1.Summary = "Work Party"; evt1.Start = new iCalDateTime(2007, 10, 15, 8, 0, 0); evt1.Duration = TimeSpan.FromHours(1); // Create another event that relates to evt1 Event evt2 = iCal.Create <Event>(); evt2.Summary = "Water Polo"; evt2.Start = new iCalDateTime(2007, 10, 15, 10, 0, 0); evt2.Duration = TimeSpan.FromHours(1); evt2.AddRelatedTo(evt1.UID, RelationshipTypes.Parent); // evt1 is the parent of evt2 iCalendarSerializer serializer = new iCalendarSerializer(iCal); serializer.Serialize(@"Calendars\Serialization\Temp\RELATED_TO1.ics"); iCal = iCalendar.LoadFromFile(@"Calendars\Serialization\Temp\RELATED_TO1.ics"); evt2 = iCal.Events[evt2.UID]; Assert.AreEqual(1, evt2.Related_To.Length); Assert.AreEqual(evt1.UID, evt2.Related_To[0].Value); Assert.AreEqual(((Parameter)evt2.Related_To[0].Parameters["RELTYPE"]).Values[0], RelationshipTypes.Parent); }
/// <summary> /// The main program execution. /// </summary> static void Main(string[] args) { // Create a new iCalendar iCalendar iCal = new iCalendar(); // Create the event, and add it to the iCalendar Event evt = iCal.Create <Event>(); // Set information about the event evt.Start = iCalDateTime.Today.AddHours(8); evt.End = evt.Start.AddHours(18); // This also sets the duration evt.Description = "The event description"; evt.Location = "Event location"; evt.Summary = "18 hour event summary"; // Set information about the second event evt = iCal.Create <Event>(); evt.Start = iCalDateTime.Today.AddDays(5); evt.End = evt.Start.AddDays(1); evt.IsAllDay = true; evt.Summary = "All-day event"; // Display each event foreach (Event e in iCal.Events) { Console.WriteLine("Event created: " + GetDescription(e)); } // Serialize (save) the iCalendar iCalendarSerializer serializer = new iCalendarSerializer(); serializer.Serialize(iCal, @"iCalendar.ics"); Console.WriteLine("iCalendar file saved." + Environment.NewLine); // Load the calendar from the file we just saved IICalendarCollection calendars = iCalendar.LoadFromFile(@"iCalendar.ics"); Console.WriteLine("iCalendar file loaded."); // Iterate through each event to display its description // (and verify the file saved correctly) foreach (IICalendar calendar in calendars) { foreach (IEvent e in calendar.Events) { Console.WriteLine("Event loaded: " + GetDescription(e)); } } }
public void SERIALIZE18() { iCalendar iCal = new iCalendar(); Event evt = iCal.Create <Event>(); evt.Summary = "Test event title"; evt.Start = DateTime.Today; evt.End = DateTime.Today.AddDays(1); evt.IsAllDay = true; Recur rec = new Recur("FREQ=WEEKLY;INTERVAL=3;BYDAY=TU,FR,SU;COUNT=4"); evt.AddRecurrence(rec); iCalendarSerializer serializer = new iCalendarSerializer(iCal); string icalString = serializer.SerializeToString(); Assert.IsNotEmpty(icalString, "iCalendarSerializer.SerializeToString() must not be empty"); ComponentBaseSerializer compSerializer = new ComponentBaseSerializer(evt); string evtString = compSerializer.SerializeToString(); Assert.IsTrue(evtString.Equals("BEGIN:VEVENT\r\nDTEND:20070320T060000Z\r\nDTSTART;VALUE=DATE:20070319\r\nDURATION:P1D\r\nRRULE:FREQ=WEEKLY;INTERVAL=3;COUNT=4;BYDAY=TU,FR,SU\r\nSUMMARY:Test event title\r\nEND:VEVENT\r\n"), "ComponentBaseSerializer.SerializeToString() serialized incorrectly"); }
public void SERIALIZE18() { iCalendar iCal = new iCalendar(); Event evt = iCal.Create <Event>(); evt.Summary = "Test event title"; evt.Start = new iCalDateTime(2007, 3, 19); evt.Start.IsUniversalTime = true; evt.Duration = new TimeSpan(24, 0, 0); evt.Created = evt.Start.Copy(); evt.DTStamp = evt.Start.Copy(); evt.UID = "123456789"; evt.IsAllDay = true; RecurrencePattern rec = new RecurrencePattern("FREQ=WEEKLY;INTERVAL=3;BYDAY=TU,FR,SU;COUNT=4"); evt.AddRecurrencePattern(rec); iCalendarSerializer serializer = new iCalendarSerializer(iCal); string icalString = serializer.SerializeToString(); Assert.IsNotEmpty(icalString, "iCalendarSerializer.SerializeToString() must not be empty"); ComponentBaseSerializer compSerializer = new ComponentBaseSerializer(evt); string evtString = compSerializer.SerializeToString(); Assert.IsTrue(evtString.Equals("BEGIN:VEVENT\r\nCREATED:20070319T000000Z\r\nDTEND;VALUE=DATE:20070320\r\nDTSTAMP:20070319T000000Z\r\nDTSTART;VALUE=DATE:20070319\r\nRRULE:FREQ=WEEKLY;INTERVAL=3;COUNT=4;BYDAY=TU,FR,SU\r\nSEQUENCE:0\r\nSUMMARY:Test event title\r\nUID:123456789\r\nEND:VEVENT\r\n"), "ComponentBaseSerializer.SerializeToString() serialized incorrectly"); serializer.Serialize(@"Calendars\Serialization\SERIALIZE18.ics"); SerializeTest("SERIALIZE18.ics", typeof(iCalendarSerializer)); }
public void SERIALIZE19() { iCalendar iCal = new iCalendar(); Event evt = iCal.Create <Event>(); evt.Summary = "Test event title"; evt.Start = new iCalDateTime(2007, 4, 29); evt.End = evt.Start.AddDays(1); evt.IsAllDay = true; RecurrencePattern rec = new RecurrencePattern("FREQ=WEEKLY;INTERVAL=3;BYDAY=TU,FR,SU;COUNT=4"); evt.AddRecurrencePattern(rec); ComponentBaseSerializer compSerializer = new ComponentBaseSerializer(evt); FileStream fs = new FileStream(@"Calendars\Serialization\SERIALIZE19.ics", FileMode.Create, FileAccess.Write); compSerializer.Serialize(fs, Encoding.UTF8); fs.Close(); iCalendar iCal1 = new iCalendar(); fs = new FileStream(@"Calendars\Serialization\SERIALIZE19.ics", FileMode.Open, FileAccess.Read); Event evt1 = ComponentBase.LoadFromStream <Event>(fs, Encoding.UTF8); fs.Close(); CompareComponents(evt, evt1); }
static public Todo Create(iCalendar iCal) { Todo t = (Todo)iCal.Create(iCal, "VTODO"); t.UID = UniqueComponent.NewUID(); return t; }
public void SERIALIZE32() { iCalendar iCal = new iCalendar(); iCal.AddProperty("X-WR-CALNAME", "DDay Test"); iCal.AddProperty("X-WR-CALDESC", "Events for a DDay Test"); iCal.AddProperty("X-PUBLISHED-TTL", "PT30M"); iCal.ProductID = "-//DDAYTEST//NONSGML www.test.com//EN"; // Create an event in the iCalendar Event evt = iCal.Create <Event>(); //Populate the properties evt.Start = new iCalDateTime(2009, 6, 28, 8, 0, 0); evt.Duration = TimeSpan.FromHours(1); evt.Url = new URI("http://www.ftb.pl/news/59941_0_1/tunnel-electrocity-2008-timetable.htm"); evt.Summary = "This is a title"; evt.Description = "This is a description"; iCalendarSerializer serializer = new iCalendarSerializer(iCal); string output = serializer.SerializeToString(); serializer.Serialize(@"Calendars\Serialization\SERIALIZE32.ics"); Assert.IsFalse(Regex.IsMatch(output, @"\r\n[\r\n]")); SerializeTest("SERIALIZE32.ics", typeof(iCalendarSerializer)); }
public void BINARY1() { iCalendar iCal = new iCalendar(); // Create a test event Event evt = iCal.Create <Event>(); evt.Summary = "Test Event"; evt.Start = new iCalDateTime(2007, 10, 15, 8, 0, 0); evt.Duration = TimeSpan.FromHours(1); // Add an attachment to this event Binary binary = new Binary(); binary.AddParameter("X-FILENAME", "WordDocument.doc"); binary.Data = ReadBinary(@"Data\Test.doc"); evt.AddAttachment(binary); iCalendarSerializer serializer = new iCalendarSerializer(iCal); if (!Directory.Exists(@"Calendars\Serialization\Temp")) { Directory.CreateDirectory(@"Calendars\Serialization\Temp"); } serializer.Serialize(@"Calendars\Serialization\Temp\BINARY1.ics"); iCal = iCalendar.LoadFromFile(@"Calendars\Serialization\Temp\BINARY1.ics"); evt = iCal.Events[0]; binary = evt.Attach[0]; Assert.IsTrue(CompareBinary(@"Data\Test.doc", binary.Data), "Serialized version of Test.doc did not match the deserialized version."); }
private bool CheckEventSlot(MeetingViewModel newMeeting) { IICalendar iCal = new iCalendar(); foreach (var meeting in meetingService.GetAll()) { if (!string.IsNullOrEmpty(meeting.RecurrenceRule)) { var evt = iCal.Create <Event>(); evt.Start = new iCalDateTime(meeting.Start); evt.End = new iCalDateTime(meeting.End); evt.RecurrenceRules.Add(new RecurrencePattern(meeting.RecurrenceRule)); var occ = evt.GetOccurrences(newMeeting.Start, newMeeting.End); if (evt.GetOccurrences(newMeeting.Start, newMeeting.End).Count > 0) { return(false); } } } return(true); }
public void TODO11() { iCalendar iCal = new iCalendar(); Todo todo = iCal.Create <Todo>(); todo.Summary = "xxxx"; todo.Description = "fdsdsfds"; // Set Start & Due date todo.DTStart = new DateTime(2007, 1, 1, 8, 0, 0); todo.Due = new DateTime(2007, 1, 7); todo.Created = DateTime.SpecifyKind(new DateTime(2007, 1, 1), DateTimeKind.Utc); todo.DTStamp = DateTime.SpecifyKind(new DateTime(2007, 1, 1), DateTimeKind.Utc); todo.UID = "b6709c95-5523-46aa-a7e5-1b5ea034b86a"; // Add an alarm in my task Alarm al = new Alarm(todo); al.Action = AlarmAction.Display; al.Description = "Reminder"; al.Trigger = new Trigger(); // Set reminder time al.Trigger.DateTime = new DateTime(2007, 1, 6, 8, 0, 0); // Save into calendar file. iCalendarSerializer serializer = new iCalendarSerializer(iCal); string serializedTodo = serializer.SerializeToString(); Assert.AreEqual( "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//DDay.iCal//NONSGML ddaysoftware.com//EN\r\nBEGIN:VTODO\r\nCREATED:20070101T000000Z\r\nDESCRIPTION:fdsdsfds\r\nDTSTAMP:20070101T000000Z\r\nDTSTART:20070101T080000\r\nDUE;VALUE=DATE:20070107\r\nSEQUENCE:0\r\nSTATUS:NEEDS-ACTION\r\nSUMMARY:xxxx\r\nUID:b6709c95-5523-46aa-a7e5-1b5ea034b86a\r\nBEGIN:VALARM\r\nACTION:DISPLAY\r\nDESCRIPTION:Reminder\r\nTRIGGER;VALUE=DATE-TIME:20070106T080000\r\nEND:VALARM\r\nEND:VTODO\r\nEND:VCALENDAR\r\n", serializedTodo); }
public ActionResult ICalendar(string shortcut, Guid hallID, string accessToken) { var iCal = new iCalendar(); var studio = _context.Photostudios.Single(x => x.Shortcut == shortcut); var hall = studio.Halls.Single(x => x.ID == hallID); foreach (var @event in hall.Calendar.Events) { var evt = iCal.Create <DDay.iCal.Event>(); // Set information about the event evt.Start = new iCalDateTime(@event.Start); evt.End = new iCalDateTime(@event.End); // This also sets the duration evt.Description = @event.Description; evt.Location = hall.Photostudio.Adress; evt.Summary = "18 hour event summary"; evt.UID = @event.ID.ToString(); } // Create a serialization context and serializer factory. // These will be used to build the serializer for our object. ISerializationContext ctx = new SerializationContext(); ISerializerFactory factory = new DDay.iCal.Serialization.iCalendar.SerializerFactory(); // Get a serializer for our object IStringSerializer serializer = factory.Build(iCal.GetType(), ctx) as IStringSerializer; string output = serializer.SerializeToString(iCal); var contentType = "text/calendar"; var bytes = Encoding.UTF8.GetBytes(output); return(File(bytes, contentType, hallID + ".ics")); }
static public Journal Create(iCalendar iCal) { Journal j = (Journal)iCal.Create(iCal, "VJOURNAL"); j.UID = UniqueComponent.NewUID(); return j; }
private static void CreateCalendarEvent(ref iCalendar iCal, AppointmentBase appointment) { // mandatory for outlook 2007 //if (String.IsNullOrEmpty (organizer)) // throw new Exception ("Organizer provided was null"); // "REQUEST" will update an existing event with the same UID (Unique ID) and a newer time stamp. //if (updatePreviousEvent) //{ // iCal.Method = "REQUEST"; //} var evt = iCal.Create <Event> (); evt.Summary = appointment.Title; evt.Start = new iCalDateTime(appointment.StartDate); evt.Duration = appointment.Duration; // TimeSpan.FromHours (duration); evt.Description = appointment.Body; evt.Location = appointment.Location; evt.IsAllDay = appointment.IsAllDayEvent; evt.UID = appointment.UID; //String.IsNullOrEmpty (eventId) ? new Guid ().ToString () : eventId; evt.Organizer = new Organizer(appointment.Organizer); evt.Alarms.Add(new Alarm { Duration = new TimeSpan(0, 15, 0), Trigger = new Trigger(new TimeSpan(0, 15, 0)), Action = AlarmAction.Display, Description = "Reminder" }); }
static public Journal Create(iCalendar iCal) { Journal j = (Journal)iCal.Create(iCal, "VJOURNAL"); j.UID = UniqueComponent.NewUID(); return(j); }
static public Event Create(iCalendar iCal) { Event evt = (Event)iCal.Create(iCal, "VEVENT"); evt.UID = UniqueComponent.NewUID(); return(evt); }
static public Todo Create(iCalendar iCal) { Todo t = (Todo)iCal.Create(iCal, "VTODO"); t.UID = UniqueComponent.NewUID(); return(t); }
public void UniqueComponent1() { iCalendar iCal = new iCalendar(); Event evt = iCal.Create <Event>(); Assert.IsNotNull(evt.UID); Assert.IsNull(evt.Created); // We don't want this to be set automatically Assert.IsNotNull(evt.DTStamp); }
static public Todo Create(iCalendar iCal) { Todo t = (Todo)iCal.Create(iCal, "VTODO"); t.UID = UniqueComponent.NewUID(); t.Created = DateTime.Now; t.DTStamp = DateTime.Now; return t; }
public void UniqueComponent1() { iCalendar iCal = new iCalendar(); Event evt = iCal.Create<Event>(); Assert.IsNotNull(evt.UID); Assert.IsNull(evt.Created); // We don't want this to be set automatically Assert.IsNotNull(evt.DTStamp); }
static public Journal Create(iCalendar iCal) { Journal j = iCal.Create<Journal>(); j.UID = UniqueComponent.NewUID(); j.Created = DateTime.Now; j.DTStamp = DateTime.Now; return j; }
public void UniqueComponent1() { iCalendar iCal = new iCalendar(); Event evt = iCal.Create<Event>(); Assert.IsNotNull(evt.UID); Assert.IsNotNull(evt.Created); Assert.IsNotNull(evt.DTStamp); }
public void UniqueComponent1() { iCalendar iCal = new iCalendar(); Event evt = iCal.Create <Event>(); Assert.IsNotNull(evt.UID); Assert.IsNotNull(evt.Created); Assert.IsNotNull(evt.DTStamp); }
private Response GetCalendarFeed() { var start = DateTime.Today.AddDays(-7); var end = DateTime.Today.AddDays(28); var queryStart = Request.Query.Start; var queryEnd = Request.Query.End; if (queryStart.HasValue) { start = DateTime.Parse(queryStart.Value); } if (queryEnd.HasValue) { end = DateTime.Parse(queryEnd.Value); } var episodes = _episodeService.EpisodesBetweenDates(start, end); var icalCalendar = new iCalendar(); foreach (var episode in episodes.OrderBy(v => v.AirDateUtc.Value)) { var occurrence = icalCalendar.Create <Event>(); occurrence.UID = "NzbDrone_episode_" + episode.Id.ToString(); occurrence.Status = episode.HasFile ? EventStatus.Confirmed : EventStatus.Tentative; occurrence.Start = new iCalDateTime(episode.AirDateUtc.Value) { HasTime = true }; occurrence.End = new iCalDateTime(episode.AirDateUtc.Value.AddMinutes(episode.Series.Runtime)) { HasTime = true }; occurrence.Description = episode.Overview; occurrence.Categories = new List <string>() { episode.Series.Network }; switch (episode.Series.SeriesType) { case SeriesTypes.Daily: occurrence.Summary = string.Format("{0} - {1}", episode.Series.Title, episode.Title); break; default: occurrence.Summary = string.Format("{0} - {1}x{2:00} - {3}", episode.Series.Title, episode.SeasonNumber, episode.EpisodeNumber, episode.Title); break; } } var serializer = new DDay.iCal.Serialization.iCalendar.SerializerFactory().Build(icalCalendar.GetType(), new DDay.iCal.Serialization.SerializationContext()) as DDay.iCal.Serialization.IStringSerializer; var icalendar = serializer.SerializeToString(icalCalendar); return(new TextResponse(icalendar, "text/calendar")); }
// From: http://sourcefield.blogspot.com/2011/06/dday-ical-example.html public void Example() { // #1: Monthly meetings that occur on the last Wednesday from 6pm - 7pm // Create an iCalendar var iCal = new iCalendar(); // Create the event var evt = iCal.Create <Event>(); evt.Summary = "Test Event"; evt.Start = new iCalDateTime(2008, 1, 1, 18, 0, 0); // Starts January 1, 2008 @ 6:00 P.M. evt.Duration = TimeSpan.FromHours(1); // Add a recurrence pattern to the event var rp = new RecurrencePattern { Frequency = FrequencyType.Monthly }; rp.ByDay.Add(new WeekDay(DayOfWeek.Wednesday, FrequencyOccurrence.Last)); evt.RecurrenceRules.Add(rp); // #2: Yearly events like holidays that occur on the same day each year. // The same as #1, except: var rp2 = new RecurrencePattern { Frequency = FrequencyType.Yearly }; evt.RecurrenceRules.Add(rp2); // #3: Yearly events like holidays that occur on a specific day like the first monday. // The same as #1, except: var rp3 = new RecurrencePattern { Frequency = FrequencyType.Yearly }; rp3.ByMonth.Add(3); rp3.ByDay.Add(new WeekDay(DayOfWeek.Monday, FrequencyOccurrence.First)); evt.RecurrenceRules.Add(rp3); /* * Note that all events occur on their start time, no matter their * recurrence pattern. So, for example, you could occur on the first Monday * of every month, but if your event is scheduled for a Friday (i.e. * evt.Start = new iCalDateTime(2008, 3, 7, 18, 0, 0)), then it will first * occur on that Friday, and then the first Monday of every month after * that. * * this can be worked around by doing this: * IPeriod nextOccurrence = pattern.GetNextOccurrence(dt); * evt.Start = nextOccurrence.StartTime; */ }
static public Todo Create(iCalendar iCal) { Todo t = iCal.Create <Todo>(); t.UID = UniqueComponent.NewUID(); t.Created = DateTime.Now; t.DTStamp = DateTime.Now; return(t); }
static public Journal Create(iCalendar iCal) { Journal j = (Journal)iCal.Create(iCal, "VJOURNAL"); j.UID = UniqueComponent.NewUID(); j.Created = DateTime.Now; j.DTStamp = DateTime.Now; return(j); }
static public Event Create(iCalendar iCal) { Event evt = (Event)iCal.Create(iCal, "VEVENT"); evt.UID = UniqueComponent.NewUID(); evt.Created = DateTime.Now; evt.DTStamp = DateTime.Now; return(evt); }
public void AddNewEvent(iCalendar iCal, DateTime Begin, DateTime End, string Discipline, string Type, string Room, string Teacher, string SubGroup, bool IsMoved) { Event evt = iCal.Create<Event>(); evt.Start = new iCalDateTime(Begin); evt.End = new iCalDateTime(End); evt.Description = "#Disc:"+Discipline+"#Type:"+Type+"#SubGroup:"+SubGroup+"#Teacher:"+Teacher+"#IsMoved:"+IsMoved.ToString(); evt.Location = Room; evt.Summary = "Занятие по предмету '"+Discipline+"', "+ Type +" для подгруппы "+SubGroup+", проводится в " + Room + ", преподаватель " + Teacher +", с "+ Begin.ToShortTimeString() +" до " + End.ToShortTimeString()+"."; if (IsMoved) evt.Summary = evt.Summary + " Перенесено."; }
public void SERIALIZE25() { iCalendar iCal = new iCalendar(); Event evt = iCal.Create <Event>(); evt.Start = DateTime.Now; evt.Duration = TimeSpan.FromHours(1); evt.Summary = @" Thank you for purchasing tickets on Ticketmaster. Your order number for this purchase is 19-36919/UK1. Tickets will be despatched as soon as possible, but may not be received until 7-10 days before the event. Please do not contact us unless you have not received your tickets within 7 days of the event. You purchased 2 tickets to: _____________________________________________________________________________________________ Prince The O2, London, UK Fri 31 Aug 2007, 18:00 Seat location: section BK 419, row M, seats 912-913 Total Charge: £69.42 http://ads.as4x.tmcs.ticketmaster.com/click.ng/site=tm&pagepos=531&adsize=336x102&lang=en-uk&majorcatid=10001&minorcatid=1&event_id=12003EA8AD65189AD&venueid=148826&artistid=135895&promoter=161&TransactionID=0902229695751936911UKA Thanks again for using Ticketmaster. Show complete HYPERLINK ""http://ntr.ticketmaster.com:80/ssp/?&C=%39%33%30%30%35%5F%33%30%33&R=%6F%6C%5F%31%33%31&U=%31%39%2D%33%36%41%31%39%2F%55%4B%31&M=%35&B=%32%2E%30&S=%68%80%74%70%73%3A%2F%3F%77%77%77%2E%74%80%63%6B%65%71%6D%61%73%74%65%72%2E%63%6F%2E"" \t ""_blank"" order detail. You can always check your order and manage your preferences in HYPERLINK ""http://ntr.ticketmaster.com:80/ssp/?&C=%39%33%30%30%30%5F%33%30%33&R=%6F%6C%5F%6D%65%6D%62%65%72&U=%31%39%2D%33%36%39%31%39%2F%55%4B%31&M=%31&B=%32%2E%30&S=%68%74%74%70%73%3A%2F%2F%77%"" \t ""_blank"" My Ticketmaster. _____________________________________________________________________________________________ C U S T O M E R S E R V I C E _____________________________________________________________________________________________ If you have any questions regarding your booking you can search for answers using our online helpdesk at http://ticketmaster.custhelp.com You can search our extensive range of answers and in the unlikely event that you cannot find an answer to your query, you can use 'Ask a Question' to contact us directly. _____________________________________________________________________________________________ This email confirms your ticket order, so print/save it for future reference. All purchases are subject to credit card approval and billing address verification. We make every effort to be accurate, but we cannot be responsible for changes, cancellations, or postponements announced after this email is sent. Please do not reply to this email. Replies to this email will not be responded to or read. If you have any questions or comments, HYPERLINK ""http://ntr.ticketmaster.com:80/ssp/?&C=%39%33%30%30%30%5F%33%30%33&R=%32&U=%31%39%2D%33%36%39%31%39%2F%55%4B%31&M=%31&B=%32%2E%30&S=%68%74%74%70%3A%2F%2F%77%77%77%2E%74%69%63%6B%65%74%6D%61%73%74%65%72%2E%63%6F%2E%75%6B%2F%68%2F%63%75%73%74%6F%6D%65%72%5F%73%65%72%76%65%2E%68%74%6D%6C"" \t ""_blank"" contact us. Ticketmaster UK Limited Registration in England No 2662632, Registered Office, 48 Leicester Square, London WC2H 7LR "; iCalendarSerializer serializer = new iCalendarSerializer(iCal); serializer.Serialize(@"Calendars\Serialization\SERIALIZE25.ics"); SerializeTest("SERIALIZE25.ics", typeof(iCalendarSerializer)); }
[Test, Category("DDay")] //Category(("FreeBusy")] public void GetFreeBusyStatus1() { IICalendar iCal = new iCalendar(); IEvent evt = iCal.Create<DDayEvent>(); evt.Summary = "Test event"; evt.Start = new iCalDateTime(2010, 10, 1, 8, 0, 0); evt.End = new iCalDateTime(2010, 10, 1, 9, 0, 0); IFreeBusy freeBusy = iCal.GetFreeBusy(new iCalDateTime(2010, 10, 1, 0, 0, 0), new iCalDateTime(2010, 10, 7, 11, 59, 59)); Assert.AreEqual(FreeBusyStatus.Free, freeBusy.GetFreeBusyStatus(new iCalDateTime(2010, 10, 1, 7, 59, 59))); Assert.AreEqual(FreeBusyStatus.Busy, freeBusy.GetFreeBusyStatus(new iCalDateTime(2010, 10, 1, 8, 0, 0))); Assert.AreEqual(FreeBusyStatus.Busy, freeBusy.GetFreeBusyStatus(new iCalDateTime(2010, 10, 1, 8, 59, 59))); Assert.AreEqual(FreeBusyStatus.Free, freeBusy.GetFreeBusyStatus(new iCalDateTime(2010, 10, 1, 9, 0, 0))); }
public static Event DinnerToEvent(Dinner dinner, iCalendar iCal) { string eventLink = "http://nrddnr.com/" + dinner.DinnerID; Event evt = iCal.Create <Event>(); evt.Start = dinner.EventDate; evt.Duration = new TimeSpan(3, 0, 0); evt.Location = dinner.Address; evt.Summary = String.Format("{0} {2} {1}", dinner.Description, dinner.HostedBy, Resources.Resources.with); evt.AddContact(dinner.ContactPhone); evt.Geo = new Geo(dinner.Latitude, dinner.Longitude); evt.Url = eventLink; evt.Description = eventLink; return(evt); }
public static Event DinnerToEvent(Dinner dinner, iCalendar iCal) { string eventLink = "http://nrddnr.com/" + dinner.DinnerID; Event evt = iCal.Create <Event>(); evt.Start = new iCalDateTime(dinner.EventDate); evt.Duration = new TimeSpan(3, 0, 0); evt.Location = dinner.Address; evt.Summary = String.Format("{0} with {1}", dinner.Description, dinner.HostedBy); evt.Contacts.Add(dinner.ContactPhone); evt.GeographicLocation = new GeographicLocation(dinner.Latitude, dinner.Longitude); evt.Url = new Uri(eventLink); evt.Description = eventLink; return(evt); }
public void BINARY2() { iCalendar iCal = new iCalendar(); // Create a test event Event evt = iCal.Create <Event>(); evt.Summary = "Test Event"; evt.Start = new iCalDateTime(2007, 10, 15, 8, 0, 0); evt.Duration = TimeSpan.FromHours(1); // Get a data file string loremIpsum = UnicodeEncoding.Default.GetString(ReadBinary(@"Data\LoremIpsum.txt")); StringBuilder sb = new StringBuilder(); // If we copy it 300 times, we should end up with a file over 2.5MB in size. for (int i = 0; i < 300; i++) { sb.AppendLine(loremIpsum); } // Add an attachment to this event Binary binary = new Binary(); binary.Data = UnicodeEncoding.Default.GetBytes(sb.ToString()); evt.AddAttachment(binary); iCalendarSerializer serializer = new iCalendarSerializer(iCal); if (!Directory.Exists(@"Calendars\Serialization\Temp")) { Directory.CreateDirectory(@"Calendars\Serialization\Temp"); } serializer.Serialize(@"Calendars\Serialization\Temp\BINARY2.ics"); iCal = iCalendar.LoadFromFile(@"Calendars\Serialization\Temp\BINARY2.ics"); evt = iCal.Events[0]; binary = evt.Attach[0]; // Ensure the generated and serialized strings match Assert.AreEqual(sb.ToString(), UnicodeEncoding.Default.GetString(binary.Data)); // Times to finish the test for attachment file sizes (on my computer): // 0.92MB = 1.2 seconds // 2.76MB = 6 seconds // 4.6MB = 15.1 seconds // 9.2MB = 54 seconds }
public void SERIALIZE17() { // Create a normal iCalendar, serialize it, and load it as a custom calendar iCalendar iCal = new iCalendar(); Event evt = iCal.Create <Event>(); evt.Summary = "Test event"; evt.Start = new DateTime(2007, 02, 15, 8, 0, 0); iCalendarSerializer serializer = new iCalendarSerializer(iCal); serializer.Serialize(@"Calendars\Serialization\SERIALIZE17.ics"); SerializeTest("SERIALIZE17.ics", typeof(CustomICal1), typeof(iCalendarSerializer)); }
static public void AddNewEvent(iCalendar iCal, EventInfo ei) { Event evt = iCal.Create <Event>(); evt.DTStart = new iCalDateTime(ei.Pattern.BeginDate.Year, ei.Pattern.BeginDate.Month, ei.Pattern.BeginDate.Day, ei.Begin.Hour, ei.Begin.Minute, ei.Begin.Second); evt.DTEnd = new iCalDateTime(ei.Pattern.BeginDate.Year, ei.Pattern.BeginDate.Month, ei.Pattern.BeginDate.Day, ei.End.Hour, ei.End.Minute, ei.End.Second); evt.Description = "#Disc:" + ei.Discipline + "#Type:" + ei.Type + "#Teacher:" + ei.Teacher + "#IsMoved:" + ei.IsMoved.ToString(); evt.Location = ei.Room; evt.Summary = ei.Discipline + ", " + ei.Type + ", " + ei.Teacher + ", с " + ei.Begin.ToShortTimeString() + " до " + ei.End.ToShortTimeString() + "."; //List<ICalendarProperty> props = new List<ICalendarProperty>(; //evt.Properties. if (ei.IsMoved) { evt.Summary = evt.Summary + " Перенесено."; } FrequencyType ft = FrequencyType.None; switch (ei.Pattern.Type) { case 1: ft = FrequencyType.Daily; break; case 2: ft = FrequencyType.Weekly; break; case 3: ft = FrequencyType.Monthly; break; } RecurrencePattern rp = new RecurrencePattern(ft, ei.Pattern.Frequency); List <WeekDay> wdList = GetDayFromMask(ei.Pattern.RepeatMask); foreach (WeekDay wd in wdList) { rp.ByDay.Add(wd); } rp.Until = ei.Pattern.EndDate; evt.RecurrenceRules.Add(rp); }
static void Main(string[] args) { // Create a new calendar IICalendar iCal = new iCalendar(); // Add the local time zone to the calendar ITimeZone local = iCal.AddLocalTimeZone(); // Build a list of additional time zones // from .NET Framework. List <ITimeZone> otherTimeZones = new List <ITimeZone>(); foreach (TimeZoneInfo tzi in System.TimeZoneInfo.GetSystemTimeZones()) { // We've already added the local time zone, so let's skip it! if (tzi != System.TimeZoneInfo.Local) { // Add the time zone to our list (but don't include it directly in the calendar). otherTimeZones.Add(iCalTimeZone.FromSystemTimeZone(tzi)); } } // Create a new event in the calendar // that uses our local time zone IEvent evt = iCal.Create <Event>(); evt.Summary = "Test Event"; evt.Start = iCalDateTime.Today.AddHours(8).SetTimeZone(local); evt.Duration = TimeSpan.FromHours(1); // Get all occurrences of the event that happen today foreach (Occurrence occurrence in iCal.GetOccurrences <IEvent>(iCalDateTime.Today)) { // Write the event with the time zone information attached Console.WriteLine(occurrence.Period.StartTime); // Note that the time printed is identical to the above, but without time zone information. Console.WriteLine(occurrence.Period.StartTime.Local); // Convert the start time to other time zones and display the relative time. foreach (ITimeZone otherTimeZone in otherTimeZones) { Console.WriteLine(occurrence.Period.StartTime.ToTimeZone(otherTimeZone)); } } }
public void GetFreeBusyStatus1() { IICalendar iCal = new iCalendar(); IEvent evt = iCal.Create <Event>(); evt.Summary = "Test event"; evt.Start = new iCalDateTime(2010, 10, 1, 8, 0, 0); evt.End = new iCalDateTime(2010, 10, 1, 9, 0, 0); IFreeBusy freeBusy = iCal.GetFreeBusy(new iCalDateTime(2010, 10, 1, 0, 0, 0), new iCalDateTime(2010, 10, 7, 11, 59, 59)); Assert.AreEqual(FreeBusyStatus.Free, freeBusy.GetFreeBusyStatus(new iCalDateTime(2010, 10, 1, 7, 59, 59))); Assert.AreEqual(FreeBusyStatus.Busy, freeBusy.GetFreeBusyStatus(new iCalDateTime(2010, 10, 1, 8, 0, 0))); Assert.AreEqual(FreeBusyStatus.Busy, freeBusy.GetFreeBusyStatus(new iCalDateTime(2010, 10, 1, 8, 59, 59))); Assert.AreEqual(FreeBusyStatus.Free, freeBusy.GetFreeBusyStatus(new iCalDateTime(2010, 10, 1, 9, 0, 0))); }
public void RECURPARSE3() { iCalendar iCal = new iCalendar(); Event evt = iCal.Create<Event>(); evt.Summary = "Test event"; evt.Start = new iCalDateTime(2006, 1, 1, 9, 0, 0); evt.Duration = new TimeSpan(1, 0, 0); evt.RecurrenceRules.Add(new RecurrencePattern("Every other month, on day 21")); IList<Occurrence> occurrences = evt.GetOccurrences( new iCalDateTime(2006, 1, 1), new iCalDateTime(2006, 12, 31)); iCalDateTime[] DateTimes = new iCalDateTime[] { new iCalDateTime(2006, 1, 1, 9, 0, 0), new iCalDateTime(2006, 1, 21, 9, 0, 0), new iCalDateTime(2006, 3, 21, 9, 0, 0), new iCalDateTime(2006, 5, 21, 9, 0, 0), new iCalDateTime(2006, 7, 21, 9, 0, 0), new iCalDateTime(2006, 9, 21, 9, 0, 0), new iCalDateTime(2006, 11, 21, 9, 0, 0) }; for (int i = 0; i < DateTimes.Length; i++) Assert.AreEqual(DateTimes[i], occurrences[i].Period.StartTime, "Event should occur on " + DateTimes[i]); Assert.AreEqual( DateTimes.Length, occurrences.Count, "There should be exactly " + DateTimes.Length + " occurrences; there were " + occurrences.Count); }
public void FreeBusy2() { IICalendar iCal = new iCalendar(); IEvent evt = iCal.Create<Event>(); evt.Summary = "Test event"; evt.Start = new iCalDateTime(2010, 10, 1, 8, 0, 0); evt.End = new iCalDateTime(2010, 10, 1, 9, 0, 0); IAttendee attendee = new Attendee("mailto:[email protected]"); attendee.ParticipationStatus = ParticipationStatus.Tentative; evt.Attendees.Add(attendee); IICalendar freeBusyCalendar = new iCalendar(); IFreeBusy freeBusy = iCal.GetFreeBusy( null, new IAttendee[] { new Attendee("mailto:[email protected]") }, new iCalDateTime(2010, 10, 1, 0, 0, 0), new iCalDateTime(2010, 10, 7, 11, 59, 59)); freeBusyCalendar.AddChild(freeBusy); iCalendarSerializer serializer = new iCalendarSerializer(); serializer.Serialize(freeBusyCalendar, @"Calendars/Serialization/FreeBusy2.ics"); SerializeTest("FreeBusy2.ics", typeof(iCalendarSerializer)); }
public void SERIALIZE25() { iCalendar iCal = new iCalendar(); Event evt = iCal.Create<Event>(); evt.Start = DateTime.Now; evt.Duration = TimeSpan.FromHours(1); evt.Summary = @" Thank you for purchasing tickets on Ticketmaster. Your order number for this purchase is 19-36919/UK1. Tickets will be despatched as soon as possible, but may not be received until 7-10 days before the event. Please do not contact us unless you have not received your tickets within 7 days of the event. You purchased 2 tickets to: _____________________________________________________________________________________________ Prince The O2, London, UK Fri 31 Aug 2007, 18:00 Seat location: section BK 419, row M, seats 912-913 Total Charge: £69.42 http://ads.as4x.tmcs.ticketmaster.com/click.ng/site=tm&pagepos=531&adsize=336x102&lang=en-uk&majorcatid=10001&minorcatid=1&event_id=12003EA8AD65189AD&venueid=148826&artistid=135895&promoter=161&TransactionID=0902229695751936911UKA Thanks again for using Ticketmaster. Show complete HYPERLINK ""http://ntr.ticketmaster.com:80/ssp/?&C=%39%33%30%30%35%5F%33%30%33&R=%6F%6C%5F%31%33%31&U=%31%39%2D%33%36%41%31%39%2F%55%4B%31&M=%35&B=%32%2E%30&S=%68%80%74%70%73%3A%2F%3F%77%77%77%2E%74%80%63%6B%65%71%6D%61%73%74%65%72%2E%63%6F%2E"" \t ""_blank"" order detail. You can always check your order and manage your preferences in HYPERLINK ""http://ntr.ticketmaster.com:80/ssp/?&C=%39%33%30%30%30%5F%33%30%33&R=%6F%6C%5F%6D%65%6D%62%65%72&U=%31%39%2D%33%36%39%31%39%2F%55%4B%31&M=%31&B=%32%2E%30&S=%68%74%74%70%73%3A%2F%2F%77%"" \t ""_blank"" My Ticketmaster. _____________________________________________________________________________________________ C U S T O M E R S E R V I C E _____________________________________________________________________________________________ If you have any questions regarding your booking you can search for answers using our online helpdesk at http://ticketmaster.custhelp.com You can search our extensive range of answers and in the unlikely event that you cannot find an answer to your query, you can use 'Ask a Question' to contact us directly. _____________________________________________________________________________________________ This email confirms your ticket order, so print/save it for future reference. All purchases are subject to credit card approval and billing address verification. We make every effort to be accurate, but we cannot be responsible for changes, cancellations, or postponements announced after this email is sent. Please do not reply to this email. Replies to this email will not be responded to or read. If you have any questions or comments, HYPERLINK ""http://ntr.ticketmaster.com:80/ssp/?&C=%39%33%30%30%30%5F%33%30%33&R=%32&U=%31%39%2D%33%36%39%31%39%2F%55%4B%31&M=%31&B=%32%2E%30&S=%68%74%74%70%3A%2F%2F%77%77%77%2E%74%69%63%6B%65%74%6D%61%73%74%65%72%2E%63%6F%2E%75%6B%2F%68%2F%63%75%73%74%6F%6D%65%72%5F%73%65%72%76%65%2E%68%74%6D%6C"" \t ""_blank"" contact us. Ticketmaster UK Limited Registration in England No 2662632, Registered Office, 48 Leicester Square, London WC2H 7LR "; iCalendarSerializer serializer = new iCalendarSerializer(iCal); serializer.Serialize(@"Calendars\Serialization\SERIALIZE25.ics"); SerializeTest("SERIALIZE25.ics", typeof(iCalendarSerializer)); }
public void SERIALIZE28() { iCalendar iCal = new iCalendar(); Event evt = iCal.Create<Event>(); evt.Summary = "Test event"; evt.Start = DateTime.Now; evt.Duration = TimeSpan.FromMinutes(30); evt.Organizer = new Cal_Address("*****@*****.**"); evt.AddAttendee("*****@*****.**"); evt.AddAttendee("*****@*****.**"); evt.AddAttendee("*****@*****.**"); iCalendarSerializer serializer = new iCalendarSerializer(iCal); serializer.Serialize(@"Calendars\Serialization\SERIALIZE28.ics"); SerializeTest("SERIALIZE28.ics", typeof(iCalendarSerializer)); }
//[Test, Category("Serialization")] public void XCAL1() { iCalendar iCal = new iCalendar(); Event evt = iCal.Create<Event>(); evt.Summary = "Test event title"; evt.Start = new iCalDateTime(2007, 4, 29); evt.End = evt.Start.AddDays(1); evt.IsAllDay = true; RecurrencePattern rec = new RecurrencePattern("FREQ=WEEKLY;INTERVAL=3;BYDAY=TU,FR,SU;COUNT=4"); evt.AddRecurrencePattern(rec); xCalSerializer serializer = new xCalSerializer(iCal); serializer.Serialize(@"Calendars\Serialization\XCAL1.xcal"); SerializeTest("XCAL1.xcal", typeof(xCalSerializer)); }
public void SERIALIZE17() { // Create a normal iCalendar, serialize it, and load it as a custom calendar iCalendar iCal = new iCalendar(); Event evt = iCal.Create<Event>(); evt.Summary = "Test event"; evt.Start = new DateTime(2007, 02, 15, 8, 0, 0); iCalendarSerializer serializer = new iCalendarSerializer(iCal); serializer.Serialize(@"Calendars\Serialization\SERIALIZE17.ics"); SerializeTest("SERIALIZE17.ics", typeof(CustomICal1)); }
public void SERIALIZE18() { iCalendar iCal = new iCalendar(); Event evt = iCal.Create<Event>(); evt.Summary = "Test event title"; evt.Start = new Date_Time(2007, 3, 19); evt.Start.Kind = DateTimeKind.Utc; evt.Duration = new TimeSpan(24, 0, 0); evt.Created = evt.Start.Copy(); evt.DTStamp = evt.Start.Copy(); evt.UID = "123456789"; evt.IsAllDay = true; Recur rec = new Recur("FREQ=WEEKLY;INTERVAL=3;BYDAY=TU,FR,SU;COUNT=4"); evt.AddRecurrence(rec); iCalendarSerializer serializer = new iCalendarSerializer(iCal); string icalString = serializer.SerializeToString(); Assert.IsNotEmpty(icalString, "iCalendarSerializer.SerializeToString() must not be empty"); ComponentBaseSerializer compSerializer = new ComponentBaseSerializer(evt); string evtString = compSerializer.SerializeToString(); Assert.IsTrue(evtString.Equals("BEGIN:VEVENT\r\nCREATED:20070319T000000Z\r\nDTEND:20070320T000000Z\r\nDTSTAMP:20070319T000000Z\r\nDTSTART;VALUE=DATE:20070319\r\nDURATION:P1D\r\nRRULE:FREQ=WEEKLY;INTERVAL=3;COUNT=4;BYDAY=TU,FR,SU\r\nSUMMARY:Test event title\r\nUID:123456789\r\nEND:VEVENT\r\n"), "ComponentBaseSerializer.SerializeToString() serialized incorrectly"); }
public void SERIALIZE19() { iCalendar iCal = new iCalendar(); Event evt = iCal.Create<Event>(); evt.Summary = "Test event title"; evt.Start = new Date_Time(2007, 4, 29); evt.End = evt.Start.AddDays(1); evt.IsAllDay = true; Recur rec = new Recur("FREQ=WEEKLY;INTERVAL=3;BYDAY=TU,FR,SU;COUNT=4"); evt.AddRecurrence(rec); ComponentBaseSerializer compSerializer = new ComponentBaseSerializer(evt); FileStream fs = new FileStream(@"Calendars\Serialization\SERIALIZE19.ics", FileMode.Create, FileAccess.Write); compSerializer.Serialize(fs, Encoding.UTF8); fs.Close(); iCalendar iCal1 = new iCalendar(); fs = new FileStream(@"Calendars\Serialization\SERIALIZE19.ics", FileMode.Open, FileAccess.Read); Event evt1 = ComponentBase.LoadFromStream<Event>(fs); fs.Close(); CompareComponents(evt, evt1); }
static public Todo Create(iCalendar iCal) { Todo t = iCal.Create<Todo>(); return t; }
public void TEST2() { iCalendar iCal = new iCalendar(); Event evt = iCal.Create<Event>(); evt.Summary = "Event summary"; evt.Start = DateTime.SpecifyKind(DateTime.Today, DateTimeKind.Utc); Recur recur = new Recur(); recur.Frequency = Recur.FrequencyType.DAILY; recur.Count = 3; recur.ByDay.Add(new Recur.DaySpecifier(DayOfWeek.Monday)); recur.ByDay.Add(new Recur.DaySpecifier(DayOfWeek.Wednesday)); recur.ByDay.Add(new Recur.DaySpecifier(DayOfWeek.Friday)); evt.AddRecurrence(recur); DDay.iCal.Serialization.iCalendar.DataTypes.RecurSerializer serializer = new DDay.iCal.Serialization.iCalendar.DataTypes.RecurSerializer(recur); Assert.IsTrue(string.Compare(serializer.SerializeToString(), "FREQ=DAILY;COUNT=3;BYDAY=MO,WE,FR") == 0, "Serialized recurrence string is incorrect"); }
public void EVALUATE1() { iCalendar iCal = new iCalendar(); Event evt = iCal.Create<Event>(); evt.Summary = "Event summary"; // Start at midnight, UTC time evt.Start = DateTime.SpecifyKind(DateTime.Today, DateTimeKind.Utc); evt.AddRecurrence(new Recur("FREQ=MINUTELY;INTERVAL=10;COUNT=5")); List<Occurrence> occurrences = evt.GetOccurrences(DateTime.Today.AddDays(1), DateTime.Today.AddDays(2)); foreach (Occurrence o in occurrences) Assert.IsTrue(o.Period.StartTime.HasTime, "All recurrences of this event should have a time set."); }
public void RECURPARSE5() { iCalendar iCal = new iCalendar(); Event evt = iCal.Create<Event>(); evt.Summary = "Test event"; evt.Start = new Date_Time(2006, 1, 1, 9, 0, 0); evt.Duration = new TimeSpan(1, 0, 0); evt.AddRecurrence(new Recur("Every 10 minutes until 1/1/2006 9:50")); List<Occurrence> occurrences = evt.GetOccurrences( new Date_Time(2006, 1, 1), new Date_Time(2006, 1, 31)); Date_Time[] DateTimes = new Date_Time[] { new Date_Time(2006, 1, 1, 9, 0, 0), new Date_Time(2006, 1, 1, 9, 10, 0), new Date_Time(2006, 1, 1, 9, 20, 0), new Date_Time(2006, 1, 1, 9, 30, 0), new Date_Time(2006, 1, 1, 9, 40, 0), new Date_Time(2006, 1, 1, 9, 50, 0) }; for (int i = 0; i < DateTimes.Length; i++) Assert.AreEqual(DateTimes[i], occurrences[i].Period.StartTime, "Event should occur on " + DateTimes[i]); Assert.AreEqual( DateTimes.Length, occurrences.Count, "There should be exactly " + DateTimes.Length + " occurrences; there were " + occurrences.Count); }
public void RRULE43() { iCalendar iCal = new iCalendar(); DDay.iCal.Components.TimeZone tz = iCal.Create<DDay.iCal.Components.TimeZone>(); tz.TZID = "US-Eastern"; tz.Last_Modified = new DateTime(1987, 1, 1, 0, 0, 0, DateTimeKind.Utc); DDay.iCal.Components.TimeZone.TimeZoneInfo standard = new DDay.iCal.Components.TimeZone.TimeZoneInfo(DDay.iCal.Components.TimeZone.STANDARD, tz); standard.Start = new DateTime(1967, 10, 29, 2, 0, 0, DateTimeKind.Utc); standard.AddRecurrence(new Recur("FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10")); standard.TZOffsetFrom = new UTC_Offset("-0400"); standard.TZOffsetTo = new UTC_Offset("-0500"); standard.TimeZoneName = "EST"; DDay.iCal.Components.TimeZone.TimeZoneInfo daylight = new DDay.iCal.Components.TimeZone.TimeZoneInfo(DDay.iCal.Components.TimeZone.DAYLIGHT, tz); daylight.Start = new DateTime(1987, 4, 5, 2, 0, 0, DateTimeKind.Utc); daylight.AddRecurrence(new Recur("FREQ=YEARLY;BYDAY=1SU;BYMONTH=4")); daylight.TZOffsetFrom = new UTC_Offset("-0500"); daylight.TZOffsetTo = new UTC_Offset("-0400"); daylight.TimeZoneName = "EDT"; Event evt = iCal.Create<Event>(); evt.Summary = "Test event"; evt.Start = new Date_Time(2007, 1, 24, 8, 0, 0, tzid, iCal); evt.Duration = TimeSpan.FromHours(1); evt.End = new Date_Time(2007, 1, 24, 9, 0, 0, tzid, iCal); Recur recur = new Recur("FREQ=MONTHLY;INTERVAL=2;BYDAY=4WE"); evt.AddRecurrence(recur); List<Occurrence> occurrences = evt.GetOccurrences( new DateTime(2007, 1, 24), new DateTime(2007, 12, 31)); Date_Time[] DateTimes = new Date_Time[] { new Date_Time(2007, 1, 24, 8, 0, 0, tzid, iCal), new Date_Time(2007, 3, 28, 8, 0, 0, tzid, iCal), new Date_Time(2007, 5, 23, 8, 0, 0, tzid, iCal), new Date_Time(2007, 7, 25, 8, 0, 0, tzid, iCal), new Date_Time(2007, 9, 26, 8, 0, 0, tzid, iCal), new Date_Time(2007, 11, 28, 8, 0, 0, tzid, iCal) }; for (int i = 0; i < DateTimes.Length; i++) Assert.AreEqual(DateTimes[i], occurrences[i].Period.StartTime, "Event should occur on " + DateTimes[i]); Assert.AreEqual( DateTimes.Length, occurrences.Count, "There should be exactly " + DateTimes.Length + " occurrences; there were " + occurrences.Count); }
public void Bug1821721() { iCalendar iCal = new iCalendar(); iCalTimeZone tz = iCal.Create<iCalTimeZone>(); tz.TZID = "US-Eastern"; tz.LastModified = new iCalDateTime(new DateTime(1987, 1, 1, 0, 0, 0, DateTimeKind.Utc)); ITimeZoneInfo standard = new iCalTimeZoneInfo(Components.STANDARD); standard.Start = new iCalDateTime(new DateTime(1967, 10, 29, 2, 0, 0, DateTimeKind.Utc)); standard.RecurrenceRules.Add(new RecurrencePattern("FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10")); standard.OffsetFrom = new UTCOffset("-0400"); standard.OffsetTo = new UTCOffset("-0500"); standard.TimeZoneName = "EST"; tz.AddChild(standard); ITimeZoneInfo daylight = new iCalTimeZoneInfo(Components.DAYLIGHT); daylight.Start = new iCalDateTime(new DateTime(1987, 4, 5, 2, 0, 0, DateTimeKind.Utc)); daylight.RecurrenceRules.Add(new RecurrencePattern("FREQ=YEARLY;BYDAY=1SU;BYMONTH=4")); daylight.OffsetFrom = new UTCOffset("-0500"); daylight.OffsetTo = new UTCOffset("-0400"); daylight.TimeZoneName = "EDT"; tz.AddChild(daylight); IEvent evt = iCal.Create<Event>(); evt.Summary = "Test event"; evt.Start = new iCalDateTime(2007, 1, 24, 8, 0, 0, tzid); evt.Duration = TimeSpan.FromHours(1); evt.End = new iCalDateTime(2007, 1, 24, 9, 0, 0, tzid); IRecurrencePattern recur = new RecurrencePattern("FREQ=MONTHLY;INTERVAL=2;BYDAY=4WE"); evt.RecurrenceRules.Add(recur); EventOccurrenceTest( iCal, new iCalDateTime(2007, 1, 24), new iCalDateTime(2007, 12, 31), new iCalDateTime[] { new iCalDateTime(2007, 1, 24, 8, 0, 0, tzid), new iCalDateTime(2007, 3, 28, 8, 0, 0, tzid), new iCalDateTime(2007, 5, 23, 8, 0, 0, tzid), new iCalDateTime(2007, 7, 25, 8, 0, 0, tzid), new iCalDateTime(2007, 9, 26, 8, 0, 0, tzid), new iCalDateTime(2007, 11, 28, 8, 0, 0, tzid) }, null ); }
static public Event Create(iCalendar iCal) { Event evt = (Event)iCal.Create(iCal, "VEVENT"); evt.UID = UniqueComponent.NewUID(); evt.Created = DateTime.Now; evt.DTStamp = DateTime.Now; return evt; }
public void RECURPARSE1() { iCalendar iCal = new iCalendar(); Event evt = iCal.Create<Event>(); evt.Summary = "Test event"; evt.Start = new Date_Time(2006, 10, 1, 9, 0, 0); evt.Duration = new TimeSpan(1, 0, 0); evt.AddRecurrence(new Recur("Every 3rd month on the last tuesday and wednesday")); List<Occurrence> occurrences = evt.GetOccurrences( new Date_Time(2006, 10, 1), new Date_Time(2007, 4, 30)); Date_Time[] DateTimes = new Date_Time[] { new Date_Time(2006, 10, 1, 9, 0, 0), new Date_Time(2006, 10, 25, 9, 0, 0), new Date_Time(2006, 10, 31, 9, 0, 0), new Date_Time(2007, 1, 30, 9, 0, 0), new Date_Time(2007, 1, 31, 9, 0, 0), new Date_Time(2007, 4, 24, 9, 0, 0), new Date_Time(2007, 4, 25, 9, 0, 0) }; for (int i = 0; i < DateTimes.Length; i++) Assert.AreEqual(DateTimes[i], occurrences[i].Period.StartTime, "Event should occur on " + DateTimes[i]); Assert.AreEqual( DateTimes.Length, occurrences.Count, "There should be exactly " + DateTimes.Length + " occurrences; there were " + occurrences.Count); }
public void GetOccurrences1() { IICalendar iCal = new iCalendar(); IEvent evt = iCal.Create<Event>(); evt.Start = new iCalDateTime(2009, 11, 18, 5, 0, 0); evt.End = new iCalDateTime(2009, 11, 18, 5, 10, 0); evt.RecurrenceRules.Add(new RecurrencePattern(FrequencyType.Daily)); evt.Summary = "xxxxxxxxxxxxx"; iCalDateTime previousDateAndTime = new iCalDateTime(2009, 11, 17, 0, 15, 0); iCalDateTime previousDateOnly = new iCalDateTime(2009, 11, 17, 23, 15, 0); iCalDateTime laterDateOnly = new iCalDateTime(2009, 11, 19, 3, 15, 0); iCalDateTime laterDateAndTime = new iCalDateTime(2009, 11, 19, 11, 0, 0); iCalDateTime end = new iCalDateTime(2009, 11, 23, 0, 0, 0); IList<Occurrence> occurrences = null; occurrences = evt.GetOccurrences(previousDateAndTime, end); Assert.AreEqual(5, occurrences.Count); occurrences = evt.GetOccurrences(previousDateOnly, end); Assert.AreEqual(5, occurrences.Count); occurrences = evt.GetOccurrences(laterDateOnly, end); Assert.AreEqual(4, occurrences.Count); occurrences = evt.GetOccurrences(laterDateAndTime, end); Assert.AreEqual(3, occurrences.Count); // Add ByHour "9" and "12" evt.RecurrenceRules[0].ByHour.Add(9); evt.RecurrenceRules[0].ByHour.Add(12); // Clear the evaluation so we can calculate recurrences again. evt.ClearEvaluation(); occurrences = evt.GetOccurrences(previousDateAndTime, end); Assert.AreEqual(11, occurrences.Count); occurrences = evt.GetOccurrences(previousDateOnly, end); Assert.AreEqual(11, occurrences.Count); occurrences = evt.GetOccurrences(laterDateOnly, end); Assert.AreEqual(8, occurrences.Count); occurrences = evt.GetOccurrences(laterDateAndTime, end); Assert.AreEqual(7, occurrences.Count); }
public void RECURPARSE6() { iCalendar iCal = new iCalendar(); Event evt = iCal.Create<Event>(); evt.Summary = "Test event"; evt.Start = new Date_Time(2006, 1, 1, 9, 0, 0); evt.Duration = new TimeSpan(1, 0, 0); evt.AddRecurrence(new Recur("Every month on the first sunday, at 5:00PM, and at 7:00PM")); List<Occurrence> occurrences = evt.GetOccurrences( new Date_Time(2006, 1, 1), new Date_Time(2006, 3, 31)); Date_Time[] DateTimes = new Date_Time[] { new Date_Time(2006, 1, 1, 9, 0, 0), new Date_Time(2006, 1, 1, 17, 0, 0), new Date_Time(2006, 1, 1, 19, 0, 0), new Date_Time(2006, 2, 5, 17, 0, 0), new Date_Time(2006, 2, 5, 19, 0, 0), new Date_Time(2006, 3, 5, 17, 0, 0), new Date_Time(2006, 3, 5, 19, 0, 0) }; for (int i = 0; i < DateTimes.Length; i++) Assert.AreEqual(DateTimes[i], occurrences[i].Period.StartTime, "Event should occur on " + DateTimes[i]); Assert.AreEqual( DateTimes.Length, occurrences.Count, "There should be exactly " + DateTimes.Length + " occurrences; there were " + occurrences.Count); }
public void Test1() { IICalendar iCal = new iCalendar(); IEvent evt = iCal.Create<Event>(); evt.Summary = "Event summary"; evt.Start = new iCalDateTime(DateTime.SpecifyKind(DateTime.Today, DateTimeKind.Utc)); IRecurrencePattern recur = new RecurrencePattern(); evt.RecurrenceRules.Add(recur); try { IList<Occurrence> occurrences = evt.GetOccurrences(DateTime.Today.AddDays(1), DateTime.Today.AddDays(2)); Assert.Fail("An exception should be thrown when evaluating a recurrence with no specified FREQUENCY"); } catch { } }
public void TEST1() { iCalendar iCal = new iCalendar(); Event evt = iCal.Create<Event>(); evt.Summary = "Event summary"; evt.Start = DateTime.SpecifyKind(DateTime.Today, DateTimeKind.Utc); Recur recur = new Recur(); evt.AddRecurrence(recur); try { List<Period> periods = evt.Evaluate(DateTime.Today.AddDays(1), DateTime.Today.AddDays(2)); Assert.Fail("An exception should be thrown when evaluating a recurrence with no specified FREQUENCY"); } catch { } }
public void Test2() { IICalendar iCal = new iCalendar(); IEvent evt = iCal.Create<Event>(); evt.Summary = "Event summary"; evt.Start = new iCalDateTime(DateTime.SpecifyKind(DateTime.Today, DateTimeKind.Utc)); IRecurrencePattern recur = new RecurrencePattern(); recur.Frequency = FrequencyType.Daily; recur.Count = 3; recur.ByDay.Add(new WeekDay(DayOfWeek.Monday)); recur.ByDay.Add(new WeekDay(DayOfWeek.Wednesday)); recur.ByDay.Add(new WeekDay(DayOfWeek.Friday)); evt.RecurrenceRules.Add(recur); RecurrencePatternSerializer serializer = new RecurrencePatternSerializer(); Assert.IsTrue(string.Compare(serializer.SerializeToString(recur), "FREQ=DAILY;COUNT=3;BYDAY=MO,WE,FR") == 0, "Serialized recurrence string is incorrect"); }
public void Test3() { IICalendar iCal = new iCalendar(); IEvent evt = iCal.Create<Event>(); evt.Start = new iCalDateTime(2008, 10, 18, 10, 30, 0); evt.Summary = "Test Event"; evt.Duration = TimeSpan.FromHours(1); evt.RecurrenceRules.Add(new RecurrencePattern("RRULE:FREQ=WEEKLY;BYDAY=MO,TU,WE,TH")); IDateTime doomsdayDate = new iCalDateTime(2010, 12, 31, 10, 30, 0); IList<Occurrence> allOcc = evt.GetOccurrences(evt.Start, doomsdayDate); foreach (Occurrence occ in allOcc) Console.WriteLine(occ.Period.StartTime.ToString("d") + " " + occ.Period.StartTime.ToString("t")); }
static public Event Create(iCalendar iCal) { Event evt = iCal.Create<Event>(); return evt; }