Beispiel #1
0
        /// <summary>
        /// 将Record添加到subprocess
        /// </summary>
        private static void Post_processSubprocess(IEvent ev, IDictionary <string, string> record)
        {
            if (record == null)
            {
                return;
            }

            CSubProcessEvent sp = (CSubProcessEvent)ev;

            List <UI_MISSION> miss = GetHistoryMissions(sp.WfEntityId);

            WorkFlows wfs = new WorkFlows();

            foreach (UI_MISSION mi in miss)
            {
                List <Process_Record> prs = new List <Process_Record>();
                foreach (var re in record)
                {
                    Process_Record pr = new Process_Record();
                    pr.Re_Name  = re.Key;
                    pr.Re_Value = re.Value;
                    prs.Add(pr);
                }
                wfs.LinkRecordInfoToMiss(mi.Miss_Id, prs);
            }
            //SubmitSignal(sp.WfEntityId, new Dictionary<string, string>(), record);
        }
Beispiel #2
0
        //保存事件实体创建时的Record Item
        private List<Process_Record> SaveCreateRecord(Dictionary<string, string> records)
        {
            List<Process_Record> record_items = new List<Process_Record>();

            foreach(var item in records)
            {
                Process_Record pr = new Process_Record();
                pr.Re_Name = item.Key;
                pr.Re_Value = item.Value;
                record_items.Add(pr);
            }

            return record_items;
        }
Beispiel #3
0
        //工作流开始运行
        public string Start(IDictionary<string, string> record)
        {
            IEvent startE = null;
            foreach(var item in m_events)
            {
                if (item.Value.GetType().Name == "CStartEvent")
                {
                    startE = item.Value;
                    break;
                }
            }
            if (startE == null)
                return null;
            m_courrentEvent = startE.name;
            startE.EnterEvent("");
            UpdateEntity(WE_STATUS.ACTIVE);
            SubmitSignal("[]");

            //状态发生了迁移
            if (GetCurrentState() != startE.name)
            {
                if (record != null)
                {
                    WorkFlows wfs = new WorkFlows();
                    Mission ms = wfs.GetWFEntityLastMission(EntityID);

                    List<Process_Record> res = new List<Process_Record>();
                    foreach (var re in record)
                    {
                        if (GetRecordItems().ContainsKey(re.Key))
                        {
                            Process_Record pre = new Process_Record();
                            pre.Re_Name = re.Key;
                            pre.Re_Value = re.Value;
                            res.Add(pre);
                        }
                    }
                    wfs.LinkRecordInfoToMiss(ms.Miss_Id, res);
                }
            }            
            
            return m_events[m_courrentEvent].currentaction + @"/?wfe_id=" + m_entityID;
        }
Beispiel #4
0
        //发送消息到工作流
        public static void SubmitSignal(int wfe_id, IDictionary <string, string> signal, IDictionary <string, string> record = null)
        {
            WorkFlows       wfs = new WorkFlows();
            WorkFlow_Entity wfe = wfs.GetWorkFlowEntity(wfe_id);

            //如果该工作流处于非激活状态,则不能向其发送信息
            if (wfe.WE_Status != WE_STATUS.ACTIVE)
            {
                return;
            }

            CWorkFlow   wf  = new CWorkFlow();
            XmlDocument doc = new XmlDocument();

            doc.LoadXml(Encoding.Default.GetString(wfe.WE_Binary));
            wf.InstFromXmlNode(doc.DocumentElement);
            wf.EntityID = wfe.WE_Id;

            string preState = wf.GetCurrentState();

            JArray ja = new JArray();

            foreach (var s in signal)
            {
                JObject jo = new JObject();
                jo.Add("name", s.Key);
                jo.Add("value", s.Value);
                ja.Add(jo);
            }
            wf.SubmitSignal(JsonConvert.SerializeObject(ja));
            //如果preEvent为subprocess
            IEvent preEvent = wf.GetCurrentEvent();

            if (preEvent.GetType().Name == "CSubProcessEvent")
            {
                Post_processSubprocess(preEvent, record);
                //wf.SubmitSignal("[]");
            }


            //状态发生了迁移
            if (wf.GetCurrentState() != preState)
            {
                if (record != null)
                {
                    Mission ms = wfs.GetWFEntityLastMission(wf.EntityID);

                    List <Process_Record> res = new List <Process_Record>();
                    foreach (var re in record)
                    {
                        //如果record中包含事件定义的需要记录的record item则记录到数据库中
                        if (wf.GetRecordItems().ContainsKey(re.Key))
                        {
                            Process_Record pre = new Process_Record();
                            pre.Re_Name  = re.Key;
                            pre.Re_Value = re.Value;
                            res.Add(pre);
                        }
                    }
                    wfs.LinkRecordInfoToMiss(ms.Miss_Id, res);
                }
                //如果当前工作流是子流程,且已执行到End
                if (wf.GetCurrentEvent().GetType().Name == "CEndEvent" && wf.ParentEntityID != -1)
                {
                    WorkFlow_Entity P_wfe = wfs.GetWorkFlowEntity(wf.ParentEntityID);

                    CWorkFlow   P_wf  = new CWorkFlow();
                    XmlDocument P_doc = new XmlDocument();
                    P_doc.LoadXml(Encoding.Default.GetString(P_wfe.WE_Binary));
                    P_wf.InstFromXmlNode(P_doc.DocumentElement);
                    P_wf.EntityID = P_wfe.WE_Id;
                    P_wf.GetCurrentState();
                }
            }

            //如果当前时间为subprocess
            if (preEvent.GetType().Name == "CSubProcessEvent")
            {
                //如果该子事件的工作模式为并行的, 则需要发送一个信号,激励其自动运行一次
                if (((CSubProcessEvent)preEvent).WorkingMode == "parallel")
                {
                    SubmitSignal(wfe_id, new Dictionary <string, string>(), record);
                }
            }
        }