Beispiel #1
0
        /// <summary>
        /// 流程撤销
        /// </summary>
        /// <param name="strFlowXML"></param>
        /// <param name="strAppXml"></param>
        /// <returns></returns>
        public bool FlowCancel(string strFlowXML, string strAppXml)
        {
            if (string.IsNullOrEmpty(strFlowXML) && string.IsNullOrEmpty(strAppXml))
            {
                return false;
            }
            string strCompanyID = string.Empty;//公司ID
            string strSystemCode = string.Empty;//系统代号
            string strModelCode = string.Empty;//模块代号
            string strFormID = string.Empty;//FORMID
            string strModelName = string.Empty;//模块名称
            string strEntityType = string.Empty;//EntityType (表名)
            string strEntityKey = string.Empty;//EntityKey (主键)
            string strCheckState = string.Empty;//审核状态
            string strReceiveID = string.Empty;//接收人

            try
            {
                EngineServicesDAL dal = new EngineServicesDAL();
                /*解析流程和业务数据XML*/
                Byte[] b = System.Text.UTF8Encoding.UTF8.GetBytes(strFlowXML);
                XElement xele = XElement.Load(System.Xml.XmlReader.Create(new MemoryStream(b)));
                strCompanyID = Common.XMLToAttribute(xele, "COMPANYID");
                strSystemCode = string.Empty;
                strModelCode = Common.XMLToAttribute(xele, "MODELCODE");
                strFormID = Common.XMLToAttribute(xele, "FORMID");
                strModelName = Common.XMLToAttribute(xele, "ModelName");
                strCheckState = Common.XMLToAttribute(xele, "CheckState");
                strReceiveID = Common.XMLToAttribute(xele, "APPUSERID");
                if (!string.IsNullOrEmpty(strAppXml))
                {
                    Byte[] Bo = System.Text.UTF8Encoding.UTF8.GetBytes(strAppXml);
                    XElement xemeBoObject = XElement.Load(System.Xml.XmlReader.Create(new MemoryStream(Bo)));
                    strSystemCode = (from item in xemeBoObject.Descendants("Name") select item).FirstOrDefault().Value;
                    try
                    {
                        strEntityType = (from item in xemeBoObject.Descendants("Object") select item).FirstOrDefault().Attribute("Name").Value;
                        strEntityKey = (from item in xemeBoObject.Descendants("Object") select item).FirstOrDefault().Attribute("Key").Value;
                        //有些特殊的模块需要改变接收人
                        if (Common.CheckModelName(strModelCode) && strCheckState == "2")
                        {
                            strReceiveID = (from item in xemeBoObject.Descendants("Object").Descendants("Attribute")
                                            where item.Attribute("Name").Value.ToUpper() == "CREATEUSERID"
                                            select item).FirstOrDefault().Attribute("DataValue").Value;
                        }
                    }
                    catch
                    {
                        Tracer.Debug("FlowCancel该单号:" + strFormID + " 中业务数据无法取得EntityKey");
                    }
                }

                string strAppFieldValue = Common.ConbinString(xele) + Common.BOObjectEscapeString(strAppXml);
                DataTable dtValue = Common.FieldStringToDataTable(strAppFieldValue, ref strAppFieldValue);
                string content = dal.GetMessageDefineString("FLOWCANCEL");
                string strUrl = string.Empty;
                Common.ReplaceUrl(ref content, ref strUrl, dtValue);
                dal.DoTaskCancel(strSystemCode, strModelCode, strFormID, strReceiveID, content);

                if (Config.IsNeedUpdateAudit)//是否执行更新审核状态
                {
                    if (!string.IsNullOrEmpty(strSystemCode) && !string.IsNullOrEmpty(strEntityType) && !string.IsNullOrEmpty(strEntityKey))
                    {
                        UpdateAuditStatus(strSystemCode, strEntityType, strEntityKey, strFormID, strCheckState);
                    }
                }
                return true;
            }
            catch (Exception e)
            {
                string cMessage = "流程待办任务撤销异常" + "\r\n" +
                                  "SystemCode:" + strSystemCode + "\r\n" +
                                  "MODELCODE:" + strModelCode + "\r\n" +
                                  "COMPANYID:" + strCompanyID + "\r\n" +
                                   "Error:" + e.Message + "\r\n" +
                                    "FORMID:" + strFormID + "\r\n" +
                                   "流程XML:" + strFlowXML + "\r\n" +
                                  "AppXml:" + strAppXml + "\r\n";
                Tracer.Debug("FlowCancel流程待办任务撤销异常" + cMessage);
                return false;
            }
        }