Пример #1
0
        public static CWorkFlow CreateWFEntityModifiedTimeOut(string wf_name, string event_name, CTimeOutProperty property, string Ser_Num = null /*2016/2/12--保证子工作流串号与父工作流相同*/)
        {
            CWorkFlow wf = new CWorkFlow();

            WorkFlows wfs = new WorkFlows();

            XmlDocument     doc    = new XmlDocument();
            WorkFlow_Define define = wfs.GetWorkFlowDefine(wf_name);

            doc.LoadXml(Encoding.Default.GetString(define.W_Xml));
            wf.InstFromXmlNode((XmlNode)doc.DocumentElement);

            //修改wf
            IEvent           ev_target   = wf.events[event_name];
            CTimeOutProperty timeout_pro = ev_target.GetTimeOutProperty();

            timeout_pro.ExactTime  = property.ExactTime;
            timeout_pro.StartTime  = property.StartTime;
            timeout_pro.TimeOffset = property.TimeOffset;

            WorkFlow_Entity wfe = new WorkFlow_Entity();

            wfe.WE_Status = WE_STATUS.CREATED;
            wfe.WE_Binary = Encoding.Default.GetBytes(wf.WriteToXmlNode().OuterXml);

            if (Ser_Num == null)
            {
                wfe.WE_Ser = "";
            }
            else
            {
                wfe.WE_Ser = Ser_Num;
            }

            if (!wfs.AddWorkEntity(wf_name, wfe))
            {
                return(null);
            }

            wf.EntityID     = wfe.WE_Id;
            wf.EntitySerial = wfe.WE_Ser;
            wf.DefineID     = define.W_ID;



            wf.RegEventsTimeOut(true);

            return(wf);
        }
Пример #2
0
        private static void UpdateEntity(CWorkFlow wf, WE_STATUS status)
        {
            try
            {
                WorkFlow_Entity wfe = new WorkFlow_Entity
                {
                    WE_Id     = wf.EntityID,
                    WE_Status = status
                };
                wfe.WE_Binary = Encoding.Default.GetBytes(wf.WriteToXmlNode().OuterXml);

                WorkFlows wfs = new WorkFlows();
                if (!wfs.SaveWorkFlowEntity(wfe))
                {
                    throw new Exception("Save WorkFlow Entity failed!");
                }
            }
            catch (Exception e)
            {
                return;
            }
        }