No Occurence being generated


#1

Hi,

I am new to this product (Aspose.iCalendar v1.2.1.0) but I get the gist of it. I have my rules and patterns saving appropriately, but when I try to use the GenerateOccurrences method I come up with a count of 0 dates each time.

Here is a sample pattern I am using

DTSTART:20060418T144347\r\nRRULE:FREQ=DAILY;UNTIL=20060623T144347Z;BYDAY=MO,TU,WE,TH,FR;BYHOUR=14;BYMINUTE=43

Not sure what I am doing wrong here. I want this rule to start on April 18th and finish on June 23rd. It should run only on weekdays at 14:32. When I use the following code I get zero dates returned:

private DateTime GetNextExecuteDate(string pattern)
{
RecurrencePattern pat = new RecurrencePattern(pattern);
DateCollection dates = pat.GenerateOccurrences();
return (dates.Count > 0?dates[0]:DateTime.Parse("1/1/1970")); // assume jan 1 1970 is null date
}

Any ideas??

Cheers,
Brett


#2

Hmm, I think it is a licensing issue (forgot to put SetLicense in play). However now I am getting nowhere using the license:

I am putting this at the top of each method that calls any of the iCalendar classes:

Aspose.iCalendar.License license = new Aspose.iCalendar.License();
license.SetLicense("Aspose.iCalendar.lic");

The .lic file is in the root of the project, and I have also tried to put it in various folders or the Resources.

Any ideas on this?

Cheers (again),

Brett


#3

Well, I got it to work with a bit of senseless coding. What I did was imbed the .lic file into the Resources. Then I used the following code to read the license infomation from the Resource and convert it into a stream (the only input usable for the SetLicense method unless the file pathing works).

Aspose.iCalendar.License license = new Aspose.iCalendar.License();
ResourceManager rm = new ResourceManager("CMSAlerts.Properties.Resources", Assembly.GetExecutingAssembly());
Byte[] bytes = (byte[])rm.GetObject("Aspose_iCalendar");
MemoryStream mst = new MemoryStream(bytes);
license.SetLicense((Stream)mst);

Surely there is an easier way I am missing??

Cheers,
Brett


#4

This explains http://www.aspose.com/wiki/default.aspx/Aspose.iCalendar/Licensing.html

Putting the license into the project folder does not work. It has to be in the same folder as Aspose.iCalendar.dll or your project executable for the pathless approach to work.

Also you can embed the license in your project and then calling Setlicense just with the name (without the path) will find it in the resources.

After that there is of course an option to specify explicit path.