IMediaContentDownloadedEvent problems
I'm noticing that if I visit /Sitefinity/Content/Documents the IMediaContentDownloadedEvent is triggering about 20 times (after the webservice callback completes)...the only data it's giving me are userid and the Url of the documents.
This should be a bug...nobody is downloading anything just browsing that page to see the documents...
...also...the event triggers twice when downloading an item from the backend?
Like
- Click Actions->Download
- Downloading->Downloaded
- Downloading->Downloaded
(same data in the event object)
Why would that be?
Also what's the diff between the IMediaContentDownloadingEvent, IMediaContentDownloadedEvent, and IMediaContentDownloadEvent...they all seem the same (the event object anyway)?
Hi,
IMediaContentDownloadingEvent is raised before a media content item (e.g. image) is downloaded and IMediaContentDownloadedEvent is raised after the operation has completed. Both inherits from IMediaContentDownloadEvent.
We will investigate if this is a bug, however please note that it is possible to have problems using these events because they are in development and there is still no documentation how to use them.
Actually they are documented, rather extensively...in fact the code I'm using is FROM that document :)
http://www.sitefinity.com/documentation/documentationarticles/developers-guide/deep-dive/sitefinity-event-system/list-of-events/libraries-events
Hello Steve,
Please excuse us for the introduced confusion, I believe what Stefani was trying to communicate is that the specification for how the events behave could be subject to change, as we're trying to address any usability issues we discover.
As for the difference between them, it's mainly when we subscribe to the particular event handler. In LibraryHttphandler we have:
if
(outputItem !=
null
)
var downloadingEvent = factory.CreateMediaContentDownloadingEvent(outputItem, request, url);
EventHub.Raise(downloadingEvent,
true
);
this
.SendCachedResponse(request, response, outputItem);
var downloadedEvent = factory.CreateMediaContentDownloadedEvent(outputItem, request, url);
EventHub.Raise(downloadedEvent,
false
);
This is the line I used in the event to debug
public
static
void
LibrariesEventHandler(IMediaContentDownloadEvent eventInfo, DownloadType type)
Debug.WriteLine(DateTime.Now +
" "
+ type.ToString() +
" "
+ eventInfo.Title);
Hello Steve,
Thnak you for the additional input.
No , that makes perfect sense, I was initially surprised as I interpreted:
Click Actions->Download
- Downloading->Downloaded
- Downloading->Downloaded
as Download ->Downloading->Downloaded->Downloading->Downloaded, which was definitely an incorrect behavior.
Regarding the double firing in first place, can you please let me know where exactly in your Global.asax you're subscribing to the Events?
Please ntoe that if you're doing it in Bootstrapper_Initialized you need to make a check whether the command for which this handler fires is "Bootstrapped", otherwise it would pass twice through your handler subscription, and consecutively execute the handlers twice,a s it registers tow handlers.
Long story short doing:
protected
void
Application_Start(
object
sender, EventArgs e)
Bootstrapper.Initialized += Bootstrapper_Initialized;
void
Bootstrapper_Initialized(
object
sender, Telerik.Sitefinity.Data.ExecutedEventArgs e)
if
(e.CommandName ==
"Bootstrapped"
)
EventHub.Subscribe<IMediaContentDownloadingEvent>(evt => LibrariesEventHandler(evt));
EventHub.Subscribe<IMediaContentDownloadedEvent>(evt => LibrariesEventHandler(evt));