/// <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);
            }
        }
Пример #2
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 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);
            }
        }