Driver.CreatePrioritization(DriverPrioritizationDataSet) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Sets a priority level (None, Low, Moderate, or Strong) for a business strategy driver and project impacts.
public:
WebSvcDriver::DriverPrioritizationDataSet ^ CreatePrioritization(WebSvcDriver::DriverPrioritizationDataSet ^ driverPrioritizationDataSet);
[System.Web.Services.Protocols.SoapDocumentMethod("http://schemas.microsoft.com/office/project/server/webservices/Driver/CreatePrioritization", ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, RequestNamespace="http://schemas.microsoft.com/office/project/server/webservices/Driver/", ResponseNamespace="http://schemas.microsoft.com/office/project/server/webservices/Driver/", Use=System.Web.Services.Description.SoapBindingUse.Literal)]
public WebSvcDriver.DriverPrioritizationDataSet CreatePrioritization(WebSvcDriver.DriverPrioritizationDataSet driverPrioritizationDataSet);
member this.CreatePrioritization : WebSvcDriver.DriverPrioritizationDataSet -> WebSvcDriver.DriverPrioritizationDataSet
Parameters
- driverPrioritizationDataSet
- DriverPrioritizationDataSet
Contains the one PrioritizationRow object in the PrioritizationDataTable.
Returns
Contains the prioritization data.
- Attributes
Examples
The example uses the SvcDriver namespace in the ProjectServerServices.dll proxy assembly. The ConfigClientEndpoints 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.
The CreatePrioritization method adds a PrioritizationRow object to the driverPrioritizationDS. The example application writes contents of the dataset to the CreatePrioritization.xml file, as follows:
<?xml version="1.0" standalone="yes"?>
<DriverPrioritizationDataSet xmlns=
"http://schemas.microsoft.com/office/project/server/webservices/DriverPrioritizationDataSet/">
<Prioritization>
<span class="label"><PRIORITIZATION_UID></span>d8d908ce-6400-458f-9edd-554209d4efcf
</PRIORITIZATION_UID>
<span class="label"><PRIORITIZATION_NAME></span>Prioritization-d8d908ce-6400-458f-9edd-554209d4efcf
</PRIORITIZATION_NAME>
<span class="label"><PRIORITIZATION_DESCRIPTION></span>Test pri</PRIORITIZATION_DESCRIPTION>
<span class="label"><PRIORITIZATION_IS_MANUAL></span>false</PRIORITIZATION_IS_MANUAL>
<span class="label"><RELATIVE_IMPORTANCE_CF_UID></span>2cd29b66-4cca-4c3e-8421-1e54c6d06dca
</RELATIVE_IMPORTANCE_CF_UID>
<CONSISTENCY_RATIO>1</CONSISTENCY_RATIO>
</Prioritization>
</DriverPrioritizationDataSet>
Following is the complete sample code.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.ServiceModel;
using PSLibrary = Microsoft.Office.Project.Server.Library;
namespace Microsoft.SDK.Project.Samples.Drivers
{
class Driver
{
private static SvcDriver.DriverClient driverClient;
private const string DRIVER_ENDPOINT = "basicHttp_Driver";
private const string OUTPUT_FILES = @"C:\Projects\Samples\Output\";
private static string outFilePathDriverImpactStmt;
private static string outFilePathDriverList;
private static string outFilePathPrioritizationInfo;
private static string outFilePathPrioritizationRow;
private static string OutFilePathDrivers;
private Dictionary<Guid, SortedList<int, SortedList<Guid, object>>>
lookupTableValues =
new Dictionary<Guid, SortedList<int, SortedList<Guid, object>>>();
static void Main(string[] args)
{
// Configure the endpoints.
ConfigClientEndpoints(DRIVER_ENDPOINT);
// If output directory does not exist, create it.
if (!Directory.Exists(OUTPUT_FILES))
{
Directory.CreateDirectory(OUTPUT_FILES);
}
outFilePathDriverImpactStmt = OUTPUT_FILES
+ "DriverImpactStatements.xml";
outFilePathDriverList = OUTPUT_FILES
+ "DriverList.xml";
outFilePathPrioritizationInfo = OUTPUT_FILES
+ "PrioritizationInfo.xml";
outFilePathPrioritizationRow = OUTPUT_FILES
+ "CreatePrioritization.xml";
OutFilePathDrivers = OUTPUT_FILES + "Drivers.xml";
// Create the Driver dataset.
SvcDriver.DriverDataSet driverInfoDS =
new SvcDriver.DriverDataSet(); ;
// Create the drivers.
driverInfoDS = CreateDrivers();
driverInfoDS.WriteXml(OutFilePathDrivers);
// Get the first driver and update its impact statements.
Guid DRV_UID =
new Guid(driverInfoDS.Driver.Rows[0][0].ToString());
// Update driver impact statements.
UpdateImpactStatement(DRV_UID);
// Read the list of drivers.
SvcDriver.DriverDataSet driverListDS =
driverClient.ReadDriverList();
driverListDS.WriteXml(outFilePathDriverList);
Console.WriteLine("\nSee XML output of the Updated DataSet at {0}",
outFilePathDriverList);
// Create prioritization.
PrioritizationInfo priInfo = CreateNewPrioritization();
// Create a guids list and add the prioritization GUID to it.
List<Guid> guids = new List<Guid>();
guids.Add(priInfo.UniqueId);
// Read prioritization.
SvcDriver.DriverPrioritizationDataSet prioritizationDS =
driverClient.ReadPrioritization(priInfo.UniqueId);
// Look-up-table values for comparison (hard-coded here).
Guid[] lookUpTableValues = new Guid[2];
// The lookup table value is greater.
lookUpTableValues[0] = new Guid("3E0D4FFF-52A6-4235-9B2D-8FB26D74A139");
// The lookup table value is less.
lookUpTableValues[1] =
new Guid("9CECF611-8F36-4CA2-89E4-640537848513");
// Add drivers to prioritization.
prioritizationDS = UpdatePrioritizationInfo(
driverInfoDS, priInfo, prioritizationDS, lookUpTableValues);
// Read updated prioritization information.
SvcDriver.DriverPrioritizationDataSet updatedPrioritizationDS =
driverClient.ReadPrioritization(priInfo.UniqueId);
updatedPrioritizationDS.WriteXml(outFilePathPrioritizationInfo);
Console.WriteLine(
"\nSee XML output of the Updated Prioritization at {0}",
outFilePathPrioritizationInfo);
// Delete prioritization.
driverClient.DeletePrioritizations(guids.ToArray());
Console.WriteLine(" Prioritization {0} deleted", priInfo.UniqueId);
guids.Clear();
// Delete drivers.
foreach (SvcDriver.DriverDataSet.DriverRow drvRow in
driverInfoDS.Driver.Rows)
{
guids.Add(drvRow.DRIVER_UID);
}
driverClient.DeleteDrivers(guids.ToArray());
Console.WriteLine("Deleted drivers");
Console.ReadKey();
}
// Update a prioritization.
private static SvcDriver.DriverPrioritizationDataSet
UpdatePrioritizationInfo(
SvcDriver.DriverDataSet driverInfoDS,
PrioritizationInfo priInfo,
SvcDriver.DriverPrioritizationDataSet prioritizationDS,
Guid[] lookUpTableValues)
{
// Add a prioritization row.
foreach (SvcDriver.DriverDataSet.DriverRow dRow in
driverInfoDS.Driver.Rows)
{
SvcDriver.DriverPrioritizationDataSet.PrioritizationEntriesDataTable
prioEntries = prioritizationDS.PrioritizationEntries;
SvcDriver.DriverPrioritizationDataSet.PrioritizationEntriesRow
prioritizationEntriesRow =
prioEntries.NewPrioritizationEntriesRow();
prioritizationEntriesRow.PRIORITIZATION_UID =
priInfo.UniqueId;
prioritizationEntriesRow.DRIVER_UID = dRow.DRIVER_UID;
prioritizationEntriesRow.DRIVER_DESCRIPTION =
dRow.DRIVER_DESCRIPTION;
prioEntries.AddPrioritizationEntriesRow(
prioritizationEntriesRow);
}
// Add driver-to-driver relations.
for (int i = 0; i < driverInfoDS.Driver.Rows.Count - 1; i++)
{
for (int j = i + 1; j < driverInfoDS.Driver.Rows.Count; j++)
{
SvcDriver.DriverPrioritizationDataSet.DriverRelationsRow
driverRelationsRow =
prioritizationDS.DriverRelations.NewDriverRelationsRow();
driverRelationsRow.PRIORITIZATION_UID = priInfo.UniqueId;
driverRelationsRow.DRIVER1_UID =
new Guid(driverInfoDS.Driver.Rows[i][0].ToString());
driverRelationsRow.DRIVER2_UID =
new Guid(driverInfoDS.Driver.Rows[j][0].ToString());
driverRelationsRow.LT_STRUCT_UID = lookUpTableValues[i];
prioritizationDS.DriverRelations.AddDriverRelationsRow(
driverRelationsRow);
// Also save the complement values.
Guid complementCodeValue =
PSLibrary.LookupTables.GetRelativeImportanceComplement(
lookUpTableValues[i]);
if (complementCodeValue != Guid.Empty)
{
driverRelationsRow =
prioritizationDS.DriverRelations.NewDriverRelationsRow();
driverRelationsRow.PRIORITIZATION_UID = priInfo.UniqueId;
driverRelationsRow.DRIVER1_UID =
new Guid(driverInfoDS.Driver.Rows[j][0].ToString());
driverRelationsRow.DRIVER2_UID =
new Guid(driverInfoDS.Driver.Rows[i][0].ToString());
driverRelationsRow.LT_STRUCT_UID = complementCodeValue;
prioritizationDS.DriverRelations.AddDriverRelationsRow(
driverRelationsRow);
}
}
}
try
{
Console.WriteLine("Updating the DataSet....");
prioritizationDS =
driverClient.UpdatePrioritization(prioritizationDS);
Console.WriteLine(" DataSet updated successfully!");
}
catch (CommunicationException e)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(
"\n***System.ServiceModel.CommunicationException:");
Console.WriteLine(e.ToString());
Console.ResetColor();
}
return prioritizationDS;
}
// Create a new prioritization.
private static PrioritizationInfo CreateNewPrioritization()
{
SvcDriver.DriverPrioritizationDataSet driverPrioritizationDS =
new SvcDriver.DriverPrioritizationDataSet();
PrioritizationInfo priInfo = new PrioritizationInfo();
priInfo.UniqueId = Guid.NewGuid();
priInfo.Name = "Prioritization-" + priInfo.UniqueId;
priInfo.Description = "Test pri";
try
{
SvcDriver.DriverPrioritizationDataSet.PrioritizationRow
prioritizationRow =
driverPrioritizationDS.Prioritization.NewPrioritizationRow();
prioritizationRow.PRIORITIZATION_UID = priInfo.UniqueId;
prioritizationRow.PRIORITIZATION_NAME = priInfo.Name;
prioritizationRow.PRIORITIZATION_DESCRIPTION =
priInfo.Description;
prioritizationRow.RELATIVE_IMPORTANCE_CF_UID =
PSLibrary.CustomField.RELATIVE_IMPORTANCE_MD_PROP_UID;
prioritizationRow.PRIORITIZATION_IS_MANUAL = false;
driverPrioritizationDS.Prioritization.AddPrioritizationRow(
prioritizationRow);
Console.WriteLine("Prioritization: Adding driver prioritization"
+ priInfo.Name);
driverClient.CreatePrioritization(driverPrioritizationDS);
Console.WriteLine("Prioritization: Creation done");
driverPrioritizationDS.WriteXml(outFilePathPrioritizationRow);
}
catch (CommunicationException e)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(
"\n System.ServiceModel.CommunicationException:");
Console.WriteLine(e.ToString());
Console.ResetColor();
}
return priInfo;
}
// Configure the custom field client endpoints.
public static void ConfigClientEndpoints(string endpt)
{
driverClient = new SvcDriver.DriverClient(endpt);
}
// Create drivers with impact statements.
private static SvcDriver.DriverDataSet CreateDrivers()
{
DriverInfo drvInfo = new DriverInfo();
SvcDriver.DriverDataSet updatedDriverDS =
new SvcDriver.DriverDataSet();
try
{
// Creates three drivers and the impact statements for each.
for (int i = 0; i < 3; i++)
{
SvcDriver.DriverDataSet drvDS =
new SvcDriver.DriverDataSet();
drvInfo.UniqueId = Guid.NewGuid();
drvInfo.Name = "Driver-" + drvInfo.UniqueId;
drvInfo.Description = "test" + drvInfo.Name;
drvInfo.StatementNone = "PROJECT_IMPACT_NONE_VALUE_TXT"
+ "-" + drvInfo.UniqueId;
drvInfo.StatementLow = "PROJECT_IMPACT_LOW_VALUE_TXT"
+ "-" + drvInfo.UniqueId;
drvInfo.StatementModerate = "PROJECT_IMPACT_MODERATE_VALUE_TXT"
+ "-" + drvInfo.UniqueId;
drvInfo.StatementStrong = "PROJECT_IMPACT_STRONG_VALUE_TXT"
+ "-" + drvInfo.UniqueId;
drvInfo.StatementExtreme = "PROJECT_IMPACT_EXTREME_VALUE_TXT"
+ "-" + drvInfo.UniqueId;
SvcDriver.DriverDataSet.DriverRow drvRow =
drvDS.Driver.NewDriverRow();
drvRow.DRIVER_UID = drvInfo.UniqueId;
drvRow.DRIVER_NAME = drvInfo.Name;
drvRow.DRIVER_DESCRIPTION = drvInfo.Description;
drvDS.Driver.AddDriverRow(drvRow);
SvcDriver.DriverDataSet.DriverImpactStatementsDataTable
drvImpStmts = drvDS.DriverImpactStatements;
SvcDriver.DriverDataSet.DriverImpactStatementsRow
stmtRow = drvImpStmts.NewDriverImpactStatementsRow();
stmtRow.DRIVER_UID = drvInfo.UniqueId;
stmtRow.PROJECT_IMPACT_CF_UID =
PSLibrary.CustomField.PROJECT_IMPACT_MD_PROP_UID;
stmtRow.LT_STRUCT_UID =
PSLibrary.LookupTables.PROJECT_IMPACT_NONE_LT_STRUCT_UID;
stmtRow.DESCRIPTION = drvInfo.StatementNone;
drvImpStmts.AddDriverImpactStatementsRow(stmtRow);
stmtRow =
drvImpStmts.NewDriverImpactStatementsRow();
stmtRow.DRIVER_UID = drvInfo.UniqueId;
stmtRow.PROJECT_IMPACT_CF_UID =
PSLibrary.CustomField.PROJECT_IMPACT_MD_PROP_UID;
stmtRow.LT_STRUCT_UID =
PSLibrary.LookupTables.PROJECT_IMPACT_LOW_LT_STRUCT_UID;
stmtRow.DESCRIPTION = drvInfo.StatementLow;
drvImpStmts.AddDriverImpactStatementsRow(stmtRow);
stmtRow =
drvImpStmts.NewDriverImpactStatementsRow();
stmtRow.DRIVER_UID = drvInfo.UniqueId;
stmtRow.PROJECT_IMPACT_CF_UID =
PSLibrary.CustomField.PROJECT_IMPACT_MD_PROP_UID;
stmtRow.LT_STRUCT_UID =
PSLibrary.LookupTables.PROJECT_IMPACT_MODERATE_LT_STRUCT_UID;
stmtRow.DESCRIPTION = drvInfo.StatementModerate;
drvImpStmts.AddDriverImpactStatementsRow(stmtRow);
stmtRow =
drvImpStmts.NewDriverImpactStatementsRow();
stmtRow.DRIVER_UID = drvInfo.UniqueId;
stmtRow.PROJECT_IMPACT_CF_UID =
PSLibrary.CustomField.PROJECT_IMPACT_MD_PROP_UID;
stmtRow.LT_STRUCT_UID =
PSLibrary.LookupTables.PROJECT_IMPACT_STRONG_LT_STRUCT_UID;
stmtRow.DESCRIPTION = drvInfo.StatementStrong;
drvImpStmts.AddDriverImpactStatementsRow(stmtRow);
stmtRow =
drvImpStmts.NewDriverImpactStatementsRow();
stmtRow.DRIVER_UID = drvInfo.UniqueId;
stmtRow.PROJECT_IMPACT_CF_UID =
PSLibrary.CustomField.PROJECT_IMPACT_MD_PROP_UID;
stmtRow.LT_STRUCT_UID =
PSLibrary.LookupTables.PROJECT_IMPACT_EXTREME_LT_STRUCT_UID;
stmtRow.DESCRIPTION = drvInfo.StatementExtreme;
drvImpStmts.AddDriverImpactStatementsRow(stmtRow);
Console.WriteLine("Adding driver " + drvInfo.Name);
driverClient.CreateDriver(
(SvcDriver.DriverDataSet)drvDS);
Console.WriteLine("Drivers {0} created successfully!", i);
updatedDriverDS.Merge(drvDS);
}
}
catch (CommunicationException e)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(
"\n***System.ServiceModel.CommunicationException:");
Console.WriteLine(e.ToString());
Console.ResetColor();
}
return updatedDriverDS;
}
// Update the driver impact statements.
private static void UpdateImpactStatement(Guid DriverGuid)
{
try
{
Guid LT_UID =
new Guid("779271C4-894D-4385-9E33-1251A9E80541");
Guid IMPACT_UID =
new Guid("1728D080-BA74-4D86-A29A-27E4318001C4");
SvcDriver.DriverDataSet drvInfoDS =
driverClient.ReadDriver(DriverGuid);
SvcDriver.DriverDataSet.DriverImpactStatementsRow impactRow;
SvcDriver.DriverDataSet.DriverImpactStatementsDataTable
drvImpactStmts = drvInfoDS.DriverImpactStatements;
impactRow =
drvImpactStmts.FindByDRIVER_UIDPROJECT_IMPACT_CF_UIDLT_STRUCT_UID(
DriverGuid, IMPACT_UID, LT_UID);
impactRow.DESCRIPTION = "new desc";
driverClient.UpdateDriver(drvInfoDS);
drvInfoDS.DriverImpactStatements.WriteXml(
outFilePathDriverImpactStmt);
Console.WriteLine(
"\nSee XML output of the Updated DataSet at {0}",
outFilePathDriverImpactStmt);
}
catch (CommunicationException e)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(
"\n***System.ServiceModel.CommunicationException:");
Console.WriteLine(e.ToString());
Console.ResetColor();
}
}
}
// This class contains the driver information.
public class DriverInfo
{
private Guid driverGuid = new Guid();
public Guid UniqueId
{
get { return this.driverGuid; }
set { this.driverGuid = value; }
}
private string driverName = string.Empty;
public string Name
{
get { return this.driverName; }
set { this.driverName = value; }
}
private string driverDescription = string.Empty;
public string Description
{
get { return this.driverDescription; }
set { this.driverDescription = value; }
}
public static int DriverType
{
get { return (int)PSLibrary.Optimizer.OptimizerEntities.Driver; }
}
private string statementNone = string.Empty;
public string StatementNone
{
get { return this.statementNone; }
set { this.statementNone = value; }
}
private string statementLow = string.Empty;
public string StatementLow
{
get { return this.statementLow; }
set { this.statementLow = value; }
}
private string statementModerate = string.Empty;
public string StatementModerate
{
get { return this.statementModerate; }
set { this.statementModerate = value; }
}
private string statementStrong = string.Empty;
public string StatementStrong
{
get { return this.statementStrong; }
set { this.statementStrong = value; }
}
private string statementExtreme = string.Empty;
public string StatementExtreme
{
get { return this.statementExtreme; }
set { this.statementExtreme = value; }
}
}
// This class contains the prioritization information.
class PrioritizationInfo
{
private Guid prioritizationGuid = Guid.NewGuid();
public Guid UniqueId
{
get { return this.prioritizationGuid; }
set { this.prioritizationGuid = value; }
}
private string prioritizationName = string.Empty;
public string Name
{
get { return this.prioritizationName; }
set { this.prioritizationName = value; }
}
private string prioritizationDescription = string.Empty;
public string Description
{
get { return this.prioritizationDescription; }
set { this.prioritizationDescription = value; }
}
}
}
Remarks
Project Server Permissions
| ManagePrioritizations | Allows a user to create or edit prioritizations for project portfolio analyses. Global permission. |