Hi ,
Please share some code snippets to remove user from any projectroom roles
Here's something I had kicking around from a while back, it should give you the precise sort of logic you need.
...
//ProjectID to manipulate int projectID = 758607;
Node PJ1 = docCli.GetNode(ref otAuth, projectID); ProjectInfo PJ2 = colCli.GetProject(ref otAuth, projectID); ProjectParticipants PJ3 = colCli.GetParticipants(ref otAuth, projectID); List<Member> Members = new List<Member>(); User AddThisDude = new User(); AddThisDude = memCli.GetUserByLoginName(ref otAuth, "Testing4"); ProjectRoleUpdateInfo PJ4 = new ProjectRoleUpdateInfo(); PJ4.UserID = 151657; PJ4.RoleAction = ProjectRoleAction.ASSIGN; PJ4.Role = ProjectRole.COORDINATOR;
for(int i = 0; i < PJ3.Coordinators.Length; i++) { Members.Add(PJ3.Coordinators[0]); }
Members.Add(AddThisDude); int mem = Members.Count; ProjectRoleUpdateInfo[] PJ5 = new ProjectRoleUpdateInfo[1]; PJ5[0] = PJ4;
colCli.UpdateProjectParticipants(ref otAuth, projectID, PJ5); PJ2.CreatedBy = 224002; colCli.UpdateProject(ref otAuth, PJ2);
In my case, I was creating some new user and adding it to the project. Note, there are some lines that do nothing, because I was break-pointing and reading what was returned from the server, for each.
updateProjectParticipants(long projectID, ProjectRoleUpdateInfo[] roleUpdateInfo)
In the CWS API, it tells you that this method allows you to manipulate roles, including removing them. So you can, instead of doing Whatever.RoleAction.ASSIGN, a Whatever.RoleAction.REMOVE (or equivalent).
Have all your ProjectRoleUpdateInfo setup, with REMOVE/ASSIGN with what you want, and then pass it up with updateProjectParticipants.
Thanks a lot Nizar