Example #1
0
        private bool EngineExecute(T_WF_DOTASK Entity, string IsTask)
        {
            bool result = false;
            EngineServicesDAL dal = new EngineServicesDAL();
            string strAppFieldValue = string.Empty;
            DataTable sourceTable = Common.FieldStringToDataTable(Entity.APPFIELDVALUE, ref strAppFieldValue);//将业务数据与流程数据转换成DataTable作为替换的源数据
            //通过系统代号,模块代号,企业ID,流程状态查到引擎配置内容

            DataTable dtFlowTrigger = dal.FlowTriggerTable(Entity.SYSTEMCODE, Entity.MODELCODE, Entity.ORDERSTATUS.ToString(), Entity.COMPANYID);
            if (dtFlowTrigger != null && dtFlowTrigger.Rows.Count > 0)
            {
                #region
                DataRow[] drs = dtFlowTrigger.Select("ISDEFAULTMSG=1");//发的是默认流程触发条件
                if (drs.Count() > 0)
                {
                    if (IsTask == "1")//新增待办任务
                    {
                        TaskCache.TaskCacheReflesh(Entity.RECEIVEUSERID);
                        dal.AddDoTask(Entity, drs[0], sourceTable, strAppFieldValue);//新增待办任务
                    }
                    else if (IsTask == "0")//消息
                    {
                        dal.AddDoTaskMessage(Entity, drs[0], sourceTable);
                    }
                }
                DataRow[] NotDefaultMsg = dtFlowTrigger.Select("ISDEFAULTMSG=0");//非默认消息,需要调用的WCF待办任务
                if (NotDefaultMsg != null && NotDefaultMsg.Count() > 0)
                {
                    foreach (DataRow dr1 in NotDefaultMsg)
                    {
                        string strAppMsg = string.Empty;
                        CallWCFService(dr1, sourceTable, ref strAppMsg);//调用WCF服务
                        if (!string.IsNullOrEmpty(strAppMsg))
                        {
                            try
                            {
                                string IsNewFlow = "1";
                                string NewFormID = string.Empty;
                                string strFormTypes = string.Empty;//表单状态
                                DataRow DRNewTrigger = null;
                                if (ApplicationValueToDataTable(strAppMsg, string.Concat(Entity.COMPANYID), ref sourceTable, ref IsNewFlow, ref NewFormID, ref strFormTypes, ref DRNewTrigger))
                                {
                                    //通过岗位查找用户,并且取第一个用户为发送消息的对像
                                    PersonnelWS.PersonnelServiceClient HRClient = new PersonnelWS.PersonnelServiceClient();
                                    if (!string.IsNullOrEmpty(dr1["OWNERPOSTID"].ToString()))
                                    {
                                        string[] Employees = HRClient.GetEmployeeIDsByPostID(dr1["OWNERPOSTID"].ToString());
                                        if (Employees != null && Employees.Count() > 0)
                                        {
                                            TaskCache.TaskCacheReflesh(NewFormID);
                                            dal.AddDoTask(Entity, dr1, sourceTable, Employees[0], NewFormID, strAppFieldValue, string.Concat(dr1["MESSAGEBODY"]), strFormTypes);//发送消息
                                        }
                                    }
                                    else
                                    {
                                        result = false;
                                        Tracer.Debug("命名空间:SMT.Workflow.Engine.Services.BLL类方法:EngineExecute()引擎调用新流程时没有选定岗位");
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                result = false;
                                Tracer.Debug("命名空间:SMT.Workflow.Engine.Services.BLL类方法:EngineExecute()" + ex.Message);
                            }
                        }
                    }
                }
                result = true;
                #endregion
            }
            else
            {

                string strMsg = "系统代号" + Entity.SYSTEMCODE + "\r\n" +
                                 "模块代号:" + Entity.MODELCODE + "\r\n" +
                                 "触发条件:" + Entity.ORDERSTATUS +
                                 "公司ID:" + Entity.COMPANYID + "\r\n" +
                                 "单据ID:" + Entity.ORDERID;
                Tracer.Debug("该单据所对应的引擎系统设置未找到,请先配置该模块引擎消息(审核通过、审核不通过、审核中)" + strMsg);
            }
            return result;
        }
Example #2
0
 /// <summary>
 /// 发送消息
 /// </summary>
 /// <param name="ReceiveUserID"></param>
 /// <param name="strFormID"></param>
 /// <param name="MsgContent"></param>
 /// <param name="ModelCode"></param>
 /// <param name="strXml"></param>
 public void AppMsgTrigger(string ReceiveUserID, string strFormID, string MsgContent, string ModelCode, string strXml, string strNewGuid)
 {
     try
     {
         EngineServicesDAL dal = new EngineServicesDAL();
         string SystemCode = string.Empty;
         if (!string.IsNullOrEmpty(strXml))
         {
             Byte[] Bo = System.Text.UTF8Encoding.UTF8.GetBytes(strXml);
             XElement xemeBoObject = XElement.Load(System.Xml.XmlReader.Create(new MemoryStream(Bo)));
             SystemCode = (from item in xemeBoObject.Descendants("Name") select item).FirstOrDefault().Value;
         }
         DataTable dtFlowTrigger = dal.FlowTriggerTable(SystemCode, ModelCode, null, null);
         if (dtFlowTrigger != null && dtFlowTrigger.Rows.Count > 0)
         {
             TaskCache.TaskCacheReflesh(ReceiveUserID);
             DataTable dtValue = Common.EncrytXmlToDataTable(strXml);
             string Url = dtFlowTrigger.Rows[0]["applicationurl"] == null ? "" : dtFlowTrigger.Rows[0]["applicationurl"].ToString();
             Url = Common.EncyptUrlNeedXMLHeader(Url, strFormID);
             // MsgTriggerBLL.ReplaceValue(ref Content, ref Url, dtValue);
             string strApplicationValue = Common.BOObjectEscapeString(strXml);
             //刷新缓存用户是否有新的待办
             //EngineCache.TaskCache.TaskCacheReflesh(ReceiveUserID);
             dal.SendTriggerTaskMsg(ReceiveUserID, SystemCode, "", strNewGuid, MsgContent, Url, strApplicationValue, string.Empty);
         }
     }
     catch (Exception e)
     {
         string cMessage = "AppMsgTrigger出现异常" + "\r\n" +
                           "ModelCode:" + ModelCode + "\r\n" +
                            "strFormID:" + strFormID + "\r\n" +
                           "异常信息:" + e.Message + "\r\n" +
                           "异常来源:" + e.Source;
         Tracer.Debug("ApplicationMsgTrigger" + cMessage);
     }
 }
Example #3
0
        /// <summary>
        /// 调用WCF返回数据转换成数据源
        /// </summary>
        /// <param name="strAppMsg">返回数据内容</param>
        /// <param name="sourceTable">原数据源Table</param>
        /// <param name="IsNewFlow">是否是新流程</param>
        /// <param name="DRFlowTrigger">新流程对应的流程定义</param>
        /// <returns></returns>
        private bool ApplicationValueToDataTable(string strAppMsg, string strCompanyID, ref DataTable sourceTable, ref string IsNewFlow, ref string NewFormID, ref string strFormTypes, ref DataRow DRFlowTrigger)
        {
            try
            {
                EngineServicesDAL dal = new EngineServicesDAL();
                if (sourceTable == null)
                {
                    sourceTable = new DataTable();
                    sourceTable.Columns.Add("FieldType", typeof(string));
                    sourceTable.Columns.Add("ColumnName", typeof(string));
                    sourceTable.Columns.Add("ColumnValue", typeof(string));
                }
                Byte[] b = System.Text.UTF8Encoding.UTF8.GetBytes(strAppMsg);
                XElement xele = XElement.Load(System.Xml.XmlReader.Create(new MemoryStream(b)));
                var v = from c in xele.Descendants("Attribute")
                        select c;
                IsNewFlow = string.Empty;
                try
                {
                    //是否是新流程(0:新流程,1:旧流程)
                    IsNewFlow = (from c in xele.Descendants("IsNewFlow") select c).FirstOrDefault().Value;
                }
                catch
                {
                    IsNewFlow = "1";
                }
                try
                {
                    NewFormID = (from c in xele.Descendants("NewFormID") select c).FirstOrDefault().Value;
                }
                catch { }
                try
                {
                    strFormTypes = (from c in xele.Descendants("FormTypes") select c).FirstOrDefault().Value;
                }
                catch { }

                if (v.Count() > 0)
                {
                    string SystemCode = string.Empty;
                    string ModelCode = string.Empty;
                    foreach (var vv in v)
                    {
                        DataRow dr = sourceTable.NewRow();
                        string Name = vv.Attribute("Name").Value.ToString();
                        DataRow[] drs = sourceTable.Select("ColumnName='" + Name + "'");
                        if (drs != null && drs.Length > 0)
                        {
                            foreach (DataRow row in drs)
                            {
                                sourceTable.Rows.Remove(row);//移除相同数据
                            }
                        }
                        string Value = vv.Attribute("DataValue").Value.ToString();
                        dr["ColumnName"] = Name;
                        dr["ColumnValue"] = Value;
                        dr["FieldType"] = "sys";
                        if (IsNewFlow == "0")
                        {
                            switch (Name)
                            {
                                case "SYSTEMCODE":
                                    SystemCode = Value;
                                    break;
                                case "MODELCODE":
                                    ModelCode = Value;
                                    break;
                            }
                        }
                        sourceTable.Rows.Add(dr);
                    }
                    //新流程,并且系统代号与模块代号不为空
                    if (IsNewFlow == "0" && !string.IsNullOrEmpty(SystemCode) && !string.IsNullOrEmpty(ModelCode))
                    {
                        DataTable table = dal.FlowTriggerTable(SystemCode, ModelCode, null, strCompanyID);
                        if (table != null && table.Rows.Count > 0)
                        {
                            DRFlowTrigger = table.Rows[0];
                        }

                    }
                    return true;
                }
            }
            catch
            {
                return false;
            }
            return false;
        }