Exemplo n.º 1
0
        /// <summary>
        /// 执行委托方法
        /// </summary>
        /// <param name="session">数据会话</param>
        /// <param name="id">实例主键ID</param>
        /// <param name="code">实例代码</param>
        /// <param name="item">事件</param>
        /// <param name="activityResource">活动资源</param>
        /// <returns>执行结果</returns>
        private static Boolean Execute(IDbSession session,
                                       int id,
                                       string code,
                                       KeyValuePair <EventFireTypeEnum, Func <int, string, IDelegateService, Boolean> > item,
                                       ActivityResource activityResource = null)
        {
            var result = false;

            if (item.Key == EventFireTypeEnum.OnProcessStarted ||
                item.Key == EventFireTypeEnum.OnProcessRunning ||
                item.Key == EventFireTypeEnum.OnProcessCompleted)
            {
                var delegateService = new ProcessDelegateService(session, id);
                delegateService.SetActivityResource(activityResource);
                result = item.Value(id, code, delegateService);
            }
            return(result);
        }
 /// <summary>
 /// 创建委托服务
 /// </summary>
 /// <param name="scopeType">委托类型</param>
 /// <param name="session">数据会话</param>
 /// <param name="context">上下文</param>
 /// <returns>委托服务</returns>
 public static DelegateServiceBase CreateDelegateService(DelegateScopeTypeEnum scopeType,
                                                         IDbSession session,
                                                         DelegateContext context)
 {
     if (scopeType == DelegateScopeTypeEnum.Process)
     {
         var processDelegateService = new ProcessDelegateService(session, context);
         return(processDelegateService);
     }
     else if (scopeType == DelegateScopeTypeEnum.Activity)
     {
         var activityDelegateService = new ActivityDelegateService(session, context);
         return(activityDelegateService);
     }
     else
     {
         throw new ApplicationException("不正确的委托类型参数!");
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// 创建委托服务
 /// </summary>
 /// <param name="scopeType">委托类型</param>
 /// <param name="session">数据会话</param>
 /// <param name="context">上下文</param>
 /// <returns>委托服务</returns>
 public static DelegateServiceBase CreateDelegateService(DelegateScopeTypeEnum scopeType,
                                                         IDbSession session,
                                                         DelegateContext context)
 {
     if (scopeType == DelegateScopeTypeEnum.Process)
     {
         var processDelegateService = new ProcessDelegateService(session, context);
         return(processDelegateService);
     }
     else if (scopeType == DelegateScopeTypeEnum.Activity)
     {
         var activityDelegateService = new ActivityDelegateService(session, context);
         return(activityDelegateService);
     }
     else
     {
         throw new ApplicationException(LocalizeHelper.GetEngineMessage("delegateservicefactory.CreateDelegateService.error"));
     }
 }