Example of creating and connecting the monitor task

create a monitor task

In connection with the task monitor there are two issues that the developer must address:

  • What is the task monitor must be provided (standard monitor task or creating some private);
  • Monitor the status of tasks directly to the system.

If you require some special functionality (e.g., tasks in log file or some other display), you may need to create a monitor task. To do this you must create a class which is implemented interface ICSSoft.STORMNET.Business.IBusinessTaskMonitor.

Monitor tasks, which displays tasks in the Windows Application Log

using System;
using ICSSoft.STORMNET.Business;
namespace CustomTaskMon
{
	public class EventTaskMon:IBusinessTaskMonitor
	{
		public EventTaskMon()
		{
		}

		#region IBusinessTaskMonitor Members
		public object BeginSubTask(string SubTask, object TaskID)
		{
			string sTaskID = TaskID==null?"N/A":TaskID.ToString();
			System.Diagnostics.EventLog.WriteEntry(string.Format("Subtask task number {0} started.", sTaskID), SubTask);
			return null;
		}

		public void EndSubTask(object SubTaskID)
		{
			string sTaskID = SubTaskID==null?"N/A":SubTaskID.ToString();
			System.Diagnostics.EventLog.WriteEntry(string.Format("Sub-task {0} ended.", sTaskID), "");
		}

		public void EndTask(object ID)
		{
			string sTaskID = ID==null?"N/A":ID.ToString();
			System.Diagnostics.EventLog.WriteEntry(string.Format("The task {0} ended.", sTaskID), "");
		}

		public void BeginTask(string TaskName, object ID)
		{
			string sTaskID = ID==null?"N/A":ID.ToString();
			System.Diagnostics.EventLog.WriteEntry(string.Format("The task {0} started.", sTaskID), TaskName);
		}

		object ICSSoft.STORMNET.Business.IBusinessTaskMonitor.BeginTask(string TaskName)
		{
			Guid taskID=Guid.NewGuid();
			BeginTask(TaskName,taskID);
			return taskID;
		}
		#endregion
	}
}

Connection EventTaskMon from the above example the application via a configuration file would be as follows:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
	<appSettings>
	<add key="BusinessTaskMonitorType" value="CustomTaskMon.EventTaskMon, CustomTaskMon, Version=1.0.0.1, Culture=neutral, PublicKeyToken=null"/>
	</appSettings>
</configuration>

Components Flexberry ORM use monitor (e.g., service data writes back the query). Therefore, the implementation of this example in Windows Application Log will have entries corresponding to the read list: