workflow or EventListener - sharepoint

We are building an extranet sharepoint portal for our clients. Each client will have a site. Total number of sites will be between 2000-3000.
I have a requirement to copy a document from a SiteCollectionA/SiteA/DocumentLibrary to another global list on another site collection when a client uploads new document.
Should i create workflow to copy the document or event listener? Client will be allowed to update document properties after the upload and these changes will have to be pushed into the global list as well.
My choice would be event listener because is much cleaner, cheaper and easier. Im not an expert with workflows, but i think it will be harder to maintain/update/re-publish workflows on 2000+ sites then an event listener.
What do you guys think?
Thanks

Definitely an event receiver, all you are doing is a simple mechanical action in response to an event.
Event receivers are much easier to develop, deploy and maintain.

Related

How to listen for Database-changes using an RestAPI from Google/Microsoft/Notion?

I am trying to integrate Google Calendar and Microsoft Todo into my Notion Workspace using NodeJS. It is quite easy to make Requests in order to create, read, update and delete data but I was wondering how I could listen for changes in the database. For instance if someone creates an event in Google Calendar, how can I directly respond to this change in Google's database by creating a new event in the Notion Database? I thought of making as many requests per minute as possible in order to notice changes as early as possible, but I do not think that is quite resource friendly.
Eventually I was also wondering if it is even possible to make a RestAPI-Server that sends out some kind of Notifications.
I hope my question is understandable.
Thank you and stay save!
They keyword you're looking for is "webhook", I don't know if Google Calendar and Microsoft Todo support webhook or not but Notion currently doesn't, learn more at https://www.reddit.com/r/Notion/comments/nd76ec/notion_api_webhooks/

Cloudant/CouchDB triggers an event by deleting a document

I am trying "update handlers" to catch create/update/delete events in IBM cloudant. It works when a document is created or updated, but not deleted. Is there any other way I can catch an event that a document is deleted and then create a document in another database to record this event? Thank you.
If you want to monitor a couchDB/Cloudant database for changes take a look at the /_changes feed: http://docs.couchdb.org/en/2.0.0/api/database/changes.html. You could implement an app that continuously monitors the feed and "logs" the desired information whenever a document is inserted, updated or deleted. For some programming languages there are libraries (such as https://www.npmjs.com/package/follow for Node.js) that make it easy to manage/process the feed.

Can i get the event about file operation on OneDrive?

As we know, we can add remote event receiver to the list. then if there is a item added or updated in this list, we can get the event send by sharepoint 2013 online.
This is the info about event in sharepoint:
[https://msdn.microsoft.com/en-us/library/Microsoft.SharePoint.SPItemEventReceiver_methods.aspx]
So can we have this kind of method in OneDrive(skydrive) too?
It means when there is a file added in the OneDrive, then my App can get this event and take some action on this file.
thanks.
The OneDrive API does not (yet!) support subscriptions to events. Please visit the OneDrive user voice and make/vote up topics that you'd like to see implemented.
To question #2 the view.changes api allows for applications to easily know which changes have happened since the application last queried OneDrive might be just what you need without subscriptions.

How to pass a value to SharePoint list event receiver?

I have a SharePoint site page with a document library web part on it, once a document is uploaded to this library, some of the library fields need to be updated according to a parameter of the page url.
I tried doing this with Event Receiver binding on the library, only to find that I cannot get the page url, or rather the parameter, in the Event Receiver. Then Session occurred to my mind, but after asking around and searching a lot, I can only get HttpContext in itemAdding but not itemAdded, what's worse, HttpContext.Current.Session always give me nulll and I'm sure I have put some value into session earlier in somewhere else.
Can someone shed some light on this, any help or advise is deeply appreciated.
SharePoint allows synchronous and asynchronous event receivers. You can get access to HttpContext and SPContext in synchronous receiver, as it runs in worker thread. Read more for accessing HttpContext and how to bind synchronous receiver programmatically.
It's a bit late but for reference I've just seen solution on this page.
It leverages custom control in master page and stores the information into HttpRuntime.Cache. Then access it from within the synchronous event.
The event receiver is not called in the page context. Therefor you can't access the page information. The only approach to this that I can see is to write custom code that prefills the values of the page before you save the item.

CQRS - how to handle new report tables (or: how to import ALL history from the event store)

I've studied some CQRS sample implementations (Java / .Net) which use event sourcing as the event store and a simple (No)SQL stores as the 'report store'.
Looks all good, but I seem to be missing something in all sample implementations.
How to handle the addition of new report stores / screens, after an application has gone in production? and how to import existing (latest) data from the event store to the new report store?
Ie:
Imagine a basic DDD/CQRS driven CRM application.
Every screen (view really) has it's own structured report store (a SQL table).
All these views get updated using handlers listening to the domain events (CustomerCreated / CustomerHasMoved, etc).
One feature of the CRM is that it can log phone calls (PhoneCallLogged event). Due to time constraints we only implemented the logging of phone calls in V1 of the CRM (viewing and reporting of who handled which phone call will be implemented in V2)
After a time running in production, we want to implement the 'reporting' of logged phone calls per customer and sales representative.
So we need to add some screens (views) and the supporting report tables (in the report store) and fill it with the data already collected in the Event Store...
That is where I get stuck while looking at the samples I studied. They don't handle the import of existing (history) data from the event store to a (new) report store.
All samples of the EventRepository (DomainRepository) only have a method 'GetById' and 'Add', they don't support getting ALL aggregate roots in once to fill a new report table.
Without this initial data import, the new screens are only updated for newly occurred events. Not for the phone calls already logged (because there was no report listener for the PhoneCallLogged event)
Any suggestions, recommendations ?
Thanks in advance,
Remco
You re-run the handler on the existing event log (eg you play the old events through the new event handler)
Consider you example ... you have a ton of PhoneCallLoggedEvents in your event log. Take your new Handles and play all the old events through it. It is then like it has always been running and will just continue to process any new events that arrive.
Cheers,
Greg
For example in Axon Framework, this can be done via:
JdbcEventStore eventStore = ...;
ReplayingCluster replayingCluster = new ReplayingCluster(
new SimpleCluster("replaying"),
eventStore,
new NoTransactionManager(),
0,
new BackloggingIncomingMessageHandler());
replayingCluster.startReplay();
Event replay is an area that is not completely documented and lacks mature tooling, but here are some starting points:
http://www.axonframework.org/docs/2.4/event-processing.html#d5e1852
https://groups.google.com/forum/#!searchin/axonframework/ReplayingCluster/axonframework/brCxc7Uha7I/Hr4LJpBJIWMJ
The 'EventRepository' only contains these methods because you only need them in production.
When adding a new denormalization for reporting, you can send all event from start to you handler.
You can do this on your development site this way :
Load your event log to the dev site
Send all events to your denormalization handler
Move your new view + handler to your production site
Run events that happened inbetween
Now you're ready

Resources