Beispiel #1
0
        public static void Create(WfStatesEntity entity)
        {
            if (entity.StateId == Guid.Empty || string.IsNullOrEmpty(entity.StateId.ToString()))
                entity.StateId = Guid.NewGuid();
            try
            {
                var parameters = new SqlParameter[13];
                parameters[0] = new SqlParameter("StateId", SqlDbType.UniqueIdentifier) { Value = entity.StateId };
                parameters[1] = new SqlParameter("StateName", SqlDbType.VarChar) { Value = entity.StateName };
                parameters[2] = new SqlParameter("TemplateId", SqlDbType.UniqueIdentifier) { Value = entity.TemplateId };
                parameters[3] = new SqlParameter("FormID", SqlDbType.UniqueIdentifier) { Value = entity.FormID };
                parameters[4] = new SqlParameter("CurrentStateType", SqlDbType.Int) { Value = entity.CurrentStateType };
                parameters[5] = new SqlParameter("ParallelStatePassWay", SqlDbType.Int) { Value = entity.ParallelStatePassWay };
                parameters[6] = new SqlParameter("CurrentParallelCount", SqlDbType.Int) { Value = entity.CurrentParallelCount };
                parameters[7] = new SqlParameter("RelationWfTemplateIds", SqlDbType.VarChar) { Value = entity.RelationWfTemplateIds };
                parameters[8] = new SqlParameter("IsRestrictUserDept", SqlDbType.Bit) { Value = entity.IsRestrictUserDept };
                parameters[9] = new SqlParameter("IsRestrictTopDept", SqlDbType.Bit) { Value = entity.IsRestrictTopDept };
                parameters[10] = new SqlParameter("IsEndState", SqlDbType.Bit) { Value = entity.IsEndState };
                parameters[11] = new SqlParameter("CreateTime", SqlDbType.Date) { Value = DateTime.Now };
                parameters[12] = new SqlParameter("IsStartState", SqlDbType.Bit) { Value = entity.IsStartState };

                DataHelper.ExecuteNoneQuery(Sql_Create_WFStateEntity, parameters);
            }
            catch (Exception e)
            {
                string s = e.Message;
            }
        }
Beispiel #2
0
        /// <summary>
        /// 获取实体信息
        /// </summary>
        /// <param name="row">数据行</param>
        /// <returns></returns>
        public static WfStatesEntity GetEntity(DataRow row)
        {
            WfStatesEntity entity = new WfStatesEntity();

            if (row["StateId"] != DBNull.Value)
                entity.StateId = Guid.Parse(row["StateId"].ToString());
            if (row["TemplateId"] != DBNull.Value)
                entity.TemplateId = Guid.Parse(row["TemplateId"].ToString());
            entity.StateName = row["StateName"].ToString();
            if (row["DealPersonLevel"] != DBNull.Value)
                entity.DealPersonLevel = Convert.ToInt32(row["DealPersonLevel"]);
            if (row["DealDeptLevel"] != DBNull.Value)
                entity.DealDeptLevel = Convert.ToInt32(row["DealDeptLevel"]);
            entity.DealPerson = row["DealPerson"].ToString();
            if (row["CreateTime"] != DBNull.Value)
                entity.CreateTime = Convert.ToDateTime(row["CreateTime"]);
            if (row["CreatePerson"] != DBNull.Value)
                entity.CreatePerson = Guid.Parse(row["CreatePerson"].ToString());
            if (row["IsEndState"] != DBNull.Value)
                entity.IsEndState = Convert.ToBoolean(row["IsEndState"]);
            if (row["FormID"] != DBNull.Value)
                entity.FormID = Guid.Parse(row["FormID"].ToString());
            if (row["CurrentStateType"] != DBNull.Value)
                entity.CurrentStateType = Convert.ToInt32(row["CurrentStateType"]);
            if (row["ParallelStatePassWay"] != DBNull.Value)
                entity.ParallelStatePassWay = Convert.ToInt32(row["ParallelStatePassWay"]);
            if (row["CurrentParallelCount"] != DBNull.Value)
                entity.CurrentParallelCount = Convert.ToInt32(row["CurrentParallelCount"]);
            entity.RelationWfTemplateIds = row["RelationWfTemplateIds"].ToString();
            if (row["IsRestrictUserDept"] != DBNull.Value)
                entity.IsRestrictUserDept = Convert.ToBoolean(row["IsRestrictUserDept"]);
            if (row["IsStartState"] != DBNull.Value)
                entity.IsStartState = Convert.ToBoolean(row["IsStartState"]);

            return entity;
        }
Beispiel #3
0
        /// <summary>
        /// 生成流程状态实体类
        /// </summary>
        /// <param name="currentXmlNode"></param>
        /// <param name="templateId"></param>
        /// <returns></returns>
        private static WfStatesEntity GetWFStates(XElement currentXmlNode, Guid templateId)
        {
            try
            {
                //  var statesEntity=new WFStatesEntity(Guid stateId,string stateName,Guid templateId,int dealPersonLevel,int dealDeptLevel,string dealPerson);
                var stateId = new Guid(GetXElementAttribute(currentXmlNode, "UniqueID"));
                // var stateName = GetXElementAttribute(currentXmlNode, "WFSLElementType") == "WFSLFinish" ? EndStateName : GetXElementAttribute(currentXmlNode, "Title");
                var stateName = GetXElementAttribute(currentXmlNode, "Title");
                var dealDeptLevel = currentXmlNode.Attribute(XName.Get("DealDeptLevel")) == null
                                        ? 0
                                        : Convert.ToInt32(currentXmlNode.Attribute(XName.Get("DealDeptLevel")).Value);
                var dealPersonLevel = currentXmlNode.Attribute(XName.Get("DealPersonLevel")) == null
                                          ? 0
                                          : Convert.ToInt32(currentXmlNode.Attribute(XName.Get("DealPersonLevel")).Value);
                var dealPerson = currentXmlNode.Attribute(XName.Get("DealPerson")) == null
                                     ? ""
                                     : currentXmlNode.Attribute(XName.Get("DealPerson")).Value;
                var formId = Guid.Empty;
                if (currentXmlNode.Attribute(XName.Get("DealFormID")) != null &&
                    !string.IsNullOrEmpty(currentXmlNode.Attribute(XName.Get("DealFormID")).Value))
                {
                    formId = new Guid(currentXmlNode.Attribute(XName.Get("DealFormID")).Value);
                }
                var currentStateType = (int)EnumWfStateType.Ordinary;
                if (currentXmlNode.Attribute(XName.Get("IsParallelState")) != null && Convert.ToBoolean(currentXmlNode.Attribute(XName.Get("IsParallelState")).Value))
                {
                    currentStateType = (int)EnumWfStateType.Parllel;
                }
                var currentParallelCount = 0;
                if (currentXmlNode.Attribute(XName.Get("IsParallelNumNotConfirm")) != null &&
                   !Convert.ToBoolean(currentXmlNode.Attribute(XName.Get("IsParallelNumNotConfirm")).Value)) //分支数确定
                {
                    if (currentXmlNode.Attribute(XName.Get("NextNodeID")) != null &&
                        currentXmlNode.Attribute(XName.Get("NextNodeID")).Value != "")
                    {
                        currentParallelCount =
                            currentXmlNode.Attribute(XName.Get("NextNodeID")).ToString().Split(',').Length;
                    }
                }

                var parallelStatePassWay = currentXmlNode.Attribute(XName.Get("ParallelStatePassWay")) == null
                                               ? 0
                                               : Convert.ToInt32(
                                                   currentXmlNode.Attribute(XName.Get("ParallelStatePassWay")).Value);

                var IsRestrictUserDept = currentXmlNode.Attribute(XName.Get("IsRestrictUserDept")) == null
                                               ? false
                                               : Convert.ToBoolean(
                                                   currentXmlNode.Attribute(XName.Get("IsRestrictUserDept")).Value);

                var IsRestrictTopDept = currentXmlNode.Attribute(XName.Get("IsRestrictTopDept")) == null
                                               ? false
                                               : Convert.ToBoolean(
                                                   currentXmlNode.Attribute(XName.Get("IsRestrictTopDept")).Value);

                var IsEndState = currentXmlNode.Attribute(XName.Get("IsEnd")) == null
                                               ? false
                                               : Convert.ToBoolean(
                                                   currentXmlNode.Attribute(XName.Get("IsEnd")).Value);

                var branchesWfInfos = GetXElementAttribute(currentXmlNode, "BranchesWfInfo");
                var statesEntity = new WfStatesEntity(stateId, stateName, templateId, formId, currentStateType, currentParallelCount,
                                                      parallelStatePassWay, branchesWfInfos, IsRestrictUserDept, IsRestrictTopDept, IsEndState);

                return statesEntity;
            }
            catch (Exception ex)
            {
                LogWritter.WriteSystemExceptionLog(ex);
                throw ex;
            }
        }
Beispiel #4
0
        /// <summary>
        ///流转后,维护流程实例ACL表和流程消息表()
        /// </summary>
        /// <param name="formId"></param>
        ///<param name="currentStateEntity"> </param>
        ///<param name="wfTemplateId"> </param>
        ///<param name="businessType"></param>
        /// <param name="dealPersonInfos"></param>
        /// <param name="wfInstancestates"> </param>
        public static void ManageWfInstanceAclandMessage(Guid formId, WfStatesEntity currentStateEntity, Guid wfTemplateId, string businessType, string dealPersons, WfInstanceStatesEntity wfInstancestates)
        {
            try
            {
                var currentWfStateId = currentStateEntity.StateId;

                var dealPersonInfos = GetDealPersonInfoFromStr(dealPersons);

                using (TransactionScope scope = new TransactionScope())
                {
                    var instanceStateDealPeronList = new List<DealPersonInfo>();

                    //更新待办为已办
                    UpdateWfMessages(formId, wfInstancestates.TransactUserID, wfInstancestates.InstanceID);

                    var way = WfDealWayEntity.Get(wfInstancestates.WfDealWayId);
                    if (wfInstancestates.WfDealWayId != Guid.Empty && way != null && way.DealWayType == 1)
                    {
                        #region 处理方式-撤回(找上一次流转人)

                        //通过处理方式的目标 环节 找流转记录
                        var wfInstanceStates = WfInstanceStatesBusiness.GetWfInstanceStatesByID(formId, wfInstancestates.WfState, wfInstancestates.InstanceID);

                        var newDealPersonList = new List<DealPersonInfo>();
                        var backPerson = new DealPersonInfo();
                        backPerson.DeptId = wfInstanceStates.TransactDepartmentID;
                        backPerson.DeptName = wfInstanceStates.TransactDepartmentName;
                        backPerson.PersonId = wfInstanceStates.TransactUserID;
                        backPerson.PersonName = wfInstanceStates.TransactUserName;
                        newDealPersonList.Add(backPerson);

                        WriteAcletc(formId, newDealPersonList, wfInstancestates.TransactUserID, wfInstancestates.InstanceID, businessType, currentWfStateId);

                        instanceStateDealPeronList = newDealPersonList;

                        #endregion
                    }
                    else if (wfInstancestates.WfDealWayId != Guid.Empty && way != null && way.DealWayType == 2)
                    {
                        #region 处理方式-退回

                        List<DealPersonInfo> listBack = Interfaces.GetDealPersonByLine(formId, wfInstancestates.WfDealWayId);

                        WriteAcletc(formId, listBack, wfInstancestates.TransactUserID, wfInstancestates.InstanceID, businessType, currentWfStateId);

                        instanceStateDealPeronList = listBack;

                        #endregion
                    }
                    else
                    {
                        #region 正常流转

                        var newDealPersonList = new List<DealPersonInfo>();

                        if (dealPersonInfos != null && dealPersonInfos.Count > 0) //外围选定下环节处理人,以外围选定发待办
                        {
                            #region 根据外围选择用户流转

                            foreach (var dealPerson in dealPersonInfos)
                            {
                                if (currentStateEntity.IsRestrictUserDept)//判断处理人是否限定部门
                                {
                                    var deptID = wfInstancestates.TransactDepartmentID;
                                    if (dealPerson.DeptId == deptID)
                                    {
                                        newDealPersonList.Add(dealPerson);
                                    }
                                }
                                else
                                {
                                    newDealPersonList.Add(dealPerson);
                                }
                            }

                            #endregion
                        }
                        else //外围不选,依据 WF_Define_ACL 定义
                        {
                            var sql = string.Format(" select distinct(a.RoleCode)  from WF_Define_ACL a with (nolock)  where a.WfTemplateID='{0}' and a.ObjectID='{1}'", wfTemplateId, currentWfStateId);
                            var dt = DataHelper.ExecuteQuery(sql);
                            if (dt != null && dt.Rows.Count > 0)
                            {
                                #region 根据环节选择的角色流转

                                var roleCodes = new List<string>();

                                foreach (DataRow row in dt.Rows)
                                {
                                    roleCodes.Add(row["RoleCode"].ToString());
                                }

                                List<WFRoleUserEntity> list = new List<WFRoleUserEntity>();

                                #region 通过角色、部门信息获取处理人

                                Guid deptID = wfInstancestates.TransactDepartmentID;
                                if (currentStateEntity.IsRestrictUserDept)//判断处理人是否限定部门
                                {
                                    list = WFRoleUserBusiness.GetUserList(roleCodes, deptID);
                                }
                                else if (currentStateEntity.IsRestrictTopDept)
                                {
                                    //获取当前部门信息
                                    var current = WFCustomBusiness.GetCustomEntity(deptID);
                                    if (current != null && current.ParentGUID != Guid.Empty)
                                    {
                                        list = WFRoleUserBusiness.GetUserList(roleCodes, current.ParentGUID);
                                    }
                                }
                                else
                                {
                                    list = WFRoleUserBusiness.GetUserList(roleCodes, Guid.Empty);
                                }

                                #endregion

                                if (list != null && list.Count > 0)
                                {
                                    List<DealPersonInfo> listDeal = new List<DealPersonInfo>();
                                    foreach (var entity in list)
                                    {
                                        DealPersonInfo deal = new DealPersonInfo();
                                        deal.DeptId = entity.DeptGuid;
                                        deal.DeptName = entity.DeptName;
                                        deal.PersonId = entity.UserGuid;
                                        deal.PersonName = entity.UserName;
                                        newDealPersonList.Add(deal);
                                    }
                                }

                                #region 三统一接口获取处理人 - 优化去除

                                //var dealpersonInfos = Interfaces.GetDealPersonInfoFromOuter(roleCodes);  //根据角色ID列表得到具体处理人信息列表
                                //if (dealpersonInfos != null && dealpersonInfos.Count > 0)
                                //{
                                //    #region 判断是否验证关区

                                //    //判断是否验证关区
                                //    string checkCustom = ConfigurationManager.AppSettings["BillCustomCheck"];
                                //    bool isCheck = false;
                                //    if (!string.IsNullOrEmpty(checkCustom) && Convert.ToBoolean(checkCustom))
                                //    {
                                //        isCheck = true;
                                //    }

                                //    #endregion

                                //    if (currentStateEntity.IsRestrictUserDept)//判断处理人是否限定部门
                                //    {
                                //        #region 限定部门

                                //        var deptID = wfInstancestates.TransactDepartmentID;

                                //        foreach (var dealPerson in dealpersonInfos)
                                //        {
                                //            if (isCheck)
                                //            {
                                //                //根据用户路径匹配关区信息
                                //                var entity = WFCustomBusiness.GetBestMatchCustom(dealPerson.AllPathName);
                                //                if (entity != null)
                                //                {
                                //                    dealPerson.DeptId = entity.GUID;
                                //                    dealPerson.DeptName = entity.CustomName;
                                //                }
                                //            }

                                //            if (dealPerson.DeptId == deptID)
                                //            {
                                //                newDealPersonList.Add(dealPerson);
                                //            }
                                //        }

                                //        #endregion
                                //    }
                                //    else if (currentStateEntity.IsRestrictTopDept)
                                //    {
                                //        #region 限定上级部门

                                //        var deptID = wfInstancestates.TransactDepartmentID;

                                //        //获取当前部门信息
                                //        var current = WFCustomBusiness.GetCustomEntity(deptID);
                                //        if (current != null && current.ParentGUID != Guid.Empty)
                                //        {
                                //            foreach (var dealPerson in dealpersonInfos)
                                //            {
                                //                if (isCheck)
                                //                {
                                //                    //根据用户路径匹配关区信息
                                //                    var entity = WFCustomBusiness.GetBestMatchCustom(dealPerson.AllPathName);
                                //                    if (entity != null)
                                //                    {
                                //                        dealPerson.DeptId = entity.GUID;
                                //                        dealPerson.DeptName = entity.CustomName;
                                //                    }
                                //                }

                                //                if (dealPerson.DeptId == current.ParentGUID)
                                //                {
                                //                    newDealPersonList.Add(dealPerson);
                                //                }
                                //            }
                                //        }

                                //        #endregion
                                //    }
                                //    else
                                //    {
                                //        #region 默认处理

                                //        foreach (var dealPerson in dealpersonInfos)
                                //        {
                                //            if (isCheck)
                                //            {
                                //                //根据用户路径匹配关区信息
                                //                var entity = WFCustomBusiness.GetBestMatchCustom(dealPerson.AllPathName);
                                //                if (entity != null)
                                //                {
                                //                    dealPerson.DeptId = entity.GUID;
                                //                    dealPerson.DeptName = entity.CustomName;
                                //                }
                                //            }

                                //            newDealPersonList.Add(dealPerson);
                                //        }

                                //        #endregion
                                //    }
                                //}

                                #endregion

                                #endregion
                            }
                            else
                            {
                                #region 没有角色(默认提交人)

                                var submitPerson = new DealPersonInfo();
                                var instanceEntity = WfInstanceBusiness.GetWfInstanceBusinessByFormID(formId);
                                if (instanceEntity != null)
                                {
                                    submitPerson.DeptId = instanceEntity.StartDepartmentID;
                                    submitPerson.DeptName = instanceEntity.StartDepartmentName;
                                    submitPerson.PersonId = instanceEntity.StartUserID;
                                    submitPerson.PersonName = instanceEntity.StartUserName;
                                    newDealPersonList.Add(submitPerson);
                                }
                                else
                                {
                                    submitPerson.DeptId = wfInstancestates.TransactDepartmentID;
                                    submitPerson.DeptName = wfInstancestates.TransactDepartmentName;
                                    submitPerson.PersonId = wfInstancestates.TransactUserID;
                                    submitPerson.PersonName = wfInstancestates.TransactUserName;
                                    newDealPersonList.Add(submitPerson);
                                }

                                #endregion
                            }
                        }

                        if (newDealPersonList != null && newDealPersonList.Count > 0)
                        {
                            WriteAcletc(formId, newDealPersonList, wfInstancestates.TransactUserID, wfInstancestates.InstanceID, businessType, currentWfStateId);
                            instanceStateDealPeronList = newDealPersonList;
                        }

                        #endregion
                    }

                    #region 转换处理人员

                    var stateDealPersons = string.Empty;
                    if (instanceStateDealPeronList != null && instanceStateDealPeronList.Count > 0)
                    {
                        var strPerson = new StringBuilder();
                        foreach (var personInfo in instanceStateDealPeronList)
                        {
                            strPerson.Append(personInfo.PersonName);
                            strPerson.Append(",");
                        }
                        stateDealPersons = strPerson.ToString().TrimEnd(',');
                    }

                    #endregion

                    wfInstancestates.DealPersonInfo = stateDealPersons;
                    WfInstanceStatesBusiness.UpdateWfInstanceState(wfInstancestates);

                    scope.Complete();
                }
            }
            catch (Exception ex)
            {
                LogWritter.WriteSystemExceptionLog(ex);
            }
        }