internal static string GetSecrearilManByUnitCode(DBSource dbsource, string UnitCode) { string secUserList = ""; //从组织机构里面查找文控 Server.Group gp = dbsource.GetGroupByName(UnitCode); if (gp == null) { return(""); } foreach (Server.Group g in gp.AllGroupList) { if (g.Description == "文控") { foreach (User user in g.AllUserList) { secUserList = user.ToString + ","; } if (!string.IsNullOrWhiteSpace(secUserList)) { secUserList = secUserList.Substring(0, secUserList.Length - 1); } break; } } return(secUserList); }
internal static Group GetSecGroupByUnitCode(DBSource dbsource, string UnitCode) { string secUserList = ""; //从组织机构里面查找文控 Server.Group gp = dbsource.GetGroupByName(UnitCode); if (gp == null) { return(null); } Server.Group resultGp = null; foreach (Server.Group g in gp.AllGroupList) { if (g.Description == "文控") { resultGp = g; break; } } return(resultGp); }
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); }