Beispiel #1
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_19.UserRemoteService);

            try {
                // Get user filter criteria types.
                UserFilterCriteriaType[] userFilterCriteriaTypes =
                    service.getAvailableUserFilterCriteriaTypes();

                // Display user filter criteria types.
                if (userFilterCriteriaTypes != null)
                {
                    foreach (UserFilterCriteriaType userFilterCriteriaType in userFilterCriteriaTypes)
                    {
                        Console.WriteLine("User Filter Criteria type with name \"{0}\" and id \"{1}\" " +
                                          "was found.", userFilterCriteriaType.name, userFilterCriteriaType.id);
                    }
                }
            } catch (Exception ex) {
                Console.WriteLine("Failed to retrieve user filter and criteria types. Exception " +
                                  "says \"{0}\"", ex.Message);
            }
        }
Beispiel #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 UserRemoteService instance.
            UserRemoteService service = (UserRemoteService)user.GetService(
                DfaService.v1_20.UserRemoteService);

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

            // Create and configure a user filter.
            UserFilter filterToAdd = new UserFilter();

            // The following field has been filled in to make a filter that allows a
            // user to access only the assigned objects. This value was determined
            // using GetUserFilterTypes.cs.
            filterToAdd.userFilterCriteriaId = 2;

            // Because this filter used the criteria type "Assigned" it is necessary
            // to specify what advertisers this user has access to. This next step
            // would be skipped for the criteria types "All" and "None".

            // Create an object filter to represent each object the user has access
            // to. Since this is an advertiser filter, an object filter represents an
            // advertiser. The total of object filter objects will need to match the
            // total of advertisers the user is assigned.
            ObjectFilter allowedObject = new ObjectFilter();

            // Insert the advertiser id of an advertiser assigned to this user.
            allowedObject.id = advertiserId;

            // Create any additional object filters that are needed, then add these
            // settings to the user filter
            filterToAdd.objectFilters = new ObjectFilter[] { allowedObject };

            try {
                // Retrieve the user who is to be modified.
                User userToModify = service.getUser(userId);

                // Add the filter to the user. The following method is specific to
                // advertiser filters. See the User class documentation for the names of
                // methods for other filters.
                userToModify.advertiserUserFilter = filterToAdd;

                // Save the changes made and display a success message.
                UserSaveResult userSaveResult = service.saveUser(userToModify);
                Console.WriteLine("User with id \"{0}\" was modified.", userSaveResult.id);
            } catch (Exception ex) {
                Console.WriteLine("Failed to add advertiser user filter. Exception says \"{0}\"",
                                  ex.Message);
            }
        }
Beispiel #3
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 ex) {
                Console.WriteLine("Failed to retrieve users. Exception says \"{0}\"", ex.Message);
            }
        }