Aspose calendar and using it in a service - processor usage high

Hi there,
My application is a windows service that runs various complicated processing tasks at given times of the day/night including collecting and processing emails. I am using your icalendar component to dynamically generate appointments so that I can see if my windows service should be running a task at any given time. I use the following function to get my list of appointments from a table where a typical rule looks like:-

DTSTART:20101122T095512
RRULE:FREQ=MINUTELY;UNTIL=99991231T235959Z;INTERVAL=5

Calculating this takes quite a while along with 100% processor time. Am I doing this the right way and is there a better way to use the calendar control?


///
/// Returns the Available appointments as a working list.
///
///
public static List<CustomAppointment> SelectAppointments(DateTime startDate, DateTime endDate, Guid userId)
{

DataSet working = SelectAppointments(userId, startDate, endDate);
List<CustomAppointment> workingList = new List<CustomAppointment>();
if (working != null && working.Tables.Count > 0)
{
foreach (DataRow row in working.Tables[0].Rows)
{
CustomAppointment appointment = new CustomAppointment();
// DALhelper.FillObjectFromDataRow(row, appointment);
try
{
appointment = (CustomAppointment)DALhelper.FillObjectFromDataRow(row, appointment);

// Now fill in the recurrance part
RecurrencePattern pattern = RecurrencePattern.FromiCalendar(row[“RecurrenceInfo”].ToString());

foreach (RecurrenceRule rule in pattern.RRules)
appointment.RRules.Add(rule);

DateCollection dt = appointment.GenerateOccurrences(startDate, endDate);

if (dt.Count > 0)
workingList.Add(appointment);
}
catch (System.Exception ex)
{
LoggingHelper.LogError(“Problem with reading appointment”, ex.ToString());
}
}

}

return workingList;

}

The custom appointment class looks like the following:-

using System;
using Aspose.iCalendar;
namespace PrimaryCareSubmissions.Applications.Helpers.BO.Scheduler
{

[Serializable]
public class CustomAppointment : Aspose.iCalendar.RecurrencePattern
{
public int AppointmentId { get; set; }
public int AppointmentType { get; set; }
public int ModuleId { get; set; }
public int Status { get; set; }
public string Subject { get; set; }
public string Description { get; set; }
public long Label { get; set; }
public string Location { get; set; }
public bool AllDay { get; set; }
public string ReminderInfo { get; set; }
public Guid UserId { get; set; }
public int ResourceID { get; set; }
public int OwnerID { get; set; }
public string AdditionalParams { get; set; }
}

}


This message was posted using Page2Forum from C# Demos - Aspose.Network Demos
Hi,

Thank you for inquiry.

jbaggaley:
Hi there,
DTSTART:20101122T095512
RRULE:FREQ=MINUTELY;UNTIL=99991231T235959Z;INTERVAL=5

Calculating this takes quite a while along with 100% processor time. Am I doing this the right way and is there a better way to use the calendar control?

The above rule would generate dates starting from 2010-Nov-22 to 9999-Dec-31, with an interval of 5 minutes. This would generate really huge number of dates, which would obviously take a lot of CPU time.

Could you please make sure that you really want to generate such huge number of appointment?

You might consider using a small range by specifying a smaller date/time value in UNTIL part of the pattern.