Exemplo n.º 1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="billGuid">单据ID</param>
        /// <param name="lineGuid">处理线ID</param>
        /// <returns></returns>
        public static List<DealPersonInfo> GetDealPersonByLine(Guid billGuid, Guid lineGuid)
        {
            try
            {
                List<DealPersonInfo> list = new List<DealPersonInfo>();

                StringBuilder strSql = new StringBuilder();
                strSql.Append(" select top 1 TransactUserID , TransactUserName , TransactDepartmentID , TransactDepartmentName from WF_InstanceStates ");
                strSql.Append(" where FormID = '" + billGuid + "' ");
                strSql.Append(" and WfState = ( ");
                strSql.Append("     select PointStateId from WF_DealWay with (nolock) ");
                strSql.Append("     where DealWayId = '" + lineGuid + "' ");
                strSql.Append(" ) ");
                strSql.Append(" order by CompleteTime desc ");

                DataTable dtTable = DataHelper.ExecuteQuery(strSql.ToString());
                if (dtTable != null && dtTable.Rows.Count > 0)
                {
                    DataRow row = dtTable.Rows[0];

                    DealPersonInfo person = new DealPersonInfo();
                    person.DeptId = Guid.Parse(row["TransactDepartmentID"].ToString());
                    person.DeptName = row["TransactDepartmentName"].ToString();
                    person.PersonId = Guid.Parse(row["TransactUserID"].ToString());
                    person.PersonName = row["TransactUserName"].ToString();

                    list.Add(person);
                }

                return list;
            }
            catch (Exception ex)
            {
                LogWritter.WriteSystemExceptionLog(ex);
                return null;
            }
        }
Exemplo n.º 2
0
        public string WorkFolwDrive(FormCollection fc)
        {
            if (!string.IsNullOrEmpty(Request.QueryString["line"]) && !string.IsNullOrEmpty(Request.QueryString["fid"]))
            {
                if (!string.IsNullOrEmpty(Request.QueryString["edit"]))
                {
                    if (Request.QueryString["edit"] == "y")
                    {
                        string msg = SaveBillData(fc);
                        if (!string.IsNullOrEmpty(msg))
                        {
                            return msg;
                        }
                    }
                }

                Guid lineGuid = Guid.Empty;
                Guid.TryParse(Request.QueryString["line"], out lineGuid);

                Guid billGuid = Guid.Empty;
                Guid.TryParse(Request.QueryString["fid"], out billGuid);

                Guid userGuid = Guid.Empty;
                Guid.TryParse(Request.QueryString["uid"], out userGuid);

                List<string> roleList = Interfaces.GetBranchAuthPerson(billGuid, lineGuid);
                if (roleList != null && roleList.Count > 0 && userGuid == Guid.Empty)
                {
                    return "LoseUser";
                }

                var dealpersonInfo = new List<DealPersonInfo>();
                if (userGuid != Guid.Empty)
                {
                    var u = unitOfWork.SysAccountBLL.GetEntityByID(userGuid);
                    DealPersonInfo person = new DealPersonInfo();
                    person.AllPathName = u.DeptName;
                    person.DeptId = u.DeptGuid;
                    person.DeptName = u.DeptName.Trim();
                    person.PersonId = u.UserId;
                    person.PersonName = u.UserName.Trim();

                    dealpersonInfo.Add(person);
                }

                var userInfo = (SysAccount)Session["CurrentUser"];

                Interfaces.DriveWorkFlowNew(billGuid, userInfo.UserId, userInfo.UserName,
                                            userInfo.DeptGuid, userInfo.DeptName,
                                            lineGuid, "流转", dealpersonInfo);

                return "Success";
            }
            else
            {
                return "Error";
            }
        }
Exemplo n.º 3
0
        public static List<DealPersonInfo> GetWFStartPersonList(string formType, Guid startDeptId)
        {
            try
            {
                WfStatesEntity startState = GetStartState(formType, startDeptId);
                if (startState != null)
                {
                    var roleCodes = new List<string>();

                    var sql = string.Format(" select distinct(a.RoleCode)  from WF_Define_ACL a with (nolock)  where a.WfTemplateID='{0}' and a.ObjectID='{1}'", startState.TemplateId, startState.StateId);
                    var dt = DataHelper.ExecuteQuery(sql);
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        foreach (DataRow row in dt.Rows)
                        {
                            roleCodes.Add(row["RoleCode"].ToString());
                        }
                    }

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

                    if (roleCodes.Count > 0)
                    {
                        List<WFRoleUserEntity> list = new List<WFRoleUserEntity>();

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

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

                                    dic.Add(entity.UserGuid, entity.UserName);
                                }
                            }

                            return listDeal;
                        }
                    }

                    #endregion
                }
            }
            catch (Exception ex)
            {
                LogWritter.WriteSystemExceptionLog(ex);
            }
            return null;
        }
Exemplo n.º 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);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// 参数转换
        /// </summary>
        /// <param name="dealPersonInfos"></param>
        /// <returns></returns>
        public static List<DealPersonInfo> GetDealPersonInfoFromStr(string dealPersonInfos)
        {
            try
            {
                if (!string.IsNullOrEmpty(dealPersonInfos))
                {
                    var dealpersons = dealPersonInfos.Split('$');
                    var dealps = new List<DealPersonInfo>();

                    foreach (var dealperson in dealpersons)
                    {
                        var deal = dealperson.Split(',');
                        if (deal != null && deal.Length > 3)
                        {
                            var dealpersoninfo = new DealPersonInfo();
                            dealpersoninfo.PersonId = new Guid(deal[0]);
                            dealpersoninfo.PersonName = deal[1];
                            dealpersoninfo.DeptId = new Guid(deal[2]);
                            dealpersoninfo.DeptName = deal[3];
                            dealps.Add(dealpersoninfo);
                        }
                    }
                    return dealps;
                }
            }
            catch (Exception ex)
            {
                LogWritter.WriteSystemExceptionLog(ex);
            }
            return null;
        }
Exemplo n.º 6
0
        // If your activity returns a value, derive from CodeActivity<TResult>
        // and return the value from the Execute method.
        protected override void Execute(CodeActivityContext context)
        {
            try
            {
                var flowData = context.GetValue(FlowDataParm);

                // flowData.WFInstance.CurrentRunState = Common.GetCodeForUserbyCodeForWf(StateName);
                flowData.WFInstance.CurrentWfState = new Guid(StateName);
                flowData.WfInstanceStates.WfState = flowData.WFInstance.CurrentWfState;
                //flowData.WfInstanceStates.RunState = flowData.WFInstance.CurrentRunState;

                var result = Common.GetDealWayInfoofTheState(flowData.WFInstance.TemplateID,
                                                             flowData.WFInstance.CurrentWfState);
                if (result != null)
                {
                    flowData.WfInstanceStates.TransactType = result[1];
                    flowData.WfInstanceStates.WfDealWayId = new Guid(result[0]);
                }
                flowData.WfInstanceStates.DealDeptLevel = DealDeptLevel;
                flowData.WfInstanceStates.DealPersonLevel = DealPersonLevel;

                //已存在该表单,则判断为重新打开,支持循环的闭合回路的流程
                if (WfInstanceBusiness.IfExistthFormId(flowData.WFInstance.FormID) > 0)
                {
                    WfInstanceBusiness.UpdateWfInstanceBusinessByFormId(flowData.WFInstance);
                }
                else
                {
                    WfInstanceBusiness.Add(flowData.WFInstance);
                }

                WfInstanceStatesBusiness.Add(flowData.WfInstanceStates);

                #region 添加已办

                List<DealPersonInfo> list = new List<DealPersonInfo>();
                DealPersonInfo person = new DealPersonInfo();
                //person.DeptId = flowData.DealPersonInfo;
                person.DeptId = flowData.WFInstance.StartDepartmentID;
                person.DeptName = flowData.WFInstance.StartDepartmentName;
                person.PersonId = flowData.WFInstance.StartUserID;
                person.PersonName = flowData.WFInstance.StartUserName;
                list.Add(person);
                Common.WriteAcletc(flowData.WFInstance.FormID, list, person.PersonId, flowData.WFInstance.InstanceID, flowData.WFInstance.BusinessType, flowData.WFInstance.CurrentWfState);

                Common.UpdateWfMessages(flowData.WFInstance.FormID, flowData.WfInstanceStates.TransactUserID,
                                        flowData.WFInstance.InstanceID);

                #endregion
            }
            catch (Exception exception)
            {
                LogWritter.WriteSystemExceptionLog(exception);
            }
        }