Exemplo n.º 1
0
        /// <summary>
        /// 获取反射调用的类
        /// 回写状态时用
        /// </summary>
        /// <param name="currentId">当前工作流主键</param>
        /// <returns></returns>
        public IWorkFlowManager GetWorkFlowManager(string currentId)
        {
            IWorkFlowManager          workFlowManager       = null;
            BaseWorkFlowCurrentEntity workFlowCurrentEntity = this.GetObject(currentId);
            string processId = this.GetObject(currentId).ProcessId.ToString();

            if (!string.IsNullOrEmpty(processId))
            {
                BaseWorkFlowProcessManager workFlowProcessManager = new BaseWorkFlowProcessManager(this.DbHelper, this.UserInfo);
                BaseWorkFlowProcessEntity  workFlowProcessEntity  = new BaseWorkFlowProcessEntity();
                if (!string.IsNullOrEmpty(processId))
                {
                    workFlowProcessEntity = workFlowProcessManager.GetObject(processId);
                }
                // 这里本来是想动态创建类库 编码外包[100]
                // System.Reflection.Assembly assembly = Assembly.Load("__code");
                // System.Reflection.Assembly assembly = Assembly.Load("app_code");
                string assemblyString = workFlowProcessEntity.CallBackAssembly;
                workFlowManager = (IWorkFlowManager)Assembly.Load(assemblyString).CreateInstance(workFlowProcessEntity.CallBackClass, true);
                // Type objType = assembly.GetType(workFlowProcessEntity.CallBackClass, true);
                // workFlowManager = (IWorkFlowManager)Activator.CreateInstance(objType);
                workFlowManager.SetUserInfo(this.UserInfo);
                workFlowManager.CurrentTableName = workFlowCurrentEntity.CategoryCode;
                if (!string.IsNullOrEmpty(workFlowProcessEntity.CallBackTable))
                {
                    // 这里本来是想动态创建类库 编码外包[100]
                    workFlowManager.CurrentTableName = workFlowProcessEntity.CallBackTable;
                }
            }
            // workFlowManager = new BaseUserBillManager(this.DbHelper, this.UserInfo);
            return(workFlowManager);
        }
        public BaseWorkFlowProcessEntity GetObject(BaseUserInfo userInfo, string id)
        {
            BaseWorkFlowProcessEntity entity = new BaseWorkFlowProcessEntity();

            var parameter = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessWorkFlowDb(userInfo, parameter, (dbHelper) =>
            {
                // 创建实现类
                var workFlowManager = new BaseWorkFlowProcessManager(dbHelper, userInfo);
                entity = workFlowManager.GetObject(id);
            });
            return(entity);
        }