private static bool SetUnitSecUser(string sid, DBSource dbsource, Project prjProject, string strCompanyCode, string strCompanyDesc, ref string strSecretarilman) { try { #region 自动设置文控,如果没有与单位代码一样的用户,就自动添加用户 User secUser = null; if (string.IsNullOrEmpty(strSecretarilman)) { secUser = dbsource.GetUserByCode(strCompanyCode); if (secUser == null) { ////UserController. CreateUser(sid, strCompanyCode, strCompanyDesc + "文控", "", "0", //// "0", "", strCompanyCode, strCompanyCode); ////secUser = dbsource.GetUserByCode(strCompanyCode); secUser = dbsource.NewUser( enUserFlage.OnLine, enUserType.Default, "", strCompanyCode, strCompanyDesc + "文控", strCompanyCode, "", null ); if (secUser != null) { User m_user = secUser; m_user.O_suser1 = m_user.dBSource.GUID; m_user.Modify(); // 强制刷新共享数据源 // //DBSourceController.RefreshShareDBManager(); DBSourceController.RefreshDBSource(sid); strSecretarilman = secUser.ToString; } } else { strSecretarilman = secUser.ToString; } } else { secUser = dbsource.GetUserByCode(strCompanyCode); } if (secUser != null) { //把用户添加到项目管理类里面的项目单位用户组 Group group = dbsource.GetGroupByName(prjProject.Code + "_ALLUnit"); if (group != null) { if (!group.UserList.Contains(secUser)) { group.AddUser(secUser); group.Modify(); } } } #endregion } catch { } return(true); }
/// <summary> /// /// </summary> /// <param name="sid"></param> /// <param name="DocKeyword"></param> /// <param name="Operator">主办人</param> /// <param name="Coordinator">协办人</param> /// <returns></returns> public static JObject SendDistriProcess(string sid, string DocKeyword, string Operator, string Coordinator) { // return RecDocument.SendDistriProcess(sid, DocKeyword, Operator, Coordinator); ExReJObject reJo = new ExReJObject(); try { User curUser = DBSourceController.GetCurrentUser(sid); if (curUser == null) { reJo.msg = "登录验证失败!请尝试重新登录!"; return(reJo.Value); } DBSource dbsource = curUser.dBSource; if (dbsource == null) { reJo.msg = "登录验证失败!请尝试重新登录!"; return(reJo.Value); } Doc doc = dbsource.GetDocByKeyWord(DocKeyword); if (doc == null) { reJo.msg = "错误的文档操作信息!指定的文档不存在!"; return(reJo.Value); } WorkFlow flow; if ((flow = doc.WorkFlow) == null) { reJo.msg = "错误的文档操作信息!指定的文档流程不存在!"; return(reJo.Value); } #region 设置本部门文控(登录用户)到部门人员状态 Server.Group group = new Server.Group(); group.AddUser(curUser); DefWorkState defWorkStateCu = flow.DefWorkFlow.DefWorkStateList.Find(dwsx => dwsx.O_Code == "DEPARTMENTCONTROL"); WorkState stateCu = flow.NewWorkState(defWorkStateCu); stateCu.SaveSelectUser(group); stateCu.IsRuning = true; stateCu.PreWorkState = flow.CuWorkState; stateCu.O_iuser5 = new int?(flow.CuWorkState.O_stateno); stateCu.Modify(); #endregion #region 设置协办部门人员状态 string[] strArry2 = Coordinator.Split(new char[] { ';' }); //每个部门一个协办分支 foreach (string op in strArry2) { string strUser = op.IndexOf("_") >= 0 ? op.Substring(0, op.IndexOf("_")) : op; Server.Group CoordinatorGroup = new Server.Group(); User CoordinatorUser = dbsource.GetUserByCode(strUser); if (CoordinatorUser != null) { CoordinatorGroup.AddUser(CoordinatorUser); DefWorkState defWorkStateCo = flow.DefWorkFlow.DefWorkStateList.Find(dwsx => dwsx.O_Code == "DEPARTMENTCONTROL"); WorkState state2 = flow.NewWorkState(defWorkStateCo); state2.SaveSelectUser(CoordinatorGroup); state2.IsRuning = true; state2.PreWorkState = flow.CuWorkState; state2.O_iuser5 = new int?(flow.CuWorkState.O_stateno); state2.Modify(); } } #endregion WorkStateBranch branch = flow.CuWorkState.workStateBranchList.Find(wsb => wsb.KeyWord == "TOCONTROL1");//[0]; branch.NextStateAddGroup(group); ExReJObject GotoNextReJo = WebWorkFlowEvent.GotoNextStateAndSelectUser(flow.CuWorkState.workStateBranchList[0]); #region 设置本部门办理人状态 string[] strArry = Operator.Split(new char[] { ';' }); Server.Group OperatorGroup = new Server.Group(); foreach (string op in strArry) { User OperatorUser = dbsource.GetUserByCode(op); if (OperatorUser != null) { OperatorGroup.AddUser(OperatorUser); } } //放置本部门办理状态人员 //WorkState state = flow.WorkStateList.Find(wsx => (wsx.Code == "MAINHANDLE") && // (wsx.CheckGroup.AllUserList.Count == 0)); //if (state == null) //{ DefWorkState defWorkState = flow.DefWorkFlow.DefWorkStateList.Find(dwsx => dwsx.O_Code == "MAINHANDLE"); WorkState state = flow.NewWorkState(defWorkState); state.SaveSelectUser(OperatorGroup); state.IsRuning = true; state.PreWorkState = stateCu; state.O_iuser5 = new int?(stateCu.O_stateno); state.Modify(); // } #endregion //reJo.data = new JArray(new JObject(new JProperty("WorkFlowKeyword", doc.WorkFlow.KeyWord))); reJo.success = true; return(reJo.Value); } catch (Exception exception) { //WebApi.CommonController.WebWriteLog(exception.Message + "\r\n" + exception.Source + "\r\n" + exception.StackTrace); reJo.msg = "分发失败!" + exception.Message; } return(reJo.Value); }