What format is the recurrence pattern stored in?

What format is the recurrence pattern stored in?

For example, how is the recurrence control repopulated if the user needs to edit the scheduled task?

I saw that one output is an array of dates. But what if the recurrence doesn’t end. I’m assuming there has to be some recurrence pattern similar to CRON that is used.

Help me out here. I like the concept, just need to make sure it will plug into our back end.

Toby

Ho tojorush,

I think you are talking about two different things here:
1. How to describe and store the recurrence pattern.
2. Occurrence dates generated by the recurrence pattern.

Aspose.Recurrence is not responsible for storing recurrence patterns, but you can serialize any recurrence pattern using standard .Net serialization and therefore “store” a recurrence pattern to later load it back. This is what Aspose.Recurrence.Demos.WinForms application does.

Each recurrence pattern is represented by a class, for example Aspose.Recurrence.Daily for a daily recurrence pattern and the class has properties to specify details of the pattern.

The way to obtain dates of occurrences for the pattern is to call GenerateOccurrences() method which requires Start and End dates. From my experience a user is never interested in receiving ALL occurrences of a pattern, because of the possible open ended pattern, in particular.

Here comes another interesting distinction: range of the recurrence pattern (which sometimes can be open ended) versus range of dates you are interested in to get occurrences for.

Therefore, the user always needs to specify Start and End dates for the range he is interested in. For example, if you display a calendar for the current month to the user, just specify dates of the beginning and end of the month you are displaying and you will get the occurrences that happen during this period. The requested range can be outside, inside or ovrlapping the recurrence pattern range and you will get only occurrences of the pattern that fall into the requested range.

So the output of the recurrence pattern is always into an array of dates.

Let me know if you think Aspose.Recurrence needs to support some interoperability with other recurrence pattern formats like CRON you mentioned. Give more details what you need and we might be able to add it to Aspose.Recurrence.








Thanks for the info. I guess my real question is storing and retrieving the recurrence pattern. To give a little more context to what we are doing, let me elaborate on the application. We have a reporting application that needs to have reports generated and emailed in a background process. We need to allow users to create some pretty flexible schedules as to when those reports should be ran.

Currently, (the way I understand it) to use your product, we would have to store a recurrence pattern as a serialized Aspose object. From an architecture standpoint, this is very short sighted and dangerous. If in 5 years we want to use a different method, all we would have is serialzed Aspose objects to work with.

What I think would be a much cleaner approach is to have the object output a standardized recurrence pattern string. This is where CRON could play in. I’m not sure how much you (or others reading this post) know about CRON, so I am copying some info below (see end of post).

The idea would be to have a method that would create a CRON tab entry based on the selected dates/times. The reverse would also be needed. Given a CRON tab entry, populate the Aspose object.

I do not claim to know the Aspose object inside and out, so my examples above may not make perfect sense. But I hope I am conveying my idea clearly.

Thanks,
Toby



NOTE: The is there just as a reference. It would not be output from the Aspose object.

The CRONTAB file:
Each line of CRONTAB has the following structure:



Position: Values:
Minute 0-59
Hour 0-23
Day 1-31
Month 1-12
Day of week 0-6 (0=Sunday, 1=Monday, …, 6=Saturday)

Instead of minute, hour, day, month or day of week it’s also possible to specify a . A * represents all possible values for that position (e.g. a * on 2nd position is the same as specifying all the possible values for hour)

It’s also possible to specify several values separated by commas: e.g. if you want a command to be executed every 10th minute so you can specify 0,10,20,30,40,50 for minute. A range of values can be specified with a -: e.g. value 0-12 for hour -> every hour a.m.

Examples
execute a command every minute
* * * * * CheckForNewFiles.exe

execute the program backup.bat every hour
0 * * * * backup.bat

do a backup every day at 0.30 p.m.
30 12 * * * backup.bat

start a backup every tuesday at midnight
0 0 * * 3 backup.bat

scan drive c for viruses on the 1st of every month at 2.45 p.m.
45 14 1 * * scan c:

copy some files every half hour
0,30 * * * * xcopy c:\docs*.
y:\users /s

copy a file every hour (a.m.) only on weekdays
0 0-12 * * 1-5 copy important.txt e:

Yes, I think I understand your concerns now.

We had recurrence pattern stored in XML format in a project that was a precursor to Aspose.Recurrence, but that was our own format for recurrence patterns. I’ll look at what other well known or standard formats for storing descriptions of recurrence patterns are available. I think, it would be preferable to use something well known format.

Here is the example of our own XML format we used to store the patterns:













Although simple, format used by CRON does not seem to be most efficient way to express what Aspose.Recurrence can do because:

1. Aspose.Recurrence allows more flexibility when specifying recurrence patterns, like 2nd Tuesday of every 4th Week or so. It also allows skip and change exemptions to occurrences. It also allows to specify end of the recurrence pattern range in three ways.

2. CRON allows minute and hour scheduling while Aspose.Recurrence’s minimal unit is a day, although time in that day can still be specified.


So when we decide what format to store recurrence patterns in, I will add this to Aspose.Recurrence with pleasure.

Please let me know:
1. Do you need to run your reports more than once per day? If yes, then do you need to run your reports at particular times during the day or periodically at certain intervals or both?
2. Will you be happy with recurrence patterns stored in our XML format as in example above or you know a better established format for this purpose.




I will add capability to Aspose.Recurrence to save recurrence objects in the following format:

<?xml version="1.0" encoding="utf-8"?>





















This will be available in Aspose.Recurrence 1.1. Due date Oct 20th.

Romank,
What you have here should get us pretty close. Can I assume that your objects will output this format as well as use it for a constructor? i.e. Is this XML string what I can store in my DB? When I pull it from the DB I can pass it to the ??? contsructor and the control will load off of that.

Please let me know:
1. Do you need to run your reports more than once per day? If yes, then do you need to run your reports at particular times during the day or periodically at certain intervals or both?
– Yes, some reports could be scheduled to run more than once a day. It will be sufficient for our needs to just run at specific time. We don’t need to schedule at intervals during a day.

2. Will you be happy with recurrence patterns stored in our XML format as in example above or you know a better established format for this purpose.
– The recuurence pattern should get us pretty close. It would be nice to have a format that is aligned to some standard. But I don’t know of one other than CRON or AT. HOwever, those don’t cover everything that your control supports.

Thanks for your responsiveness.

Toby

  1. Yes, Aspose.Recurrence 1.1 will be able to store and load its objects into/from XML format. To load and store objects you would use .Net XML serialization like this:

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

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


    2. I’ve found iCalendar format on the net. It is actually described in an RFC and there is a corresponding XML schema for it. The format is quite complex and much more than recurrence. I think some calendar applications use this format to exchange data.

    The recurrence part of iCalendar seems to be powerfull enough to capture everything what Aspose.Recurrence can do and more including events that happen more than once a day.

    There is a good user-friendly description on how to build recurrence patterns in iCalendar available here: http://tipi.sourceforge.net/doc/recur/indexs01.html.

    I will be considering introducing support for export/import of recurrence patterns in iCalendar format in the next version, Aspose.Recurrence 1.2. It will probably include support for all recurrence patterns that can be described using iCalendar.









Following up on this, I have the same issues as Toby, requiring to save recurrence patterns for each task in a SQL database. (seems somewhat of an oversight in the design of the control!). The current 1.1 control serializes to a very large Xml file - I got 8k for one recurrence pattern, in a pretty unintelligible format.

Have you seen the vCalendar spec - see http://www.imc.org/pdi/ - this encapsulates recurrence patterns in a very short string (typically less than 20 characters).

Brian Smith

Hi Brian,

Yes we plan to support vCalendar (iCalendar) format in the next version (available sometime end of March).
Further version will also support time of day patterns (hours, minutes etc) as opposed to days only.

Please elaborate more on what you think is an oversight in the design of the control.

What is the status on the new version? The last post I saw said it should have been released in March. Is it now ready?

Thanks
Toby

We’ve started work on iCalendar patterns just several weeks ago. New estimated delivery is sometime in August.

Aspose.iCalendar that supports time patterns is available.