Driver library is used to create business strategy associated with departments and project impacts.
Here below is the given code to create Driver Library using PSI.
First I am exporting Driver Library data from one environment and then importing data into another environment.
Exporting: Use export environment credentials
DriverWebSvc.DriverDataSet driverDataSet = new DriverWebSvc.DriverDataSet();
// Read the list of drivers.
DriverWebSvc.DriverDataSet driverList = driverWebSvc.ReadDriverList();
foreach (DriverWebSvc.DriverDataSet.DriverRow driverRow in driverList.Driver.Rows)
{
DriverWebSvc.DriverDataSet driverDataSetTemp = driverWebSvc.ReadDriver(driverRow.DRIVER_UID);
// Merging Driver data table
driverDataSet.Driver.Merge(driverDataSetTemp.Driver);
// Merging DriverImpactStatements data table
driverDataSet.DriverImpactStatements.Merge(driverDataSetTemp.DriverImpactStatements);
// Merging DriverDepartments data table
driverDataSet.DriverDepartments.Merge(driverDataSetTemp.DriverDepartments);
}
Importing: Use import environment credentials
DriverWebSvc.DriverDataSet targetDriverDataSet = driverWebSvc.ReadDriverList();
//Deleting existing driver library from environment
List<Guid> driverUids = new List<Guid>();
foreach (DriverDataSet.DriverRow driverRow in targetDriverDataSet.Driver.Rows)
{
driverUids.Add(driverRow.DRIVER_UID);
}
if (driverUids.Count > 0)
driverWebSvc.DeleteDrivers(driverUids.ToArray());
foreach (DriverDataSet.DriverRow driverRow in driverDataSet.Driver.Rows)
{
try
{
DriverWebSvc.DriverDataSet drvDS = new DriverWebSvc.DriverDataSet();
//Adding Driver row
drvDS.Driver.Rows.Add(driverRow.ItemArray);
// Adding Driver Impact Statements row
foreach (DriverDataSet.DriverImpactStatementsRow driverImpactStatementsRow in driverDataSet.DriverImpactStatements.Rows)
{
if (driverImpactStatementsRow.DRIVER_UID == driverRow.DRIVER_UID)
{
drvDS.DriverImpactStatements.Rows.Add(driverImpactStatementsRow.ItemArray);
}
}
// Adding Driver Impact Statements row
foreach (DriverDataSet.DriverDepartmentsRow driverDepartmentsRow in driverDataSet.DriverDepartments.Rows)
{
if (driverDepartmentsRow.DRIVER_UID == driverRow.DRIVER_UID)
{
drvDS.DriverImpactStatements.Rows.Add(driverDepartmentsRow.ItemArray);
}
}
driverWebSvc.CreateDriver((DriverWebSvc.DriverDataSet)drvDS);
successfulRecords++;
}
catch (SoapException sEx)
{
//log exception
}
catch (Exception ex)
{
//log exception
}
}
Hope this code will help you.Thanks
0 Comment(s)