Hi,
I got several problems with the RecurrenceRule.
To check this - I use the following Pattern:
DTSTART:20140807T113000Z
DTEND:20140807T123000Z
RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=TU,WE,TH
My need is to find the first two occurrences of an appointment.
I tried this with the following code:
The problem "MaximumCandidates" is for daily, weekly, monthly one day.
So in this case if I check on thuresday I get only one occurrence.
Is there a working way to limit the outcome to a fix number of results?
On thing I found when checking (with your source code) how the things work internally is a bug in SetEffectiveRange
Here the code FIRST checks if the private fields are in the correct order (_effectiveEnd <_effectiveStart).
AFTER that the values are assigned.
So I could call this with wrong parameters - and the next call (with correct parameters) would fail!
You should check the parameters not the private fields (and for sure not BEFORE they are assigned).
Last not least I found a thread with an "isolated assembly" containing only the recurrence rule classes.
http://www.telerik.com/forums/sql-reporting-display-all-recurring-appointments
Is there an "up to date" version of this assembly - and how is it licensed?
Manfred
I got several problems with the RecurrenceRule.
To check this - I use the following Pattern:
DTSTART:20140807T113000Z
DTEND:20140807T123000Z
RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=TU,WE,TH
My need is to find the first two occurrences of an appointment.
I tried this with the following code:
RecurrenceRule rR;
if
(RecurrenceRule.TryParse(rRule,
out
rR)) {
rR.MaximumCandidates = 2;
//rR.SetEffectiveRange(pAppointment.Start.AddMinutes(-1), pAppointment.End.AddDays(400));
foreach
(DateTime dtCheck
in
rR.Occurrences) {
if
(dtCheck > pAppointment.Start) {
//next occurrence found
The problem "MaximumCandidates" is for daily, weekly, monthly one day.
So in this case if I check on thuresday I get only one occurrence.
Is there a working way to limit the outcome to a fix number of results?
On thing I found when checking (with your source code) how the things work internally is a bug in SetEffectiveRange
Here the code FIRST checks if the private fields are in the correct order (_effectiveEnd <_effectiveStart).
AFTER that the values are assigned.
So I could call this with wrong parameters - and the next call (with correct parameters) would fail!
You should check the parameters not the private fields (and for sure not BEFORE they are assigned).
Last not least I found a thread with an "isolated assembly" containing only the recurrence rule classes.
http://www.telerik.com/forums/sql-reporting-display-all-recurring-appointments
Is there an "up to date" version of this assembly - and how is it licensed?
Manfred
7 Answers, 1 is accepted
0
ManniAT
Top achievements
Rank 2
answered on 07 Aug 2014, 09:03 AM
And one more problem - I have a recurrence starting today.
Then I change End by to a date before today...
Now I have an orphan in the database with the following recurrence :
DTSTART:20140807T140000Z
DTEND:20140807T150000Z
RRULE:FREQ=DAILY;UNTIL=20140805T000000Z;INTERVAL=1;BYDAY=MO,TU,WE,TH,FR,SA,SU
I think either validation should avoid such a scenario (not allow saving) or the rule should result in deleting the appointment (not sure if this is a good idea).
Then I change End by to a date before today...
Now I have an orphan in the database with the following recurrence :
DTSTART:20140807T140000Z
DTEND:20140807T150000Z
RRULE:FREQ=DAILY;UNTIL=20140805T000000Z;INTERVAL=1;BYDAY=MO,TU,WE,TH,FR,SA,SU
I think either validation should avoid such a scenario (not allow saving) or the rule should result in deleting the appointment (not sure if this is a good idea).
0
Hello Manfred,
Straight to your questions:
1. I would suggest limiting the occurrence number to 2 as shown below:
//code behind
2. Could you please explain a bit more about the bug you have found with our Recurrence Rule SetEffectiveRange method. Listing a steps in order to replicate the problem would be very helpful.
3. I would suggest reviewing this blog post that demonstrates how to find all occurrences for a specific recurrence rule using SQL Server.
4. I would like to clarify that in general the recurrence rule is generated by creating an appointment. In order to have a recurrence rule which has an end date before the start date you first need to create such appointment. The RadScheduler advanced form offer in-built validation that prevents creating an appointment with end date before the start date. You can test this validation with our RadScheduler demos.
Regards,
Boyan Dimitrov
Telerik
Straight to your questions:
1. I would suggest limiting the occurrence number to 2 as shown below:
//code behind
string
rule =
"DTSTART:20140807T113000Z\r\nDTEND:20140807T123000Z\r\nRRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=TU,WE,TH\r\n\r\n"
;
RecurrenceRule rR;
if
(RecurrenceRule.TryParse(rule,
out
rR))
{
IEnumerable<DateTime> occr = rR.Occurrences;
List<DateTime> firstTwoOccur =
new
List<DateTime>();
int
count = 0;
foreach
(DateTime dtCheck
in
rR.Occurrences)
{
firstTwoOccur.Add(dtCheck);
count++;
if
(count == 2)
{
break
;
}
}
}
2. Could you please explain a bit more about the bug you have found with our Recurrence Rule SetEffectiveRange method. Listing a steps in order to replicate the problem would be very helpful.
3. I would suggest reviewing this blog post that demonstrates how to find all occurrences for a specific recurrence rule using SQL Server.
4. I would like to clarify that in general the recurrence rule is generated by creating an appointment. In order to have a recurrence rule which has an end date before the start date you first need to create such appointment. The RadScheduler advanced form offer in-built validation that prevents creating an appointment with end date before the start date. You can test this validation with our RadScheduler demos.
Regards,
Boyan Dimitrov
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0
ManniAT
Top achievements
Rank 2
answered on 12 Aug 2014, 08:37 AM
[quote]Boyan Dimitrov said:Hello Manfred,
Straight to your answers:
1. I would suggest limiting the occurrence number to 2 as shown below:
From "my side" I know how to do it.
The problem is how to get these two results.
The reason - if I hav a rule wich starts 2 years ago (old appointment) and I want to get a recurrence for now / today and tomorrow I'll never get this result since Max is set to 3000 by default.
I could change Max to something but this (the reason why I posted) doesn't work as expected since it count's the "candidates".
And I have no chance to set Start without setting an end.
Create an appointment at 2012/1/1 hourly every 3 hours.
And then - find the occurrence for today (lets say 7 AM and the following one).
The same code should be able to retrive the current (and the next) from an appointment with yearly recurrence rule.
For the first example your code will fail!
Of course - I could set start and end - but to when?
Let's say "max possible distance between two occurrences" which would be Today (always my start) plus a buffer of two years.
Two years is neede since I need the "next two" - and if the last was yesterday it would be almost 2 years (minus one day).
But this range used with an hourly rule would result in several thousand results.
Call SetRange with End BEFORE start - this will (faulty) work!
AFTER that call do it again with correct parameters (End after Start) - you get an excpetion.
Just take a look at the source code - it has just 5 lines or so :)
3. I would suggest reviewing this blog post that demonstrates how to find all occurrences for a specific recurrence rule using SQL Server.
I know the post (that's why I asked) - my questions are:
Is there an "up to date version" (maintained version) of the assembly used there?
What is the licensing of this assembly?
4. I would like to clarify that in general the recurrence rule is generated by creating an appointment. In order to have a recurrence rule which has an end date before the start date you first need to create such appointment. The RadScheduler advanced form offer in-built validation that prevents creating an appointment with end date before the start date. You can test this validation with our RadScheduler demos.
I'm not creating an appointment with end before start!
Steps to reproduce:
Create a recurring appointment (daily - start today - never end).
Save it.
Open it again and change the recurrence End-By to Yesterday.
No validation checks this - and that's the problem!!!!!
I attached a screenshot using your sample.
Thanks for your detaild answers so far
Manfred
Straight to your answers:
1. I would suggest limiting the occurrence number to 2 as shown below:
From "my side" I know how to do it.
The problem is how to get these two results.
The reason - if I hav a rule wich starts 2 years ago (old appointment) and I want to get a recurrence for now / today and tomorrow I'll never get this result since Max is set to 3000 by default.
I could change Max to something but this (the reason why I posted) doesn't work as expected since it count's the "candidates".
And I have no chance to set Start without setting an end.
Create an appointment at 2012/1/1 hourly every 3 hours.
And then - find the occurrence for today (lets say 7 AM and the following one).
The same code should be able to retrive the current (and the next) from an appointment with yearly recurrence rule.
For the first example your code will fail!
Of course - I could set start and end - but to when?
Let's say "max possible distance between two occurrences" which would be Today (always my start) plus a buffer of two years.
Two years is neede since I need the "next two" - and if the last was yesterday it would be almost 2 years (minus one day).
But this range used with an hourly rule would result in several thousand results.
2. Could you please explain a bit more about the bug you have found with our Recurrence Rule SetEffectiveRange method. Listing a steps in order to replicate the problem would be very helpful.
AFTER that call do it again with correct parameters (End after Start) - you get an excpetion.
Just take a look at the source code - it has just 5 lines or so :)
3. I would suggest reviewing this blog post that demonstrates how to find all occurrences for a specific recurrence rule using SQL Server.
I know the post (that's why I asked) - my questions are:
Is there an "up to date version" (maintained version) of the assembly used there?
What is the licensing of this assembly?
4. I would like to clarify that in general the recurrence rule is generated by creating an appointment. In order to have a recurrence rule which has an end date before the start date you first need to create such appointment. The RadScheduler advanced form offer in-built validation that prevents creating an appointment with end date before the start date. You can test this validation with our RadScheduler demos.
I'm not creating an appointment with end before start!
Steps to reproduce:
Create a recurring appointment (daily - start today - never end).
Save it.
Open it again and change the recurrence End-By to Yesterday.
No validation checks this - and that's the problem!!!!!
I attached a screenshot using your sample.
Thanks for your detaild answers so far
Manfred
0
Accepted
Hello Manfred,
I would like to clarify that your observations are absolutely correct.
1. I have managed to fix this problem by using a custom class that inherits the RecurrenceRule class and override the GetOccurrenceStart method. In the following code snippet I modifed the weekly recurrence rule in order to find only two occurrence appointments for August 2014 for an appointment that starts in 2002.
//code behind
2. Indeed I replicated the problem but the validation method is not virtual method so it could not be override. I have logged this issue in our system for fixing.
3. You can safely use it in your project. This attachment is provided for public use.
4. Indeed there is no validation for this case. I logged this problem in our system as well for fixing.
Thank you for your feedback and time spent for finding those problems with our control.
Regards,
Boyan Dimitrov
Telerik
I would like to clarify that your observations are absolutely correct.
1. I have managed to fix this problem by using a custom class that inherits the RecurrenceRule class and override the GetOccurrenceStart method. In the following code snippet I modifed the weekly recurrence rule in order to find only two occurrence appointments for August 2014 for an appointment that starts in 2002.
//code behind
public
class
ModifiedWeeklyRecurrenceRule : RecurrenceRule
{
protected
override
DateTime GetOccurrenceStart(
int
index)
{
return
this
.EffectiveStart.Add(
new
TimeSpan(index, 0, 0, 0));
}
}
...
string
rule =
"DTSTART:20020807T113000Z\r\nDTEND:20020807T123000Z\r\nRRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=TU,WE,TH\r\n\r\n"
;
RecurrenceRule rR;
if
(ModifiedWeeklyRecurrenceRule.TryParse(rule,
out
rR))
{
rR.SetEffectiveRange(
new
DateTime(2014, 8, 1),
new
DateTime(2014, 8, 30));
rR.Range.MaxOccurrences = 2;
foreach
(DateTime dtCheck
in
rR.Occurrences)
{
}
}
2. Indeed I replicated the problem but the validation method is not virtual method so it could not be override. I have logged this issue in our system for fixing.
3. You can safely use it in your project. This attachment is provided for public use.
4. Indeed there is no validation for this case. I logged this problem in our system as well for fixing.
Thank you for your feedback and time spent for finding those problems with our control.
Regards,
Boyan Dimitrov
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0
ManniAT
Top achievements
Rank 2
answered on 15 Aug 2014, 09:15 AM
Hi Boyan,
thank you for your detailed answer.
Finally (something like) this was also my approach.
In your code the end in "SetEffectiveRange" call) depends on the type of occurrence.
That was my "problem".
So I added a method that takes a start and a number of occurrences.
This methds adds a specific period to the start parameter to get the end of the effective range.
Which is one day for daily, one year for...
Of course I had to add this to every subclass of Occurrence - but anyhow it works now.
Manfred
thank you for your detailed answer.
Finally (something like) this was also my approach.
In your code the end in "SetEffectiveRange" call) depends on the type of occurrence.
That was my "problem".
So I added a method that takes a start and a number of occurrences.
This methds adds a specific period to the start parameter to get the end of the effective range.
Which is one day for daily, one year for...
Of course I had to add this to every subclass of Occurrence - but anyhow it works now.
Manfred
0
ManniAT
Top achievements
Rank 2
answered on 15 Aug 2014, 09:24 AM
A last few words about point 3.
This assembly is extremely helpful.
Not only for SQL Server but also for cases like mine where I build a windows service which checks schedules and run jobs.
I would be a good idea if this assembly could be
a.) maintained
--for an example if the bug I mentioned is fixed, or some other changes in the code are made
--the assembly should also be rebuilt / deployed
b.) available at some popular place (product downloads or so)
Just my two cents
Manfred
This assembly is extremely helpful.
Not only for SQL Server but also for cases like mine where I build a windows service which checks schedules and run jobs.
I would be a good idea if this assembly could be
a.) maintained
--for an example if the bug I mentioned is fixed, or some other changes in the code are made
--the assembly should also be rebuilt / deployed
b.) available at some popular place (product downloads or so)
Just my two cents
Manfred
0
Hello Manfred,
Thank you for the valuable feedback.
We will do our best to update the assembly used constantly so it is consistent with the most recent version of the product.
Please let us know if you need further assistance.
Regards,
Plamen
Telerik
Thank you for the valuable feedback.
We will do our best to update the assembly used constantly so it is consistent with the most recent version of the product.
Please let us know if you need further assistance.
Regards,
Plamen
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.