Esempio n. 1
0
        private static void RunSample(CalendarResourceService service)
        {
            try
            {
                const String TEST_RESOURCE_ID = "NYV-BUILDING-5-Batman";
                // Create a new CalendarResource
                AppsExtendedEntry entry = service.CreateCalendarResource(
                    TEST_RESOURCE_ID, "Batman", "6 Person VC", "CR");

                Console.WriteLine("Created: "
                    + entry.getPropertyValueByName(AppsCalendarResourceNameTable.resourceId));

                // Retrieve a CalendarResource
                entry = service.RetrieveCalendarResource(TEST_RESOURCE_ID);

                Console.WriteLine("Retrieved: "
                    + entry.getPropertyValueByName(AppsCalendarResourceNameTable.resourceEmail));

                Console.WriteLine("Dscription: "
                    + entry.getPropertyValueByName(AppsCalendarResourceNameTable.resourceDescription));

                Console.WriteLine("Resource Id: "
                    + entry.getPropertyValueByName(AppsCalendarResourceNameTable.resourceId));

                Console.WriteLine("Common name: "
                    + entry.getPropertyValueByName(AppsCalendarResourceNameTable.resourceCommonName));

                //Retrieve all resources
                Console.WriteLine("Retrieving all calendar resources (this may take some time) ..... ");
                AppsExtendedFeed feed = service.RetrieveAllCalendarResources();
                Console.WriteLine("Retrieved Entries Count: " + feed.Entries.Count);

                foreach (AppsExtendedEntry resourceEntry in feed.Entries)
                {
                    Console.WriteLine("Resource Emails: "
                        + entry.getPropertyValueByName(AppsCalendarResourceNameTable.resourceEmail));
                }

                //Delete a resource
                service.DeleteCalendarResource(TEST_RESOURCE_ID);
                Console.WriteLine("Deleted: " + TEST_RESOURCE_ID);
                Console.Read();

            }
            catch (AppsException a)
            {
                Console.WriteLine("A Google Apps error occurred.");
                Console.WriteLine();
                Console.WriteLine("Error code: {0}", a.ErrorCode);
                Console.WriteLine("Invalid input: {0}", a.InvalidInput);
                Console.WriteLine("Reason: {0}", a.Reason);
            }
        }