Ejemplo n.º 1
0
        /// <summary>
        /// 通过工作流实体的id获得工作流实体
        /// </summary>
        /// <param name="wfe_id"></param>
        /// <returns></returns>
        public static UI_WFEntity_Info GetWorkFlowEntiy(int wfe_id, bool FullInfo = false)
        {
            UI_WFEntity_Info wfe  = new UI_WFEntity_Info();
            WorkFlows        wfs  = new WorkFlows();
            WorkFlow_Entity  wfe1 = wfs.GetWorkFlowEntity(wfe_id);

            if (FullInfo)
            {
                CWorkFlow   wf  = new CWorkFlow();
                XmlDocument doc = new XmlDocument();
                doc.LoadXml(Encoding.Default.GetString(wfe1.WE_Binary));
                XmlNode xml = doc.DocumentElement;
                wf.ParaseBaseInfo(xml);
                WorkFlow_Define wfd = wfs.GetWorkFlowDefine(wfe_id);
                //wfe.name = wfd.W_Name;
                //wfe.description = wfd.W_Attribution;
                wfe.Binary      = Encoding.Default.GetString(wfe1.WE_Binary);
                wfe.name        = wf.name;
                wfe.description = wf.description;
            }

            wfe.EntityID       = wfe1.WE_Id;
            wfe.serial         = wfe1.WE_Ser;
            wfe.Status         = wfe1.WE_Status;
            wfe.Last_TransTime = wfe1.Last_Trans_Time;
            return(wfe);
        }
Ejemplo n.º 2
0
        //fhp添加方法结束-----

        /// <summary>
        /// 或的工作流的信息以及指定变量的值
        /// </summary>
        /// <param name="wfe_id">工作流实体ID</param>
        /// <param name="paras">变量列表
        /// 例如: 要获得工作流(ID 为 4)的Equip_GyCode的当前值,则:
        /// Dictionary paras = new Dictionary();
        /// paras["Equip_GyCode"] = null;
        /// UI_WFEntity_Info wfei = GetWorkFlowEntityWithParams(4, paras);
        ///
        /// 调用完成后, wfei返回了 name, description, EntityID, serial, Status
        /// 而paras["Equip_GyCode"] 将会被设置为正确值
        /// </param>
        /// <returns></returns>
        public static UI_WFEntity_Info GetWorkFlowEntityWithParams(int wfe_id, IDictionary <string, object> paras)
        {
            UI_WFEntity_Info wfe  = new UI_WFEntity_Info();
            WorkFlows        wfs  = new WorkFlows();
            WorkFlow_Entity  wfe1 = wfs.GetWorkFlowEntity(wfe_id);

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

            doc.LoadXml(Encoding.Default.GetString(wfe1.WE_Binary));
            XmlNode xml = doc.DocumentElement;

            wf.ParaseBaseInfo(xml);
            wf.ParseParams(xml.SelectSingleNode("paramtable"));

            Dictionary <string, object> _tmp = new Dictionary <string, object>(paras);

            foreach (var par in _tmp)
            {
                paras[par.Key] = wf.paramstable[par.Key].value;
            }


            wfe.name        = wf.name;
            wfe.description = wf.description;
            wfe.EntityID    = wf.EntityID;
            wfe.serial      = wf.EntitySerial;
            wfe.Status      = wfe1.WE_Status;
            return(wfe);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 检查SubProcess的状态
        /// </summary>
        private void CheckSubEventStatus()
        {
            //如果当前状态是SubProcess, 则要检测子时间是否已经执行完毕,
            //若已经执行完毕,则需要将返回值从子事件中取回
            if (m_events[m_courrentEvent].GetType().Name == "CSubProcessEvent")
            {
                CSubProcessEvent subE = (CSubProcessEvent)(m_events[m_courrentEvent]);
                WorkFlows wfs = new WorkFlows();

                WorkFlow_Entity wfe = wfs.GetWorkFlowEntity(subE.WfEntityId);
                //自流程已执行完成
                if (wfe.WE_Status == WE_STATUS.DONE)
                {
                    CWorkFlow subWf = new CWorkFlow();
                    XmlDocument doc = new XmlDocument();
                    doc.LoadXml(Encoding.Default.GetString(wfs.GetWorkFlowEntity(subE.WfEntityId).WE_Binary));
                    subWf.InstFromXmlNode(doc.DocumentElement);
                    subWf.EntityID = subE.WfEntityId;

                    IEvent subEnd = subWf.GetCurrentEvent();
                    //将变量返回回来
                    foreach (var p in subE.m_paramsFrom)
                    {
                        subE.paramlist[p.Key].value = subEnd.paramlist[p.Value].value;
                    }
                    //若子工作流的工作方式为串行, 则父工作流在子流程完成后继续向下执行
                    if (subE.WorkingMode == "serial")
                    {
                        StateTransfer("");
                        if (m_events[m_courrentEvent].GetType().Name == "CEndEvent")
                        {
                            //将该工作流置为已完成(结束)
                            UpdateEntity(WE_STATUS.DONE);
                            //2016.1.3 添加子事件返回

                        }
                        else
                            //更新工作流到数据库,不改变状态
                            UpdateEntity(WE_STATUS.INVALID);
                    }
                }


            }
        }
Ejemplo n.º 4
0
        public string get_equip_info(string wfe_id)
        {
            WorkFlows wfsd    = new WorkFlows();
            Mission   db_miss = wfsd.GetWFEntityMissions(Convert.ToInt16(wfe_id)).Last();//获取该实体最后一个任务


            WorkFlow_Entity wfe = wfsd.GetWorkFlowEntity(Convert.ToInt16(wfe_id));
            //CWorkFlow wf = new CWorkFlow();
            WorkFlows  wfs = new WorkFlows();
            UI_MISSION ui  = new UI_MISSION();

            ui.WE_Entity_Ser = wfe.WE_Ser;
            ui.WE_Event_Desc = db_miss.Miss_Desc;
            ui.WE_Event_Name = db_miss.Event_Name;
            ui.WE_Name       = db_miss.Miss_Name;
            ui.Mission_Url   = "";                                               //历史任务的页面至空
            ui.Miss_Id       = db_miss.Miss_Id;
            List <Mission_Param> mis_pars = wfsd.GetMissParams(db_miss.Miss_Id); //获取当前任务参数

            foreach (var par in mis_pars)
            {
                CParam cp = new CParam();
                cp.type                     = par.Param_Type;
                cp.name                     = par.Param_Name;
                cp.value                    = par.Param_Value;
                cp.description              = par.Param_Desc;
                ui.Miss_Params[cp.name]     = cp.value;
                ui.Miss_ParamsDesc[cp.name] = cp.description;
            }
            List <EquipListModel> EquipList = Zz_Equips(ui.Miss_Params["Zz_Name"].ToString());
            List <object>         miss_obj  = new List <object>();
            int i = 1;

            foreach (var item in EquipList)
            {
                object m = new
                {
                    index           = i,
                    Equip_Id        = item.Equip_Id,
                    Equip_GyCode    = item.Equip_GyCode,
                    Equip_Code      = item.Equip_Code,
                    Equip_Type      = item.Equip_Type,
                    Equip_Specialty = item.Equip_Specialty,
                    Equip_ABCMark   = item.Equip_ABCMark
                };
                miss_obj.Add(m);
                i++;
            }

            string str = JsonConvert.SerializeObject(miss_obj);

            return("{" + "\"data\": " + str + "}");
        }
Ejemplo n.º 5
0
        // GET: /A7dot1dot1/机动处确认
        public void createA13dot1(string from_wfe_id)
        {
            //create new flow A13.1
            UI_MISSION miss           = CWFEngine.GetActiveMission <Person_Info>(Convert.ToInt32(from_wfe_id), ((IObjectContextAdapter)(new EquipWebContext())).ObjectContext);
            string     th_problem     = Convert.ToString(miss.Miss_Params["Th_ProblemRecords"]);
            JArray     j_Problem_data = JArray.Parse(th_problem);

            for (int i = 0; i < j_Problem_data.Count; i++)
            {
                JObject j_obj            = JObject.Parse(j_Problem_data[i].ToString());
                string  problem_catalogy = j_obj["problem_catalogy"].ToString();
                string  problem_detail   = j_obj["problem_detail"].ToString();
                //将7.1.1的串号赋给新产生的13.1的工作流
                WorkFlows          wfsd       = new WorkFlows();
                WorkFlow_Entity    wfecurrent = wfsd.GetWorkFlowEntity(Convert.ToInt32(from_wfe_id));
                UI_WorkFlow_Entity wfe        = CWFEngine.CreateAWFEntityByName("A13dot1", wfecurrent.WE_Ser);

                if (wfe != null)
                {
                    Dictionary <string, string> record = wfe.GetRecordItems();
                    record["username"] = (Session["User"] as EquipModel.Entities.Person_Info).Person_Name;
                    record["time"]     = DateTime.Now.ToString();
                    wfe.Start(record);
                    int flow_id = wfe.EntityID;
                    Dictionary <string, string> signal1 = new Dictionary <string, string>();
                    signal1["start_done"] = "true";
                    CWFEngine.SubmitSignal(flow_id, signal1, record);
                    //paras
                    Dictionary <string, string> signal = new Dictionary <string, string>();
                    signal["ZzSubmit_done"]        = "true";
                    signal["Cj_Name"]              = miss.Miss_Params["Cj_Name"].ToString();
                    signal["Zz_Name"]              = miss.Miss_Params["Zz_Name"].ToString();
                    signal["Equip_GyCode"]         = miss.Miss_Params["Equip_GyCode"].ToString();
                    signal["Equip_Code"]           = miss.Miss_Params["Equip_Code"].ToString();
                    signal["Equip_Type"]           = miss.Miss_Params["Equip_Type"].ToString();
                    signal["Problem_Desc"]         = problem_detail;
                    signal["Problem_DescFilePath"] = "";
                    signal["Zy_Type"]              = problem_catalogy;
                    signal["Zy_SubType"]           = miss.Miss_Params["Zy_SubType"].ToString();
                    signal["Equip_ABCMark"]        = miss.Miss_Params["Equip_ABCMark"].ToString();
                    signal["Data_Src"]             = "特护记录";

                    //submit
                    //record
                    //record["username"] = (Session["User"] as EquipModel.Entities.Person_Info).Person_Name;
                    record["time"] = DateTime.Now.ToString();
                    //submit
                    CWFEngine.SubmitSignal(flow_id, signal, record);
                }
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 获取某一工作流实体的历史任务
        /// </summary>
        /// <param name="entity_id">工作流实体ID</param>
        /// <returns></returns>
        public static List <UI_MISSION> GetHistoryMissions(int entity_id)
        {
            List <UI_MISSION> his_miss = new List <UI_MISSION>();

            WorkFlows      wfs     = new WorkFlows();
            List <Mission> db_miss = wfs.GetWFEntityMissions(entity_id);

            WorkFlow_Entity wfe = wfs.GetWorkFlowEntity(entity_id);
            //恢复工作流实体
            CWorkFlow   wf  = new CWorkFlow();
            XmlDocument doc = new XmlDocument();

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


            foreach (var mi in db_miss)
            {
                UI_MISSION ui_mi = new UI_MISSION();
                ui_mi.WE_Entity_Id  = entity_id;
                ui_mi.WE_Entity_Ser = wfe.WE_Ser;
                ui_mi.WE_Event_Desc = mi.Miss_Desc;
                ui_mi.WE_Event_Name = mi.Event_Name;
                ui_mi.WE_Name       = mi.Miss_Name;
                ui_mi.Mission_Url   = ""; //历史任务的页面至空
                ui_mi.Miss_Id       = mi.Miss_Id;

                List <Mission_Param> mis_pars = wfs.GetMissParams(mi.Miss_Id);
                foreach (var par in mis_pars)
                {
                    CParam cp = new CParam();
                    cp.type                          = par.Param_Type;
                    cp.name                          = par.Param_Name;
                    cp.value                         = par.Param_Value;
                    cp.description                   = par.Param_Desc;
                    ui_mi.Miss_Params[cp.name]       = cp.value;
                    ui_mi.Miss_ParamsAppRes[cp.name] = wf.paramstable[cp.name].linkEventsApp_res[ui_mi.WE_Event_Name];
                    ui_mi.Miss_ParamsDesc[cp.name]   = cp.description;//xwm modified
                }
                his_miss.Add(ui_mi);
            }
            return(his_miss);
        }
Ejemplo n.º 7
0
        //获得工作流实体的当前任务
        public static UI_MISSION GetActiveMission <T>(int entity_id, ObjectContext oc, bool bAuthCheck = true)
        {
            UI_MISSION miss = new UI_MISSION();

            WorkFlows wfs = new WorkFlows();

            WorkFlow_Entity wfe = wfs.GetWorkFlowEntity(entity_id);

            miss.WE_Entity_Id  = wfe.WE_Id;
            miss.WE_Name       = wfs.GetWorkFlowEntityName(wfe.WE_Id);
            miss.WE_Entity_Ser = wfe.WE_Ser;

            //恢复工作流实体
            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;
            //权限验证
            if (bAuthCheck)
            {
                IEvent ev = wf.GetCurrentEvent();
                if (!ev.CheckAuthority <T>((Dictionary <string, object>)HttpContext.Current.Session[authority_params], oc))
                {
                    return(null);
                }
            }

            miss.WE_Event_Name = wf.GetCurrentEvent().name;
            miss.WE_Event_Desc = wf.GetCurrentEvent().description;
            miss.Mission_Url   = wf.CurrentEventLink();
            //读取参数的值
            foreach (var pa in wf.GetCurrentEvent().paramlist)
            {
                miss.Miss_Params[pa.Key]       = pa.Value.value;
                miss.Miss_ParamsAppRes[pa.Key] = wf.GetCurrentEvent().paramsApp_res[pa.Key];
            }

            return(miss);
        }
Ejemplo n.º 8
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);
                }
            }
        }