Not sure if the title covers the question well, but here it comes.
I have a project with:
- A website: webforms (Aps.net 4,c#) where the user can upload files, interact with them and manually trigger some batch processing
- A classlib with all the business logic for the processing
- An app that runs on a machine at the customers location and is scheduled to upload files by SFTP to our server.
- A console app that is scheduled on the server and does the batch processing for the files that are uploaded by SFTP.
‘heavy use customers’ use the SFTP app, the others use the website.
The console app and the website both use the same classlib.
What mechanism can I use to send logging/progress information to the website or the console app without implementing two classlibs? I do not want the classlib to be aware that it is called by the console app or the website. For example they also share the same settings. etc.
Any ideas?
Events.
You could add events to the classes that perform the actual business logic in your shared lib. When something happens that requires feedback, you can raise that event in the class.
The consuming application (either the console app or the web-app) can subscribe to those events, and take the appropriate action that is specific to their platform.
A very simplyfied example:
In your console-app you can do this, for instance: