Driver Prioritization sets Priority level for business strategy and project impacts.
Here below is the given code to create Driver Prioritization using PSI.
First I am exporting Driver Prioritization data from one environment and then importing data into another environment.
Exporting: Use export environment credentials
DriverWebSvc.DriverPrioritizationDataSet driverPrioritizationDataSet = new DriverWebSvc.DriverPrioritizationDataSet();
// Reads the list of prioritizations
DriverWebSvc.DriverPrioritizationDataSet prioritizationList = driverWebSvc.ReadPrioritizationList();
foreach (DriverWebSvc.DriverPrioritizationDataSet.PrioritizationRow prioritizationRow in prioritizationList.Prioritization.Rows)
{
DriverWebSvc.DriverPrioritizationDataSet driverPrioritizationDataSetTemp = driverWebSvc.ReadPrioritization(prioritizationRow.PRIORITIZATION_UID);
// Merging Prioritization data table
driverPrioritizationDataSet.Prioritization.Merge(driverPrioritizationDataSetTemp.Prioritization);
// Merging PrioritizationEntries data table
driverPrioritizationDataSet.PrioritizationEntries.Merge(driverPrioritizationDataSetTemp.PrioritizationEntries);
// Merging DriverRelations data table
driverPrioritizationDataSet.DriverRelations.Merge(driverPrioritizationDataSetTemp.DriverRelations);
}
Importing: Use import environment credentials
DriverWebSvc.DriverPrioritizationDataSet targetDriverPrioritizationDataSet = driverWebSvc.ReadPrioritizationList();
List<Guid> prioritizationUids = new List<Guid>();
foreach (DriverPrioritizationDataSet.PrioritizationRow prioritizationRow in targetDriverPrioritizationDataSet.Prioritization.Rows)
{
prioritizationUids.Add(prioritizationRow.PRIORITIZATION_UID);
}
if (prioritizationUids.Count > 0)
driverWebSvc.DeletePrioritizations(prioritizationUids.ToArray());
foreach (DriverPrioritizationDataSet.PrioritizationRow prioritizationRow in driverPrioritizationDataSet.Prioritization.Rows)
{
try
{
DriverWebSvc.DriverPrioritizationDataSet drvDS = new DriverWebSvc.DriverPrioritizationDataSet();
// Adding Prioritization row
drvDS.Prioritization.Rows.Add(prioritizationRow.ItemArray);
// Adding Prioritization Entries row
foreach (DriverPrioritizationDataSet.PrioritizationEntriesRow prioritizationEntriesRow in driverPrioritizationDataSet.PrioritizationEntries.Rows)
{
if (prioritizationEntriesRow.PRIORITIZATION_UID == prioritizationRow.PRIORITIZATION_UID)
{
drvDS.PrioritizationEntries.Rows.Add(prioritizationEntriesRow.ItemArray);
}
}
// Adding Driver Relations row
foreach (DriverPrioritizationDataSet.DriverRelationsRow driverRelationsRow in driverPrioritizationDataSet.DriverRelations.Rows)
{
if (driverRelationsRow.PRIORITIZATION_UID == prioritizationRow.PRIORITIZATION_UID)
{
drvDS.DriverRelations.Rows.Add(driverRelationsRow.ItemArray);
}
}
driverWebSvc.CreatePrioritization((DriverWebSvc.DriverPrioritizationDataSet)drvDS);
}
catch (SoapException sEx)
{
//log exception
}
catch (Exception ex)
{
//log exception
}
}
Hope this code will help you.Thanks
0 Comment(s)