Using the Component and Persist the Resultset

Hello,

I am currently evaluating your product and I have a couple of questions:

1. I am trying to play around with the Recurrence component and I cannot figure out how it works. See the code below:


Dim dly As New Aspose.Recurrence.Daily
dly.EndDate = New DateTime(2003, 11, 30)
dly.StartDate = System.DateTime.Now
Dim aryDates As Aspose.Recurrence.DateArray
dly.GenerateOccurrences(dly.StartDate, dly.EndDate, aryDates)
Dim dt As DateTime
For Each dt In aryDates
Debug.WriteLine(dt.Date)
Next


Can someone please give me some direction?

2. How could I persist this information to a database? Should I use the component to generate the occurences and then store that information in a database?


Please Help!

Hi,

Your code is fine, just two small changes you need to make to get it to work:

1. You need to create a new aryDates before passing into GenerateOccurrences function like this:
Dim aryDates As NEW Aspose.Recurrence.DateArray
dly.GenerateOccurrences(dly.StartDate, dly.EndDate, aryDates)

2. The evaluation version is limited to generate occurrences only for dates 01/Jan/2000 - 30/Jun/2000. So you you will not see any occurrences generated for year 2003 like in your code.

-------------
Regarding persistence.

It depends what you want to persist in the database.

At the moment you can save the recurrence pattern itself into XML format using .Net XML serialization. What gets saves is pattern specific details and any excemptions to the pattern (the occurrence dates themselves are not stored).
Once you saved the pattern into XML, you can store it as a string anywhere including a database.
Later, you can reload the pattern object and easily generate all its occurrences.
This allows you, for example to design a user interface that lets user create and configure recurrence patterns, save it into some document and read it back later.
See Aspose.Recurrence.Demos.VB.WinForms demo project does just that.

//To save object to a file in XML format.
Daily recur = new Daily(5);
XmlSerializer serializer = new XmlSerializer(recur.GetType());
StreamWriter writer = new StreamWriter(fileName);
serializer.Serialize(writer, recur);

//To load object from a file
StreamReader reader = new StreamReader(fileName);
recur = serializer.Deserialize(reader) as Daily;


If you needs are different and you want to actually store dates of the occurrences, then it is very simple. You just go throug the array of occurrence dates calculated for you and save each date into your own recordset.


For more details about Aspose.Recurrence and .Net XML serialization see thisdiscussion.

Thanks for your help.