|
|
Comments and Discussions
|
|
 |
|

|
Hi Doug,
First of all, thanks a lot for this project, it's really useful.
I intend to use your library to consume .ics calendars (published to web from Outlook 2007) and display the events on a Calendar control on an aspx page, all in C# code-behind.
It would be nice if you could update this article (or create a new one) with the newest version on DDay.iCal (version 0.80).
In particular, could you describe what is the Occurence object relative to the Event object? Which one should I loop through to get my list of events on each day (when my DayRenderEventHandler gets fired)?
Thanks again,
Emmanuel
|
|
|
|

|
Funny you mention an updated article. I'm currently making some major changes to DDay.iCal and I'll update this article when that new version is released (likely to be version 0.90).
What you want to do is call Event.GetOccurrences(...) and use the list of Occurrence objects returned in your DayRenderEventHandler to show the different events.
Let me know if you have more questions.
Thanks,
-Doug
|
|
|
|

|
Hi Doug,
Right now, I'm calling _Calendars.GetOccurrences<Event>(...) which returns me a list of Event Occurences. Then, for each day, I loop through each Occurrence object from the list. Which date should I compare with my DayRender date? occ.Period.StartTime.Local.Date or occ.Component.Start.Local.Date? Not quite sure what's the difference between these two...
Thanks again,
Emmanuel
|
|
|
|

|
Use occ.Period.StartTime.Local.Date. This represents the current occurrence date/time, whereas occ.Component.Start.Local.Date represents the date/time of the original component. For example, if you schedule an event that starts on March 14th, 2010 at 8:00 AM, and recurs every week on the same day/time. evt.GetOccurrences(...) would return the following dates (contained in Occurrence.Period):
3/14/2010 8:00 AM
3/21/2010 8:00 AM
3/28/2010 8:00 AM
4/4/2010 8:00 AM
etc.
You'll notice on each of these Occurrence objects, the 'Component' points back to the original event (March 14th, 2010 at 8:00, and recurs every week).
Hope that clears it up a bit.
Let me know if you have more questions.
Thanks,
-Doug
|
|
|
|

|
Got it now.
Thanks for the explanation, it's very much appreciated.
I'll keep an eye on the next version release (any expected date?).
Emmanuel
|
|
|
|
|

|
I just updated this article for the new release of DDay.iCal. Let me know what you think.
Thanks,
-Doug
|
|
|
|

|
thanks for this. I have been looking into something like this all day...
my big question is: can ics files support outlook tasks as well as outlook calendar appointments?
The reason i ask is that everyone is concerned about synchronizing with the outlook calendar, but not many about setting new tasks!
Also, can we limit this to a 1-way feed? From a custom web calendar to outlook but not the reverse? I suppose it would be a setting within the custom web calendar.
|
|
|
|

|
Yes, iCalendar support Events as well as Todo items.
As far as the 1-way feed, that would be a setting in Outlook, or in the web server that distributed the iCalendar.
And sorry about the late response, just saw this
-Doug
|
|
|
|

|
Hi Doug,
Thank you for such a wonderful post. It helped me a lot.
Can you also give me an idea how to parse vcards.
Thanks
Panna
|
|
|
|

|
Panna,
I'm glad you've found DDay.iCal useful - don't forget to use the most recent version (now 0.71) from SourceForge.net[^], if you haven't done so already.
As far as vcards go, I haven't really given it much thought. In theory, it's a very close format to iCalendar, so I could share some of the code base and create a library for it. I'll give some thought to it, and if I have the time and use for it, I'll put it together.
In the meantime, there are several articles on CodeProject about vcard. Just search for "vcard c#".
-Doug
|
|
|
|

|
I'm having difficulties getting the Event.OccursOn to work properly. I have an event that starts at the 17th at 4PM Mountain Standard Time and runs for 2 hours. This converts to 11PM UTC to 1AM UTC the next day. Event.OccursOn evals to true irregardless of which of the two days (the 17th or 18th) I pass in as a UTC date. So when iterating thru the dates (as in the console app), that same event is now listed for both days, but the date is displayed using "evt.Start.Local.ToShortTimeString()". This is very confusing because is shows a two hour event starting at 4PM the 17th and 4PM the 18th as well. It should only display for the 17th. I'm having to manually check each Start Date and End Date with my own logic to really tell if that event is for the 17th or the 18th. Or am I confused here?
|
|
|
|

|
Yes, if you want to be truly accurate, you cannot convert times to UTC. You need to use time zones instead.
-Doug
|
|
|
|

|
Can you explain how to use TimeZones? I'm consuming someone else's iCalendar output, so I can't change it there.
|
|
|
|

|
Unfortunately, if you're consuming someone else's iCalendar output, you cannot "fix" the accuracy of the calendar. When an event is recorded that it happened from 11:00 PM to 1:00 AM (regardless of the UTC designation), then it "occurred" on both days. This information is important to preserve, as it maintains the accuracy of the calendar.
So - you might need to use another method other than "OccursOn" to build your calendar.
Let me know if you have more questions,
-Doug
|
|
|
|

|
Doug, just gotta say, _THANK YOU_ for the extraordinarily quick responses to my questions!
|
|
|
|

|
No problemo, let me know if you have more questions.
-Doug
|
|
|
|

|
Also, does this TimeZone issue affect the way I pass in dates into the Event.Evaluate() function?
|
|
|
|

|
I am having hard time attaching a Word 2007 document file to event object.
Here is my code
...
...
DDay.iCal.iCalendar iCal = new DDay.iCal.iCalendar();
DDay.iCal.Components.Event iCalEvent = iCal.Create<DDay.iCal.Components.Event>();
Binary[] binAttachList = new Binary[1];
binAttachList[0] = new Binary();
binAttachList[0].AddParameter("X-FILENAME", activity.Attachment.DisplayName);
binAttachList[0].AddParameter("VALUE", "BINARY");
binAttachList[0].SetEncoding(EncodingType.Base64);
binAttachList[0].Data = Read(@“C:\Temp\MyFile.doc”);
iCalEvent.Attach = binAttachList;
...
...
private static byte[] Read(string fileName)
{
using (FileStream reader = new FileStream(fileName, FileMode.Open))
{
byte[] binaryData = new byte[reader.Length];
reader.Read(binaryData, 0, (int)reader.Length);
return binaryData;
}
}
The file does get attached, but if I open it in Office Word again it doesn’t open.
What am I doing wrong? Could you please help me solve this problem?
|
|
|
|

|
This problem has been fixed in the development version of the code, and will be included in the next release.
Thanks,
-Doug
|
|
|
|

|
Thanks for this Article/Software package. It looks like it will help me accomplish a goal of getting Outlook Calendars viewable through our Intranet.
This example gives an option to show data for the current day, and for the next 7. I'd like to use the ASP.NET Calendar Object to give users an option to choose a date in the past/future to view. Idealy I'd like to have a Monthly view that would show Events for all 30-31 days, for any month in the future.
I'd like to emulate the Outlook interface as closely as possible. Can anybody point me in the right direction?
Thanks,
Tommy
|
|
|
|

|
Hi,
Thanks for creating a great icalendar class library. I have one quick question. I'm parsing iCalendar files and some VEVENTS have DESCRIPTION items and some don't. If I try and get the DESCRIPTION from a VEVENT that doesn't have a value defined I get the following error message:
Unhandled Exception: System.NullReferenceException: Object reference not set to
an instance of an object.
at DDay_iCal_TEST.Program.Main(String[] args) in C:\...\Program.cs:line 57
Press any key to continue . . .
Here's line 57:
strEventDescription = evt.Description.ToString();
Do you have any suggestions on how I can handle situations where some VEVENTS have items like DESCRIPTION and some don't?
Thanks.
|
|
|
|

|
Hi,
i'm trying to convert palm calendar into iCalendar equivalent (for a HotSync conduit), and i meet some difficulties in the use of FrequencyOccurrence for recurrent events, using a DaySpecifier object embedded in the ByDay property of a RecurrencePattern object. For example (record is my palm event object):
RecurrencePattern recPattern = new RecurrencePattern();
recPattern.ByDay.Add(new DaySpecifier(record.StartTime.DayOfWeek, FrequencyOccurrence.First));
Here is my problem: it seems that FrequencyOccurrence enumeration doesn't contain a Fourth statement:
public enum FrequencyOccurrence
{
None = -2147483648,
ThirdToLast = -3,
SecondToLast = -2,
Last = -1,
First = 1,
Second = 2,
Third = 3,
}
which is neccessary if the day of the event appears five times in the month.
Thank you for you great work !!
|
|
|
|

|
When I create an alarm in an Todo, I get an exception in Serializer.
How to create an alarm with DateTime set ?
Thanks.
|
|
|
|

|
First, thanks for the grat job.
Second, is supportted the net framework 1.1?
Thanks a lot.
|
|
|
|

|
Sorry for the delay in answering. No, the lowest version of the framework supported is .NET 2.0. Also, the Compact Framework is not supported, though this may be a feature that could be added in the future.
|
|
|
|

|
Are there any examples written in VB? Has anyone converted example 5 into VB at all?
|
|
|
|

|
Hi,
thanks exactly what I have been looking for.
Just a question :
Here is some samples on save ical into sql database.
but there is no one to load an ical whit data (string) stored in sql.
Do I have to create a temporaly ics file whit the serialised data in sql before load it ?
thanks again
David.
|
|
|
|

|
Douglas,
Can you kindly provide us some sample code to read the iCalText from the database. I can store my calendar with events using Serializer class in the database, as suggested by you in your previous message, but when I try to read it from the database using either "iCalendar.LoadFromStream" or "serializer.Deserialize" methods I get the following error
antlr.MismatchedTokenException: expecting "CRLF", found ' '
serializer.Deserialize expects TextReader as parameter and I use the following to read string into textreader
TextReader trMyCal = new StringReader(str_iCal);
iCalendar.LoadFromStream expects Stream object as parameter and I use the following to initialize my Stream object
Stream myStreamCalText = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(str_iCal));
I suspect the new line characters are getting replaced with 2 empty spaces when being store in the database. I tried to replace " " string in my str_iCal with "\r\n" but that does not work either
I am storing serializer.SerializeToString() in nText field of SQL 2005 database.
Thanks for the good work. I appreciate your help
-Rakesh
|
|
|
|

|
Great work -- I'm glad I didn't have to write this.
One suggestion, though: add GetRecurrences(start, end|timespan) & GetRecurrences(date) methods that perform the Evaluate and return an enumeration of the recurrences within that period in order (eg by ascending start datetime & descending duration). This would greatly reduce code in very common scenarios.
-----
Keith J. Farmer [MSFT:VC#/DLinq]
|
|
|
|

|
Thanks!
That's a good idea - one that many people have noted. Methinks I'll add it to the next major release I actually like the GetRecurrences() methodology. Anyhow, thanks for the note.
Regards,
-Doug
|
|
|
|

|
This article and your code are both great! I am planning to use your library to schedule some jobs and I want to store the events in SQL Server. I have seen the thread were you showed someone how to serialze and store the calendar in a DB. My needs are different: I need to poll the calendar and find events that fit within a small timespan to kick-off jobs. The db will be polled on a timer and I am concerned about performance. I think that defining a db schema that mirrors the iCal schema and storing each scheduled event as a record (or several records if needed) will ease the querying of the data. The only time I would need to structure the data in ICS format is when a user wants to export their scheduled jobs to their personal calendar client. Do you think that creating a db schema based on your library/iCal/ICS is the right way to go?
|
|
|
|

|
Christopher,
Yes, I would use the ICS format for scheduled jobs, but I see no need to duplicate the ICS format in the database. Really, all you'd need to do is detect changes in your ICS file (via some sort of hash, or by using the iCalendar's LastModified property), and then re-evaluate your recurrences whenever the iCalendar changes.
From my perspective, all you'd need to do is store a list of Date/Times when the event recurs, the iCalendar where the event is stored, and the UID of the event, in a recurrence table in the database. Then, in another database table, you can store the actual iCalendar text. When querying the recurrence table, and finding an event that needs some action taken, you can then load the corresponding iCalendar and take action based on the event.
So, when the iCalendar file changes, you'd clear out the recurrences in your recurrence table in the database, and repopulate it via the iCalendar file. Of course, you'll only want to populate a given period in the future, and will periodically need to calculate future occurrences (once monthly, perhaps?)
Anyhow, that's what I'd do.
Let me know if you have more questions, or if you'd like me to clarify further.
Thanks,
-Doug
|
|
|
|

|
RE: "all you'd need to do is store a list of Date/Times when the event recurs, the iCalendar where the event is stored, and the UID of the event, in a recurrence table in the database"
Yes, that is the direction that I have been going in. Thanks!
On another note, is there any XML support in your library? I don't see anything. Part of what I am working on requires a web service where iCal data will be used by the web methods. I vaguely remember seeing an XSD somewhere for iCal but don't remeber if it was a standard or an individual's implementation. I could write a schema myself, but would prefer a standard and would like it to work easily with your library. Any thoughts?
Thanks,
Chris
-- modified at 9:12 Tuesday 7th August, 2007
|
|
|
|

|
Chris,
Sorry in the delay in answering.
There is currently no support for an XML format in DDay.iCal, however, I have been putting a significant amount of effort into abstracting the serialization mechanisms in DDay.iCal to support any type of format (namely, xCal). There has been enough demand for an xCal format to move this forward. The only problem is that I'm short on time these days. It may take several months to get the xCal format built into DDay.iCal. I'll try to get this done ASAP.
Thanks,
-Doug
|
|
|
|

|
One option is to BASE64 encode the iCalendar, so it will be XML-compliant. Also, I've been working on the xCal standard for DDay.iCal, so I'm hoping it will be complete within the next month or so. Anyhow, it will be complete once it passes all of the unit tests.
Thanks,
-Doug
|
|
|
|

|
Hi!
Seems that you've put the xml-compliance on hold. It's a pity, it would have been very useful and would also make your project more "complete".
Any news regarding this? Will you keep developing this project? Can we expect any updates in the near future?
And thanks for a very nice article and project! Good work!
|
|
|
|

|
Hi,
Yes, I've had so many other projects that are keeping my attention that I haven't had a chance to push forward the xCal serialization. This is still on the slate, as it would be useful in many scenarios. I am still working on the project, albeit slowly. The major direction of DDay.iCal currently is in development of iCalendar validation. See http://icalvalid.wikidot.com/[^].
If you have suggestions of directions to take the project, or feature requests, please use the SourceForge.net project page[^.
Thanks!!
-Doug
|
|
|
|

|
Hello!
Very good!!!
Can I use Icalendar on windows mobile?
or else, is there any ical's free version for windows mobile?
Thank you for your response
Céline
|
|
|
|

|
Sorry about the wait - I've answered this question before in the SourceForge forums, but I thought I'd answer here also, to save people time.
No, DDay.iCal does not currently support the .NET Compact Framework. I've thought about supporting this in the future, but this does not fit into my plans for the near future.
Thanks,
-Doug
|
|
|
|

|
How can I generate the ical file dynamically and send it to the users browser for download?
Great project! This code has really helped me.
thanks.
|
|
|
|

|
Yes, you sure can.
You can serialize the iCalendar to the output stream of your web page. All you'd need to do is make sure you set the mime type to "application/calendar", and it should behave properly.
Thanks,
-Doug
(Sorry about the delay in answering)
|
|
|
|

|
Very helpful for learning iCalendar format. Thanks. By the way, do you have any plan for next release for can create/modify the schedule..?
|
|
|
|

|
Thanks!
I'll be writing another article in the next several weeks that describes how to create/modify items. DDay.iCal is already capable of this, though. If you download the full DDay.iCal package from SourceForge, there are some examples of adding/modifying items to calendars.
If you have any other questions, please let me know.
-Doug
|
|
|
|

|
Very nice! You get my 5.
--
My sites for smart .NET developers:
DayPilot - Open-source Outlook-like calendar control for ASP.NET
DotLucene - The fastest open source fulltext search engine for .NET
MenuPilot - Open-source task menu for ASP.NET 2.0
Seekafile Server - Flexible open-source search server
DotNetFirebird
|
|
|
|

|
Hi, firstly, gr8 article.
However, I would like to save the iCal information for every user of my app in a SQL 2000 database. Can you provide me with the basic information on how to go about it. Or have anyy links that have a tut.
I've checked the project's website & wikipedia. Didnot find any tut on how to do this.
Thnx 4 the wonderful article.
|
|
|
|

|
Thanks!
First of all, I'll try to get my next article out quickly, which talks about more advanced concepts like serialization and customization. I'm also working on some in-depth documentation and tutorials for my web site.
Anyway, that said, here's how I would do it:
First, include the DDay.iCal.Serialization namespace:
using DDay.iCal.Serialization; Then, you can do something like the following:
iCalendar iCal = new iCalendar();
Event evt = iCal.Create<Event>();
evt.Summary = "My event summary";
evt.Start = DateTime.Now;
iCalendarSerializer serializer = new iCalendarSerializer(iCal);
string iCalendarString = serializer.SerializeToString();
SqlConnection connection = new SqlConnection("...connectionstring...");
SqlCommand cmd = new SqlCommand(@"
INSERT INTO myTable(Username, iCalendarString)
VALUES (@uid, @str)", connection);
cmd.Parameters.Add("@uid", SqlDbType.VarChar);
cmd.Parameters.Add("@str", SqlDbType.VarChar);
cmd.Parameters["@uid"].Value = ...username...;
cmd.Parameters["@str"].Value = iCalendarString;
try
{
connection.Open();
cmd.ExecuteNonQuery();
connection.Close();
}
catch(Exception ex)
{
... catch errors ...
}Let me know if you have any more questions or problems,
-Doug
|
|
|
|

|
Thnx 4 the quick reply Doughlas,
I think this should work. My initial worry was the structure of the table(s) in case I wanted to save the .ics file in a database. Mapping all objects to fields & doing tht correctly was my biggest worry.
Kinda busy this week, but'll definitely start work on this by monday.
I was planning a calendar/to-do/events framework @ an enterprise level where there is one enterprise calendar (common for the entire office), every user can create his/her personal appointments/events/to-do lists and has the ability to send a selected set of events to other users (lets say a manager to his team, detailing the target dates for the entire year).
Will let U know as I proceed.
Thnx again for the help.
|
|
|
|

|
First off thanks for the great library.
I am sort of hijacking this thread because my question has a lot to do with SQL Server. In this example you posted you are writing the iCalendar to the database. My question is how to retrieve it back out correctly? The only ways I see of loading the iCalendar is from the filestream. Is there a way of getting the text back out of the database and then creating the calendar object from that?
|
|
|
|
 |
|
|
General News Suggestion Question Bug Answer Joke Rant Admin
|
This article describes the steps to load and view iCalendars in your program by using the DDay.iCal library
| Type | Article |
| Licence | BSD |
| First Posted | 11 Mar 2007 |
| Views | 125,546 |
| Downloads | 1,150 |
| Bookmarked | 113 times |
|
|