예제 #1
0
 /// <summary>
 /// 得到审核主表最新的一个实体
 /// </summary>
 /// <param name="conn">OracleConnection</param>
 /// <param name="formid">formid</param>
 /// <returns></returns>
 public FLOW_FLOWRECORDMASTER_T GetFlowerMasterIDByFormid(OracleConnection conn, string formid)
 {
     try
     {
         FLOW_FLOWRECORDMASTER_T model = new FLOW_FLOWRECORDMASTER_T();
         string            selSql      = "SELECT INSTANCEID,FORMID,EDITUSERID,EDITUSERNAME FROM FLOW_FLOWRECORDMASTER_T WHERE   FORMID=:FORMID   ORDER BY CREATEDATE DESC";
         OracleParameter[] pageparm    =
         {
             new OracleParameter(":FORMID", OracleType.NVarChar, 100)
         };
         pageparm[0].Value = formid;
         DataTable dt = OracleDataProvider.GetDataTable(conn, selSql, pageparm);
         if (dt.Rows.Count > 0)
         {                                                               //多次提交单据的时候,取最新的一条数据
             model.INSTANCEID   = dt.Rows[0]["INSTANCEID"].ToString();   //
             model.FORMID       = dt.Rows[0]["FORMID"].ToString();       //
             model.EDITUSERID   = dt.Rows[0]["EDITUSERID"].ToString();   //
             model.EDITUSERNAME = dt.Rows[0]["EDITUSERNAME"].ToString(); //
         }
         return(model);
     }
     catch (Exception e)
     {
         throw new Exception(e.Message, e);
     }
 }
예제 #2
0
파일: FlowMonitor.cs 프로젝트: jjg0519/OA
        /// <summary>
        /// 将每一步的流程审核过程中的持久化实例保存下来
        /// </summary>
        /// <param name="submitData">SubmitData</param>
        public static void AddInstance(SubmitData submitData, FlowUser fUser)
        {
            string instanceid = "";

            try
            {
                //1查找工作流程实例ID;2查询工作流持久化对像;3保存持久化
                FLOW_INSTANCE_STATEDAL  dal    = new FLOW_INSTANCE_STATEDAL();
                FLOW_FLOWRECORDMASTER_T master = dal.GetFlowerMasterIDByFormid(dal.GetOracleConnection(), submitData.FormID);
                if (master != null && !string.IsNullOrEmpty(master.INSTANCEID.Trim()))
                {
                    FLOW_INSTANCE_STATE entity = new FLOW_INSTANCE_STATE();
                    FLOW_INSTANCE_STATE model  = dal.GetInstanceModel(dal.GetOracleConnection("OracleConnection"), master.INSTANCEID);
                    if (!string.IsNullOrEmpty(model.INSTANCE_ID))
                    {
                        instanceid         = model.INSTANCE_ID;
                        entity.INSTANCE_ID = model.INSTANCE_ID;                //
                        entity.STATE       = model.STATE;                      //
                        entity.STATUS      = model.STATUS;                     //
                        entity.UNLOCKED    = model.UNLOCKED;                   //
                        entity.BLOCKED     = model.BLOCKED;                    //
                        entity.INFO        = model.INFO;                       //
                        entity.MODIFIED    = model.MODIFIED;                   //
                        entity.OWNER_ID    = model.OWNER_ID;                   //
                        entity.OWNED_UNTIL = model.OWNED_UNTIL;                //
                        entity.NEXT_TIMER  = model.NEXT_TIMER;                 //
                        entity.CREATEID    = submitData.ApprovalUser.UserID;   //创建人ID
                        entity.CREATENAME  = submitData.ApprovalUser.UserName; //创建人姓名
                        entity.EDITID      = fUser.NextEditUserID;             //下一个审核人ID
                        entity.EDITNAME    = fUser.NextEditUserName;           //下一个审核人姓名
                        entity.FORMID      = master.FORMID;
                        FLOW_INSTANCE_STATEDAL inDal = new FLOW_INSTANCE_STATEDAL();
                        inDal.Add(inDal.GetOracleConnection(), entity);
                        LogHelper.WriteLog("Formid=" + submitData.FormID + "; instanceid=" + instanceid + " 将每一步的流程审核过程中的持久化实例保存下来,成功!");
                    }
                    else
                    {
                        LogHelper.WriteLog("Formid=" + submitData.FormID + "; 没法找到持久化数据库的instanceid,可能丢失 instanceid=" + master.INSTANCEID + " ");
                    }
                }
            }
            catch (Exception e)
            {
                LogHelper.WriteLog("Formid=" + submitData.FormID + "; instanceid=" + instanceid + " 将每一步的流程审核过程中的持久化实例保存下来出错:异常信息:" + e.ToString());
                //throw new Exception(e.Message, e);
            }
        }
예제 #3
0
        /// <summary>
        /// 获取流程(只返回前100条detail)
        /// </summary>
        /// <param name="con">OracleConnection连接对象</param>
        /// <param name="FormID">表单ID</param>
        /// <param name="FlowGUID">明细ID</param>
        /// <param name="CheckState">审批状态(同意:1,不同意:0 ,未处理:2,会签同意7,会签不同意8)</param>
        /// <param name="Flag">审批状态(已审批:1,未审批:0)</param>
        /// <param name="ModelCode">模块代码</param>
        /// <param name="CompanyID">创建公司ID</param>
        /// <param name="EditUserID">操作人</param>
        /// <param name="FlowType">流程类型(0:审批流程,1:任务流程)</param>
        /// <returns></returns>      
        public static List<FLOW_FLOWRECORDDETAIL_T> GetFlowRecordTop(OracleConnection con ,string FormID, string FlowGUID, string CheckState, string Flag, string ModelCode, string CompanyID, string EditUserID, List<string> FlowType)
        {
            if (con.State != ConnectionState.Open)
            {
                con.Open();
            }
            #region 旧的sql

//            StringBuilder sb = new StringBuilder();
//            sb.Append(@"select FLOW_FLOWRECORDMASTER_T.CHECKSTATE,FLOW_FLOWRECORDMASTER_T.CREATECOMPANYID,FLOW_FLOWRECORDMASTER_T.CREATEDATE,
//                           FLOW_FLOWRECORDMASTER_T.CREATEDEPARTMENTID,FLOW_FLOWRECORDMASTER_T.CREATEPOSTID,FLOW_FLOWRECORDMASTER_T.CREATEUSERID,
//                           FLOW_FLOWRECORDMASTER_T.CREATEUSERNAME,FLOW_FLOWRECORDMASTER_T.EDITDATE,FLOW_FLOWRECORDMASTER_T.EDITUSERID,
//                           FLOW_FLOWRECORDMASTER_T.EDITUSERNAME,FLOW_FLOWRECORDMASTER_T.FLOWCODE,FLOW_FLOWRECORDMASTER_T.FLOWRECORDMASTERID,
//                           FLOW_FLOWRECORDMASTER_T.FLOWSELECTTYPE,FLOW_FLOWRECORDMASTER_T.FLOWTYPE,FLOW_FLOWRECORDMASTER_T.FORMID,
//                       FLOW_FLOWRECORDMASTER_T.INSTANCEID,FLOW_FLOWRECORDMASTER_T.MODELCODE 
//                    from FLOW_FLOWRECORDMASTER_T");
//            sb.Append(" where FLOWRECORDMASTERID in (");
//            sb.Append(@" select distinct FLOW_FLOWRECORDMASTER_T.FLOWRECORDMASTERID from FLOW_FLOWRECORDMASTER_T 
//                            join FLOW_FLOWRECORDDETAIL_T
//                            on FLOW_FLOWRECORDMASTER_T.FLOWRECORDMASTERID=FLOW_FLOWRECORDDETAIL_T.FLOWRECORDMASTERID where 1=1");

//            #region detail 条件
//            if (!string.IsNullOrEmpty(FlowGUID))
//            {
//                sb.Append(" and FLOW_FLOWRECORDDETAIL_T.FLOWRECORDDETAILID='" + FlowGUID + "'");

//            }
//            if (!string.IsNullOrEmpty(Flag))
//            {
//                sb.Append(" and FLOW_FLOWRECORDDETAIL_T.FLAG='" + Flag + "'");
//            }

//            if (!string.IsNullOrEmpty(EditUserID))
//            {
//                sb.Append(" and (FLOW_FLOWRECORDDETAIL_T.EDITUSERID='" + EditUserID + "' or FLOW_FLOWRECORDDETAIL_T.AGENTUSERID='" + EditUserID + "')");
//            }
//            #endregion

//            #region master 条件

//            if (!string.IsNullOrEmpty(CompanyID))
//            {
//                sb.Append(" and FLOW_FLOWRECORDMASTER_T.CREATECOMPANYID='" + CompanyID + "'");
//            }
//            if (!string.IsNullOrEmpty(ModelCode))
//            {
//                sb.Append(" and FLOW_FLOWRECORDMASTER_T.MODELCODE='" + ModelCode + "'");
//            }
//            if (!string.IsNullOrEmpty(FormID))
//            {
//                sb.Append(" and FLOW_FLOWRECORDMASTER_T.FORMID='" + FormID + "'");
//            }
//            if (!string.IsNullOrEmpty(CheckState))
//            {
//                sb.Append(" and FLOW_FLOWRECORDMASTER_T.CHECKSTATE='" + CheckState + "'");
//            }

//            if (FlowType != null)
//            {
//                if (FlowType.Count == 1)
//                {
//                    sb.Append(" and FLOW_FLOWRECORDMASTER_T.FLOWTYPE='" + FlowType[0] + "'");
//                }
//                else
//                {
//                    sb.Append(" and FLOW_FLOWRECORDMASTER_T.FLOWTYPE in (");
//                    for (int i = 0; i < FlowType.Count - 1; i++)
//                    {
//                        sb.Append("'" + FlowType[i] + "',");
//                    }
//                    sb.Append("'" + FlowType[FlowType.Count - 1] + "'");
//                    sb.Append(")");
//                }
//            }
//            #endregion

//            sb.Append(")");

//            sb.Append(" and rownum <=20");
//            sb.Append(" order by FLOW_FLOWRECORDMASTER_T.CREATEDATE desc");
            #endregion
            #region 新的sql(根据结果排序)

            StringBuilder sb = new StringBuilder();
            sb.Append(@"select * from ( select FLOW_FLOWRECORDMASTER_T.CHECKSTATE,FLOW_FLOWRECORDMASTER_T.CREATECOMPANYID,FLOW_FLOWRECORDMASTER_T.CREATEDATE,
                           FLOW_FLOWRECORDMASTER_T.CREATEDEPARTMENTID,FLOW_FLOWRECORDMASTER_T.CREATEPOSTID,FLOW_FLOWRECORDMASTER_T.CREATEUSERID,
                           FLOW_FLOWRECORDMASTER_T.CREATEUSERNAME,FLOW_FLOWRECORDMASTER_T.EDITDATE,FLOW_FLOWRECORDMASTER_T.EDITUSERID,
                           FLOW_FLOWRECORDMASTER_T.EDITUSERNAME,FLOW_FLOWRECORDMASTER_T.FLOWCODE,FLOW_FLOWRECORDMASTER_T.FLOWRECORDMASTERID,
                           FLOW_FLOWRECORDMASTER_T.FLOWSELECTTYPE,FLOW_FLOWRECORDMASTER_T.FLOWTYPE,FLOW_FLOWRECORDMASTER_T.FORMID,
                       FLOW_FLOWRECORDMASTER_T.INSTANCEID,FLOW_FLOWRECORDMASTER_T.MODELCODE 
                    from FLOW_FLOWRECORDMASTER_T");
            sb.Append(" where FLOWRECORDMASTERID in (");
            sb.Append(@" select distinct FLOW_FLOWRECORDMASTER_T.FLOWRECORDMASTERID from FLOW_FLOWRECORDMASTER_T 
                            join FLOW_FLOWRECORDDETAIL_T
                            on FLOW_FLOWRECORDMASTER_T.FLOWRECORDMASTERID=FLOW_FLOWRECORDDETAIL_T.FLOWRECORDMASTERID where 1=1");

            #region detail 条件
            if (!string.IsNullOrEmpty(FlowGUID))
            {
                sb.Append(" and FLOW_FLOWRECORDDETAIL_T.FLOWRECORDDETAILID='" + FlowGUID + "'");

            }
            if (!string.IsNullOrEmpty(Flag))
            {
                sb.Append(" and FLOW_FLOWRECORDDETAIL_T.FLAG='" + Flag + "'");
            }

            if (!string.IsNullOrEmpty(EditUserID))
            {
                sb.Append(" and (FLOW_FLOWRECORDDETAIL_T.EDITUSERID='" + EditUserID + "' or FLOW_FLOWRECORDDETAIL_T.AGENTUSERID='" + EditUserID + "')");
            }
            #endregion

            #region master 条件

            if (!string.IsNullOrEmpty(CompanyID))
            {
                sb.Append(" and FLOW_FLOWRECORDMASTER_T.CREATECOMPANYID='" + CompanyID + "'");
            }
            if (!string.IsNullOrEmpty(ModelCode))
            {
                sb.Append(" and FLOW_FLOWRECORDMASTER_T.MODELCODE='" + ModelCode + "'");
            }
            if (!string.IsNullOrEmpty(FormID))
            {
                sb.Append(" and FLOW_FLOWRECORDMASTER_T.FORMID='" + FormID + "'");
            }
            if (!string.IsNullOrEmpty(CheckState))
            {
                sb.Append(" and FLOW_FLOWRECORDMASTER_T.CHECKSTATE='" + CheckState + "'");
            }

            if (FlowType != null)
            {
                if (FlowType.Count == 1)
                {
                    sb.Append(" and FLOW_FLOWRECORDMASTER_T.FLOWTYPE='" + FlowType[0] + "'");
                }
                else
                {
                    sb.Append(" and FLOW_FLOWRECORDMASTER_T.FLOWTYPE in (");
                    for (int i = 0; i < FlowType.Count - 1; i++)
                    {
                        sb.Append("'" + FlowType[i] + "',");
                    }
                    sb.Append("'" + FlowType[FlowType.Count - 1] + "'");
                    sb.Append(")");
                }
            }
            #endregion

            sb.Append(")");

            sb.Append(" and rownum <=20)");
            sb.Append(" order by CREATEDATE desc");
            #endregion
            List<FLOW_FLOWRECORDDETAIL_T> listDetail = new List<FLOW_FLOWRECORDDETAIL_T>();
            List<FLOW_FLOWRECORDMASTER_T> listMaster = new List<FLOW_FLOWRECORDMASTER_T>();          
                OracleDataReader dr = null;
                try
                {

                    List<string> listMasterID = new List<string>();
                    //OracleCommand command = con.CreateCommand();
                    //command.CommandText = sb.ToString();
                    //dr = command.ExecuteReader();
                    dr = MsOracle.ExecuteReaderByTransaction(con, sb.ToString(), null);
                    while (dr.Read())
                    {
                        #region master
                        FLOW_FLOWRECORDMASTER_T master = new FLOW_FLOWRECORDMASTER_T();

                        //master.ACTIVEROLE = dr["ACTIVEROLE"] == DBNull.Value ? null : dr["ACTIVEROLE"].ToString();
                        //master.BUSINESSOBJECT = dr["BUSINESSOBJECT"] == DBNull.Value ? null : dr["BUSINESSOBJECT"].ToString();
                        master.CHECKSTATE = dr["CHECKSTATE"] == DBNull.Value ? null : dr["CHECKSTATE"].ToString();
                        master.CREATECOMPANYID = dr["CREATECOMPANYID"] == DBNull.Value ? null : dr["CREATECOMPANYID"].ToString();
                        master.CREATEDATE = (DateTime)dr["CREATEDATE"];
                        master.CREATEDEPARTMENTID = dr["CREATEDEPARTMENTID"] == DBNull.Value ? null : dr["CREATEDEPARTMENTID"].ToString();
                        master.CREATEPOSTID = dr["CREATEPOSTID"] == DBNull.Value ? null : dr["CREATEPOSTID"].ToString();
                        master.CREATEUSERID = dr["CREATEUSERID"] == DBNull.Value ? null : dr["CREATEUSERID"].ToString();
                        master.CREATEUSERNAME = dr["CREATEUSERNAME"] == DBNull.Value ? null : dr["CREATEUSERNAME"].ToString();
                        master.EDITDATE = dr["EDITDATE"] == DBNull.Value ? null : (DateTime?)dr["EDITDATE"];
                        master.EDITUSERID = dr["EDITUSERID"] == DBNull.Value ? null : dr["EDITUSERID"].ToString();
                        master.EDITUSERNAME = dr["EDITUSERNAME"] == DBNull.Value ? null : dr["EDITUSERNAME"].ToString();
                        master.FLOWCODE = dr["FLOWCODE"] == DBNull.Value ? null : dr["FLOWCODE"].ToString();
                        master.FLOWRECORDMASTERID = dr["FLOWRECORDMASTERID"].ToString();
                        master.FLOWSELECTTYPE = dr["FLOWSELECTTYPE"] == DBNull.Value ? null : dr["FLOWSELECTTYPE"].ToString();
                        master.FLOWTYPE = dr["FLOWTYPE"] == DBNull.Value ? null : dr["FLOWTYPE"].ToString();
                        master.FORMID = dr["FORMID"] == DBNull.Value ? null : dr["FORMID"].ToString();
                        master.INSTANCEID = dr["INSTANCEID"] == DBNull.Value ? null : dr["INSTANCEID"].ToString();
                        //master.KPITIMEXML = dr["KPITIMEXML"] == DBNull.Value ? null : dr["KPITIMEXML"].ToString();
                        master.MODELCODE = dr["MODELCODE"] == DBNull.Value ? null : dr["MODELCODE"].ToString();
                        master.FLOW_FLOWRECORDDETAIL_T = new EntityCollection<FLOW_FLOWRECORDDETAIL_T>();
                        listMaster.Add(master);
                        listMasterID.Add("'" + master.FLOWRECORDMASTERID + "'");
                        #endregion

                    }
                    dr.Close();
                    if (listMasterID.Count > 0)
                    {
                        string sql = @"select *  from FLOW_FLOWRECORDDETAIL_T where FLOWRECORDMASTERID in (" + string.Join(",", listMasterID.ToArray()) + ")";
                 
                        dr = MsOracle.ExecuteReaderByTransaction(con, sql, null);
                        while (dr.Read())
                        {
                            #region detail
                            FLOW_FLOWRECORDDETAIL_T detail = new FLOW_FLOWRECORDDETAIL_T();
                            string FLOWRECORDMASTERID = dr["FLOWRECORDMASTERID"].ToString();
                            detail.FLOW_FLOWRECORDMASTER_T = listMaster.FirstOrDefault(m => m.FLOWRECORDMASTERID == FLOWRECORDMASTERID);
                            detail.FLOW_FLOWRECORDMASTER_T.FLOW_FLOWRECORDDETAIL_T.Add(detail);

                            detail.AGENTEDITDATE = dr["AGENTEDITDATE"] == DBNull.Value ? null : (DateTime?)dr["AGENTEDITDATE"];
                            detail.AGENTERNAME = dr["AGENTERNAME"] == DBNull.Value ? null : dr["AGENTERNAME"].ToString();
                            detail.AGENTUSERID = dr["AGENTUSERID"] == DBNull.Value ? null : dr["AGENTUSERID"].ToString();
                            detail.CHECKSTATE = dr["CHECKSTATE"] == DBNull.Value ? null : dr["CHECKSTATE"].ToString();
                            detail.CONTENT = dr["CONTENT"] == DBNull.Value ? null : dr["CONTENT"].ToString();
                            detail.CREATECOMPANYID = dr["CREATECOMPANYID"] == DBNull.Value ? null : dr["CREATECOMPANYID"].ToString();
                            detail.CREATEDATE = (DateTime)dr["CREATEDATE"];
                            detail.CREATEDEPARTMENTID = dr["CREATEDEPARTMENTID"] == DBNull.Value ? null : dr["CREATEDEPARTMENTID"].ToString();
                            detail.CREATEPOSTID = dr["CREATEPOSTID"] == DBNull.Value ? null : dr["CREATEPOSTID"].ToString();
                            detail.CREATEUSERID = dr["CREATEUSERID"] == DBNull.Value ? null : dr["CREATEUSERID"].ToString();
                            detail.CREATEUSERNAME = dr["CREATEUSERNAME"] == DBNull.Value ? null : dr["CREATEUSERNAME"].ToString();
                            detail.EDITCOMPANYID = dr["EDITCOMPANYID"] == DBNull.Value ? null : dr["EDITCOMPANYID"].ToString();
                            detail.EDITDATE = dr["EDITDATE"] == DBNull.Value ? null : (DateTime?)dr["EDITDATE"];
                            detail.EDITDEPARTMENTID = dr["EDITDEPARTMENTID"] == DBNull.Value ? null : dr["EDITDEPARTMENTID"].ToString();
                            detail.EDITPOSTID = dr["EDITPOSTID"] == DBNull.Value ? null : dr["EDITPOSTID"].ToString();
                            detail.EDITUSERID = dr["EDITUSERID"] == DBNull.Value ? null : dr["EDITUSERID"].ToString();
                            detail.EDITUSERNAME = dr["EDITUSERNAME"] == DBNull.Value ? null : dr["EDITUSERNAME"].ToString();
                            detail.FLAG = dr["FLAG"] == DBNull.Value ? null : dr["FLAG"].ToString();
                            //detail.FLOW_FLOWRECORDMASTER_T.FLOWRECORDMASTERID = dr["FLOWRECORDMASTERID"].ToString();
                            detail.FLOWRECORDDETAILID = dr["FLOWRECORDDETAILID"] == DBNull.Value ? null : dr["FLOWRECORDDETAILID"].ToString();
                            detail.PARENTSTATEID = dr["PARENTSTATEID"] == DBNull.Value ? null : dr["PARENTSTATEID"].ToString();
                            detail.STATECODE = dr["STATECODE"] == DBNull.Value ? null : dr["STATECODE"].ToString();
                            detail.FLOW_CONSULTATION_T = new EntityCollection<FLOW_CONSULTATION_T>();
                            listDetail.Add(detail);

                            #endregion
                        }
                        dr.Close();
                    }

                    return listDetail;

                }
                catch (Exception ex)
                {
                    if (dr != null && !dr.IsClosed)
                    {
                        dr.Close();
                    }

                    if (con.State == ConnectionState.Open)
                    {
                        con.Close();
                    }
                    throw new Exception("FLOW_FLOWRECORDDETAIL_TDAL->GetFlowRecordTop:-" + FormID + "-" + ex.Message + ex.InnerException);
                }
        

        }
예제 #4
0
        /// <summary>
        /// 获取流程
        /// </summary>
        /// <param name="con">OracleConnection连接对象</param>
        /// <param name="FormID">表单ID</param>
        /// <param name="FlowGUID">明细ID</param>
        /// <param name="CheckState">审批状态(同意:1,不同意:0 ,未处理:2,会签同意7,会签不同意8)</param>
        /// <param name="Flag">审批状态(已审批:1,未审批:0)</param>
        /// <param name="ModelCode">模块代码</param>
        /// <param name="CompanyID">创建公司ID</param>
        /// <param name="EditUserID">操作人</param>
        /// <param name="FlowType">流程类型(0:审批流程,1:任务流程)</param>
        /// <returns></returns>      
        public static List<FLOW_FLOWRECORDDETAIL_T> GetFlowRecordV(OracleConnection con, string FormID, string FlowGUID, string CheckState, string Flag, string ModelCode, string CompanyID, string EditUserID, List<string> FlowType)
        {
            if (con.State != ConnectionState.Open)
            {
                con.Open();
            }
            #region sql

            StringBuilder sb = new StringBuilder();
            sb.Append(@"select FLOW_FLOWRECORDDETAIL_T.* from FLOW_FLOWRECORDDETAIL_T
join FLOW_FLOWRECORDMASTER_T
on FLOW_FLOWRECORDMASTER_T.FLOWRECORDMASTERID=FLOW_FLOWRECORDDETAIL_T.FLOWRECORDMASTERID
where 1=1 ");

            if (!string.IsNullOrEmpty(FlowGUID))
            {
                sb.Append(" and FLOW_FLOWRECORDDETAIL_T.FLOWRECORDDETAILID='" + FlowGUID + "'");

            }
            if (!string.IsNullOrEmpty(Flag))
            {
                sb.Append(" and FLOW_FLOWRECORDDETAIL_T.FLAG='" + Flag + "'");
            }

            if (!string.IsNullOrEmpty(EditUserID))
            {
                sb.Append(" and (FLOW_FLOWRECORDDETAIL_T.EDITUSERID='" + EditUserID + "' or FLOW_FLOWRECORDDETAIL_T.AGENTUSERID='" + EditUserID + "')");
            }


            if (!string.IsNullOrEmpty(CompanyID))
            {
                sb.Append(" and FLOW_FLOWRECORDMASTER_T.CREATECOMPANYID='" + CompanyID + "'");
            }
            if (!string.IsNullOrEmpty(ModelCode))
            {
                sb.Append(" and FLOW_FLOWRECORDMASTER_T.MODELCODE='" + ModelCode + "'");
            }
            if (!string.IsNullOrEmpty(FormID))
            {
                sb.Append(" and FLOW_FLOWRECORDMASTER_T.FORMID='" + FormID + "'");
            }
            if (!string.IsNullOrEmpty(CheckState))
            {
                sb.Append(" and FLOW_FLOWRECORDMASTER_T.CHECKSTATE='" + CheckState + "'");
            }

            if (FlowType != null)
            {
                if (FlowType.Count == 1)
                {
                    sb.Append(" and FLOW_FLOWRECORDMASTER_T.FLOWTYPE='" + FlowType[0] + "'");
                }
                else
                {
                    sb.Append(" and FLOW_FLOWRECORDMASTER_T.FLOWTYPE in (");
                    for (int i = 0; i < FlowType.Count - 1; i++)
                    {
                        sb.Append("'" + FlowType[i] + "',");
                    }
                    sb.Append("'" + FlowType[FlowType.Count - 1] + "'");
                    sb.Append(")");
                }
            }


            #endregion
            List<FLOW_FLOWRECORDDETAIL_T> listDetail = new List<FLOW_FLOWRECORDDETAIL_T>();
            List<FLOW_FLOWRECORDMASTER_T> listMaster = new List<FLOW_FLOWRECORDMASTER_T>();
            
                OracleDataReader dr = null;
                try
                {
                    List<string> listDetailID = new List<string>();
                    List<string> listMasterID = new List<string>();
               
                    //OracleCommand command = con.CreateCommand();
                    //command.CommandText = sb.ToString();
                    //dr = command.ExecuteReader();
                    dr = MsOracle.ExecuteReaderByTransaction(con, sb.ToString(), null);
                    while (dr.Read())
                    {
                        #region detail
                        FLOW_FLOWRECORDDETAIL_T detail = new FLOW_FLOWRECORDDETAIL_T();
                        detail.FLOW_FLOWRECORDMASTER_T = new FLOW_FLOWRECORDMASTER_T();
                        detail.AGENTEDITDATE = dr["AGENTEDITDATE"] == DBNull.Value ? null : (DateTime?)dr["AGENTEDITDATE"];
                        detail.AGENTERNAME = dr["AGENTERNAME"] == DBNull.Value ? null : dr["AGENTERNAME"].ToString();
                        detail.AGENTUSERID = dr["AGENTUSERID"] == DBNull.Value ? null : dr["AGENTUSERID"].ToString();
                        detail.CHECKSTATE = dr["CHECKSTATE"] == DBNull.Value ? null : dr["CHECKSTATE"].ToString();
                        detail.CONTENT = dr["CONTENT"] == DBNull.Value ? null : dr["CONTENT"].ToString();
                        detail.CREATECOMPANYID = dr["CREATECOMPANYID"] == DBNull.Value ? null : dr["CREATECOMPANYID"].ToString();
                        detail.CREATEDATE = (DateTime)dr["CREATEDATE"];
                        detail.CREATEDEPARTMENTID = dr["CREATEDEPARTMENTID"] == DBNull.Value ? null : dr["CREATEDEPARTMENTID"].ToString();
                        detail.CREATEPOSTID = dr["CREATEPOSTID"] == DBNull.Value ? null : dr["CREATEPOSTID"].ToString();
                        detail.CREATEUSERID = dr["CREATEUSERID"] == DBNull.Value ? null : dr["CREATEUSERID"].ToString();
                        detail.CREATEUSERNAME = dr["CREATEUSERNAME"] == DBNull.Value ? null : dr["CREATEUSERNAME"].ToString();
                        detail.EDITCOMPANYID = dr["EDITCOMPANYID"] == DBNull.Value ? null : dr["EDITCOMPANYID"].ToString();
                        detail.EDITDATE = dr["EDITDATE"] == DBNull.Value ? null : (DateTime?)dr["EDITDATE"];
                        detail.EDITDEPARTMENTID = dr["EDITDEPARTMENTID"] == DBNull.Value ? null : dr["EDITDEPARTMENTID"].ToString();
                        detail.EDITPOSTID = dr["EDITPOSTID"] == DBNull.Value ? null : dr["EDITPOSTID"].ToString();
                        detail.EDITUSERID = dr["EDITUSERID"] == DBNull.Value ? null : dr["EDITUSERID"].ToString();
                        detail.EDITUSERNAME = dr["EDITUSERNAME"] == DBNull.Value ? null : dr["EDITUSERNAME"].ToString();
                        detail.FLAG = dr["FLAG"] == DBNull.Value ? null : dr["FLAG"].ToString();
                        detail.FLOW_FLOWRECORDMASTER_T.FLOWRECORDMASTERID = dr["FLOWRECORDMASTERID"].ToString();
                        detail.FLOWRECORDDETAILID = dr["FLOWRECORDDETAILID"] == DBNull.Value ? null : dr["FLOWRECORDDETAILID"].ToString();
                        detail.PARENTSTATEID = dr["PARENTSTATEID"] == DBNull.Value ? null : dr["PARENTSTATEID"].ToString();
                        detail.STATECODE = dr["STATECODE"] == DBNull.Value ? null : dr["STATECODE"].ToString();
                        detail.FLOW_CONSULTATION_T = new EntityCollection<FLOW_CONSULTATION_T>();
                        listDetail.Add(detail);
                        listDetailID.Add("'" + detail.FLOWRECORDDETAILID + "'");
                        if (!listMasterID.Contains(detail.FLOW_FLOWRECORDMASTER_T.FLOWRECORDMASTERID))
                        {
                            listMasterID.Add("'" + detail.FLOW_FLOWRECORDMASTER_T.FLOWRECORDMASTERID + "'");
                        }


                        #endregion
                    }
                    dr.Close();

                    #region master
                    if (listMasterID.Count > 0)
                    {
                        string sql= @"select CHECKSTATE,CREATECOMPANYID,CREATEDATE,CREATEDEPARTMENTID,CREATEPOSTID,CREATEUSERID,CREATEUSERNAME,
                                               EDITDATE,EDITUSERID,EDITUSERNAME,FLOWCODE,FLOWRECORDMASTERID,FLOWSELECTTYPE,FLOWTYPE,FORMID,INSTANCEID,MODELCODE
                                              from FLOW_FLOWRECORDMASTER_T where FLOWRECORDMASTERID in (" + string.Join(",", listMasterID.ToArray()) + ")";
                     
                        dr = MsOracle.ExecuteReaderByTransaction(con, sql, null);
                        while (dr.Read())
                        {
                            #region master
                            FLOW_FLOWRECORDMASTER_T master = new FLOW_FLOWRECORDMASTER_T();

                            //master.ACTIVEROLE = dr["ACTIVEROLE"] == DBNull.Value ? null : dr["ACTIVEROLE"].ToString();
                            //master.BUSINESSOBJECT = dr["BUSINESSOBJECT"] == DBNull.Value ? null : dr["BUSINESSOBJECT"].ToString();
                            master.CHECKSTATE = dr["CHECKSTATE"] == DBNull.Value ? null : dr["CHECKSTATE"].ToString();
                            master.CREATECOMPANYID = dr["CREATECOMPANYID"] == DBNull.Value ? null : dr["CREATECOMPANYID"].ToString();
                            master.CREATEDATE = (DateTime)dr["CREATEDATE"];
                            master.CREATEDEPARTMENTID = dr["CREATEDEPARTMENTID"] == DBNull.Value ? null : dr["CREATEDEPARTMENTID"].ToString();
                            master.CREATEPOSTID = dr["CREATEPOSTID"] == DBNull.Value ? null : dr["CREATEPOSTID"].ToString();
                            master.CREATEUSERID = dr["CREATEUSERID"] == DBNull.Value ? null : dr["CREATEUSERID"].ToString();
                            master.CREATEUSERNAME = dr["CREATEUSERNAME"] == DBNull.Value ? null : dr["CREATEUSERNAME"].ToString();
                            master.EDITDATE = dr["EDITDATE"] == DBNull.Value ? null : (DateTime?)dr["EDITDATE"];
                            master.EDITUSERID = dr["EDITUSERID"] == DBNull.Value ? null : dr["EDITUSERID"].ToString();
                            master.EDITUSERNAME = dr["EDITUSERNAME"] == DBNull.Value ? null : dr["EDITUSERNAME"].ToString();
                            master.FLOWCODE = dr["FLOWCODE"] == DBNull.Value ? null : dr["FLOWCODE"].ToString();
                            master.FLOWRECORDMASTERID = dr["FLOWRECORDMASTERID"].ToString();
                            master.FLOWSELECTTYPE = dr["FLOWSELECTTYPE"] == DBNull.Value ? null : dr["FLOWSELECTTYPE"].ToString();
                            master.FLOWTYPE = dr["FLOWTYPE"] == DBNull.Value ? null : dr["FLOWTYPE"].ToString();
                            master.FORMID = dr["FORMID"] == DBNull.Value ? null : dr["FORMID"].ToString();
                            master.INSTANCEID = dr["INSTANCEID"] == DBNull.Value ? null : dr["INSTANCEID"].ToString();
                            //master.KPITIMEXML = dr["KPITIMEXML"] == DBNull.Value ? null : dr["KPITIMEXML"].ToString();
                            master.MODELCODE = dr["MODELCODE"] == DBNull.Value ? null : dr["MODELCODE"].ToString();
                            master.FLOW_FLOWRECORDDETAIL_T = new EntityCollection<FLOW_FLOWRECORDDETAIL_T>();
                            listMaster.Add(master);
                            #endregion

                        }
                        dr.Close();

                    }
                    #endregion
                    #region FLOW_CONSULTATION_T

                    List<FLOW_CONSULTATION_T> listConsultation = new List<FLOW_CONSULTATION_T>();
                    if (!string.IsNullOrEmpty(FormID) && !string.IsNullOrEmpty(ModelCode))
                    {
                        if (listDetailID.Count > 0)
                        {

                            string sql = @"select * from FLOW_CONSULTATION_T where FLOWRECORDDETAILID in (" + string.Join(",", listDetailID.ToArray()) + ")";
                      
                            dr = MsOracle.ExecuteReaderByTransaction(con, sql, null);
                            while (dr.Read())
                            {
                                #region FLOW_CONSULTATION_T
                                FLOW_CONSULTATION_T consul = new FLOW_CONSULTATION_T();
                                consul.CONSULTATIONCONTENT = dr["CONSULTATIONCONTENT"] == DBNull.Value ? null : dr["CONSULTATIONCONTENT"].ToString();
                                consul.CONSULTATIONDATE = dr["CONSULTATIONDATE"] == DBNull.Value ? null : (DateTime?)dr["CONSULTATIONDATE"];
                                consul.CONSULTATIONID = dr["CONSULTATIONID"] == DBNull.Value ? null : dr["CONSULTATIONID"].ToString();
                                consul.CONSULTATIONUSERID = dr["CONSULTATIONUSERID"] == DBNull.Value ? null : dr["CONSULTATIONUSERID"].ToString();
                                consul.CONSULTATIONUSERNAME = dr["CONSULTATIONUSERNAME"] == DBNull.Value ? null : dr["CONSULTATIONUSERNAME"].ToString();
                                consul.FLAG = dr["FLAG"] == DBNull.Value ? null : dr["FLAG"].ToString();
                                consul.FLOW_FLOWRECORDDETAIL_T = new FLOW_FLOWRECORDDETAIL_T();
                                consul.FLOW_FLOWRECORDDETAIL_T.FLOWRECORDDETAILID = dr["FLOWRECORDDETAILID"].ToString();
                                consul.REPLYCONTENT = dr["REPLYCONTENT"] == DBNull.Value ? null : dr["REPLYCONTENT"].ToString();
                                consul.REPLYDATE = dr["REPLYDATE"] == DBNull.Value ? null : (DateTime?)dr["REPLYDATE"];
                                consul.REPLYUSERID = dr["REPLYUSERID"] == DBNull.Value ? null : dr["REPLYUSERID"].ToString();
                                consul.REPLYUSERNAME = dr["REPLYUSERNAME"] == DBNull.Value ? null : dr["REPLYUSERNAME"].ToString();

                                listConsultation.Add(consul);

                                #endregion

                            }
                            dr.Close();

                        }
                    }
                    #endregion
              
                    listDetail.ForEach(detail =>
                    {
                        #region
                        FLOW_FLOWRECORDMASTER_T master = listMaster.FirstOrDefault(m => m.FLOWRECORDMASTERID == detail.FLOW_FLOWRECORDMASTER_T.FLOWRECORDMASTERID);

                        detail.FLOW_FLOWRECORDMASTER_T = master;
                        if (master.FLOW_FLOWRECORDDETAIL_T == null)
                        {
                            master.FLOW_FLOWRECORDDETAIL_T = new EntityCollection<FLOW_FLOWRECORDDETAIL_T>();
                        }
                        master.FLOW_FLOWRECORDDETAIL_T.Add(detail);

                        if (!string.IsNullOrEmpty(FormID) && !string.IsNullOrEmpty(ModelCode))
                        {
                            IEnumerable<FLOW_CONSULTATION_T> iFLOW_CONSULTATION_T = listConsultation.Where(c => c.FLOW_FLOWRECORDDETAIL_T.FLOWRECORDDETAILID == detail.FLOWRECORDDETAILID);
                            if (iFLOW_CONSULTATION_T.Count() > 0)
                            {
                                detail.FLOW_CONSULTATION_T = new EntityCollection<FLOW_CONSULTATION_T>();
                                foreach (var consultation in iFLOW_CONSULTATION_T)
                                {
                                    consultation.FLOW_FLOWRECORDDETAIL_T = detail;
                                    detail.FLOW_CONSULTATION_T.Add(consultation);
                                }
                            }
                        }
                        #endregion
                    });
                    return listDetail;

                }
                catch (Exception ex)
                {
                    if (dr != null && !dr.IsClosed)
                    {
                        dr.Close();
                    }

                    if (con.State == ConnectionState.Open)
                    {
                        con.Close();
                    }
                    throw new Exception("FLOW_FLOWRECORDDETAIL_TDAL->GetFlowRecordV:-" + FormID + "-" + ex.Message + ex.InnerException);
                }

    



        }
예제 #5
0
파일: FlowBLL2.cs 프로젝트: JuRogn/OA
        /// <summary>
        /// 新增流程(对数据库操作)
        /// </summary>
        /// <param name="ApprovalData"></param>
        /// <param name="APPDataResult"></param>
        /// <returns></returns>    
        public DataResult AddFlow2(OracleConnection con, SubmitData submitData, DataResult dataResult, ref string msg)
        {
            // WorkflowRuntime workflowRuntime = null;
            WorkflowInstance instance = null;


            try
            {
                msg += "获取定义的流程" + DateTime.Now.ToString() + "\r\n";
                #region 获取定义的流程
                LogHelper.WriteLog("获取定义的流程.GetFlowByModelName:submitData.ApprovalUser.DepartmentID=" + submitData.ApprovalUser.DepartmentID + ";OrgType='" + ((int)submitData.FlowType).ToString() + "'");
                List<FLOW_MODELFLOWRELATION_T> MODELFLOWRELATION = GetFlowByModelName(con, submitData.ApprovalUser.CompanyID, submitData.ApprovalUser.DepartmentID, submitData.ModelCode, ((int)submitData.FlowType).ToString());//对数据库操作
                if (MODELFLOWRELATION == null || MODELFLOWRELATION.Count == 0)
                {
                    dataResult.FlowResult = FlowResult.FAIL;
                    dataResult.Err = "没有找到可使用的流程";
                    return dataResult;
                }
                msg += "获取定义的流程完成" + DateTime.Now.ToString() + "\r\n";
                #endregion
                FLOW_MODELFLOWRELATION_T flowRelation = MODELFLOWRELATION[0];
                FLOW_FLOWDEFINE_T flowDefine = flowRelation.FLOW_FLOWDEFINE_T;
                if (flowDefine.RULES != null && flowDefine.RULES.Trim() == "")
                {
                    flowDefine.RULES = null;
                }
                //if (string.IsNullOrEmpty(flowDefine.RULES.Trim()))
                //{
                //    flowDefine.RULES = null;
                //}
                msg += " SMTWorkFlowManage.CreateWorkFlowRuntime(true)" + DateTime.Now.ToString() + "\r\n";
                workflowRuntime = SMTWorkFlowManage.CreateWorkFlowRuntime(true);
                instance = SMTWorkFlowManage.CreateWorkflowInstance(workflowRuntime, flowDefine.XOML, flowDefine.RULES);
                LogHelper.WriteLog("AddFlow2创建工作流实例ID=" + instance.InstanceId);
                workflowRuntime.WorkflowCompleted += delegate(object sender, WorkflowCompletedEventArgs e)
                {
                    instance = null;

                };
                msg += " SMTWorkFlowManage.CreateWorkFlowRuntime(true)完成" + DateTime.Now.ToString() + "\r\n";
                #region master赋值
                FLOW_FLOWRECORDMASTER_T master = new FLOW_FLOWRECORDMASTER_T();
                master.INSTANCEID = instance.InstanceId.ToString();
                master.BUSINESSOBJECT = submitData.XML;
                master.FORMID = submitData.FormID;
                master.MODELCODE = submitData.ModelCode;
                master.ACTIVEROLE = Utility.GetActiveRlue(flowDefine.LAYOUT);
                master.FLOWTYPE = ((int)submitData.FlowType).ToString();
                master.FLOWSELECTTYPE = ((int)submitData.FlowSelectType).ToString();
                master.FLOWCODE = flowDefine.FLOWCODE;
                #endregion

                #region 获取下一状态数据
                msg += " 获取下一状态数据" + DateTime.Now.ToString() + "\r\n";
                DateTime star = DateTime.Now;
                GetUserByFlow2(submitData.ApprovalUser.CompanyID, flowDefine.XOML, flowDefine.RULES, master.ACTIVEROLE, submitData.XML, submitData.ApprovalUser.UserID, submitData.ApprovalUser.PostID, submitData.FlowType, ref dataResult, ref msg);
                DateTime end = DateTime.Now;
                msg += " 获取下一状态数据完成" + DateTime.Now.ToString() + "\r\n";
                string str = Service2.DateDiff(end, star);
                if (dataResult.FlowResult == FlowResult.FAIL)
                {
                    return dataResult;
                }
                submitData.NextStateCode = dataResult.AppState;
                if (dataResult.IsCountersign)
                {
                    #region
                    if (dataResult.FlowResult == FlowResult.Countersign)
                    {
                        if (submitData.DictCounterUser == null || submitData.DictCounterUser.Keys.Count == 0)
                        {
                            return dataResult;
                        }
                    }
                    else
                    {
                        if (submitData.DictCounterUser == null || submitData.DictCounterUser.Keys.Count == 0)
                        {
                            submitData.DictCounterUser = dataResult.DictCounterUser;
                        }
                    }
                    #endregion
                }
                else
                {
                    #region
                    if (dataResult.FlowResult == FlowResult.MULTIUSER)
                    {
                        if (submitData.NextApprovalUser == null || (Utility.GetString(submitData.NextApprovalUser.UserID) == "" || Utility.GetString(submitData.NextApprovalUser.UserName) == ""))
                        {
                            return dataResult;
                        }
                    }
                    else
                    {
                        if (submitData.DictCounterUser == null || submitData.DictCounterUser.Keys.Count == 0)
                        {
                            submitData.NextApprovalUser = dataResult.UserInfo[0];
                        }
                    }
                    #endregion
                }

                #endregion

                #region 实体赋值
                FLOW_FLOWRECORDDETAIL_T entity = new FLOW_FLOWRECORDDETAIL_T();
                entity.FLOW_FLOWRECORDMASTER_T = master;
                entity.CREATECOMPANYID = submitData.ApprovalUser.CompanyID;
                entity.CREATEDEPARTMENTID = submitData.ApprovalUser.DepartmentID;
                entity.CREATEPOSTID = submitData.ApprovalUser.PostID;
                entity.CREATEUSERID = submitData.ApprovalUser.UserID;
                entity.CREATEUSERNAME = submitData.ApprovalUser.UserName;
                #endregion
                msg += " 处理kpi时间" + DateTime.Now.ToString() + "\r\n";
                #region 处理kpi时间
                string KPITime = "";
                #region 加入缓存
                string pscResult = CacheProvider.GetCache<string>(flowRelation.MODELFLOWRELATIONID);
                if (string.IsNullOrEmpty(pscResult))
                {
                    PerformanceServiceWS.PerformanceServiceClient psc = new PerformanceServiceWS.PerformanceServiceClient();
                    pscResult = psc.GetKPIPointsByBusinessCode(flowRelation.MODELFLOWRELATIONID);//调用服务
                    CacheProvider.Add<string>(flowRelation.MODELFLOWRELATIONID, pscResult);
                    psc.Close();
                }
                #endregion
                //PerformanceServiceWS.PerformanceServiceClient psc = new PerformanceServiceWS.PerformanceServiceClient();
                //string pscResult = psc.GetKPIPointsByBusinessCode(flowRelation.MODELFLOWRELATIONID);//调用服务
                //psc.Close();
                if (!string.IsNullOrEmpty(pscResult))
                {
                    XElement xe = XElement.Parse(pscResult);
                    Func<XElement, bool> f = (x) =>
                    {
                        XAttribute xid = x.Attribute("id");
                        XAttribute xvalue = x.Attribute("value");
                        if (xid == null || xvalue == null)
                            return false;
                        else
                        {
                            if (xid.Value == dataResult.AppState)
                                return true;
                            else return false;
                        }
                    };
                    XElement FlowNode = xe.Elements("FlowNode").FirstOrDefault(f);
                    if (FlowNode != null)
                    {
                        KPITime = FlowNode.Attribute("value").Value;
                    }
                }

                dataResult.KPITime = KPITime;
                master.KPITIMEXML = pscResult;
                #endregion
                msg += " 处理kpi时间完成" + DateTime.Now.ToString() + "\r\n";
                FlowDataType.FlowData FlowData = new FlowDataType.FlowData();
                FlowData.xml = submitData.XML;

                if (!dataResult.IsCountersign)
                {
                    #region  非会签
                    UserInfo AppUser = new UserInfo(); //下一审核人
                    AppUser = submitData.NextApprovalUser;
                    dataResult.UserInfo.Clear();
                    dataResult.UserInfo.Add(AppUser);
                    UserInfo AgentAppUser = GetAgentUserInfo(submitData.ModelCode, AppUser.UserID);//查询是否启用了代理人                    
                    dataResult = DoFlowRecord2(con, workflowRuntime, instance, entity, submitData.NextStateCode, AppUser, AgentAppUser, submitData.SubmitFlag, submitData.FlowType); //处理流程数据
                    dataResult.IsCountersign = false;
                    dataResult.AgentUserInfo = AgentAppUser;
                    #endregion
                }
                else
                {
                    msg += " 会签" + DateTime.Now.ToString() + "\r\n";
                    #region  会签
                    //Tracer.Debug("-----DoFlowRecord_Add:" + DateTime.Now.ToString()+"\n");
                    dataResult.DictCounterUser = submitData.DictCounterUser;
                    Dictionary<UserInfo, UserInfo> dictAgentUserInfo = GetAgentUserInfo2(submitData.ModelCode, submitData.DictCounterUser);
                    dataResult = DoFlowRecord_Add(con, workflowRuntime, instance, entity, submitData.NextStateCode, submitData.DictCounterUser, dictAgentUserInfo, submitData.SubmitFlag, submitData.FlowType); //处理流程数据
                    //Tracer.Debug("-----DoFlowRecord_AddEnd:" + DateTime.Now.ToString()+"\n");
                    dataResult.IsCountersign = true;
                    dataResult.DictAgentUserInfo = dictAgentUserInfo;
                    #endregion
                    msg += "会签完成" + DateTime.Now.ToString() + "\r\n";
                }
                msg += "激发流程引擎执行到一下流程" + DateTime.Now.ToString() + "\r\n";
                #region 激发流程引擎执行到一下流程
                string ss = "";
                int n = 0;
                if (dataResult.AppState == null || dataResult.AppState == "")
                {
                    msg += " workflowRuntime.GetService<FlowEvent>()" + DateTime.Now.ToString() + "\r\n";
                    workflowRuntime.GetService<FlowEvent>().OnDoFlow(instance.InstanceId, FlowData); //激发流程引擎执行到一下流程
                    msg += " workflowRuntime.GetService<FlowEvent>()完成" + DateTime.Now.ToString() + "\r\n";
                }
                else
                {
                    StateMachineWorkflowInstance workflowinstance = new StateMachineWorkflowInstance(workflowRuntime, instance.InstanceId);

                    workflowinstance.SetState(dataResult.AppState); //流程跳转到指定节点

                    while (true)
                    {

                        ss += (n++).ToString() + "|" + workflowinstance.CurrentStateName + "\r\n";
                        string stateName = workflowinstance.CurrentStateName;
                        if (stateName != null && stateName.ToUpper().IndexOf("STATE") >= 0)
                        {
                            break;
                        }

                    }
                }

                #endregion
                msg += "激发流程引擎执行到一下流程完成" + DateTime.Now.ToString() + "\r\n";
                msg += "System.Threading.Thread.Sleep(1000)" + DateTime.Now.ToString() + "\r\n";
                //System.Threading.Thread.Sleep(1000);//当前用到
                dataResult.ModelFlowRelationID = flowRelation.MODELFLOWRELATIONID; //返回关联ID
                dataResult.KPITime = KPITime;
                //dataResult.CanSendMessage = true;
                if (submitData.FlowType == FlowType.Task)
                {
                    dataResult.SubModelCode = Utility.GetSubModelCode(master.ACTIVEROLE, dataResult.AppState); //返回下一子模块代码
                }
                msg += "System.Threading.Thread.Sleep(1000)完成" + DateTime.Now.ToString() + "\r\n";
                return dataResult;
            }

            catch (Exception e)
            {

                throw new Exception(e.Message);
            }
            finally
            {

                instance = null;
                SMTWorkFlowManage.ColseWorkFlowRuntime(workflowRuntime);
            }


        }
예제 #6
0
        /// <summary>
        /// 更新:[流程审批实例表]
        /// </summary>
        /// <param name="con">OracleConnection 连接对象</param>
        /// <param name="model">流程审批实例表</param>
        public static int Update(OracleConnection con, FLOW_FLOWRECORDMASTER_T model)
        {
            try
            {
                if (con.State != ConnectionState.Open)
                {
                    con.Open();
                }
                string updSql = "UPDATE FLOW_FLOWRECORDMASTER_T SET INSTANCEID=:INSTANCEID,FLOWSELECTTYPE=:FLOWSELECTTYPE,MODELCODE=:MODELCODE,FLOWCODE=:FLOWCODE,FORMID=:FORMID,FLOWTYPE=:FLOWTYPE,CHECKSTATE=:CHECKSTATE,CREATEUSERID=:CREATEUSERID,CREATEUSERNAME=:CREATEUSERNAME,CREATECOMPANYID=:CREATECOMPANYID,CREATEDEPARTMENTID=:CREATEDEPARTMENTID,CREATEPOSTID=:CREATEPOSTID,CREATEDATE=:CREATEDATE,EDITUSERID=:EDITUSERID,EDITUSERNAME=:EDITUSERNAME,EDITDATE=:EDITDATE,ACTIVEROLE=:ACTIVEROLE,BUSINESSOBJECT=:BUSINESSOBJECT,KPITIMEXML=:KPITIMEXML WHERE   FLOWRECORDMASTERID=:FLOWRECORDMASTERID";
                OracleParameter[] pageparm =
                {               
                    new OracleParameter(":FLOWRECORDMASTERID",OracleType.NVarChar), 
                    new OracleParameter(":INSTANCEID",OracleType.NVarChar), 
                    new OracleParameter(":FLOWSELECTTYPE",OracleType.NVarChar), 
                    new OracleParameter(":MODELCODE",OracleType.NVarChar), 
                    new OracleParameter(":FLOWCODE",OracleType.NVarChar), 
                    new OracleParameter(":FORMID",OracleType.NVarChar), 
                    new OracleParameter(":FLOWTYPE",OracleType.NVarChar), 
                    new OracleParameter(":CHECKSTATE",OracleType.NVarChar), 
                    new OracleParameter(":CREATEUSERID",OracleType.NVarChar), 
                    new OracleParameter(":CREATEUSERNAME",OracleType.NVarChar), 
                    new OracleParameter(":CREATECOMPANYID",OracleType.NVarChar), 
                    new OracleParameter(":CREATEDEPARTMENTID",OracleType.NVarChar), 
                    new OracleParameter(":CREATEPOSTID",OracleType.NVarChar), 
                    new OracleParameter(":CREATEDATE",OracleType.DateTime), 
                    new OracleParameter(":EDITUSERID",OracleType.NVarChar), 
                    new OracleParameter(":EDITUSERNAME",OracleType.NVarChar), 
                    new OracleParameter(":EDITDATE",OracleType.DateTime), 
                    new OracleParameter(":ACTIVEROLE",OracleType.NVarChar), 
                    new OracleParameter(":BUSINESSOBJECT",OracleType.NVarChar), 
                    new OracleParameter(":KPITIMEXML",OracleType.NVarChar) 

                };
                pageparm[0].Value = MsOracle.GetValue(model.FLOWRECORDMASTERID);//
                pageparm[1].Value = MsOracle.GetValue(model.INSTANCEID);//
                pageparm[2].Value = MsOracle.GetValue(model.FLOWSELECTTYPE);//0:固定流程,1:自选流程
                pageparm[3].Value = MsOracle.GetValue(model.MODELCODE);//
                pageparm[4].Value = MsOracle.GetValue(model.FLOWCODE);//
                pageparm[5].Value = MsOracle.GetValue(model.FORMID);//
                pageparm[6].Value = MsOracle.GetValue(model.FLOWTYPE);//0:审批流程,1:任务流程
                pageparm[7].Value = MsOracle.GetValue(model.CHECKSTATE);//1:审批中,2:审批通过,3审批不通过,5撤销(为与字典保持一致)
                pageparm[8].Value = MsOracle.GetValue(model.CREATEUSERID);//
                pageparm[9].Value = MsOracle.GetValue(model.CREATEUSERNAME);//
                pageparm[10].Value = MsOracle.GetValue(model.CREATECOMPANYID);//
                pageparm[11].Value = MsOracle.GetValue(model.CREATEDEPARTMENTID);//
                pageparm[12].Value = MsOracle.GetValue(model.CREATEPOSTID);//
                pageparm[13].Value = MsOracle.GetValue(model.CREATEDATE);//
                pageparm[14].Value = MsOracle.GetValue(model.EDITUSERID);//
                pageparm[15].Value = MsOracle.GetValue(model.EDITUSERNAME);//
                pageparm[16].Value = MsOracle.GetValue(model.EDITDATE);//
                pageparm[17].Value = MsOracle.GetValue(model.ACTIVEROLE);//
                pageparm[18].Value = MsOracle.GetValue(model.BUSINESSOBJECT);//
                pageparm[19].Value = MsOracle.GetValue(model.KPITIMEXML);//

                int n = MsOracle.ExecuteSQLByTransaction(con, updSql, pageparm);
                LogHelper.WriteLog("FLOW_FLOWRECORDMASTER_TDAL->Update 更新:[流程审批实例表]成功:FLOWRECORDDETAILID=" + model.FLOWRECORDMASTERID + ";EDITUSERID=" + model.EDITUSERID + ";CHECKSTATE=" + model.CHECKSTATE + ";时间:" + DateTime.Now.ToString());
                return n;

            }
            catch (Exception ex)
            {
                if (con.State == ConnectionState.Open)
                {
                    con.Close();
                }
                LogHelper.WriteLog("FLOW_FLOWRECORDMASTER_TDAL->Update 更新:[流程审批实例表]失败:FLOWRECORDDETAILID=" + model.FLOWRECORDMASTERID + ";EDITUSERID=" + model.EDITUSERID + ";CHECKSTATE=" + model.CHECKSTATE + ";时间:" + DateTime.Now.ToString() + "\r\n异常信息:" + ex.Message);

                throw new Exception("FLOW_FLOWRECORDMASTER_TDAL->Update:" + ex.Message);
            }


        }
예제 #7
0
        public static FLOW_FLOWRECORDMASTER_T GetFLOW_FLOWRECORDMASTER_T(string masterID)
        {
            using (OracleConnection con = new OracleConnection(ADOHelper.ContextOracleConnection))
            {
                OracleDataReader dr = null;

                try
                {
                    string sql = @"select * from FLOW_FLOWRECORDMASTER_T where flowrecordmasterid='{0}'";
                    FLOW_FLOWRECORDMASTER_T master = null;
                    sql = string.Format(sql, masterID);
                    con.Open();
                    OracleCommand command = con.CreateCommand();
                    command.CommandText = sql;
                    dr = command.ExecuteReader();

                    while (dr.Read())
                    {
                        #region master
                        master = new FLOW_FLOWRECORDMASTER_T();
                        master.ACTIVEROLE = dr["ACTIVEROLE"] == DBNull.Value ? null : dr["ACTIVEROLE"].ToString();
                        master.BUSINESSOBJECT = dr["BUSINESSOBJECT"] == DBNull.Value ? null : dr["BUSINESSOBJECT"].ToString();
                        master.CHECKSTATE = dr["CHECKSTATE"] == DBNull.Value ? null : dr["CHECKSTATE"].ToString();
                        master.CREATECOMPANYID = dr["CREATECOMPANYID"] == DBNull.Value ? null : dr["CREATECOMPANYID"].ToString();
                        master.CREATEDATE = (DateTime)dr["CREATEDATE"];
                        master.CREATEDEPARTMENTID = dr["CREATEDEPARTMENTID"] == DBNull.Value ? null : dr["CREATEDEPARTMENTID"].ToString();
                        master.CREATEPOSTID = dr["CREATEPOSTID"] == DBNull.Value ? null : dr["CREATEPOSTID"].ToString();
                        master.CREATEUSERID = dr["CREATEUSERID"] == DBNull.Value ? null : dr["CREATEUSERID"].ToString();
                        master.CREATEUSERNAME = dr["CREATEUSERNAME"] == DBNull.Value ? null : dr["CREATEUSERNAME"].ToString();
                        master.EDITDATE = dr["EDITDATE"] == DBNull.Value ? null : (DateTime?)dr["EDITDATE"];
                        master.EDITUSERID = dr["EDITUSERID"] == DBNull.Value ? null : dr["EDITUSERID"].ToString();
                        master.EDITUSERNAME = dr["EDITUSERNAME"] == DBNull.Value ? null : dr["EDITUSERNAME"].ToString();
                        master.FLOWCODE = dr["FLOWCODE"] == DBNull.Value ? null : dr["FLOWCODE"].ToString();
                        master.FLOWRECORDMASTERID = dr["FLOWRECORDMASTERID"].ToString();
                        master.FLOWSELECTTYPE = dr["FLOWSELECTTYPE"] == DBNull.Value ? null : dr["FLOWSELECTTYPE"].ToString();
                        master.FLOWTYPE = dr["FLOWTYPE"] == DBNull.Value ? null : dr["FLOWTYPE"].ToString();
                        master.FORMID = dr["FORMID"] == DBNull.Value ? null : dr["FORMID"].ToString();
                        master.INSTANCEID = dr["INSTANCEID"] == DBNull.Value ? null : dr["INSTANCEID"].ToString();
                        master.KPITIMEXML = dr["KPITIMEXML"] == DBNull.Value ? null : dr["KPITIMEXML"].ToString();
                        master.MODELCODE = dr["MODELCODE"] == DBNull.Value ? null : dr["MODELCODE"].ToString();

                        #endregion

                    }
                    dr.Close();
                    con.Close();
                    return master;


                }
                catch (Exception ex)
                {
                    if (dr != null && !dr.IsClosed)
                    {
                        dr.Close();
                    }

                    if (con.State == ConnectionState.Open)
                    {
                        con.Close();
                    }
                    throw new Exception("GetFLOW_FLOWRECORDMASTER_T:" + ex.Message + ex.InnerException);
                }

            }
        }
예제 #8
0
        public static List<FLOW_FLOWRECORDMASTER_T> GetFlowRecordBySubmitUserID(string CheckState, string EditUserID)
        {
            List<FLOW_FLOWRECORDMASTER_T> listMaster = new List<FLOW_FLOWRECORDMASTER_T>();
            List<string> listMasterID = new List<string>();
            using (OracleConnection con = new OracleConnection(ADOHelper.ContextOracleConnection))
            {
                OracleDataReader dr = null;
                try
                {
                    StringBuilder sbMaster = new StringBuilder();
                    sbMaster.Append(@"select FLOWRECORDMASTERID,INSTANCEID,MODELCODE,FLOWCODE,
                                        FORMID,CHECKSTATE,CREATEUSERID,CREATEUSERNAME,CREATECOMPANYID,CREATEDEPARTMENTID,CREATEPOSTID,
                                         CREATEDATE,EDITUSERID,EDITUSERNAME,EDITDATE,FLOWTYPE,FLOWSELECTTYPE
                                         from FLOW_FLOWRECORDMASTER_T where 1=1 ");
                    if (!string.IsNullOrEmpty(EditUserID))
                    {
                        sbMaster.Append(" and CREATEUSERID='" + EditUserID + "'");
                    }

                    if (!string.IsNullOrEmpty(CheckState))
                    {
                        sbMaster.Append(" and CHECKSTATE='" + CheckState + "'");
                    }


                    #region
                    con.Open();
                    OracleCommand cmd = con.CreateCommand();
                    cmd.CommandText = sbMaster.ToString();
                    dr = cmd.ExecuteReader();
                    while (dr.Read())
                    {
                        #region master
                        FLOW_FLOWRECORDMASTER_T master = new FLOW_FLOWRECORDMASTER_T();
                        //master.ACTIVEROLE = dr["ACTIVEROLE"] == DBNull.Value ? null : dr["ACTIVEROLE"].ToString();
                        //master.BUSINESSOBJECT = dr["BUSINESSOBJECT"] == DBNull.Value ? null : dr["BUSINESSOBJECT"].ToString();
                        master.CHECKSTATE = dr["CHECKSTATE"] == DBNull.Value ? null : dr["CHECKSTATE"].ToString();
                        master.CREATECOMPANYID = dr["CREATECOMPANYID"] == DBNull.Value ? null : dr["CREATECOMPANYID"].ToString();
                        master.CREATEDATE = (DateTime)dr["CREATEDATE"];
                        master.CREATEDEPARTMENTID = dr["CREATEDEPARTMENTID"] == DBNull.Value ? null : dr["CREATEDEPARTMENTID"].ToString();
                        master.CREATEPOSTID = dr["CREATEPOSTID"] == DBNull.Value ? null : dr["CREATEPOSTID"].ToString();
                        master.CREATEUSERID = dr["CREATEUSERID"] == DBNull.Value ? null : dr["CREATEUSERID"].ToString();
                        master.CREATEUSERNAME = dr["CREATEUSERNAME"] == DBNull.Value ? null : dr["CREATEUSERNAME"].ToString();
                        master.EDITDATE = dr["EDITDATE"] == DBNull.Value ? null : (DateTime?)dr["EDITDATE"];
                        master.EDITUSERID = dr["EDITUSERID"] == DBNull.Value ? null : dr["EDITUSERID"].ToString();
                        master.EDITUSERNAME = dr["EDITUSERNAME"] == DBNull.Value ? null : dr["EDITUSERNAME"].ToString();
                        master.FLOWCODE = dr["FLOWCODE"] == DBNull.Value ? null : dr["FLOWCODE"].ToString();
                        master.FLOWRECORDMASTERID = dr["FLOWRECORDMASTERID"].ToString();
                        master.FLOWSELECTTYPE = dr["FLOWSELECTTYPE"] == DBNull.Value ? null : dr["FLOWSELECTTYPE"].ToString();
                        master.FLOWTYPE = dr["FLOWTYPE"] == DBNull.Value ? null : dr["FLOWTYPE"].ToString();
                        master.FORMID = dr["FORMID"] == DBNull.Value ? null : dr["FORMID"].ToString();
                        master.INSTANCEID = dr["INSTANCEID"] == DBNull.Value ? null : dr["INSTANCEID"].ToString();
                        //master.KPITIMEXML = dr["KPITIMEXML"] == DBNull.Value ? null : dr["KPITIMEXML"].ToString();
                        master.MODELCODE = dr["MODELCODE"] == DBNull.Value ? null : dr["MODELCODE"].ToString();
                        master.FLOW_FLOWRECORDDETAIL_T = new EntityCollection<FLOW_FLOWRECORDDETAIL_T>();
                        listMaster.Add(master);
                        listMasterID.Add("'" + master.FLOWRECORDMASTERID + "'");
                        #endregion

                    }
                    dr.Close();

                    if (listMasterID.Count > 0)
                    {
                        #region detail
                        cmd.CommandText = @"select * from FLOW_FLOWRECORDDETAIL_T where FLOWRECORDMASTERID in (" + string.Join(",", listMasterID.ToArray()) + ")";
                        dr = cmd.ExecuteReader();
                        while (dr.Read())
                        {
                            #region detail
                            FLOW_FLOWRECORDDETAIL_T detail = new FLOW_FLOWRECORDDETAIL_T();
                            detail.FLOW_FLOWRECORDMASTER_T = listMaster.FirstOrDefault(m => m.FLOWRECORDMASTERID == dr["FLOWRECORDMASTERID"].ToString());
                            detail.FLOW_FLOWRECORDMASTER_T.FLOW_FLOWRECORDDETAIL_T.Add(detail);
                            detail.AGENTEDITDATE = dr["AGENTEDITDATE"] == DBNull.Value ? null : (DateTime?)dr["AGENTEDITDATE"];
                            detail.AGENTERNAME = dr["AGENTERNAME"] == DBNull.Value ? null : dr["AGENTERNAME"].ToString();
                            detail.AGENTUSERID = dr["AGENTUSERID"] == DBNull.Value ? null : dr["AGENTUSERID"].ToString();
                            detail.CHECKSTATE = dr["CHECKSTATE"] == DBNull.Value ? null : dr["CHECKSTATE"].ToString();
                            detail.CONTENT = dr["CONTENT"] == DBNull.Value ? null : dr["CONTENT"].ToString();
                            detail.CREATECOMPANYID = dr["CREATECOMPANYID"] == DBNull.Value ? null : dr["CREATECOMPANYID"].ToString();
                            detail.CREATEDATE = (DateTime)dr["CREATEDATE"];
                            detail.CREATEDEPARTMENTID = dr["CREATEDEPARTMENTID"] == DBNull.Value ? null : dr["CREATEDEPARTMENTID"].ToString();
                            detail.CREATEPOSTID = dr["CREATEPOSTID"] == DBNull.Value ? null : dr["CREATEPOSTID"].ToString();
                            detail.CREATEUSERID = dr["CREATEUSERID"] == DBNull.Value ? null : dr["CREATEUSERID"].ToString();
                            detail.CREATEUSERNAME = dr["CREATEUSERNAME"] == DBNull.Value ? null : dr["CREATEUSERNAME"].ToString();
                            detail.EDITCOMPANYID = dr["EDITCOMPANYID"] == DBNull.Value ? null : dr["EDITCOMPANYID"].ToString();
                            detail.EDITDATE = dr["EDITDATE"] == DBNull.Value ? null : (DateTime?)dr["EDITDATE"];
                            detail.EDITDEPARTMENTID = dr["EDITDEPARTMENTID"] == DBNull.Value ? null : dr["EDITDEPARTMENTID"].ToString();
                            detail.EDITPOSTID = dr["EDITPOSTID"] == DBNull.Value ? null : dr["EDITPOSTID"].ToString();
                            detail.EDITUSERID = dr["EDITUSERID"] == DBNull.Value ? null : dr["EDITUSERID"].ToString();
                            detail.EDITUSERNAME = dr["EDITUSERNAME"] == DBNull.Value ? null : dr["EDITUSERNAME"].ToString();
                            detail.FLAG = dr["FLAG"] == DBNull.Value ? null : dr["FLAG"].ToString();
                            //detail.FLOW_FLOWRECORDMASTER_T.FLOWRECORDMASTERID = dr["FLOWRECORDMASTERID"].ToString();
                            detail.FLOWRECORDDETAILID = dr["FLOWRECORDDETAILID"] == DBNull.Value ? null : dr["FLOWRECORDDETAILID"].ToString();
                            detail.PARENTSTATEID = dr["PARENTSTATEID"] == DBNull.Value ? null : dr["PARENTSTATEID"].ToString();
                            detail.STATECODE = dr["STATECODE"] == DBNull.Value ? null : dr["STATECODE"].ToString();
                            #endregion
                        }
                        dr.Close();
                        #endregion
                    }

                    con.Close();
                    return listMaster;
                    #endregion


                }
                catch (Exception ex)
                {
                    if (dr != null && !dr.IsClosed)
                    {
                        dr.Close();
                    }
                    if (con.State == ConnectionState.Open)
                    {
                        con.Close();
                    }
                    throw ex;
                }

            }
        }
예제 #9
0
        public static void UpdateMasterINSTANCEID(FLOW_FLOWRECORDMASTER_T master)
        {
            using (OracleConnection con = new OracleConnection(ADOHelper.ContextOracleConnection))
            {
                try
                {
                    #region
                    con.Open();


                    OracleCommand cmd = con.CreateCommand();
                    cmd.CommandText = "update FLOW_FLOWRECORDMASTER_T set INSTANCEID='" + master.INSTANCEID + "'  where FLOWRECORDMASTERID='" + master.FLOWRECORDMASTERID + "'";

                    cmd.ExecuteNonQuery();
                    con.Close();
                    #endregion


                }
                catch (Exception ex)
                {
                    if (con.State == ConnectionState.Open)
                    {
                        con.Close();
                    }
                    throw ex;
                }

            }
        }
예제 #10
0
        public static void Update(FLOW_FLOWRECORDMASTER_T master)
        {
            using (OracleConnection con = new OracleConnection(ADOHelper.ContextOracleConnection))
            {
                StringBuilder sb = new StringBuilder();//更新流程主表状态记录日志
                sb.AppendLine("FLOWRECORDMASTERID=" + master.FLOWRECORDMASTERID + "\r\n");
                sb.AppendLine("INSTANCEID=" + master.INSTANCEID + "\r\n");
                sb.AppendLine("MODELCODE=" + master.MODELCODE + "\r\n");
                sb.AppendLine("FLOWCODE=" + master.FLOWCODE + "\r\n");
                sb.AppendLine("FORMID=" + master.FORMID + "\r\n");
                sb.AppendLine("CHECKSTATE=" + master.CHECKSTATE + "\r\n");
                sb.AppendLine("CREATEUSERID=" + master.CREATEUSERID + "\r\n");
                sb.AppendLine("CREATEUSERNAME="******"\r\n");
                sb.AppendLine("CREATECOMPANYID=" + master.CREATECOMPANYID + "\r\n");
                sb.AppendLine("CREATEDEPARTMENTID=" + master.CREATEDEPARTMENTID + "\r\n");
                sb.AppendLine("CREATEPOSTID=" + master.CREATEPOSTID + "\r\n");
                sb.AppendLine("CREATEDATE=" + master.CREATEDATE + "\r\n");
                sb.AppendLine("EDITUSERID=" + master.EDITUSERID + "\r\n");
                sb.AppendLine("EDITUSERNAME="******"\r\n");
                sb.AppendLine("EDITDATE=" + master.EDITDATE + "\r\n");
                sb.AppendLine("ACTIVEROLE=" + master.ACTIVEROLE + "\r\n");
                sb.AppendLine("FLOWTYPE=" + master.FLOWTYPE + "\r\n");
                sb.AppendLine("FLOWSELECTTYPE=" + master.FLOWSELECTTYPE + "\r\n");
                //sb.AppendLine("BUSINESSOBJECT=" + master.BUSINESSOBJECT + "\r\n");
                sb.AppendLine("KPITIMEXML=" + master.KPITIMEXML + "\r\n");
                LogHelper.WriteLog("更新流程主表状态(表FLOW_FLOWRECORDMASTER_T):\r\n" + sb.ToString());
                try
                {
                    string sql = @"update FLOW_FLOWRECORDMASTER_T set ACTIVEROLE=:pACTIVEROLE,BUSINESSOBJECT=:pBUSINESSOBJECT,CHECKSTATE=:pCHECKSTATE,
                                      CREATECOMPANYID=:pCREATECOMPANYID,CREATEDATE=:pCREATEDATE,CREATEDEPARTMENTID=:pCREATEDEPARTMENTID,CREATEPOSTID=:pCREATEPOSTID,
                                     CREATEUSERID=:pCREATEUSERID,CREATEUSERNAME=:pCREATEUSERNAME,EDITDATE=:pEDITDATE,EDITUSERID=:pEDITUSERID,EDITUSERNAME=:pEDITUSERNAME,
                                        FLOWCODE=:pFLOWCODE,FLOWSELECTTYPE=:pFLOWSELECTTYPE,FLOWTYPE=:pFLOWTYPE,
                                       FORMID=:pFORMID,INSTANCEID=:pINSTANCEID,KPITIMEXML=:pKPITIMEXML,MODELCODE=:pMODELCODE 
                                      where FLOWRECORDMASTERID=:pFLOWRECORDMASTERID";



                    #region
                    con.Open();


                    OracleCommand cmd = con.CreateCommand();
                    cmd.CommandText = sql;


                    ADOHelper.AddParameter("FLOWRECORDMASTERID", master.FLOWRECORDMASTERID, OracleType.VarChar, cmd.Parameters);
                    ADOHelper.AddParameter("INSTANCEID", master.INSTANCEID, OracleType.VarChar, cmd.Parameters);
                    ADOHelper.AddParameter("MODELCODE", master.MODELCODE, OracleType.VarChar, cmd.Parameters);
                    ADOHelper.AddParameter("FLOWCODE", master.FLOWCODE, OracleType.VarChar, cmd.Parameters);
                    ADOHelper.AddParameter("FORMID", master.FORMID, OracleType.VarChar, cmd.Parameters);
                    ADOHelper.AddParameter("CHECKSTATE", master.CHECKSTATE, OracleType.VarChar, cmd.Parameters);
                    ADOHelper.AddParameter("CREATEUSERID", master.CREATEUSERID, OracleType.VarChar, cmd.Parameters);
                    ADOHelper.AddParameter("CREATEUSERNAME", master.CREATEUSERNAME, OracleType.VarChar, cmd.Parameters);
                    ADOHelper.AddParameter("CREATECOMPANYID", master.CREATECOMPANYID, OracleType.NVarChar, cmd.Parameters);
                    ADOHelper.AddParameter("CREATEDEPARTMENTID", master.CREATEDEPARTMENTID, OracleType.NVarChar, cmd.Parameters);
                    ADOHelper.AddParameter("CREATEPOSTID", master.CREATEPOSTID, OracleType.NVarChar, cmd.Parameters);
                    ADOHelper.AddParameter("CREATEDATE", master.CREATEDATE, OracleType.DateTime, cmd.Parameters);
                    ADOHelper.AddParameter("EDITUSERID", master.EDITUSERID, OracleType.VarChar, cmd.Parameters);
                    ADOHelper.AddParameter("EDITUSERNAME", master.EDITUSERNAME, OracleType.VarChar, cmd.Parameters);
                    ADOHelper.AddParameter("EDITDATE", master.EDITDATE, OracleType.DateTime, cmd.Parameters);
                    ADOHelper.AddParameter("ACTIVEROLE", master.ACTIVEROLE, OracleType.Clob, cmd.Parameters);
                    ADOHelper.AddParameter("FLOWTYPE", master.FLOWTYPE, OracleType.NVarChar, cmd.Parameters);
                    ADOHelper.AddParameter("FLOWSELECTTYPE", master.FLOWSELECTTYPE, OracleType.NVarChar, cmd.Parameters);
                    ADOHelper.AddParameter("BUSINESSOBJECT", master.BUSINESSOBJECT, OracleType.Clob, cmd.Parameters);
                    ADOHelper.AddParameter("KPITIMEXML", master.KPITIMEXML, OracleType.Clob, cmd.Parameters);




                    cmd.ExecuteNonQuery();

                    con.Close();
                    #endregion
                }
                catch (Exception ex)
                {
                    if (con.State == ConnectionState.Open)
                    {
                        con.Close();
                    }
                    throw new Exception("FLOW_FLOWRECORDMASTER_TDAL_Update" + ex.Message);
                }

            }
        }
예제 #11
0
        public static void Add(FLOW_FLOWRECORDMASTER_T master)
        {

            using (OracleConnection con = new OracleConnection(ADOHelper.ContextOracleConnection))
            {
                try
                {
                    string sql = @"insert into FLOW_FLOWRECORDMASTER_T(ACTIVEROLE,BUSINESSOBJECT,CHECKSTATE,CREATECOMPANYID,
                                        CREATEDATE,CREATEDEPARTMENTID,CREATEPOSTID,CREATEUSERID,CREATEUSERNAME,EDITDATE,EDITUSERID,EDITUSERNAME,
                                        FLOWCODE,FLOWRECORDMASTERID,FLOWSELECTTYPE,FLOWTYPE,FORMID,INSTANCEID,KPITIMEXML,MODELCODE) 
                                  values(:pACTIVEROLE,:pBUSINESSOBJECT,:pCHECKSTATE,:pCREATECOMPANYID,
                                        :pCREATEDATE,:pCREATEDEPARTMENTID,:pCREATEPOSTID,:pCREATEUSERID,:pCREATEUSERNAME,:pEDITDATE,:pEDITUSERID,:pEDITUSERNAME,
                                        :pFLOWCODE,:pFLOWRECORDMASTERID,:pFLOWSELECTTYPE,:pFLOWTYPE,:pFORMID,:pINSTANCEID,:pKPITIMEXML,:pMODELCODE)";

                    #region
                    con.Open();


                    OracleCommand cmd = con.CreateCommand();
                    cmd.CommandText = sql;




                    ADOHelper.AddParameter("FLOWRECORDMASTERID", master.FLOWRECORDMASTERID, OracleType.VarChar, cmd.Parameters);
                    ADOHelper.AddParameter("INSTANCEID", master.INSTANCEID, OracleType.VarChar, cmd.Parameters);
                    ADOHelper.AddParameter("MODELCODE", master.MODELCODE, OracleType.VarChar, cmd.Parameters);
                    ADOHelper.AddParameter("FLOWCODE", master.FLOWCODE, OracleType.VarChar, cmd.Parameters);
                    ADOHelper.AddParameter("FORMID", master.FORMID, OracleType.VarChar, cmd.Parameters);
                    ADOHelper.AddParameter("CHECKSTATE", master.CHECKSTATE, OracleType.VarChar, cmd.Parameters);
                    ADOHelper.AddParameter("CREATEUSERID", master.CREATEUSERID, OracleType.VarChar, cmd.Parameters);
                    ADOHelper.AddParameter("CREATEUSERNAME", master.CREATEUSERNAME, OracleType.VarChar, cmd.Parameters);
                    ADOHelper.AddParameter("CREATECOMPANYID", master.CREATECOMPANYID, OracleType.NVarChar, cmd.Parameters);
                    ADOHelper.AddParameter("CREATEDEPARTMENTID", master.CREATEDEPARTMENTID, OracleType.NVarChar, cmd.Parameters);
                    ADOHelper.AddParameter("CREATEPOSTID", master.CREATEPOSTID, OracleType.NVarChar, cmd.Parameters);
                    ADOHelper.AddParameter("CREATEDATE", master.CREATEDATE, OracleType.DateTime, cmd.Parameters);
                    ADOHelper.AddParameter("EDITUSERID", master.EDITUSERID, OracleType.VarChar, cmd.Parameters);
                    ADOHelper.AddParameter("EDITUSERNAME", master.EDITUSERNAME, OracleType.VarChar, cmd.Parameters);
                    ADOHelper.AddParameter("EDITDATE", master.EDITDATE, OracleType.DateTime, cmd.Parameters);
                    ADOHelper.AddParameter("ACTIVEROLE", master.ACTIVEROLE, OracleType.Clob, cmd.Parameters);
                    ADOHelper.AddParameter("FLOWTYPE", master.FLOWTYPE, OracleType.NVarChar, cmd.Parameters);
                    ADOHelper.AddParameter("FLOWSELECTTYPE", master.FLOWSELECTTYPE, OracleType.NVarChar, cmd.Parameters);
                    ADOHelper.AddParameter("BUSINESSOBJECT", master.BUSINESSOBJECT, OracleType.NClob, cmd.Parameters);
                    ADOHelper.AddParameter("KPITIMEXML", master.KPITIMEXML, OracleType.Clob, cmd.Parameters);




                    cmd.ExecuteNonQuery();

                    con.Close();
                    #endregion
                }
                catch (Exception ex)
                {
                    if (con.State == ConnectionState.Open)
                    {
                        con.Close();
                    }
                    throw new Exception("FLOW_FLOWRECORDMASTER_TDAL_Add:" + ex.Message);
                }

            }
        }
예제 #12
0
        /// <summary>
        /// 更新:[流程审批实例表]
        /// </summary>
        /// <param name="con">OracleConnection 连接对象</param>
        /// <param name="master">流程审批实例表</param>
        public static int UpdateMasterINSTANCEID(OracleConnection con, FLOW_FLOWRECORDMASTER_T master)
        {
            try
            {
                if (con.State != ConnectionState.Open)
                {
                    con.Open();
                }
                string updSql = "UPDATE FLOW_FLOWRECORDMASTER_T SET INSTANCEID=:INSTANCEID WHERE   FLOWRECORDMASTERID=:FLOWRECORDMASTERID";
                OracleParameter[] pageparm =
                {               
                    new OracleParameter(":FLOWRECORDMASTERID",OracleType.NVarChar), 
                    new OracleParameter(":INSTANCEID",OracleType.NVarChar) 

                };
                pageparm[0].Value = master.FLOWRECORDMASTERID;//
                pageparm[1].Value = master.INSTANCEID;//

                int n = MsOracle.ExecuteSQLByTransaction(con, updSql, pageparm);
                LogHelper.WriteLog("FLOW_FLOWRECORDMASTER_TDAL->UpdateMasterINSTANCEID 更新:[流程审批实例表]成功:master.FLOWRECORDMASTERID=" + master.FLOWRECORDMASTERID + ";master.INSTANCEID=" + master.INSTANCEID + ";时间:" + DateTime.Now.ToString());
                return n;
            }
            catch (Exception ex)
            {
                if (con.State == ConnectionState.Open)
                {
                    con.Close();
                }
                LogHelper.WriteLog("FLOW_FLOWRECORDMASTER_TDAL->UpdateMasterINSTANCEID 更新:[流程审批实例表]失败:master.FLOWRECORDMASTERID=" + master.FLOWRECORDMASTERID + ";master.INSTANCEID=" + master.INSTANCEID + ";时间:" + DateTime.Now.ToString() + "\r\n异常信息:" + ex.Message);

                throw new Exception("FLOW_FLOWRECORDMASTER_TDAL->UpdateMasterINSTANCEID:" + ex.Message);
            }
        }
예제 #13
0
파일: FlowBLL.cs 프로젝트: JuRogn/OA
        /// <summary>
        /// 新增流程(对数据库操作)
        /// </summary>
        /// <param name="ApprovalData"></param>
        /// <param name="APPDataResult"></param>
        /// <returns></returns>    
        public DataResult AddFlow2(OracleConnection con, SubmitData submitData, DataResult dataResult, ref FlowUser user)
        {
            // WorkflowRuntime workflowRuntime = null;
            WorkflowInstance instance = null;


            try
            {
                #region 获取定义的流程
                user.TrackingMessage += "获取定义的流程.GetFlowByModelName:submitData.ApprovalUser.DepartmentID=" + submitData.ApprovalUser.DepartmentID + ";OrgType='" + ((int)submitData.FlowType).ToString() + "'";
                List<FLOW_MODELFLOWRELATION_T> MODELFLOWRELATION = GetFlowByModelName(con, submitData.ApprovalUser.CompanyID, submitData.ApprovalUser.DepartmentID, submitData.ModelCode, ((int)submitData.FlowType).ToString(), ref user);//对数据库操作
                if (MODELFLOWRELATION == null || MODELFLOWRELATION.Count == 0)
                {
                    dataResult.FlowResult = FlowResult.FAIL;
                    dataResult.Err = "没有找到可使用的流程";
                    if (submitData.ApprovalUser.CompanyID == user.CompayID && submitData.ApprovalUser.DepartmentID == user.DepartmentID)
                    {
                        dataResult.Err = "没有找到公司[ " + user.CompayName + " ]下部门[ " + user.DepartmentName + " ]的匹配流程返回";
                    }
                    else
                    {
                        dataResult.Err = "没有找到公司[ " + user.CompayName + " ]的可使用匹配流程";

                    }
                    return dataResult;
                }

                #endregion
                FLOW_MODELFLOWRELATION_T flowRelation = MODELFLOWRELATION[0];//只取其中一条流程
                FLOW_FLOWDEFINE_T flowDefine = flowRelation.FLOW_FLOWDEFINE_T;
                user.FlowCode = flowDefine.FLOWCODE;//流程代码
                user.FlowName = flowDefine.DESCRIPTION;//流程名称
                if (flowDefine.RULES != null && flowDefine.RULES.Trim() == "")
                {
                    flowDefine.RULES = null;
                }
                workflowRuntime = SMTWorkFlowManage.CreateWorkFlowRuntime(true);
                instance = SMTWorkFlowManage.CreateWorkflowInstance(workflowRuntime, flowDefine.XOML, flowDefine.RULES);
                LogHelper.WriteLog("新增 FormID=" + user.FormID + " 流程名称=" + flowDefine.DESCRIPTION + "("+flowDefine.FLOWCODE+") 提交人=" + user.UserName + " 公司名称=" + user.CompayName + " 部门名称=" + user.DepartmentName + " 岗位名称=" + user.PostName + "  WorkflowInstance ID=" + instance.InstanceId.ToString());
                workflowRuntime.WorkflowCompleted += delegate(object sender, WorkflowCompletedEventArgs e)
                {
                    instance = null;

                };
                #region master赋值
                FLOW_FLOWRECORDMASTER_T master = new FLOW_FLOWRECORDMASTER_T();
                master.INSTANCEID = instance.InstanceId.ToString();
                master.BUSINESSOBJECT = submitData.XML;
                master.FORMID = submitData.FormID;
                master.MODELCODE = submitData.ModelCode;
                master.ACTIVEROLE = Utility.GetActiveRlue(flowDefine.LAYOUT);
                master.FLOWTYPE = ((int)submitData.FlowType).ToString();
                master.FLOWSELECTTYPE = ((int)submitData.FlowSelectType).ToString();
                master.FLOWCODE = flowDefine.FLOWCODE;
                #endregion

                #region 获取下一状态数据
                user.TrackingMessage += "FORMID=" + user.FormID + "获取下一状态数据(开始)";
                GetUserByFlow2(submitData.ApprovalUser.CompanyID, flowDefine.XOML, flowDefine.RULES, master.ACTIVEROLE, submitData.XML, submitData.ApprovalUser.UserID, submitData.ApprovalUser.PostID, submitData.FlowType, ref dataResult, ref user);
                LogHelper.WriteLog("FormID=" + user.FormID + " 获取下一状态数据! dataResult.FlowResult=" + dataResult.FlowResult.ToString());
                user.TrackingMessage += "FORMID=" + user.FormID + "获取下一状态数据(结束)";
                if (dataResult.FlowResult == FlowResult.FAIL)
                {
                    return dataResult;
                }
                submitData.NextStateCode = dataResult.AppState;
                if (dataResult.IsCountersign)
                {
                    #region 检查会签是角色是否有审核人员
                    #region 记录日志
                    if(submitData.DictCounterUser!=null)
                    {
                         LogHelper.WriteLog("FormID=" + user.FormID + " submitData.DictCounterUser="******"FormID=" + user.FormID + "  dataResult.DictCounterUser="******"FormID=" + user.FormID + " submitData.DictCounterUser 会签角色里没有发现有审核人员,所以返回!");
                            return dataResult;
                        }
                    }
                    else
                    {
                        if (submitData.DictCounterUser == null || submitData.DictCounterUser.Keys.Count == 0)
                        {
                            submitData.DictCounterUser = dataResult.DictCounterUser;
                        }
                    }
                    #endregion
                }
                else
                {
                    #region 检查非会签角色里是否有审核人员
                    if (dataResult.FlowResult == FlowResult.MULTIUSER)
                    {
                        LogHelper.WriteLog("FormID=" + user.FormID + " 发现有多个审核人员!");
                        if (submitData.NextApprovalUser == null || (Utility.GetString(submitData.NextApprovalUser.UserID) == "" || Utility.GetString(submitData.NextApprovalUser.UserName) == ""))
                        {
                            LogHelper.WriteLog("FormID=" + user.FormID + " 发现有多个审核人员!但下一审核人为空,所以返回选择审核人!");
                            return dataResult;
                        }
                        else
                        {
                            LogHelper.WriteLog("FormID=" + user.FormID + " 发现有多个审核人员,但发现下一审核人不为空 usrid="+(Utility.GetString(submitData.NextApprovalUser.UserID)+" 姓名="+Utility.GetString(submitData.NextApprovalUser.UserName)));
                        }
                    }
                    else
                    {
                        if (submitData.DictCounterUser == null || submitData.DictCounterUser.Keys.Count == 0)
                        {
                            submitData.NextApprovalUser = dataResult.UserInfo[0];
                        }
                    }
                    #endregion
                }

                #endregion

                #region 实体赋值 当提交人为空时,创建人变成单据所属人,如果不为空,则创建人保存为系统登录人;创建公司,部门,岗位,仍然保存单据所属人的公司,部门,岗位
                FLOW_FLOWRECORDDETAIL_T entity = new FLOW_FLOWRECORDDETAIL_T();
                entity.FLOW_FLOWRECORDMASTER_T = master;
                entity.CREATECOMPANYID = submitData.ApprovalUser.CompanyID;
                entity.CREATEDEPARTMENTID = submitData.ApprovalUser.DepartmentID ;
                entity.CREATEPOSTID = submitData.ApprovalUser.PostID;
                entity.CREATEUSERID = string.IsNullOrEmpty(submitData.SumbitUserID) ? submitData.ApprovalUser.UserID : submitData.SumbitUserID;
                entity.CREATEUSERNAME = string.IsNullOrEmpty(submitData.SumbitUserName) ? submitData.ApprovalUser.UserName : submitData.SumbitUserName;
                #endregion
                user.TrackingMessage += " 处理kpi时间\r\n";
                #region 处理kpi时间
                string KPITime = "";
                #region 加入缓存
                string pscResult = CacheProvider.GetCache<string>(flowRelation.MODELFLOWRELATIONID);
                if (string.IsNullOrEmpty(pscResult))
                {
                    PerformanceServiceWS.PerformanceServiceClient psc = new PerformanceServiceWS.PerformanceServiceClient();
                    pscResult = psc.GetKPIPointsByBusinessCode(flowRelation.MODELFLOWRELATIONID);//调用服务
                    CacheProvider.Add<string>(flowRelation.MODELFLOWRELATIONID, pscResult);
                    psc.Close();
                }
                #endregion
                //PerformanceServiceWS.PerformanceServiceClient psc = new PerformanceServiceWS.PerformanceServiceClient();
                //string pscResult = psc.GetKPIPointsByBusinessCode(flowRelation.MODELFLOWRELATIONID);//调用服务
                //psc.Close();
                if (!string.IsNullOrEmpty(pscResult))
                {
                    XElement xe = XElement.Parse(pscResult);
                    Func<XElement, bool> f = (x) =>
                    {
                        XAttribute xid = x.Attribute("id");
                        XAttribute xvalue = x.Attribute("value");
                        if (xid == null || xvalue == null)
                            return false;
                        else
                        {
                            if (xid.Value == dataResult.AppState)
                                return true;
                            else return false;
                        }
                    };
                    XElement FlowNode = xe.Elements("FlowNode").FirstOrDefault(f);
                    if (FlowNode != null)
                    {
                        KPITime = FlowNode.Attribute("value").Value;
                    }
                }

                dataResult.KPITime = KPITime;
                master.KPITIMEXML = pscResult;
                #endregion
                user.TrackingMessage += " 处理kpi时间完成\r\n";
                FlowDataType.FlowData FlowData = new FlowDataType.FlowData();
                FlowData.xml = submitData.XML;

                if (!dataResult.IsCountersign)
                {
                    #region  确定非会签的下一个审核人
                    UserInfo AppUser = new UserInfo(); //下一审核人
                    AppUser = submitData.NextApprovalUser;
                    dataResult.UserInfo.Clear();
                    dataResult.UserInfo.Add(AppUser);
                    UserInfo AgentAppUser = GetAgentUserInfo(submitData.ModelCode, AppUser.UserID);//查询是否启用了代理人                    
                    dataResult = DoFlowRecord2(con, workflowRuntime, instance, entity, submitData.NextStateCode, AppUser, AgentAppUser, submitData.SubmitFlag, submitData.FlowType,ref user); //处理流程数据
                    dataResult.IsCountersign = false;
                    dataResult.AgentUserInfo = AgentAppUser;
                    #endregion
                }
                else
                {
                    user.TrackingMessage += " 会签\r\n";
                    #region  确定会签角色里的审核人员
                    //Tracer.Debug("-----DoFlowRecord_Add:" + DateTime.Now.ToString()+"\n");
                    dataResult.DictCounterUser = submitData.DictCounterUser;
                    Dictionary<UserInfo, UserInfo> dictAgentUserInfo = GetAgentUserInfo2(submitData.ModelCode, submitData.DictCounterUser);
                    dataResult = DoFlowRecord_Add(con, workflowRuntime, instance, entity, submitData.NextStateCode, submitData.DictCounterUser, dictAgentUserInfo, submitData.SubmitFlag, submitData.FlowType); //处理流程数据
                    //Tracer.Debug("-----DoFlowRecord_AddEnd:" + DateTime.Now.ToString()+"\n");
                    dataResult.IsCountersign = true;
                    dataResult.DictAgentUserInfo = dictAgentUserInfo;
                    #endregion
                    user.TrackingMessage += "会签完成\r\n";
                }
                user.TrackingMessage += "激发流程引擎执行到一下流程\r\n";
                #region 激发流程引擎执行到一下流程
                string ss = "";
                int n = 0;
                StateMachineWorkflowInstance workflowinstance = new StateMachineWorkflowInstance(workflowRuntime, instance.InstanceId);
                ManualWorkflowSchedulerService scheduleService = workflowRuntime.GetService(typeof(ManualWorkflowSchedulerService)) as ManualWorkflowSchedulerService;
               if (dataResult.AppState == null || dataResult.AppState == "")
                {
                    user.TrackingMessage += " workflowRuntime.GetService<FlowEvent>()\r\n";
                    scheduleService.RunWorkflow(workflowinstance.InstanceId);
                    workflowRuntime.GetService<FlowEvent>().OnDoFlow(instance.InstanceId, FlowData); //激发流程引擎执行到一下流程
                    scheduleService.RunWorkflow(workflowinstance.InstanceId);
                    user.TrackingMessage += " workflowRuntime.GetService<FlowEvent>()完成\r\n";
                }
                else
                {
                    scheduleService.RunWorkflow(workflowinstance.InstanceId);
                    workflowinstance.SetState(dataResult.AppState); //流程跳转到指定节点
                }

                #endregion
                user.TrackingMessage += "激发流程引擎执行到一下流程完成\r\n";
                user.TrackingMessage += "System.Threading.Thread.Sleep(1000)\r\n";
                //System.Threading.Thread.Sleep(1000);//当前用到
                dataResult.ModelFlowRelationID = flowRelation.MODELFLOWRELATIONID; //返回关联ID
                dataResult.KPITime = KPITime;
                //dataResult.CanSendMessage = true;
                if (submitData.FlowType == FlowType.Task)
                {
                    dataResult.SubModelCode = Utility.GetSubModelCode(master.ACTIVEROLE, dataResult.AppState); //返回下一子模块代码
                }
                user.TrackingMessage += "System.Threading.Thread.Sleep(1000)完成\r\n";
                return dataResult;
            }

            catch (Exception e)
            {
                user.ErrorMsg += "新增流程出错 FormID=" + user.FormID + " CompayName=" + user.CompayName + "FlowName=" + user.FlowName + "异常信息:\r\n" + e.ToString() + "\r\n";
                LogHelper.WriteLog("FormID=" + user.FormID + " CompayName=" + user.CompayName + "FlowName=" + user.FlowName + " 新增流程出错,异常信息:\r\n" + e.ToString());
                throw new Exception("FormID=" + user.FormID+" 时间:"+DateTime.Now.ToString()+" 新增流程出错,请联系管理员! ");
            }
            finally
            {
                instance = null;
                SMTWorkFlowManage.ColseWorkFlowRuntime(workflowRuntime);
            }


        }