コード例 #1
0
        public void run()
        {
            if (this.State != ProcessInstanceEnum.INITIALIZED)
            {
                throw new EngineException(this.Id,
                                          this.WorkflowProcess,
                                          this.ProcessId, "The state of the process instance is " + this.State + ",can not run it ");
            }

            INetInstance netInstance = (INetInstance)this.RuntimeContext.KernelManager.getNetInstance(this.ProcessId, this.Version);

            if (netInstance == null)
            {
                throw new EngineException(this.Id,
                                          this.WorkflowProcess,
                                          this.ProcessId, "The net instance for the  workflow process [Id=" + this.ProcessId + "] is Not found");
            }
            //触发事件
            ProcessInstanceEvent pevent = new ProcessInstanceEvent();

            pevent.EventType = ProcessInstanceEventEnum.BEFORE_PROCESS_INSTANCE_RUN;
            pevent.Source    = this;
            this.fireProcessInstanceEvent(pevent);

            this.State       = ProcessInstanceEnum.RUNNING;
            this.StartedTime = this.RuntimeContext.CalendarService.getSysDate();
            this.RuntimeContext.PersistenceService.SaveOrUpdateProcessInstance(this);
            netInstance.run(this);
        }
コード例 #2
0
ファイル: KernelManager.cs プロジェクト: spenleeV/fireflow
        /// <summary>在获取工作流网实例的时候,调用createNetInstance方法,创建实例</summary>
        /// <param name="processId">流程定义ID</param>
        /// <param name="version">流程版本号</param>
        public INetInstance getNetInstance(String processId, Int32 version)
        {
            INetInstance netInstance = (this.netInstanceMap.ContainsKey(processId + "_V_" + version)) ? this.netInstanceMap[processId + "_V_" + version] : null;

            if (netInstance == null)
            {
                //数据流定义在runtimeContext初始化的时候,就被加载了,将流程定义的xml读入到内存中
                WorkflowDefinition def = this.RuntimeContext.DefinitionService.GetWorkflowDefinitionByProcessIdAndVersionNumber(processId, version);
                netInstance = this.createNetInstance(def);
            }
            return(netInstance);
        }