public ICollection <string> GetUsersInGroup(MFilesVault vault, int groupId) { var ovault = MFServerUtility.GetVault(vault); var users = GetUsersFromGroup(ovault, groupId); return(users.Select(uid => ovault.UserOperations.GetUserAccount(uid)).Select(la => MfUserUtils.GetUserNameWithoutDomain(la.LoginName)).ToList()); }
public ICollection <string> GetUsersInGroup(MFilesVault vault, string groupName) { var ovault = MFServerUtility.GetVault(vault); var group = GetGroupByName(ovault, groupName, vault.Id); return(GetUsersInGroup(ovault, group.GroupId)); }
public ICollection <string> GetUsersInGroupByAlias(MFilesVault vault, string groupAlias) { var ovault = MFServerUtility.GetVault(vault); var groupId = MfAlias.GetUsergroup(ovault, groupAlias); return(GetUsersInGroup(ovault, groupId)); }
public void RenameGroupName(MFilesVault vault, int groupId, string newName) { var ovault = MFServerUtility.GetVault(vault); var uga = ovault.UserGroupOperations.GetUserGroupAdmin(groupId); uga.UserGroup.Name = newName; ovault.UserGroupOperations.UpdateUserGroupAdmin(uga); }
public void AddUserToGroup(MFilesVault vault, string userName, string groupName) { var ovault = MFServerUtility.GetVault(vault); var groupId = GetGroupId(ovault, groupName); var userId = GetUserId(ovault, userName); AddUserToGroup(ovault, userId, groupId); }
public void AddUserToGroup(MFilesVault vault, string userName, params int[] groupIds) { var ovault = MFServerUtility.GetVault(vault); var userId = GetUserId(ovault, userName); foreach (var groupId in groupIds) { AddUserToGroup(ovault, userId, groupId); } }
public int GetObjectVersion(MFilesVault vault, int objType, int objId) { var mfVault = MFServerUtility.GetVault(vault); var objID = new ObjID(); objID.SetIDs(objType, objId); var objVer = mfVault.ObjectOperations.GetLatestObjVer(objID, false, false); return(objVer.Version); }
public bool UninstallApps(MFilesVault vault) { var ovault = MFServerUtility.GetVault(vault); var apps = ovault.CustomApplicationManagementOperations.GetCustomApplications(); foreach (CustomApplication ca in apps) { ovault.CustomApplicationManagementOperations.UninstallCustomApplication(ca.ID); } return(true); }
public void DisableVaultUser(string userName, MFilesVault vault) { var mVault = MFServerUtility.GetVault(vault); if (!HasVaultUser(userName, vault)) { Log.Error(string.Format("用户({0})不存在于vault({1}),vaultname={2},中!", userName, vault.Guid, mVault.Name)); return; } MfUserUtils.DisableVaultUser(mVault, userName); }
public ICollection <MFilesUserGroup> GetUserGroupsContainsString(MFilesVault vault, string groupStr) { var mfVault = MFServerUtility.GetVault(vault); var groups = mfVault.UserGroupOperations.GetUserGroupsAdmin(); var list = (from UserGroupAdmin uga in groups where !uga.UserGroup.Predefined && uga.UserGroup.Name.Contains(groupStr) && uga.UserGroup.Name != groupStr select ConvertTo(uga, vault.Id)).ToList(); list.Sort(); return(list); }
public ICollection <MFilesUserGroup> GetUserGroups(MFilesVault vault, bool includeInternalGroup = false) { var mfVault = MFServerUtility.GetVault(vault); var groups = mfVault.UserGroupOperations.GetUserGroupsAdmin(); if (includeInternalGroup) { return((from UserGroupAdmin uga in groups select ConvertTo(uga, vault.Id)).ToList()); } return((from UserGroupAdmin uga in groups where !uga.UserGroup.Predefined select ConvertTo(uga, vault.Id)).ToList()); }
public void EnableVaultUser(string userName, MFilesVault vault) { var mVault = MFServerUtility.GetVault(vault); if (!HasVaultUser(userName, vault)) { var err = string.Format("用户{0}不存在于vault{1},vaultname={2},中!", userName, vault.Guid, mVault.Name); Log.Error(err); throw new Exception(err); } MfUserUtils.EnableVaultUser(mVault, userName); }
internal void Create(MFilesVault vault, MFObject obj) { var mfVault = MFServerUtility.GetVault(vault); try { Create(mfVault, obj); } catch (Exception ex) { throw new Exception(obj.ToString(), ex); } }
public MfContact GetContact(MFilesVault vault, MetadataAliases aliases, string userName) { var mfVault = MFServerUtility.GetVault(vault); var userId = MfUserUtils.GetUserAccount(mfVault, userName); if (userId == null) { return(null); } var uid = userId.Value; //userid return(GetContactByUserId(mfVault, aliases, uid)); }
public bool ImportApp(string zipPath, MFilesVault vault) { var zipDirectory = new DirectoryInfo(zipPath); var ovault = MFServerUtility.GetVault(vault); foreach (var di in zipDirectory.GetDirectories()) { var targetPath = Path.Combine(Path.GetTempPath(), di.Name + ".zip"); var zip = new ZipFile(); zip.AddSelectedFiles("name!=*.zip and name!=*.pdb and name!=*.log", di.FullName, di.Name, true); zip.Save(targetPath); ImportApp(targetPath, ovault); } return(true); }
public MFObject GetMFObject <T>(MFilesVault vault, MetadataAliases aliases, T entity) where T : InternalEntity { if (entity is Project) { //var config = VaultConfig.GetConfigFromString(vault.Template.MetadataJson); var projObj = aliases.GetMfProject(entity as Project);// config.GetMfProjectObject(entity as Project); return(projObj); } if (entity is MfContact) { var mfVault = MFServerUtility.GetVault(vault); var contactObj = aliases.GetMfContact(mfVault, entity as MfContact); return(contactObj); } return(null); }
public bool Backup(MFilesVault vault) { var path = Path.Combine(Path.GetTempPath(), vault.Guid + ".mfb"); var ovault = MFServerUtility.GetVault(vault); var backup = new BackupJob { BackupType = MFBackupType.MFBackupTypeFull, TargetFile = path, VaultGUID = ovault.GetGUID(), OverwriteExistingFiles = true }; var app = MFServerUtility.ConnectToMfApp(vault); app.VaultManagementOperations.BackupVault(backup); return(true); }
public ICollection <MFilesUserGroup> GetGroupsByUser(MFilesVault vault, string userName) { var ret = new List <MFilesUserGroup>(); var ovault = MFServerUtility.GetVault(vault); var userid = GetUserId(ovault, userName); var usergroups = ovault.UserGroupOperations.GetUserGroupsAdmin(); foreach (UserGroupAdmin uga in usergroups) { foreach (int id in uga.UserGroup.Members) { if (id < 0) { ret.AddRange(GetUserGroupsOfUserEx(userid, -id, uga, ovault)); } else { if (id == userid && !uga.UserGroup.Predefined) { ret.Add(ConvertTo(uga, vault.Id)); } } } } var newret = new List <MFilesUserGroup>(); foreach (var a in ret) { var found = false; foreach (var b in newret) { if (b.Id == a.Id) { found = true; break; } } if (!found) { newret.Add(a); } } return(newret); }
public void AddUserGroupToVault(MFilesVault vault, MFilesUserGroup userGroup) { var ovault = MFServerUtility.GetVault(vault); var newuga = new UserGroupAdmin { UserGroup = new UserGroup { Name = userGroup.Name } }; if (!String.IsNullOrEmpty(userGroup.Alias)) { newuga.SemanticAliases = new SemanticAliases { Value = userGroup.Alias }; } var ug = ovault.UserGroupOperations.AddUserGroupAdmin(newuga); userGroup.Id = ug.UserGroup.ID; }
public void RemoveUserFromGroup(MFilesVault vault, string userName, params int[] groupIds) { var ovault = MFServerUtility.GetVault(vault); var userid = -1; var users = ovault.UserOperations.GetUserAccounts(); var un = MfUserUtils.GetUserNameWithoutDomain(userName).ToUpper(); foreach (UserAccount ua in users) { var un0 = MfUserUtils.GetUserNameWithoutDomain(ua.LoginName); if (un0.ToUpper() == un) { userid = ua.ID; break; } } foreach (var groupId in groupIds) { RemoveUserFromGroupById(ovault, userid, groupId); } }
public MFDownloadFile DownloadFile(MFilesVault vault, int objType, int objId, int fileId) { var mfVault = MFServerUtility.GetVault(vault); var objID = new ObjID(); objID.SetIDs(objType, objId); var objVer = mfVault.ObjectOperations.GetLatestObjVer(objID, false, false); var objVersion = mfVault.ObjectOperations.GetObjectInfo(objVer, true, false); if (objVersion.FilesCount == 0) { return(null); } if (fileId > 0) { ObjectFile fv = null; foreach (ObjectFile file in objVersion.Files) { if (file.FileVer.ID == fileId) { fv = file; break; } } if (fv == null) { fv = objVersion.Files[1]; } var session = mfVault.ObjectFileOperations.DownloadFileInBlocks_Begin(fv.FileVer.ID, fv.FileVer.Version); var content = mfVault.ObjectFileOperations.DownloadFileInBlocks_ReadBlock(session.DownloadID, session.FileSize32, 0); return(new MFDownloadFile { Content = content, Name = fv.Title, Extension = fv.Extension, Version = objVer.Version }); } return(null); }
public int?GetUserId(string userName, MFilesVault vault) { var mfVault = MFServerUtility.GetVault(vault); return(MfUserUtils.GetUserAccount(mfVault, userName)); }
public void RemoveUserGroupById(MFilesVault vault, int groupId) { var mfVault = MFServerUtility.GetVault(vault); mfVault.UserGroupOperations.RemoveUserGroupAdmin(groupId); }
public MFProjectParty GetParty(MFilesVault vault, string partyName, MetadataAliases aliases, int?currentUserId = null) { var mfVault = MFServerUtility.GetVault(vault); var partyObj = aliases.Objects["ObjParticipant"]; var partyClass = partyObj.ClassDict["ClassParticipant"]; var typeId = MfAlias.GetObjType(mfVault, partyObj.Alias); var classId = MfAlias.GetObjectClass(mfVault, partyClass.Alias); var scs = new SearchConditions(); MFSearchConditionUtils.AddBaseConditions(scs, typeId, classId); var namePropId = MfAlias.GetPropDef(mfVault, partyClass.PropDict["PropParticipantName"]); var nameSC = MFSearchConditionUtils.Property(MFConditionType.MFConditionTypeEqual, namePropId, MFDataType.MFDatatypeText, partyName); scs.Add(-1, nameSC); var res = mfVault.ObjectSearchOperations.SearchForObjectsByConditions(scs, MFSearchFlags.MFSearchFlagNone, false); if (res.Count != 1) { return(null); } var party = new MFProjectParty { Name = partyName }; var obj = res[1]; party.InternalId = obj.ObjVer.ID; var managerPropId = MfAlias.GetPropDef(mfVault, partyClass.PropDict["PropProjPM"]); var managerTV = mfVault.ObjectPropertyOperations.GetProperty(obj.ObjVer, managerPropId).Value; if (!managerTV.IsNULL() && !managerTV.IsUninitialized()) { party.ManagerCount = 1; var contactId = managerTV.GetLookupID(); var userId = GetContactAccount(mfVault, aliases, contactId); if (currentUserId != null && userId == currentUserId.Value) { party.IsCurrentManager = true; } } var vmPropId = MfAlias.GetPropDef(mfVault, partyClass.PropDict["PropProjVicePMs"]); var vmTV = mfVault.ObjectPropertyOperations.GetProperty(obj.ObjVer, vmPropId).Value; if (!vmTV.IsNULL() && !vmTV.IsUninitialized()) { var lkps = vmTV.GetValueAsLookups(); party.ViceManagerCount = lkps.Count; if (currentUserId != null && !party.IsCurrentManager) { for (var i = 1; i <= lkps.Count; i++) { var contactId = lkps[i].Item; var userId = GetContactAccount(mfVault, aliases, contactId); if (userId == currentUserId.Value) { party.IsCurrentViceManager = true; break; } } } } var mmPropId = MfAlias.GetPropDef(mfVault, partyClass.PropDict["PropMembers"]); var mmTV = mfVault.ObjectPropertyOperations.GetProperty(obj.ObjVer, mmPropId).Value; if (!mmTV.IsNULL() && !mmTV.IsUninitialized()) { var lkps = mmTV.GetValueAsLookups(); party.MemberCount = lkps.Count; if (currentUserId != null && !party.IsCurrentViceManager && !party.IsCurrentManager) { for (var i = 1; i <= lkps.Count; i++) { var contactId = lkps[i].Item; var userId = GetContactAccount(mfVault, aliases, contactId); if (userId == currentUserId.Value) { party.IsCurrentMember = true; break; } } } } return(party); }
public MFilesUserGroup GetUserGroupById(MFilesVault vault, int groupId) { var mfVault = MFServerUtility.GetVault(vault); return(GetGroupById(mfVault, groupId, vault.Id)); }
public void Delete(MFilesVault vault, int objType, int objId) { var mfVault = MFServerUtility.GetVault(vault); Delete(mfVault, objType, objId); }
public string GetAccountName(int userId, MFilesVault vault) { var mfVault = MFServerUtility.GetVault(vault); return(MfUserUtils.GetUserNameWithoutDomain(mfVault, userId)); }
public MFilesUserGroup GetUserGroupByName(MFilesVault vault, string groupName) { var mfVault = MFServerUtility.GetVault(vault); return(GetGroupByName(mfVault, groupName, vault.Id)); }
public MfContact GetContactByContactId(MFilesVault vault, MetadataAliases aliases, int contactId) { var mfVault = MFServerUtility.GetVault(vault); return(GetContactById(mfVault, aliases, contactId)); }
internal void Update(MFilesVault vault, MFObject obj) { var mfVault = MFServerUtility.GetVault(vault); Update(mfVault, obj); }