I'm switching my app's calendar from Telerik Scheduler to jQuery fullcalendar. I'm storing recurring events in the db using iCal RRULEs.
The question is, when someone drags an event to a new date, how can I update the RRULE so each subsequent occurrence is bumped by the same time delta?
I've looked at DDay.iCal and I see the method
RecurrencePattern.IncrementDate(ref iCalDateTime dt, int Interval)
That sounds like what I'm looking for, but there are no details in the documentation.
Any suggestions?
Thanks so much,
Michael
RecurrencePattern.IncrementDate is not really meant to be used outside of the library itself. Perhaps I'll look into making it protected/private (if it can be done without breaking the overall functionality).
Generally, all you need to do is change the Start of the event by the delta you've determined (let's say 1 day, for example), and every recurrence in that event will also be changed by that amount.
If you don't want the entire event to be changed by the delta, but only a specific occurrence, then there's other ways to handle that.
Could you clarify perhaps with an example event, the delta you want to move it, and the expected result?
Related
I am wanting to read a specific message from an EventHub.
I'm using the EventHubConsumerClient and the ReadEventsFromPartitionAsync using a partitionId, and Offset I have.
client.ReadEventsFromPartitionAsync(partitionId, EventPosition.FromOffset(offset), cancellationSource.Token);
The issue I have is, that despite the Offset and Partition ID being correct, I'm not getting the messages I expect back.
Context
I working on something to validate that messages are being properly processed in a distributed system.
Source Event Hub -> Processor Function -> Destination Event Hubs.
I read both ends (hubs) and validate messages arrive where they should, if they don't, look up the message from the Source Event Hub, (by partitionId and offset matching against a message ID).
It is the messages I'm looking up that don't appear to have message IDs or offset IDs I expect.
UPDATE:
I was mistaken in my recall of the defaults for EventPosition and referenced docs for the wrong SDK package below. By default, EventPosition.FromOffset is inclusive. (src)
The creation pattern in the question would include the event at the provided offset. If you're not seeing the event returned, then the offset would seem to be incorrect.
Original Answer (incorrect):
The EventPosition that you're building is non-inclusive and will not include the event at that offset, but rather start at the next available event. Using the following overload should target the event that you're looking for:
EventPosition.FromOffset(offset, true)
It looks as if the summary in the docs doesn't do a great job of calling attention to the default; I'll take a follow-up to make that more clear.
The issue was due to the incorrect offsets being provided from the AZ Function binding metadata.
Using a batch of one - correct.
Using a batch of more than one, completely wrong offsets, sequences etc.
Updated the eventhubs package (preview..) and it works fine :/
I am working on creating an iCal feed for our application. Things are going well. I have everything working except exceptions. For example when you schedule a recurring event and need to cancel a day, I am using the EXDATE tag in the feed and that is working fine for removing a scheduled occurrence.
The issues is if you have a recurring event that starts today # 2pm and recurrs 5 times. In our application the user can change any one of those weeks to start # 3pm if needed. How to I specify that in the iCal feed?
I have been looking at the documentation, but must be missing something...
Thanks a bunch!!
Drowsy is on the right track.
The UID's MUST match so that the adjusment is recognised as
belonging to the original event.
The Recurrence Id matches it to the instance of the recurring sequence that is being modified.
This is because of course one might be changing the date and time
as well as other changes and one doesn't want the original
instance there generated by the recurring spec, as well as the
modification.
And yes finally the sequence id must be there so
that one knows the sequence or layer of modifications in case
there are several.
For example - here's a dump of what google calendar generates if you modify a recurring event.
BEGIN:VEVENT
DTSTART;TZID=Australia/Sydney:20140325T084000
DTEND;TZID=Australia/Sydney:20140325T101000
DTSTAMP:20140327T060506Z
UID:vu2d4gjdj4mpfuvas53qi32s7k#google.com
RECURRENCE-ID;TZID=Australia/Sydney:20140325T083000
CREATED:20131216T033331Z
DESCRIPTION:
LAST-MODIFIED:20140327T060215Z
LOCATION:
SEQUENCE:1
STATUS:CONFIRMED
SUMMARY:test Event
TRANSP:OPAQUE
END:VEVENT
BEGIN:VEVENT
DTSTART;TZID=Australia/Sydney:20140128T083000
DTEND;TZID=Australia/Sydney:20140128T100000
RRULE:FREQ=WEEKLY;UNTIL=20141208T213000Z;BYDAY=TU
DTSTAMP:20140327T060506Z
UID:vu2d4gjdj4mpfuvas53qi32s7k#google.com
CREATED:20131216T033331Z
DESCRIPTION:
LAST-MODIFIED:20140222T101012Z
LOCATION:
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY:Test event
TRANSP:OPAQUE
END:VEVENT
I believe as long as you generate a record with a RECURRENCE-ID based on the original time, and using the original UID you should be able to set the DTSTART and DTEND values for a single instance. You would need to increment the SEQUENCE too. That should trigger updates on client software.
I suppose it should be done with IMediaSeeking SetPositions, but I don't know how define parameters inside.
There is no dedicated method to step back in DirectShow (as such existing for stepping forward). Yes you can use IMediaSeeking::SetPositions, however but note that it is not DirectShow itself who implement it, but actual underlying filters, so support for re-positioning depends on filters and implementation, and may be limited to, for example, stepping through key frames (splice points) only. DirectShow.NET is onyl a wrapper over DirectShow and it also does not add anything on top what DirectShow offers for stepping.
IBasicVideo *pBasicVideo=NULL;//Interface to the Ibasic Video
HRESULT hr;
REFTIME pavgfrt=0;//Get the reftime variable
REFERENCE_TIME pnowrt=0;//Get the reference time variable
pBasicVideo->get_AvgTimePerFrame(&pavgfrt);
pBasicVideo->get_AvgTimePerFrame(&pavgfrt);//Get the avg time per frame in seconds
pSeek->GetCurrentPosition(&pnowrt);//Get the current time in the unit of 100 nanoseconds
REFERENCE_TIME temp=pnowrt;//store it in a temp variable
REFERENCE_TIME temp1=(REFERENCE_TIME)(pavgfrt*10000000);//convert avg time into the format of current time
pnowrt=temp+temp1;//Add to framestep forward and subtract to framestep backward
pSeek->SetPositions(&pnowrt,AM_SEEKING_AbsolutePositioning, NULL,AM_SEEKING_NoPositioning);//Set the seeking position to the new time
pnowrt=0;//Reset the time variable
This works for me in C++. Wrapping this code in C# may not be difficult for you. Hope this helps.
If I understood correctly Facebook externalhit scrapes page every 24h for new data. Since my users are going to share dynamic images on Facebook,the image should not be cached, because it would change much more then once every 24h.
Does externalhit ignores something like:
context.Response.Cache.SetCacheability(HttpCacheability.NoCache);
Is there some way to force it not to cache image? I know using linter clears cache but it would be silly to instruct my users to run linter every time they want to see a changed image instead of cached one.
I assume some script to lint urls programmatically would be agianst their TOS?
Use a different URL for each image, and have the like button point to that URL - that's basically the only way to do this - otherwise you'd retroactively be changing the details of the thing which was liked - and the fields are locked after X likes and won't be updated ( I think X = 100)
I guess it's not possible! Just to accept answer.
Can anyone find a constant in the .NET framework that defines the number of days in a week (7)?
DateTime.DaysInAWeek // Something like this???
Of course I can define my own, but I'd rather not if it's somewhere in there already.
Update:
I am looking for this because I need to allow the user to select a week (by date, rather than week number) from a list in a DropDownList.
You could probably use System.Globalization.DateTimeFormatInfo.CurrentInfo.DayNames.Length.
I think it's ok to harcode this one. I don't think it will change any soon.
Edit: I depends where you want to use this constant. Inside the some calendar related algorithm it is obvious what 7 means. On the other hand sometimes named constant make code much more readable.
Try this:
Enum.GetNames(System.DayOfWeek).Length
If you look at the IL code for Calendar.AddWeeks you will see that Microsoft itself uses a hardcoded 7 in the code.
Also the rotor source uses a hardcoded 7.
Still, I would suggest to use a const.
I used this:
public static readonly int WeekNumberOfDays = Enum.GetNames(typeof(DayOfWeek)).Length;
I don't believe there is one. TimeSpan defines constants for the number of ticks per milli/second/minute/hour/day, but nothing at the level of a week.
I ran a query across the standard libraries for symbols (methods/constants/fields/etc) containing the word 'Week'. Nothing came back. FYI, I ran this query using ReSharper.
I'm not sure what exactly you're looking for, but you can try DateHelper (CODE.MSDN). It's a library I put together for typical date needs. You might be able to use the week methods or the List methods. method list
Edit - no more MSDN code, not on GitHub as part of lib: https://github.com/tbasallo/toolshed
Do you mean calendar weeks or just common weeks?
Obviously, there are calendar weeks that might be shortrer than seven days. The last calendar week of the year is usually shorter, and depending on your definition of calendar week, the first week might be shorter as well.
In that case, I'm afraid you will have to roll out your own week length function. It's not really hard to do with the DateTime class, I did it before, if you need more help let me know.
GregorianCalendar has AddWeeks(1) which will add 7 days to a date.