public void changeOnwer(String userName, ModelObject modl) { DataManagementService dmService = DataManagementService.getService(Session.getConnection()); //ModelObject user = findUser(userName); ModelObject user = findModel(cfg.get("query_builder_userByUname_name") , new string[] { cfg.get("query_builder_userByUname_queryKey") }, new string[] { userName }); if (null == user) { throw new Exception("构建器查找用户失败,请确认申请人在TC是否存在。"); } //根据USER查找GROUP dmService.GetProperties(new ModelObject[] { user }, new string[] { "default_group" }); ModelObject userGroup = user.GetProperty("default_group").ModelObjectValue; if (null == userGroup) { throw new Exception("构建器查找用户组失败。"); } ObjectOwner[] ownerData = new ObjectOwner[1]; ObjectOwner ownrObj = new ObjectOwner(); ownrObj.Object = modl; ownrObj.Group = (Teamcenter.Soa.Client.Model.Strong.Group)userGroup; ownrObj.Owner = (Teamcenter.Soa.Client.Model.Strong.User)user; ownerData[0] = ownrObj; ServiceData returnData = dmService.ChangeOwnership(ownerData); if (returnData.sizeOfPartialErrors() > 0) { throw new Exception("修改所有者失败" + returnData.GetPartialError(0).Messages[0]); } }
public void changeOnwer(String userName, String groupName, ModelObject modl) { //ModelObject user = findUser(userName); ModelObject user = findModel("__WEB_find_user", new string[] { "User ID" }, new string[] { userName }); if (null == user) { return; } //ModelObject userGroup = findGroup(groupName); ModelObject userGroup = findModel("__WEB_group", new string[] { "Name" }, new string[] { groupName }); if (null == userGroup) { return; } DataManagementService dmService = DataManagementService.getService(Session.getConnection()); ObjectOwner[] ownerData = new ObjectOwner[1]; ObjectOwner ownrObj = new ObjectOwner(); ownrObj.Object = modl; ownrObj.Group = (Teamcenter.Soa.Client.Model.Strong.Group)userGroup; ownrObj.Owner = (Teamcenter.Soa.Client.Model.Strong.User)user; ownerData[0] = ownrObj; ServiceData returnData = dmService.ChangeOwnership(ownerData); if (returnData.sizeOfPartialErrors() > 0) { throw new Exception("Change ownership service: 005" + "Change ownership service - "); } }