Security.DeleteProjectCategories 方法
會刪除 web 安全性權限的專案類別資訊。
命名空間: WebSvcSecurity
組件: ProjectServerServices (在 ProjectServerServices.dll 中)
語法
'宣告
<SoapDocumentMethodAttribute("https://schemas.microsoft.com/office/project/server/webservices/Security/DeleteProjectCategories", RequestNamespace := "https://schemas.microsoft.com/office/project/server/webservices/Security/", _
ResponseNamespace := "https://schemas.microsoft.com/office/project/server/webservices/Security/", _
Use := SoapBindingUse.Literal, ParameterStyle := SoapParameterStyle.Wrapped)> _
Public Sub DeleteProjectCategories ( _
projUids As Guid() _
)
'用途
Dim instance As Security
Dim projUids As Guid()
instance.DeleteProjectCategories(projUids)
[SoapDocumentMethodAttribute("https://schemas.microsoft.com/office/project/server/webservices/Security/DeleteProjectCategories", RequestNamespace = "https://schemas.microsoft.com/office/project/server/webservices/Security/",
ResponseNamespace = "https://schemas.microsoft.com/office/project/server/webservices/Security/",
Use = SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Wrapped)]
public void DeleteProjectCategories(
Guid[] projUids
)
參數
- projUids
類型:[]
備註
[專案] 權限] 功能可讓使用者或群組已授與 「 管理基本專案安全性 」 類別權限授與使用者和群組存取其所擁有的專案。它們能夠運作 like 安全性類別。如需詳細資訊,請參閱 < https://blogs.msdn.com/b/project/archive/2010/03/04/project-2010-project-permissions.aspx。
Project Server 權限
權限 |
描述 |
---|---|
非標準 |
您必須具備ManageWorkflow通用權限或ChangeWorkflow通用權限。如果您有ChangeWorkflow權限,您也必須OpenProject類別權限和SaveProject類別權限。 |
範例
The example uses the SvcSecurity namespace in the ProjectServerServices.dll proxy assembly. The ConfigureClientEndPoints method uses an app.config file for setting the WCF binding, behavior, and endpoint. For information about creating a PSI proxy assembly and an app.config file, see Prerequisites for WCF-Based Code Samples.
注意事項 |
---|
本範例會假設專案沒有任何指派給它的類別。 |
此範例會呼叫ReadProjectList方法,以取得專案的清單。然後它會呼叫CreateProjectCategories建立ProjectCategoriesDataset ,並將它寫入 XML 檔案Categories.xml,如下列程式碼所示。
<?xml version="1.0" standalone="yes"?>
<SecurityProjectCategoriesDataSet xmlns="https://schemas.microsoft.com/office/project/server/
webservices/SecurityProjectCategoriesDataSet/">
<ProjectCategories>
<WSEC_CAT_UID>
321f7584-1f8b-4065-a432-a59b9412d8ba</WSEC_CAT_UID>
<PROJ_UID>ff9c1198-fb7b-4e9d-88a9-1415d46a3443</PROJ_UID>
</ProjectCategories>
</SecurityProjectCategoriesDataSet>
會呼叫UpdateProjectCategories方法來更新ProjectCategoriesDataset及更新的資料集會寫入UpdatedCategories.xml檔案,如下列程式碼所示。
<?xml version="1.0" standalone="yes"?>
<SecurityProjectCategoriesDataSet xmlns="https://schemas.microsoft.com/office/project/server/
webservices/SecurityProjectCategoriesDataSet/">
<ProjectCategories>
<WSEC_CAT_UID>
8ce0a52b-6218-4670-bf53-8e8df21af590</WSEC_CAT_UID>
<PROJ_UID>aed0e69b-4470-4ddb-b063-184a9c06c9de</PROJ_UID>
</ProjectCategories>
</SecurityProjectCategoriesDataSet>
DeleteProjectCategories方法會採用陣列的專案 Guid,並刪除ProjectCategoriesDataset中的項目。以下是完成的範例程式碼。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.ServiceModel;
namespace Microsoft.SDK.Project.Samples.Security
{
class Security
{
private const string ENDPOINT_S = "basicHttp_Security";
private const string ENDPOINT_P = "basicHttp_Project";
private const string OUTPUT_FILES = @"C:\Projects\Samples\Output\";
private static string outFilePathCategories;
private static string outFilePathUpdatedCategories;
private static SvcSecurity.SecurityClient securityClient;
private static SvcProject.ProjectClient projectClient;
static void Main(string[] args)
{
// If directory does not exist, create it.
if (!Directory.Exists(OUTPUT_FILES))
{
Directory.CreateDirectory(OUTPUT_FILES);
}
// Assign the path where the output XML file will be saved.
outFilePathCategories = OUTPUT_FILES + "Categories.xml";
outFilePathUpdatedCategories = OUTPUT_FILES + "UpdatedCategories.xml";
// Configure the endpoints.
bool configResult = false;
configResult = ConfigClientEndpoints(ENDPOINT_P);
configResult = ConfigClientEndpoints(ENDPOINT_S);
try
{
// Create a project DataSet.
SvcProject.ProjectDataSet pDS = new SvcProject.ProjectDataSet();
pDS = projectClient.ReadProjectList();
// Create a project category.
SvcSecurity.SecurityProjectCategoriesDataSet projectCategoryDataSet1 =
new SvcSecurity.SecurityProjectCategoriesDataSet();
SvcSecurity.SecurityProjectCategoriesDataSet.ProjectCategoriesRow row1 =
projectCategoryDataSet1.ProjectCategories.NewProjectCategoriesRow();
row1.WSEC_CAT_UID = Guid.NewGuid();
row1.PROJ_UID = pDS.Project[2].PROJ_UID;
projectCategoryDataSet1.ProjectCategories.AddProjectCategoriesRow(row1);
securityClient.CreateProjectCategories(projectCategoryDataSet1);
// Read project category DataSet.
SvcSecurity.SecurityProjectCategoriesDataSet projectCategoryDataSet =
securityClient.ReadProjectCategory(row1.PROJ_UID);
// Write the project category DataSet to an XML file.
Console.WriteLine("\nWriting the ProjectCategoryDataSet to an XML file...");
projectCategoryDataSet.WriteXml(outFilePathCategories);
Console.WriteLine("\nSee XML output of ProjectCategoryDataSet at {0}",
outFilePathCategories);
Console.Write("\nPress any key to continue: ");
Console.ReadKey(true);
// Update project category DataSet.
SvcSecurity.SecurityProjectCategoriesDataSet projectCategoryDataSet3 =
new SvcSecurity.SecurityProjectCategoriesDataSet();
SvcSecurity.SecurityProjectCategoriesDataSet.ProjectCategoriesRow row2 =
projectCategoryDataSet3.ProjectCategories.NewProjectCategoriesRow();
row2.WSEC_CAT_UID = Guid.NewGuid();
row2.PROJ_UID = pDS.Project[3].PROJ_UID;
projectCategoryDataSet3.ProjectCategories.AddProjectCategoriesRow(row2);
securityClient.UpdateProjectCategories(projectCategoryDataSet3);
// Read project category DataSet.
SvcSecurity.SecurityProjectCategoriesDataSet updatedPDS =
securityClient.ReadProjectCategory(row2.PROJ_UID);
// Write the updated project category DataSet to an XML file.
Console.WriteLine("\nWriting the ProjectCategoryDataSet to an XML file...");
updatedPDS.WriteXml(outFilePathUpdatedCategories);
Console.WriteLine("\nSee XML output of ProjectCategoryDataSet at {0}",
outFilePathUpdatedCategories);
Console.Write("\nPress any key to continue: ");
Console.ReadKey(true);
// Delete project categories.
Guid[] guidarray = new Guid[2];
guidarray[0] = row1.PROJ_UID;
guidarray[1] = row2.PROJ_UID;
securityClient.DeleteProjectCategories(guidarray);
}
catch (CommunicationException e)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(
"\n***System.ServiceModel.CommunicationException:");
Console.WriteLine(e.ToString());
Console.ResetColor();
}
}
// Configure the PSI client endpoints.
public static bool ConfigClientEndpoints(string endpt)
{
bool result = true;
switch (endpt)
{
case ENDPOINT_P:
projectClient = new SvcProject.ProjectClient(endpt);
break;
case ENDPOINT_S:
securityClient = new SvcSecurity.SecurityClient(endpt);
break;
default:
result = false;
Console.WriteLine("Invalid endpoint: {0}", endpt);
break;
}
return result;
}
}
}