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