<p>I am currently working on a project with specific requirements.  A brief overview of these are as follows:  </p>

<ul>
<li>Data is retrieved from external webservices</li>
<li>Data is stored in SQL 2005</li>
<li>Data is manipulated via a web GUI</li>
<li>The windows service that communicates with the web services has no coupling with our internal web UI, except via the database.</li>
<li>Communication with the web services needs to be both time-based, and triggered via user intervention on the web UI.</li>
</ul>

<p>The current (pre-pre-production) model for web service communication triggering is via a database table that stores trigger requests generated from the manual intervention.  I do not really want to have multiple trigger mechanisms, but would like to be able to populate the database table with triggers based upon the time of the call.  As I see it there are two ways to accomplish this.</p>

<p>1) Adapt the trigger table to store two extra parameters.  One being "Is this time-based or manually added?" and a nullable field to store the timing details (exact format to be determined).  If it is a manaully created trigger, mark it as processed when the trigger has been fired, but not if it is a timed trigger.<br>
<em>or</em><br>
2) Create a second windows service that creates the triggers on-the-fly at timed intervals.</p>

<p>The second option seems like a fudge to me, but the management of option 1 could easily turn into a programming nightmare (how do you know if the last poll of the table returned the event that needs to fire, and how do you then stop it re-triggering on the next poll)</p>

<p>I'd appreciate it if anyone could spare a few minutes to help me decide which route (one of these two, or possibly a third, unlisted one) to take.</p>

[{'answer_id': 3275, 'author': 'Vaibhav', 'author_id': 380, 'author_profile': 'https://Stackoverflow.com/users/380', 'pm_score': 0, 'selected': False, 'text': "<p>The way I see it is this.</p>\n\n<p>You have a Windows Service, which is playing the role of a scheduler and in it there are some classes which simply call the webservices and put the data in your databases.</p>\n\n<p>So, you can use these classes directly from the WebUI as well and import the data based on the WebUI trigger.</p>\n\n<p>I don't like the idea of storing a user generated action as a flag (trigger) in the database where some service will poll it (at an interval which is not under the user's control) to execute that action.</p>\n\n<p>You could even convert the whole code into an exe which you can then schedule using the Windows Scheduler. And call the same exe whenever the user triggers the action from the Web UI.</p>\n"}, {'answer_id': 3282, 'author': 'ZombieSheep', 'author_id': 377, 'author_profile': 'https://Stackoverflow.com/users/377', 'pm_score': 0, 'selected': False, 'text': '<p>@Vaibhav</p>\n\n<p>Unfortunately, the physical architecture of the solution will not allow any direct communication between the components, other than Web UI to Database, and database to service (which can then call out to the web services).  I do, however, agree that re-use of the communication classes would be the ideal here - I just can\'t do it within the confines of our business*</p>\n\n<p>*Isn\'t it always the way that a technically "better" solution is stymied by external factors?</p>\n'}, {'answer_id': 5101, 'author': 'brendan', 'author_id': 225, 'author_profile': 'https://Stackoverflow.com/users/225', 'pm_score': 3, 'selected': True, 'text': '<p>Why not use a SQL Job instead of the Windows Service?  You can encapsulate all of you db "trigger" code in Stored Procedures.  Then your UI and SQL Job can call the same Stored Procedures and create the triggers the same way whether it\'s manually or at a time interval.</p>\n'}]
['https://Stackoverflow.com/questions/3272', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/377/']