Beispiel #1
0
        /// <summary>
        ///  流程咨讯 
        /// </summary>
        /// <param name="UserAndForm"></param>
        /// <param name="strTitle"></param>
        /// <param name="strFlowXML"></param>
        /// <param name="strAppXml"></param>  
        /// <returns></returns>
        public bool FlowConsultati(OracleConnection con, List<CustomUserMsg> UserAndForm, string strTitle, string strFlowXML, string strAppXml)
        {
            string strCompanyID = string.Empty;//公司ID 
            string strSystemCode = string.Empty;//系统代号
            string strModelCode = string.Empty;//模块代号
            string strFormID = string.Empty;//FORMID
            string strModelName = string.Empty;//模块名称
            if (UserAndForm.Count > 0)
            {
                try
                {
                    EnginFlowDAL dal = new EnginFlowDAL();
                    /*解析流程和业务数据XML*/
                    Byte[] b = System.Text.UTF8Encoding.UTF8.GetBytes(strFlowXML);
                    XElement xele = XElement.Load(System.Xml.XmlReader.Create(new MemoryStream(b)));
                    strCompanyID = XMLToAttribute(xele, "COMPANYID");
                    strSystemCode = string.Empty;
                    strModelCode = XMLToAttribute(xele, "MODELCODE");
                    strFormID = XMLToAttribute(xele, "FORMID");
                    strModelName = XMLToAttribute(xele, "ModelName");
                    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;
                    }

                    /*在T_WF_MESSAGEDEFINE 中查找消息内容*/
                    string content = dal.GetMessageDefine(con, "FLOWCONSULTATI");
                    string strAppFieldValue = ConbinString(xele) + BOObjectEscapeString(strAppXml);
                    DataTable dtValue = FieldStringToDataTable(strAppFieldValue, ref strAppFieldValue);

                    /*在消息触发规则定义中查找消息链接*/
                    DataTable dtFlowTrigger = dal.FlowTriggerTable(con, strSystemCode, strModelCode, string.Empty, strCompanyID);
                    if (dtFlowTrigger != null && dtFlowTrigger.Rows.Count > 0)
                    {
                        string Url = dtFlowTrigger.Rows[0]["applicationurl"].ToString();
                        ReplaceUrl(ref content, ref Url, dtValue);
                        string strContent = string.Empty;
                        foreach (CustomUserMsg custom in UserAndForm)
                        {
                            if (!string.IsNullOrEmpty(strTitle))
                            {
                                content = strTitle;
                            }
                            //刷新缓存用户是否有新的待办
                            //EngineCache.TaskCache.TaskCacheReflesh(custom.UserID);
                            dal.FlowConsultatiMsg(con, custom.UserID, strSystemCode, strModelCode, custom.FormID, content, Url, BOObjectEscapeString(strAppXml), strFlowXML, strAppXml);
                        }
                        return true;
                    }
                    else
                    {
                        //未能在触发规则定义中找到一条数据,无法发送咨讯
                        string cMessage = "未能在触发规则定义中找到一条数据,无法发送咨讯" + "\r\n" +
                                     "SystemCode:" + strSystemCode + "\r\n" +
                                     "Content:" + content + "\r\n" +
                                     "MODELCODE:" + strModelCode + "\r\n" +
                                     "COMPANYID:" + strCompanyID + "\r\n" +
                                     "FORMID:" + strFormID + "\r\n";
                        LogHelper.WriteLog("FlowConsultati()流程咨讯" + cMessage);
                        return false;
                    }

                }
                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";

                    LogHelper.WriteLog("FlowConsultati()流程咨讯" + cMessage);
                    return false;
                }

            }
            else
            {
                string cMessage = "发送咨讯出现错误(没有指定接收人员)" + "\r\n" +
                                     "SystemCode:" + strSystemCode + "\r\n" +
                                     "MODELCODE:" + strModelCode + "\r\n" +
                                     "COMPANYID:" + strCompanyID + "\r\n" +
                                     "FORMID:" + strFormID + "\r\n";
                LogHelper.WriteLog("FlowConsultati()流程咨讯" + cMessage);
                return false;
            }
        }
Beispiel #2
0
        /// <summary>
        /// 流程待办任务撤销
        /// </summary>
        /// <param name="strFlowXml"></param>
        /// <param name="strAppXml"></param>      
        /// <returns></returns>
        public bool FlowCancel(OracleConnection con, string strFlowXml, string strAppXml, ref string ErroMessage)
        {
            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
            {
                EnginFlowDAL dal = new EnginFlowDAL();
                /*解析流程和业务数据XML*/
                Byte[] b = System.Text.UTF8Encoding.UTF8.GetBytes(strFlowXml);
                XElement xele = XElement.Load(System.Xml.XmlReader.Create(new MemoryStream(b)));
                strCompanyID = XMLToAttribute(xele, "COMPANYID");
                strSystemCode = string.Empty;
                strModelCode = XMLToAttribute(xele, "MODELCODE");
                strFormID = XMLToAttribute(xele, "FORMID");
                strModelName = XMLToAttribute(xele, "ModelName");
                strCheckState = XMLToAttribute(xele, "CheckState");
                strReceiveID = 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 (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
                    {
                        LogHelper.WriteLog("FlowCancel该单号:" + strFormID + " 中业务数据无法取得EntityKey");
                    }
                }

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

                if (Config.IsNeedUpdateAudit)//是否执行更新审核状态
                {
                    if (!string.IsNullOrEmpty(strSystemCode) && !string.IsNullOrEmpty(strEntityType) && !string.IsNullOrEmpty(strEntityKey))
                    {
                        LogHelper.WriteLog("UpdateAuditStatus开始更新...FORMID=" + strFormID + "");
                        bool bol= UpdateAuditStatus(strSystemCode, strEntityType, strEntityKey, strFormID, strCheckState, ref ErroMessage);
                        LogHelper.WriteLog("UpdateAuditStatus结束更新...FORMID=" + strFormID + "");
                        if (!bol)
                        {
                            throw new Exception(ErroMessage); //抛出异常终止执行流程                                  
                        }
                    }
                }
                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";
                LogHelper.WriteLog("FlowCancel流程待办任务撤销异常" + cMessage + ErroMessage);
               // LogHelper.WriteLog("FlowCancel流程待办任务撤销异常" + cMessage + ErroMessage);
                return false;
            }

        }