/// <Summary>
/// Add the specified permission to the specified group
/// </Summary>
/// <Param name = "permissionsname"> permission name </param>
/// <Param name = "groupname"> group name </param>
/// <Param name = "projectname"> project to which the Group belongs </param>
/// <Returns> </returns>
Public static string addpowerforgroup (string permissionsname, string groupname, string projectname, string collectionuri)
{
Stringbuilder sp = new stringbuilder ();
SP. append ("/A + project frameworkglobalsecurity # permissionsname" + '"' +" N: [# projectname] \\# groupname "+ '"' + "Allow/collection: # collectionuri ");
Sp. Replace ("# permissionsname", permissionsname );
Sp. Replace ("# groupname", groupname );
Sp. Replace ("# projectname", projectname );
Sp. Replace ("# collectionuri", collectionuri );
Return sp. tostring ();
}
/// <Summary>
/// Remove a specified permission from a specified group
/// </Summary>
/// <Param name = "permissionsname"> permission name </param>
/// <Param name = "groupname"> group name </param>
/// <Param name = "projectname"> name of the team project, for example, surekamspm3 </param>
/// <Returns> </returns>
Public static string movepowerforgroup (string permissionsname, string groupname, string projectname, string collectionuri)
{
Stringbuilder sp = new stringbuilder ();
SP. append ("/a-server frameworkglobalsecurity # permissionsname" + '"' +" N: [# projectname] \\# groupname "+ '"' + "Allow/collection: # collectionuri ");
Sp. Replace ("# permissionsname", permissionsname );
Sp. Replace ("# groupname", groupname );
Sp. Replace ("# projectname", projectname );
Sp. Replace ("# collectionuri", collectionuri );
Return sp. tostring ();
}
/// <Summary>
/// Call tfssecurity to grant the specified permission to the specified group
/// </Summary>
/// <Param name = "permissionsname"> permission name </param>
/// <Param name = "groupname"> group name </param>
/// <Returns> </returns>
Public static string excuteaddpowerforgroup (string permissionsname, string groupname, string projectname, string collectionuri)
{
PROCESS p = new process ();
String sorted STR = addpowerforgroup (permissionsname, groupname, projectname, collectionuri );
P. startinfo. filename = "C: \ Program Files (x86) \ Microsoft Visual Studio 10.0 \ common7 \ ide \ tfssecurity.exe ";
// Execute commands and Parameters
P. startinfo. Arguments = shortstr;
P. startinfo. useshellexecute = false; // close shell usage
P. startinfo. redirectstandardinput = true;
P. startinfo. redirectstandardoutput = true;
P. startinfo. redirectstandarderror = true;
P. startinfo. createnowindow = true; // you can specify not to display a window.
P. Start (); // start the process
String standardoutput = P. standardoutput. readtoend ();
String erroroutput = P. standarderror. readtoend ();
String message = standardoutput + "#" + erroutput;
Return message;
}
/// <Summary>
/// Delete the specified permission for the specified group
/// </Summary>
/// <Param name = "permissionsname"> permission name </param>
/// <Param name = "groupname"> group name </param>
/// <Returns> </returns>
Public static string excutemovepowerforgroup (string permissionsname, string groupname, string projectname, string collectionuri)
{
PROCESS p = new process ();
String inclustr = movepowerforgroup (permissionsname, groupname, projectname, collectionuri );
P. startinfo. filename = "C: \ Program Files (x86) \ Microsoft Visual Studio 10.0 \ common7 \ ide \ tfssecurity.exe ";
// Execute commands and Parameters
P. startinfo. Arguments = shortstr;
P. startinfo. useshellexecute = false; // close shell usage
P. startinfo. redirectstandardinput = true;
P. startinfo. redirectstandardoutput = true;
P. startinfo. redirectstandarderror = true;
P. startinfo. createnowindow = true; // you can specify not to display a window.
P. Start (); // start the process
String standardoutput = P. standardoutput. readtoend ();
String erroroutput = P. standarderror. readtoend ();
String message = standardoutput + "#" + erroutput;
Return message;
}
/// <Summary>
/// Execute the command to obtain the permission group (Project Group) of all projects in the project set
/// </Summary>
/// <Param name = "collectionurl"> project URL, for example, http: // 10.2.11.35: 8080/TFS/surekamspm3 </param>
/// <Returns> return the correct output stream + "#" + error output stream </returns>
Public static string excutegetauthortygroup (string collectionurl)
{
PROCESS p = new process ();
String required STR = producecmd. getauthoritygroup (collectionurl );
P. startinfo. filename = "C: \ Program Files (x86) \ Microsoft Visual Studio 10.0 \ common7 \ ide \ tfssecurity.exe ";
// Execute commands and Parameters
P. startinfo. Arguments = shortstr;
P. startinfo. useshellexecute = false; // close shell usage
P. startinfo. redirectstandardinput = true;
P. startinfo. redirectstandardoutput = true;
P. startinfo. redirectstandarderror = true;
P. startinfo. createnowindow = true; // you can specify not to display a window.
P. Start (); // start the process
String standardoutput = P. standardoutput. readtoend ();
String erroroutput = P. standarderror. readtoend ();
String message = standardoutput + "#" + erroutput;
Return message;
}