Hi all,
The use case that I am triying to replicate is that we have some events and these can be daily/weekly/monthly/yearly recurring. So I decided to use the calendar & Scheduling component as it provided the recurrence option. When I tested the daily and weekly recurrended options it worked perfectly but to my surprise when trying to get the events recurring every month or year the trouble started.
Even tought I am using the RecurrenceFrequency.Monthly as my frecuency rule, as we can see from the image it still seem to put it as a daily recurrence. Same happens when the RecurrenceFrequency.Yearly option is used. Here the code used:
foreach (Evento evento in this.ListaEventosAgenda)
{
EventData eventoNuevo = new EventData() {StartDate=evento.fechaInciio,EndDate=evento.fechaFin,Title=evento.titulo,LeadBorderColor = Color.FromHex(evento.colorCategoria),ItemBackgroundColor=Color.White,
Id=evento.id,idOrg=evento.idOrg,idCategoria=evento.idCategoria,imageUrl=evento.fotoUrl,Detail=evento.descripcion,IsAllDay=evento.isAllDay,recurrenciaAnual= evento.recurrenciaAnual,recurrenciaMensual=evento.recurrenciaMensual,
recurrenciaSemanal=evento.recurrenciaSemanal,recurrenciaDiaria=evento.recurrenciaDiaria, categoria=evento.categoria,Color = Color.FromHex(evento.colorCategoria)
};
//StartDate: evento.fechaInciio,endTime: evento.fechaFin,eventText: evento.titulo,leadColor: Color.FromHex("59B6B8"),itemColor: Color.White,
//detalles: evento.descripcion, id: evento.id,imageUrl: evento.fotoUrl, IsAllDay: evento.isAllDay
RecurrenceRule recurrenceRule = null;
if (evento.recurrenciaDiaria)
{
//var recurrencePattern = new RecurrencePattern(new int[] { }, RecurrenceDays.WeekDays, RecurrenceFrequency.Daily, 1, null, null);// { MaxOccurrences = 37 };
//recurrenceRule = new RecurrenceRule(recurrencePattern);
recurrenceRule = new RecurrenceRule(new RecurrencePattern()
{
Frequency = RecurrenceFrequency.Daily,
});
eventoNuevo.RecurrenceRule = recurrenceRule;
}
else if (evento.recurrenciaSemanal)
{
//var recurrencePattern = new RecurrencePattern(new int[] { }, RecurrenceDays.WeekDays, RecurrenceFrequency.Weekly, 7, null, null);// { MaxOccurrences = 37 };
recurrenceRule = new RecurrenceRule(new RecurrencePattern()
{
Frequency = RecurrenceFrequency.Weekly,
});
try
{
eventoNuevo.RecurrenceRule = recurrenceRule;
}
catch (Exception error)
{
Debug.WriteLine(error.Message); ;
}
}
else if (evento.recurrenciaMensual)
{
var a = eventoNuevo.StartDate.DayOfWeek;
//var recurrencePattern = new RecurrencePattern(new int[] { }, RecurrenceDays.WeekDays, RecurrenceFrequency.Monthly, 30, null, null);// { MaxOccurrences = 37 };
recurrenceRule = new RecurrenceRule(new RecurrencePattern()
{
Frequency = RecurrenceFrequency.Monthly,
});
eventoNuevo.RecurrenceRule = recurrenceRule;
}
else if (evento.recurrenciaAnual)
{
//var recurrencePattern = new RecurrencePattern(new int[] { }, RecurrenceDays.WeekDays, RecurrenceFrequency.Daily, 365, null, null);// { MaxOccurrences = 37 };
recurrenceRule = new RecurrenceRule(new RecurrencePattern()
{
Frequency = RecurrenceFrequency.Yearly,
});
eventoNuevo.RecurrenceRule = recurrenceRule;
}
this.Events.Add(eventoNuevo);
}