Example #1
0
        /// <summary>
        /// Runs the methods above to demonstrate usage of the .NET
        /// client library.
        /// </summary>
        static void Main(string[] args)
        {
            if (args.Length != 3)
            {
                Console.WriteLine("Usage: unshare_profiles <consumerKey> <consumerSecret> <adminEmail>");
            }
            else
            {
                String consumerKey    = args[0];
                String consumerSecret = args[1];
                String adminEmail     = args[2];

                ProfilesManager manager = new ProfilesManager(consumerKey, consumerSecret, adminEmail);

                BatchResult result = manager.UnshareProfiles();

                Console.WriteLine("Success: " + result.Success + " - Error: " + result.Error);
                foreach (Contact entry in result.ErrorEntries)
                {
                    Console.WriteLine(" > Failed to update " + entry.Id +
                                      ": (" + entry.BatchData.Status.Code + ") "
                                      + entry.BatchData.Status.Reason);
                }
            }
        }
Example #2
0
        /// <summary>
        /// Unshare all profiles for the domain
        /// </summary>
        public BatchResult UnshareProfiles()
        {
            BatchResult result = new BatchResult()
            {
                ErrorEntries = new List <Contact>(),
            };
            int index = 0;

            if (this.profiles == null)
            {
                this.GetAllProfiles();
            }
            while (index < this.Profiles.Count)
            {
                List <Contact> requestFeed = new List <Contact>();

                for (int i = 0; i < this.BatchSize && index < this.Profiles.Count; ++i, ++index)
                {
                    Contact entry = this.Profiles[index];

                    entry.ContactEntry.Status = new Status(false);
                    entry.BatchData           = new GDataBatchEntryData(GDataBatchOperationType.update);
                    requestFeed.Add(entry);
                }

                Feed <Contact> responseFeed =
                    cr.Batch(requestFeed,
                             new Uri("https://www.google.com/m8/feeds/profiles/domain/" + this.domain + "/full/batch"),
                             GDataBatchOperationType.Default);

                // Check the status of each operation.
                foreach (Contact entry in responseFeed.Entries)
                {
                    if (entry.BatchData.Status.Code == 200)
                    {
                        ++result.Success;
                    }
                    else
                    {
                        ++result.Error;
                        result.ErrorEntries.Add(entry);
                    }
                }
            }
            return(result);
        }
Example #3
0
        /// <summary>
        /// Unshare all profiles for the domain
        /// </summary>
        public BatchResult UnshareProfiles() {
            BatchResult result = new BatchResult() {
                ErrorEntries = new List<Contact>(),
            };
            int index = 0;

            if (this.profiles == null) {
                this.GetAllProfiles();
            }
            while (index < this.Profiles.Count) {
                List<Contact> requestFeed = new List<Contact>();

                for (int i = 0; i < this.BatchSize && index < this.Profiles.Count; ++i, ++index) {
                    Contact entry = this.Profiles[index];

                    entry.ContactEntry.Status = new Status(false);
                    entry.BatchData = new GDataBatchEntryData(GDataBatchOperationType.update);
                    requestFeed.Add(entry);
                }

                Feed<Contact> responseFeed =
                    cr.Batch(requestFeed,
                             new Uri("https://www.google.com/m8/feeds/profiles/domain/" + this.domain + "/full/batch"),
                             GDataBatchOperationType.Default);

                // Check the status of each operation.
                foreach (Contact entry in responseFeed.Entries) {
                    if (entry.BatchData.Status.Code == 200) {
                        ++result.Success;
                    } else {
                        ++result.Error;
                        result.ErrorEntries.Add(entry);
                    }
                }
            }
            return result;
        }