/// <summary> /// Run the code example. /// </summary> /// <param name="user">The Dfa user object running the code example. /// </param> public override void Run(DfaUser user) { // Create PlacementStrategyRemoteService instance. PlacementStrategyRemoteService service = (PlacementStrategyRemoteService)user.GetService( DfaService.v1_19.PlacementStrategyRemoteService); String placementStrategyName = _T("INSERT_PLACEMENT_STRATEGY_NAME_HERE"); // Create placement strategy structure. PlacementStrategy placementStrategy = new PlacementStrategy(); placementStrategy.id = 0; placementStrategy.name = placementStrategyName; try { // Create placement strategy. PlacementStrategySaveResult placementStrategySaveResult = service.savePlacementStrategy(placementStrategy); if (placementStrategySaveResult != null) { // Display placement strategy id. Console.WriteLine("Placement Strategy with id \"{0}\" was created.", placementStrategySaveResult.id); } } catch (Exception e) { Console.WriteLine("Failed to create placement strategy. Exception says \"{0}\"", e.Message); } }
/// <summary> /// Run the code example. /// </summary> /// <param name="user">The Dfa user object running the code example. /// </param> public override void Run(DfaUser user) { // Create PlacementStrategyRemoteService instance. PlacementStrategyRemoteService service = (PlacementStrategyRemoteService)user.GetService( DfaService.v1_20.PlacementStrategyRemoteService); String searchString = _T("INSERT_SEARCH_STRING_CRITERIA_HERE"); // Create placement strategy search criteria structure. PlacementStrategySearchCriteria placementStrategySearchCriteria = new PlacementStrategySearchCriteria(); placementStrategySearchCriteria.pageSize = 10; placementStrategySearchCriteria.searchString = searchString; try { // Get placement strategy record set. PlacementStrategyRecordSet placementStrategyRecordSet = service.getPlacementStrategiesByCriteria(placementStrategySearchCriteria); // Display placement strategy names, ids and descriptions. if (placementStrategyRecordSet != null && placementStrategyRecordSet.records != null) { foreach (PlacementStrategy strategy in placementStrategyRecordSet.records) { Console.WriteLine("Placement Strategy with name \"{0}\" and id \"{1}\" was found.", strategy.name, strategy.id); } } else { Console.WriteLine("No placement strategies found for your criteria."); } } catch (Exception ex) { Console.WriteLine("Failed to retrieve placement strategies. Exception says \"{0}\"", ex.Message); } }