MoST contains a variety of automated processes for queuing tasks that might take longer than a user is willing to wait, such as sending bulk emails, importing and exporting data, etc.
It is also possible to extend this processing capability to allow for any custom automated processes such as syncronising data between external sources via web services or SQL database instances, or any other kind of custom background processing that may be required for the website that isn't catered for directly by existing built-in automated processes.
To extend this functionality, simply download the MoST Automation Project, edit the file called 'MoST.Service.Custom.cs' and add any methods or functions you require, then compile and overwrite the existing assemply in the 'bin' folder called 'MoST.Services.dll'.
MoST will automatically execute any defined methods within this class ever 60 seconds. The timer control is also passed into the class allowing you to customise it's properties such as the interval that it will execute your methods or functions, or whether you want to stop the timer while your methods or functions perform their tasks.
If you do opt for stopping the timer control while your methods or functions execute you should add error handling so that should something go wrong your timer will continue to function.
Example
using
System;
using
System.Timers;
using
System.Web;
namespace
MoST.Service.Custom
{
public
class
Process
{
#region Declarations
Timer _Timer;
HttpContext _Context;
#endregion
/// <summary>
/// Call for any custom background processing requirements.
/// </summary>
/// <param name="Timer">Timer control used for handling user defined custom processes</param>
/// <param name="Context">HttpContext for this request</param>
public
Process(Timer Timer, HttpContext Context)
{
_Timer = Timer;
_Context = Context;
// Make any calls to methods or functions here...
DoStuff();
}
#region Methods
private
void
DoStuff()
{
try
{
_Timer.Enabled =
false
;
Console.Write(
"I am doing some stuff."
);
}
catch
(Exception exError)
{
Util.HandleException(exError);
}
if
(_Timer.Enabled ==
false
)
{
_Timer.Enabled =
true
;
}
}
#endregion
}
}
You can download the VisualStudio automation assemply project here.
Your comments have been posted, thank you.
Please make sure all required fields are completed.
Please make sure all required fields are completed.
Links to external sites are not supported.
Your email address doesn't appear to be correct.
An error occured while attempting to post your comment, please try again.