⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 schedulerecomp.cs

📁 基于DotNet的开源工作流引擎
💻 CS
字号:
using System;
using log4net;
using NetBpm.Util.Client;
using NetBpm.Util.DB;
using NetBpm.Util.EComp;
using NetBpm.Workflow.Organisation.EComp;
using NetBpm.Workflow.Scheduler.Impl;
using Castle.Services.Transaction;
using Castle.Facilities.NHibernateIntegration;

namespace NetBpm.Workflow.Scheduler.EComp.Impl
{
	[Transactional]
	public class SchedulerEComp : AbstractEComp, ISchedulerSessionLocal
	{
		private static SchedulerComponentImpl implementation = SchedulerComponentImpl.Instance;
		private static readonly ILog log = LogManager.GetLogger(typeof (SchedulerEComp));

		public SchedulerEComp(ISessionManager sessionManager) : base(sessionManager)
		{
		}

		[Transaction(TransactionMode.Requires)]
		public virtual void scheduleJob(Job job)
		{
			ScheduleJob(job, null);
		}

		[Transaction(TransactionMode.Requires)]
		public virtual void ScheduleJob(Job job, String reference)
		{
			DbSession dbSession = null;
			try
			{
				dbSession = OpenSession();
				implementation.ScheduleTask(job, reference, dbSession);
			}
			catch (Exception e)
			{
				log.Error("error when scheduling job with reference " + reference, e);
			}
		}

		[Transaction(TransactionMode.Requires)]
		public virtual void CancelJobs(String reference)
		{
			DbSession dbSession = null;
			try
			{
				dbSession = OpenSession();
				implementation.CancelTasks(reference, dbSession);
			}
			catch (Exception e)
			{
				log.Error("error when canceling jobs with reference " + reference, e);
			}
		}

		[Transaction(TransactionMode.Requires)]
		public virtual long ExecuteJobs()
		{
			long millisToWait = 0;
			DbSession dbSession = null;
			IOrganisationSessionLocal organisationComponent = null;
			try
			{
				dbSession = OpenSession();
				organisationComponent = (IOrganisationSessionLocal) ServiceLocator.Instance.GetService(typeof (IOrganisationSessionLocal));
				millisToWait = implementation.ExecuteTask(dbSession, organisationComponent);
				ServiceLocator.Instance.Release(organisationComponent);
			}
			catch (Exception e)
			{
				log.Error("error when executing job ", e);
			}
			finally
			{
				ServiceLocator.Instance.Release(organisationComponent);
			}
			return millisToWait;
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -