/// <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 CreativeRemoteService instance.
      CreativeRemoteService service = (CreativeRemoteService) user.GetService(
          DfaService.v1_19.CreativeRemoteService);

      long advertiserId = long.Parse(_T("INSERT_ADVERTISER_ID_HERE"));
      String creativeName = _T("INSERT_CREATIVE_NAME_HERE");
      String mobileAssetFileName = _T("INSERT_MOBILE_ASSET_FILE_NAME_HERE");
      long typeId = long.Parse(_T("INSERT_TYPE_ID_HERE"));

      // Set mobile display creative structure.
      MobileDisplayCreative mobileDisplayCreative = new MobileDisplayCreative();
      mobileDisplayCreative.advertiserId = advertiserId;
      mobileDisplayCreative.name = creativeName;
      mobileDisplayCreative.typeId = typeId;
      mobileDisplayCreative.archived = false;

      // Set mobile creative asset.
      HTMLCreativeAsset htmlCreativeAsset = new MobileDisplayCreativeAsset();
      htmlCreativeAsset.assetFilename = mobileAssetFileName;
      mobileDisplayCreative.creativeAssets = new HTMLCreativeAsset[] {htmlCreativeAsset};

      try {
        // Create mobile display creative.
        CreativeSaveResult creativeSaveResult = service.saveCreative(mobileDisplayCreative, 0);

        // Display new creative id.
        Console.WriteLine("Mobile display creative with id \"{0}\" was created.",
            creativeSaveResult.id);
      } catch (Exception ex) {
        Console.WriteLine("Failed to create display creative. Exception says \"{0}\"",
            ex.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 CreativeRemoteService instance.
      CreativeRemoteService service = (CreativeRemoteService) user.GetService(
          DfaService.v1_20.CreativeRemoteService);

      long advertiserId = long.Parse(_T("INSERT_ADVERTISER_ID_HERE"));
      string assetName = _T("INSERT_SWF_ASSET_NAME_HERE");
      string pathToFile = _T("INSERT_PATH_TO_SWF_FILE_HERE");

      // Set HTML asset Structure.
      CreativeAsset swfAsset = new CreativeAsset();
      // Set it to true if this asset is being used for HTML creative.
      swfAsset.forHTMLCreatives = true;
      swfAsset.advertiserId = advertiserId;
      swfAsset.content = MediaUtilities.GetAssetDataFromUrl(new Uri(pathToFile));
      swfAsset.name = assetName;

      try {
        //Create asset.
        CreativeAssetSaveResult result = service.saveCreativeAsset(swfAsset);

        // Display asset file name.
        Console.WriteLine("Asset was saved with file name of \"{0}\".", result.savedFilename);
      } catch (Exception ex) {
        Console.WriteLine("Failed to create html asset. Exception says \"{0}\"",
            ex.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 AdvertiserRemoteService instance.
              AdvertiserRemoteService service = (AdvertiserRemoteService) user.GetService(
              DfaService.v1_19.AdvertiserRemoteService);

              long networkId = long.Parse(_T("INSERT_NETWORK_ID_HERE"));
              string advertiserName = _T("INSERT_ADVERTISER_NAME_HERE");

              // Create advertiser structure.
              Advertiser advertiser = new Advertiser();
              advertiser.name = advertiserName;
              advertiser.networkId = networkId;
              advertiser.id = 0;
              advertiser.advertiserGroupId = 0;
              advertiser.approved = true;

              try {
            // Create advertiser.
            AdvertiserSaveResult result = service.saveAdvertiser(advertiser);
            if (result != null) {
              // Display advertiser id.
              Console.WriteLine("Advertiser with id \"{0}\" was created.", result.id);
            } else {
              Console.WriteLine("Could not create advertiser for the specified network id.");
            }
              } catch (Exception e) {
            Console.WriteLine("Failed to create advertiser. 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 AdvertiserGroupRemoteService instance.
      AdvertiserGroupRemoteService service = (AdvertiserGroupRemoteService) user.GetService(
          DfaService.v1_19.AdvertiserGroupRemoteService);

      string advertiserGroupName = _T("INSERT_ADVERTISER_GROUP_NAME_HERE");

      // Create advertiser group structure.
      AdvertiserGroup advertiserGroup = new AdvertiserGroup();
      advertiserGroup.id = 0;
      advertiserGroup.name = advertiserGroupName;

      try {
        // Create advertiser group.
        AdvertiserGroupSaveResult advertiserGroupSaveResult =
            service.saveAdvertiserGroup(advertiserGroup);

        // Display advertiser group id.
        Console.WriteLine("Advertiser Group with id \"{0}\" was created.",
            advertiserGroupSaveResult.id);

      } catch (Exception ex) {
        Console.WriteLine("Failed to create advertiser group. Exception says \"{0}\"",
            ex.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 CreativeRemoteService instance.
      ContentCategoryRemoteService service = (ContentCategoryRemoteService) user.GetService(
          DfaService.v1_19.ContentCategoryRemoteService);

      String searchString = _T("INSERT_SEARCH_STRING_CRITERIA_HERE");

      // Create content category search criteria structure.
      ContentCategorySearchCriteria searchCriteria = new ContentCategorySearchCriteria();
      searchCriteria.pageSize = 10;
      searchCriteria.searchString = searchString;

      try {
        // Get content category record set.
        ContentCategoryRecordSet contentCategoryRecordSet =
            service.getContentCategories(searchCriteria);

        // Display content category names, ids and descriptions.
        if (contentCategoryRecordSet != null && contentCategoryRecordSet.records != null) {
          foreach (ContentCategory contentCategory in contentCategoryRecordSet.records) {
            Console.WriteLine("Content category with name \"{0}\" and id \"{1}\" was found.",
                contentCategory.name, contentCategory.id);
          }
        } else {
          Console.WriteLine("No content categories found for your search criteria.");
        }
      } catch (Exception ex) {
        Console.WriteLine("Failed to get content categories. Exception says \"{0}\"",
            ex.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 SpotlightRemoteService instance.
      SpotlightRemoteService service = (SpotlightRemoteService) user.GetService(
          DfaService.v1_20.SpotlightRemoteService);

      long activityGroupId = long.Parse(_T("INSERT_ACTIVITY_GROUP_ID_HERE"));
      long activityTypeId = long.Parse(_T("INSERT_ACTIVITY_TYPE_ID_HERE"));
      long tagMethodTypeId = long.Parse(_T("INSERT_TAG_METHOD_TYPE_ID_HERE"));
      long countryId = long.Parse(_T("INSERT_COUNTRY_ID_HERE"));
      string url = _T("INSERT_EXPECTED_URL_HERE");
      string activityName = _T("INSERT_ACTIVITY_NAME_HERE");

      // Set spotlight activity structure.
      SpotlightActivity spotActivity = new SpotlightActivity();
      spotActivity.id = 0;
      spotActivity.activityGroupId = activityGroupId;
      spotActivity.activityTypeId = activityTypeId;
      spotActivity.tagMethodTypeId = tagMethodTypeId;
      spotActivity.name = activityName;
      spotActivity.expectedUrl = url;
      spotActivity.countryId = countryId;

      try {
        // Create the spotlight tag activity.
        SpotlightActivitySaveResult result =  service.saveSpotlightActivity(spotActivity);

        // Display new spotlight activity id.
        if (result != null) {
          Console.WriteLine("Spotlight activity with id \"{0}\" was created.", result.id);
        }
      } catch (Exception ex) {
        Console.WriteLine("Failed to create spotlight activity. Exception says \"{0}\"",
            ex.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 CreativeRemoteService instance.
              CreativeRemoteService service = (CreativeRemoteService) user.GetService(
              DfaService.v1_19.CreativeRemoteService);

              long creativeId = long.Parse(_T("INSERT_CREATIVE_ID"));
              long placementId = long.Parse(_T("INSERT_PLACEMENT_ID"));

              // Create creative placement assignment structure.
              CreativePlacementAssignment creativePlacementAssignment =
              new CreativePlacementAssignment();
              creativePlacementAssignment.creativeId = creativeId;
              creativePlacementAssignment.placementId = placementId;
              creativePlacementAssignment.placementIds = new long[] {placementId};

              try {
            // Assign creatives to placements.
            CreativePlacementAssignmentResult[] results =
            service.assignCreativesToPlacements(
                new CreativePlacementAssignment[] {creativePlacementAssignment});
            // Display new ads that resulted from the assignment.
            foreach (CreativePlacementAssignmentResult result in results) {
              Console.WriteLine("Ad with name \"{0}\" and id \"{1}\" was created.", result.adName,
              result.adId);
            }
              } catch (Exception e) {
            Console.WriteLine("Failed to create ad. 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 PlacementRemoteService instance.
              PlacementRemoteService service = (PlacementRemoteService) user.GetService(
              DfaService.v1_19.PlacementRemoteService);

              String searchString = _T("INSERT_SEARCH_STRING_HERE");

              // Set placement search criteria.
              PlacementSearchCriteria searchCriteria = new PlacementSearchCriteria();
              searchCriteria.pageSize = 10;
              searchCriteria.searchString = searchString;

              try {
            // Get placements.
            PlacementRecordSet placements = service.getPlacementsByCriteria(searchCriteria);

            // Display placment names and ids.
            if (placements.records != null) {
              foreach (Placement result in placements.records) {
            Console.WriteLine("Placment with name \"{0}\" and id \"{1}\" was found.",
                result.name, result.id);
              }
            } else {
              Console.WriteLine("No placements found for your criteria");
            }
              } catch (Exception e) {
            Console.WriteLine("Failed to retrieve placements. 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 CampaignRemoteService instance.
      CampaignRemoteService service = (CampaignRemoteService) user.GetService(
          DfaService.v1_19.CampaignRemoteService);

      String searchString = _T("INSERT_SEARCH_STRING_CRITERIA_HERE");

      // Create campaign search criteria structure.
      CampaignSearchCriteria searchCriteria = new CampaignSearchCriteria();
      searchCriteria.pageSize = 10;
      searchCriteria.searchString = searchString;

      try {
        // Get the campaigns.
        CampaignRecordSet recordSet = service.getCampaignsByCriteria(searchCriteria);

        // Display campaign names and ids.
        if (recordSet.records != null) {
          foreach (Campaign result in recordSet.records) {
            Console.WriteLine("Campaign with name \"{0}\" and id \"{1}\" was found.",
                result.name, result.id);
          }
        } else {
          Console.WriteLine("No campaigns found for your search criteria.");
        }
      } catch (Exception ex) {
        Console.WriteLine("Failed to retrieve campaigns. Exception says \"{0}\"", ex.Message);
      }
    }
Esempio n. 10
0
    /// <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 ReportRemoteService instance.
      ReportRemoteService service = (ReportRemoteService) user.GetService(
          DfaService.v1_19.ReportRemoteService);

      long queryId = long.Parse(_T("INSERT_QUERY_ID_HERE"));

      // Create report search criteria object.
      ReportSearchCriteria reportSearchCriteria = new ReportSearchCriteria();
      reportSearchCriteria.queryId = queryId;

      try {
        // Get report information.
        ReportInfoRecordSet reportInfoRecordSet =
            service.getReportsByCriteria(reportSearchCriteria);

        // Display information on reports.
        if (reportInfoRecordSet.records != null && reportInfoRecordSet.records.Length > 0) {
          foreach (ReportInfo report in reportInfoRecordSet.records) {
            Console.WriteLine("Report with ID '{0}', status of '{1}' and URL of '{2}' was found.",
                report.reportId, report.status, report.url);
          }
        } else {
          Console.WriteLine("No reports found for your query ID.");
        }
      } catch (Exception ex) {
        Console.WriteLine("Failed to retrieve all reports. Exception says \"{0}\"", ex.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 SpotlightRemoteService instance.
              SpotlightRemoteService service = (SpotlightRemoteService) user.GetService(
              DfaService.v1_20.SpotlightRemoteService);

              // Set search criteria.
              CountrySearchCriteria countrySearchCriteria = new CountrySearchCriteria();
              countrySearchCriteria.secure = false;

              try {
            // Get countries.
            Country[] countries = service.getCountriesByCriteria(countrySearchCriteria);

            // Display country names, codes and secure server support information.
            if (countries != null) {
              foreach (Country result in countries) {
            Console.WriteLine("Country name \"{0}\", country code \"{1}\", supports a secure " +
                "server? \"{2}\".", result.name, result.id, result.secure);
              }
            }
              } catch (Exception e) {
            Console.WriteLine("Failed to retrieve countries. 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 SpotlightRemoteService instance.
      SpotlightRemoteService service = (SpotlightRemoteService) user.GetService(
          DfaService.v1_20.SpotlightRemoteService);

      long advertiserId = long.Parse(_T("INSERT_ADVERTISER_ID_HERE"));

      // Set activity group search criteria structure and
      // use advertiser id as search criteria.
      SpotlightActivityGroupSearchCriteria activityGroupSearchCriteria =
          new SpotlightActivityGroupSearchCriteria();
      activityGroupSearchCriteria.advertiserId = advertiserId;

      try {
        // Get activity group.
        SpotlightActivityGroupRecordSet recordSet =
            service.getSpotlightActivityGroups(activityGroupSearchCriteria);

        // Display activity group names and ids.
        if (recordSet.records != null) {
          foreach (SpotlightActivityGroup result in recordSet.records) {
           Console.WriteLine("Activity group with name \"{0}\" and id \"{1}\" was found.",
              result.name, result.id);
          }
        } else {
          Console.WriteLine("No activity groups found for your criteria.");
        }
      } catch (Exception ex) {
        Console.WriteLine("Failed to retrieve activity groups. Exception says \"{0}\"",
            ex.Message);
      }
    }
Esempio n. 13
0
    /// <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 SiteRemoteService instance.
      SiteRemoteService service = (SiteRemoteService) user.GetService(
          DfaService.v1_19.SiteRemoteService);

      String searchString = _T("INSERT_SEARCH_STRING_CRITERIA_HERE");

      // Create DFA site search criteria structure.
      DfaSiteSearchCriteria searchCriteria = new DfaSiteSearchCriteria();
      searchCriteria.pageSize = 10;
      searchCriteria.searchString = searchString;

      try {
        // Get the sites.

        DfaSiteRecordSet dfaSiteRecordSet = service.getDfaSites(searchCriteria);

        // Display DFA site names and ids.
        if (dfaSiteRecordSet != null && dfaSiteRecordSet.records != null) {
          foreach (DfaSite dfaSite in dfaSiteRecordSet.records) {
            Console.WriteLine("DFA site with name \"{0}\" and id \"{1}\" was found.",
                dfaSite.name, dfaSite.id);
          }
        } else {
          Console.WriteLine("No DFA sites found for your search criteria.");
        }

      } catch (Exception ex) {
        Console.WriteLine("Failed to retrieve DFA sites. Exception says \"{0}\"",
            ex.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_19.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 e) {
            Console.WriteLine("Failed to retrieve placement strategies. 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 CreativeFieldRemoteService instance.
      CreativeFieldRemoteService service = (CreativeFieldRemoteService) user.GetService(
          DfaService.v1_19.CreativeFieldRemoteService);

      String searchString = _T("INSERT_SEARCH_STRING_CRITERIA_HERE");

      // Set up creative field search criteria structure.
      CreativeFieldSearchCriteria creativeFieldSearchCriteria = new CreativeFieldSearchCriteria();
      creativeFieldSearchCriteria.pageSize = 10;
      creativeFieldSearchCriteria.searchString = searchString;


      try {
        // Get creative fields for the selected criteria.
        CreativeFieldRecordSet creativeFields =
            service.getCreativeFields(creativeFieldSearchCriteria);

        // Display creative field names, ids, advertiser ids, and number of values.
        if (creativeFields != null && creativeFields.records != null) {
          foreach (CreativeField creativeField in creativeFields.records) {
            Console.WriteLine("Creative field with name \"{0}\", id \"{1}\", Advertiser id " +
                "\"{2}\", and containing \"{3}\" values was found.", creativeField.name,
                creativeField.id, creativeField.advertiserId, creativeField.totalNumberOfValues);
          }
        } else {
          Console.WriteLine("No creative fields found for your search criteria");
        }
      } catch (Exception ex) {
        Console.WriteLine("Failed to retrieve creative fields. Exception says \"{0}\"",
            ex.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 SubnetworkRemoteService instance.
      SubnetworkRemoteService service = (SubnetworkRemoteService) user.GetService(
          DfaService.v1_19.SubnetworkRemoteService);

      long networkId = long.Parse(_T("INSERT_NETWORK_ID_HERE"));
      String subnetworkName = _T("INSERT_SUBNETWORK_NAME_HERE");
      long permission1 = long.Parse(_T("INSERT_FIRST_PERMISSION_ID_HERE"));
      long permission2 = long.Parse(_T("INSERT_SECOND_PERMISSION_ID_HERE"));

      // Create subnetwork structure.
      Subnetwork subnetwork = new Subnetwork();
      subnetwork.id = 0;
      subnetwork.name = subnetworkName;
      subnetwork.networkId = networkId;

      // Create an array of all permissions assigned to this subnetwork and add
      // it to the subnetwork structure. To get list of available permissions,
      // run GetAvailablePermissions.cs.
      subnetwork.availablePermissions = new long[] {permission1, permission2};

      try {
        // Create subnetwork.
        SubnetworkSaveResult subnetworkSaveResult = service.saveSubnetwork(subnetwork);

        // Display subnetwork id.
        Console.WriteLine("Subnetwork with id \"{0}\" was created.", subnetworkSaveResult.id);
      } catch (Exception ex) {
        Console.WriteLine("Failed to create subnetwork. Exception says \"{0}\"", ex.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 AdvertiserGroupRemoteService instance.
      AdvertiserGroupRemoteService service = (AdvertiserGroupRemoteService) user.GetService(
          DfaService.v1_20.AdvertiserGroupRemoteService);

      String searchString = _T("INSERT_SEARCH_STRING_CRITERIA_HERE");

      // Create advertiser group search criteria structure.
      AdvertiserGroupSearchCriteria advGroupSearchCriteria = new AdvertiserGroupSearchCriteria();
      advGroupSearchCriteria.pageSize = 10;
      advGroupSearchCriteria.searchString = searchString;

      try {
        // Get advertiser group record set.
        AdvertiserGroupRecordSet advertiserGroupRecordSet =
          service.getAdvertiserGroups(advGroupSearchCriteria);

        // Display advertiser group names, ids and advertiser count.
        if (advertiserGroupRecordSet != null && advertiserGroupRecordSet.records != null) {
          foreach (AdvertiserGroup advertiserGroup in advertiserGroupRecordSet.records) {
            Console.WriteLine("Advertiser Group with name \"{0}\", id \"{1}\", containing \"{2}\"" +
                " advertisers was found.", advertiserGroup.name, advertiserGroup.id,
                advertiserGroup.advertiserCount);
          }
        } else {
          Console.WriteLine("No advertiser groups found for your search criteria.");
        }
      } catch (Exception ex) {
        Console.WriteLine("Failed to retrieve advertiser groups. Exception says \"{0}\"",
            ex.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 CreativeGroupRemoteService instance.
              CreativeGroupRemoteService service = (CreativeGroupRemoteService) user.GetService(
              DfaService.v1_20.CreativeGroupRemoteService);

              long advertiserId = long.Parse(_T("INSERT_ADVERTISER_ID_HERE"));
              int groupNumber = int.Parse(_T("INSERT_GROUP_NUMBER_HERE"));
              string creativeGroupName = _T("INSERT_CREATIVE_GROUP_NAME_HERE");

              // Create creative group structure.
              CreativeGroup creativeGroup = new CreativeGroup();
              creativeGroup.id = -1;
              creativeGroup.name = creativeGroupName;
              creativeGroup.groupNumber = groupNumber;
              creativeGroup.advertiserId = advertiserId;

              try {
            // Create creative group.
            CreativeGroupSaveResult creativeGroupSaveResult = service.saveCreativeGroup(creativeGroup);

            // Display new creative group id.
            Console.WriteLine("Creative group with id \"{0}\" was created.",
            creativeGroupSaveResult.id);
              } catch (Exception e) {
            Console.WriteLine("Failed to create creative group. 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 AdvertiserRemoteService instance.
      AdvertiserRemoteService service = (AdvertiserRemoteService) user.GetService(
          DfaService.v1_19.AdvertiserRemoteService);

      String searchString = _T("INSERT_SEARCH_STRING_CRITERIA_HERE");

      // Create advertiser search criteria structure.
      AdvertiserSearchCriteria advSearchCriteria = new AdvertiserSearchCriteria();
      advSearchCriteria.pageSize = 10;
      advSearchCriteria.searchString = searchString;

      try {
        // Get advertiser record set.
        AdvertiserRecordSet recordSet = service.getAdvertisers(advSearchCriteria);

        // Display advertiser names, ids and spotlight configuration ids.
        if (recordSet.records != null) {
          foreach (Advertiser result in recordSet.records) {
            Console.WriteLine("Advertiser with name \"{0}\", id \"{1}\", and spotlight " +
                "configuration id \"{2}\" was found.", result.name, result.id, result.spotId);
          }
        } else {
          Console.WriteLine("No advertisers found for your criteria.");
        }
      } catch (Exception ex) {
        Console.WriteLine("Failed to retrieve advertisers. Exception says \"{0}\"", ex.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 SubnetworkRemoteService instance.
      SubnetworkRemoteService service = (SubnetworkRemoteService) user.GetService(
          DfaService.v1_19.SubnetworkRemoteService);

      String searchString = _T("INSERT_SEARCH_STRING_CRITERIA_HERE");

      // Set subnetwork search criteria.
      SubnetworkSearchCriteria searchCriteria = new SubnetworkSearchCriteria();
      searchCriteria.pageSize = 10;
      searchCriteria.searchString = searchString;

      try {
        // Get subnetworks.
        SubnetworkRecordSet subnetworks = service.getSubnetworks(searchCriteria);

        // Display subnetwork names, ids, and subnetwork ids.
        if (subnetworks != null && subnetworks.records != null) {
          foreach (Subnetwork subNetwork in subnetworks.records) {
            Console.WriteLine("Subnetwork with name \"{0}\", id \"{1}\", and Subnetwork id " +
                "\"{2}\" was found.", subNetwork.name, subNetwork.id, subNetwork.networkId);
          }
        } else {
          Console.WriteLine("No subnetworks found for your criteria.");
        }
      } catch (Exception ex) {
        Console.WriteLine("Failed to retrieve subnetworks. Exception says \"{0}\"", ex.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 AdRemoteService instance.
              AdRemoteService service = (AdRemoteService) user.GetService(
              DfaService.v1_20.AdRemoteService);

              long campaignId = long.Parse(_T("INSERT_CAMPAIGN_ID_HERE"));
              long sizeId = long.Parse(_T("INSERT_SIZE_ID_HERE"));
              long creativeId = long.Parse(_T("INSERT_CREATIVE_ID_HERE"));
              long placementId = long.Parse(_T("INSERT_PLACEMENT_ID_HERE"));
              String adName = _T("INSERT_AD_NAME_HERE");
              long typeId = long.Parse(_T("INSERT_AD_TYPEID_HERE"));

              // Create rotation group structure.
              RotationGroup rotationGroup = new RotationGroup();
              rotationGroup.id = 0;
              rotationGroup.name = adName;
              rotationGroup.active = true;
              rotationGroup.archived = false;
              rotationGroup.campaignId = campaignId;
              rotationGroup.sizeId = sizeId;
              rotationGroup.typeId = typeId;
              rotationGroup.priority = 12;
              rotationGroup.ratio = 1;

              // Set ad start and end dates.
              rotationGroup.startTime = DateTime.Today.AddDays(1);
              rotationGroup.endTime = DateTime.Today.AddMonths(1);

              // Add creatives to the ad.
              CreativeAssignment creativeAssignment = new CreativeAssignment();
              creativeAssignment.active = true;
              creativeAssignment.creativeId = creativeId;

              // Create click through url.
              ClickThroughUrl clickThroughUrl = new ClickThroughUrl();
              clickThroughUrl.defaultLandingPageUsed = true;
              clickThroughUrl.landingPageId = 0;
              creativeAssignment.clickThroughUrl = clickThroughUrl;

              // Create creative assigments.
              rotationGroup.creativeAssignments = new CreativeAssignment[] {creativeAssignment};
              rotationGroup.rotationType = 1;

              // Assign ad to placement.
              PlacementAssignment placementAssignment = new PlacementAssignment();
              placementAssignment.active = true;
              placementAssignment.placementId = placementId;
              rotationGroup.placementAssignments = new PlacementAssignment[] {placementAssignment};

              try {
            // Create rotation group.
            AdSaveResult result = service.saveAd(rotationGroup);

            // Display new ad id.
            Console.WriteLine("Ad with id \"{0}\" was created.", result.id);
              } catch (Exception e) {
            Console.WriteLine("Failed to create rotation group. 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 CreativeFieldRemoteService instance.
      CreativeFieldRemoteService service = (CreativeFieldRemoteService) user.GetService(
          DfaService.v1_19.CreativeFieldRemoteService);

      String searchString = _T("INSERT_SEARCH_STRING_CRITERIA_HERE");

      // Set up creative field value search criteria structure.
      CreativeFieldValueSearchCriteria creativeValueSearchCriteria =
          new CreativeFieldValueSearchCriteria();
      creativeValueSearchCriteria.pageSize = 10;
      creativeValueSearchCriteria.searchString = searchString;

      try {
        // Get creative field values for the selected criteria.
        CreativeFieldValueRecordSet creativeFieldValues =
            service.getCreativeFieldValues(creativeValueSearchCriteria);

        // Display creative field value names and ids.
        if (creativeFieldValues != null && creativeFieldValues.records != null) {
          foreach (CreativeFieldValue creativeFieldValue in creativeFieldValues.records) {
            Console.WriteLine("Creative field value with name \"{0}\" and id \"{1}\" was found.",
                creativeFieldValue.name, creativeFieldValue.id);
          }
        } else {
          Console.WriteLine("No creative field values found for your criteria");
        }
      } catch (Exception ex) {
        Console.WriteLine("Failed to retrieve creative field values. Exception says \"{0}\"",
            ex.Message);
      }
    }
Esempio n. 23
0
        /// <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 SizeRemoteService instance.
              SizeRemoteService service = (SizeRemoteService) user.GetService(
              DfaService.v1_20.SizeRemoteService);

              int width = int.Parse(_T("INSERT_WIDTH_HERE"));
              int height = int.Parse(_T("INSERT_HEIGHT_HERE"));

              SizeSearchCriteria criteria = new SizeSearchCriteria();
              criteria.width = width;
              criteria.height = height;

              try {
            // Get size.
            SizeRecordSet sizeRecords = service.getSizes(criteria);

            if (sizeRecords.records != null) {
              foreach (Size size in sizeRecords.records) {
            // Display size id.
            Console.WriteLine("Size id for \"{0}\" width and \"{1}\" height is \"{2}\".",
                size.width, size.height, size.id);
              }
            }
              } catch (Exception e) {
            Console.WriteLine("Failed to retrieve size. 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 SpotlightRemoteService instance.
              SpotlightRemoteService service = (SpotlightRemoteService) user.GetService(
              DfaService.v1_19.SpotlightRemoteService);

              long spotlightConfigurationId = long.Parse(_T("INSERT_SPOTLIGHT_CONFIGURATION_ID_HERE"));
              int activityType = int.Parse(_T("INSERT_ACTIVITY_TYPE_HERE"));
              string groupName = _T("INSERT_GROUP_NAME_HERE");

              // Set spotlight activity group structure.
              SpotlightActivityGroup spotlightActivityGroup = new SpotlightActivityGroup();
              spotlightActivityGroup.id = 0;
              spotlightActivityGroup.spotlightConfigurationId = spotlightConfigurationId;
              spotlightActivityGroup.groupType = activityType;
              spotlightActivityGroup.name = groupName;

              try {
            // Create the activity group.
            SpotlightActivityGroupSaveResult result = service.saveSpotlightActivityGroup(
            spotlightActivityGroup);

            // Display activity group id.
            if (result != null) {
              Console.WriteLine("Activity group with id \"{0}\" was created.", result.id);
            }
              } catch (Exception e) {
            Console.WriteLine("Failed to create spotlight activity group. 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 ContentCategoryRemoteService instance.
              ContentCategoryRemoteService service = (ContentCategoryRemoteService) user.GetService(
              DfaService.v1_19.ContentCategoryRemoteService);

              string contentCategoryName = _T("INSERT_CONTENT_CATEGORY_NAME_HERE");

              // Create content category structure.
              ContentCategory contentCategory = new ContentCategory();
              contentCategory.id = 0;
              contentCategory.name = contentCategoryName;

              try {
            // Create content category.
            ContentCategorySaveResult contentCategorySaveResult =
            service.saveContentCategory(contentCategory);

            // Display content category id.
            Console.WriteLine("Content category with id \"{0}\" was created.",
            contentCategorySaveResult.id);
              } catch (Exception e) {
            Console.WriteLine("Failed to add content category. 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 CreativeGroupRemoteService instance.
              CreativeGroupRemoteService service = (CreativeGroupRemoteService) user.GetService(
              DfaService.v1_19.CreativeGroupRemoteService);

              long advertiserId = long.Parse(_T("INSERT_ADVERTISER_ID_HERE"));

              // Set up creative group search criteria structure.
              CreativeGroupSearchCriteria creativeGroupSearchCriteria = new CreativeGroupSearchCriteria();
              creativeGroupSearchCriteria.advertiserIds = new long[] {advertiserId};

              try {
            // Get creatives groups for the selected criteria.
            CreativeGroupRecordSet creativeGroups =
            service.getCreativeGroups(creativeGroupSearchCriteria);

            // Display creative group names, ids, advertiser ids, and group numbers.
            if (creativeGroups != null && creativeGroups.records != null) {
              foreach (CreativeGroup creativeGroup in creativeGroups.records) {
            Console.WriteLine("Creative group with name \"{0}\" , id \"{1}\", advertiser id " +
                "\"{2}\" and group number \"{3}\" was found.", creativeGroup.name,
                creativeGroup.id, creativeGroup.advertiserId, creativeGroup.groupNumber);
              }
            } else {
              Console.WriteLine("No creative groups found for your search criteria");
            }
              } catch (Exception e) {
            Console.WriteLine("Failed to retrieve creative groups. Exception says \"{0}\"",
            e.Message);
              }
        }
Esempio n. 27
0
        /// <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 UserRemoteService instance.
              UserRemoteService service = (UserRemoteService) user.GetService(
              DfaService.v1_20.UserRemoteService);

              String searchString = _T("INSERT_SEARCH_STRING_CRITERIA_HERE");

              // Set user search criteria.
              UserSearchCriteria searchCriteria = new UserSearchCriteria();
              searchCriteria.pageSize = 10;
              searchCriteria.searchString = searchString;

              try {
            // Get users that match the search criteria.
            UserRecordSet users = service.getUsersByCriteria(searchCriteria);

            // Display user names, ids, network ids, subnetwork ids, and group ids.
            if (users != null && users.records != null) {
              foreach (User userResult in users.records) {
            Console.WriteLine("User with name \"{0}\", id \"{1}\", network id \"{2}\", subnetwork" +
                " id \"{3}\", and user group id \"{4}\" was found.", userResult.name, userResult.id,
                userResult.networkId, userResult.subnetworkId, userResult.userGroupId);
              }
            } else {
              Console.WriteLine("No users found for your search criteria.");
            }
              } catch (Exception e) {
            Console.WriteLine("Failed to retrieve users. 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 CreativeFieldRemoteService instance.
              CreativeFieldRemoteService service = (CreativeFieldRemoteService) user.GetService(
              DfaService.v1_19.CreativeFieldRemoteService);

              long advertiserId = long.Parse(_T("INSERT_ADVERTISER_ID_HERE"));
              string creativeFieldName = _T("INSERT_CREATIVE_FIELD_NAME_HERE");

              // Create creative field structure.
              CreativeField creativeField = new CreativeField();
              creativeField.id = -1;
              creativeField.name = creativeFieldName;
              creativeField.advertiserId = advertiserId;

              try {
            // Create creative field.
            CreativeFieldSaveResult creativeFieldSaveResult = service.saveCreativeField(creativeField);

            // Display creative field id.
            Console.WriteLine("Creative field with id \"{0}\" was created.",
            creativeFieldSaveResult.id);
              } catch (Exception e) {
            Console.WriteLine("Failed to add creative field. 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 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) {
      // Request the creative service from the service client factory.
      CreativeRemoteService creativeService = (CreativeRemoteService) user.GetService(
          DfaService.v1_19.CreativeRemoteService);

      string assetName = _T("INSERT_ASSET_NAME_HERE");
      string pathToFile = _T("INSERT_PATH_TO_FILE_HERE");
      long creativeId = long.Parse(_T("INSERT_IN_STREAM_VIDEO_CREATIVE_ID_HERE"));

      // Create the In-Stream video creative asset.
      CreativeAsset inStreamVideoAsset = new CreativeAsset();
      inStreamVideoAsset.name = assetName;
      inStreamVideoAsset.content = MediaUtilities.GetAssetDataFromUrl(
          new Uri(pathToFile).AbsolutePath);

      // Create an upload request to make this asset a media file for an existing
      // In-Stream creative.
      InStreamAssetUploadRequest inStreamAssetUploadRequest = new InStreamAssetUploadRequest();
      inStreamAssetUploadRequest.mediaFile = true;
      inStreamAssetUploadRequest.inStreamAsset = inStreamVideoAsset;
      inStreamAssetUploadRequest.creativeId = creativeId;

      try {
        // Save the media file.
        InStreamVideoCreative inStreamVideoCreative =
            creativeService.uploadInStreamAsset(inStreamAssetUploadRequest);

        // Display a success message.
        Console.WriteLine("Added a media file to In-Stream video creative with ID \"{0}\".",
            inStreamVideoCreative.id);
      } catch (Exception ex) {
        Console.WriteLine("Failed to add a media file to in-stream video creative. " +
            "Exception says \"{0}\"", ex.Message);
      }
    }