Exemplo n.º 1
0
        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");
        }
Exemplo n.º 2
0
        /// <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));
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 进入该事件(Event)
        /// </summary>
        /// <param name="strjson"></param>
        public override void EnterEvent(string strjson)
        {
            if (beforeaction != "")
            {
                string strjson1 = "{param:'{";
                foreach (var par in m_beforeActionParams)
                {
                    string tmp = string.Format("{0}:\"{1}\",", par.Key, parselEventActionParams(par.Value));
                    strjson1 += tmp;
                }
                strjson1.TrimEnd(new char[] { ',' });
                strjson1 += "}'}";
                try
                {
                    byte[] bytes = Encoding.UTF8.GetBytes(strjson1);

                    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(beforeaction);
                    request.ContentType   = @"application/json";
                    request.Accept        = "application/xml";
                    request.Method        = "POST";
                    request.ContentLength = bytes.Length;

                    Stream postStream = request.GetRequestStream();
                    postStream.Write(bytes, 0, bytes.Length);
                    postStream.Dispose();

                    //结束动作函数返回值
                    HttpWebResponse response       = (HttpWebResponse)request.GetResponse();
                    Stream          responseStream = response.GetResponseStream();
                    StreamReader    sr             = new StreamReader(responseStream, Encoding.UTF8);
                    //对返回结果进行处理
                    OpResutsfromAction(sr.ReadToEnd());
                }
                catch (Exception e)
                {
                    Trace.WriteLine("EnterEvent error:" + e.Message);
                    //return;
                }
            }

            CWorkFlow wf = new CWorkFlow();

            //2016/2/12--保证子工作流串号与父工作流相同
            if (!wf.CreateEntity(WfName, this.m_parentWF.EntitySerial))
            {
                Trace.WriteLine("Create {0} SubProcess error!", WfName);
                return;
            }
            WfEntityId        = wf.EntityID;
            wf.ParentEntityID = m_parentWF.EntityID;
            //设置子流程初始参数
            foreach (var parTo in m_paramsTo)
            {
                wf.paramstable[parTo.Value].value = m_params[parTo.Key].value;
            }

            //2016/2/12--将自己的Record传给子流程
            //2016/2/14--发现WFEngine中已通过Post_processSubprocess将record传给了子流程,故而取消修改
            //至于为何没有起作用,待调试
            //WorkFlows wfs = new WorkFlows();
            //Mission ms = wfs.GetWFEntityLastMission(wf.EntityID);
            //List<Process_Record> parent_res = wfs.GetMissionRecordInfo(ms.Miss_Id);
            //Dictionary<string, string> res = new Dictionary<string, string>();
            //foreach (var re in parent_res)
            //{
            //如果record中包含事件定义的需要记录的record item则记录到数据库中
            //    if (m_parentWF.GetRecordItems().ContainsKey(re.Re_Name))
            //    {
            //         res[re.Re_Name] = re.Re_Value;
            //    }
            //}
            wf.Start(null); //原始版本 wf.Start(null);

            string sub_status = "";

            do
            {
                sub_status = wf.GetCurrentState();
                wf.SubmitSignal("[]");
            } while (wf.GetCurrentState() != sub_status); //给子流程激励,直至其状态不再发生变化,即需要人员介入

            //如果以并行方式工作, 发送激励信号
            //if (WorkingMode == "parallel")
            //    m_parentWF.SubmitSignal("[]");
            base.UpdateCurrentEvent();
        }