This project is a reference example of the Exago BI Scheduler Queue extensibility feature. This project should be modified, reviewed, and tested for compatibility prior to implementing into a production environment.
This is free for all Exago Inc. clients and prospective clients to use for any legal purpose, to modify, and to share; without accreditation.


The remainder of this README walks through how to set up the project. The following are prerequisites:
*   Microsoft Visual Studio, with NuGet
*   Microsoft SQL Server based database

For assistance, please file a services ticket at https://support.exagoinc.com/hc/en-us/requests/new

1.  Use the provided SQL in "New-Database-Setup.sql" to create the necessary database tables.

2.  Open the "ExagoExtensibility.sln" project file in Visual Studio.
    a.  Update the reference path for "WebReportsApi.dll" to the ./bin folder of your Exago installation.
    b.  Make sure that the reference path for "SQLUtils.dll" is to the included Resources folder (NOT the Exago ./bin folder).
	c.  Optional (Windows Only) -- Uncomment the lines in the Scripts\StartService and StopService scripts to automatically stop and start the scheduler service on project build.
		Update the references in the Scripts\StartService.bat and Scripts\StopService.bat to your scheduler service name (Default is "eWebReportsScheduler_ExagoScheduler")
    d.  Build the project.

3. Add the following lines to the Exago installation's "appSettings.config" file, between <appSettings></appSettings>:
    <add key="tnSchedulerJobs" value="dbo.SchedulerJobs" />
	<add key="sqUpdateReports" value="True" />
	<add key="sqMaxExecutionMinutes" value="1440" />
	<add key="sqWriteLog" value="False" />
	
	For tnSchedulerJobs appsetting, change the value to reflect the database table and corresponding schema that will store scheduler jobs for the SchedulerQueue. 
	For sqUpdateReports appsetting, change the value to reflect if report updates should be pushed to existing schedules.
	For sqMaxExecutionMinutes appsetting, change the value to reflect the amount of time in minutes where jobs should be reset to 'Ready' if 'Running' when flushed or a scheduler service is started.
	For sqWriteLog appsetting, change the value to True to enable logging for Scheduler Queue calls from the UI.  
	
4. Add the following lines to the Exago installation's "web.config" file, directly above <system.web>. Change the CAPITALIZED text to the connection settings for your folder management database and scheduler queue database:
    <connectionStrings>
		<add name="SchedulerQueueDatabaseConnection" connectionString="Server=SERVERNAME;Database=ExagoSchedulerQueue;User ID=USERID;Password=PASSWORD;Trusted_Connection=False;" providerName="System.Data.SqlClient" />
    </connectionStrings>


5. Add the following lines to the Exago installation's "web.config" file, between <assemblyBinding></assemblyBinding>:
    <dependentAssembly>
        <assemblyIdentity name="SQLUtils" publicKeyToken="80f40c942314817c" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-1.0.0.0" newVersion="1.0.0.0" />
    </dependentAssembly>
    <dependentAssembly>
        <assemblyIdentity name="SQLUtils" publicKeyToken="80f40c942314817c" culture="neutral" />
        <bindingRedirect oldVersion="1.0.0.1-1.0.1.1" newVersion="1.0.1.1" />
    </dependentAssembly>

6. Open the Exago Administration Console.
    Add the following Parameters, with default settings:
        userId
        companyId
    
    Scheduler Settings: 
		Custom Queue Service: assembly=PATH_TO_EXTENSIBILITY_PROJECT\bin\Debug\ExagoSchedulerQueue.dll;Class=ExagoExtensibility.SchedulerQueue
		
7. In the Exago API, set values for the Parameters userId and companyId.

8. For each Scheduler Service:
    a. Add the <queue_service> setting in "eWebReportsScheduler.xml" with: assembly=PATH_TO_EXTENSIBILITY_PROJECT\bin\Debug\ExagoSchedulerQueue.dll;Class=ExagoExtensibility.SchedulerQueue
    b. Add the following lines in eWebReportsScheduler.exe.config in the Scheduler's install directory. 
		1) In the <configSections> add the following tag: 
			<section name="connectionStrings" type="System.Configuration.ConnectionStringsSection, System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" requirePermission="false"/>
		2) In its own section directly below <configSections> add the following and change the CAPITALIZED text to the connection settings for your scheduler queue database:  
			<connectionStrings>
				<add name="SchedulerQueueDatabaseConnection" connectionString="Server=SERVERNAME;Database=ExagoReports;User ID=USERID;Password=PASSWORD;Trusted_Connection=False;" providerName="System.Data.SqlClient" />
			</connectionStrings>
		3) Add the following lines between <appSettings></appSettings>: 
			<add key="tnSchedulerJobs" value="dbo.SchedulerJobs" />
			<add key="sqWriteLog" value="False" />
			<add key="sqUpdateReports" value="True" />
			
			For tnSchedulerJobs appsetting, change the value to reflect the database table and corresponding schema that will store scheduler jobs for the SchedulerQueue. 
			For sqUpdateReports appsetting, change the value to reflect if report updates should be pushed to existing schedules.  
			For sqMaxExecutionMinutes appsetting, change the value to reflect the amount of time in minutes where jobs should be reset to 'Ready' if 'Running' when flushed or a scheduler service is started.
			For sqWriteLog appsetting, change the value to True to enable logging for Scheduler Queue calls from the Scheduler Service.  
						
9. Restart the scheduling service(s).
		
Logging Information:
	Logs for scheduler queue for calls from the UI will be generated into WebReports.log by default.
	Logs for scheduler queue for calls from the scheduler service will be generated into eWebReportsScheduler.log by default. 
	Logging for the scheduler queue will use the same settings as configured in log4net. 
	More information on configuring log4net can be found here: https://support.exagoinc.com/hc/en-us/articles/215058008