public JsonResult ListKeyParams(int defId) { List <object> pars = new List <object>(); if (defId == -1) { return(Json(new { data = pars.ToArray() })); } CWorkFlow wf = new CWorkFlow(); WorkFlows wfs = new WorkFlows(); XmlDocument doc = new XmlDocument(); doc.LoadXml(Encoding.Default.GetString(wfs.GetWorkFlowDefineByID(defId).W_Xml)); wf.InstFromXmlNode((XmlNode)doc.DocumentElement); var ev = wf.events["Start"]; foreach (var k in ev.paramlist) { pars.Add(new { par_name = k.Value.name, par_desc = k.Value.description, par_value = "" }); } return(Json(new { data = pars.ToArray() })); }
/// <summary> /// 绑定执行对象 /// </summary> /// <param name="wf">工作流</param> /// <returns></returns> public bool attachTarget(WorkFlow_Define wf) { if (wf == null) { return(false); } XmlDocument doc = new XmlDocument(); doc.LoadXml(Encoding.Default.GetString(wf.W_Xml)); m_workFlow.InstFromXmlNode((XmlNode)doc.DocumentElement); m_workFlow.DefineID = wf.W_ID; return(true); }
//public string CreateFlow(string flowname) //{ // UI_WorkFlow_Entity wfe = CWFEngine.CreateAWFEntityByName(flowname); // 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(); // return wfe.Start(record); // //Json(new { url = wfe.Start(record), wfe_id = wfe.EntityID }); // //"{url:'" + wfe.Start(record) + "', wfe_id:'" + wfe.EntityID + "'}"; // } // else // return null; //} public string CreateFlow(string flowname) { UI_WorkFlow_Entity wfe = CWFEngine.CreateAWFEntityByName(flowname); 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); Dictionary <string, string> signal = new Dictionary <string, string>(); signal["currentuser"] = (Session["User"] as EquipModel.Entities.Person_Info).Person_Name; signal["start_done"] = "true"; //submit CWFEngine.SubmitSignal(wfe.EntityID, signal, record); CWorkFlow wf = new CWorkFlow(); XmlDocument doc = new XmlDocument(); doc.LoadXml(CWFEngine.GetWorkFlowEntiy(wfe.EntityID, true).Binary); wf.InstFromXmlNode(doc.DocumentElement); string returl = ""; if (wf.GetCurrentEvent().CheckAuthority <Person_Info>((Dictionary <string, object>)Session[CWFEngine.authority_params], ((IObjectContextAdapter)(new EquipWebContext())).ObjectContext)) { returl = wf.GetCurrentEvent().currentaction + "?wfe_id=" + wfe.EntityID.ToString(); //如果权限认证通过则返回正确的页面URL return(returl); //return returl; } else { //如果权限认证不通过, 则删除刚创建的工作流实体, 并返回 -1 CWFEngine.RemoveWFEntity(wfe.EntityID); return("-1"); } //Json(new { url = wfe.Start(record), wfe_id = wfe.EntityID }); //"{url:'" + wfe.Start(record) + "', wfe_id:'" + wfe.EntityID + "'}"; } else { return(null); } }
/// <summary> /// 从数据库记录加载类对象 /// </summary> /// <param name="job">数据库记录</param> public override void Load(Timer_Jobs job) { //加载工作流定义 WorkFlows wfs = new WorkFlows(); WorkFlow_Define wf_define = wfs.GetWorkFlowDefineByID(job.workflow_ID); m_workFlow = null; if (wf_define != null) { XmlDocument doc = new XmlDocument(); doc.LoadXml(Encoding.Default.GetString(wf_define.W_Xml)); m_workFlow = new CWorkFlow(); m_workFlow.InstFromXmlNode((XmlNode)doc.DocumentElement); m_workFlow.DefineID = job.workflow_ID; } base.Load(job); CreateCallback = CustomAction; }
/// <summary> /// 执行工作流创建工作 /// </summary> protected override void __processing() { //Trace.WriteLine(string.Format("Creating WorkFlow {0}", m_workFlow.name)); foreach (var rp in (List <TimerCreateWFPa>)m_run_params) { if (rp.wf_timer != null) { //创建工作流 CWorkFlow wf = new CWorkFlow(); wf.InstFromXmlNode(m_workFlow.WriteToXmlNode()); //修改定时器 foreach (var ti in rp.wf_timer) { try { DateTime?dt = null; if (ti.Value["ExactTime"] != "") { dt = DateTime.Parse(ti.Value["ExactTime"]); } wf.events[ti.Key].TimeOutProperty.SetAttribute("exact_time", dt); TimeSpan?ts = null; if (ti.Value["OffsetTime"] != "") { ts = TimeSpan.Parse(ti.Value["OffsetTime"]); } wf.events[ti.Key].TimeOutProperty.SetAttribute("offset_time", ts); wf.events[ti.Key].TimeOutProperty.SetAttribute("time_start", ti.Value["TimeStart"]); wf.events[ti.Key].TimeOutProperty.SetAttribute("action", ti.Value["Action"]); wf.events[ti.Key].TimeOutProperty.SetAttribute("call_back", ti.Value["CallBack"]); } catch { continue; } } //更新工作流变量 foreach (var pp in ((Dictionary <string, string>)(rp.wf_params))) { try { CParam pa = wf.paramstable[pp.Key]; pa.value = pp.Value; if (pp.Key == "Zz_Name" || pp.Key == "ZzName" || pp.Key == "Pqname" || pp.Key == "Equip_GyCode") { wf.description = wf.description + "(" + pp.Value + ")"; } } catch { continue; } } //创建工作流 wf.CreateEntityBySelf(); // //回调 AfterCreate(wf.EntityID); ((List <int>)m_run_result).Add(wf.EntityID); //工作流开始工作 wf.Start((IDictionary <string, string>)(rp.wf_record)); } } }
public string CreateA14dot3s_submitsignal(string json1) { try { JObject item = (JObject)JsonConvert.DeserializeObject(json1); EquipManagment tm = new EquipManagment(); string temp = item["sample"].ToString(); JArray jsonVal = JArray.Parse(temp) as JArray; dynamic table2 = jsonVal; foreach (dynamic T in table2) { //加载原工作流工作流 CWorkFlow m_workFlow = new CWorkFlow(); WorkFlows wfs = new WorkFlows(); WorkFlow_Define wf_define = wfs.GetWorkFlowDefine("A14dot3dot3"); m_workFlow = null; if (wf_define != null) { XmlDocument doc = new XmlDocument(); doc.LoadXml(Encoding.Default.GetString(wf_define.W_Xml)); m_workFlow = new CWorkFlow(); m_workFlow.InstFromXmlNode((XmlNode)doc.DocumentElement); m_workFlow.DefineID = wf_define.W_ID; } //加载超时属性数据 TimerCreateWFPa TCP = new TimerCreateWFPa(); TimerCreateWFPa.TimerSetting time_set = new TimerCreateWFPa.TimerSetting(); time_set.Time_start = "wf_create"; time_set.Exact_time = ""; time_set.Offset_time = (DateTime.Now.AddDays(5) - DateTime.Now).ToString(); //time_set.Offset_time = (DateTime.Now.AddMinutes(3) - DateTime.Now).ToString(); time_set.Action = "INVILID"; time_set.Call_back = "http://localhost/CallBack/testCallBack"; TCP.AppendTimer("PqAssess", time_set); //创建写入timeout属性的工作流 CWorkFlow wf = new CWorkFlow(); wf.InstFromXmlNode(m_workFlow.WriteToXmlNode()); //修改定时器 foreach (var ti in TCP.wf_timer) { try { DateTime?dt = null; if (ti.Value["ExactTime"] != "") { dt = DateTime.Parse(ti.Value["ExactTime"]); } wf.events[ti.Key].TimeOutProperty.SetAttribute("exact_time", dt); TimeSpan?ts = null; if (ti.Value["OffsetTime"] != "") { ts = TimeSpan.Parse(ti.Value["OffsetTime"]); } wf.events[ti.Key].TimeOutProperty.SetAttribute("offset_time", ts); wf.events[ti.Key].TimeOutProperty.SetAttribute("time_start", ti.Value["TimeStart"]); wf.events[ti.Key].TimeOutProperty.SetAttribute("action", ti.Value["Action"]); wf.events[ti.Key].TimeOutProperty.SetAttribute("call_back", ti.Value["CallBack"]); } catch { continue; } } //创建工作流 wf.CreateEntityBySelf(); //开启工作流 Dictionary <string, string> record = new Dictionary <string, string>(); record.Add("username", "system_temporary"); record.Add("time", DateTime.Now.ToString()); TCP.wf_record = record; wf.Start((IDictionary <string, string>)(TCP.wf_record)); Dictionary <string, string> signal = new Dictionary <string, string>(); string Equip_Code = T.Equip_Code; int Equip_location_EA_Id = tm.getEA_id_byCode(Equip_Code); signal["Zz_Name"] = tm.getZzName(Equip_location_EA_Id); signal["Equip_GyCode"] = T.Equip_GyCode; signal["Equip_Code"] = T.Equip_Code; signal["Equip_ABCMark"] = T.Equip_ABCMark; signal["SubmitJxPlan_Done"] = "true"; //record Dictionary <string, string> record1 = new Dictionary <string, string>(); record1["username"] = (Session["User"] as EquipModel.Entities.Person_Info).Person_Name; record1["time"] = DateTime.Now.ToString(); //submit CWFEngine.SubmitSignal(Convert.ToInt32(wf.EntityID), signal, record1); } } catch (Exception e) { return(""); } return("/A14dot3/Index"); }