/// <summary>
 /// overwritten Query method
 /// </summary>
 /// <param name="uri">The URI for the query</param>
 /// <returns>the retrieved AppsExtendedFeed</returns>
 public AppsExtendedFeed QueryGroups(Uri uri)
 {
     try
     {
         Stream           feedStream = Query(uri);
         AppsExtendedFeed feed       = new AppsExtendedFeed(uri, this);
         feed.Parse(feedStream, AlternativeFormat.Atom);
         feedStream.Close();
         if (true)
         {
             AtomLink next, prev = null;
             while ((next = feed.Links.FindService("next", null)) != null && next != prev)
             {
                 feedStream = Query(new Uri(next.HRef.ToString()));
                 feed.Parse(feedStream, AlternativeFormat.Atom);
                 feedStream.Close();
                 prev = next;
             }
         }
         return(feed);
     }
     catch (GDataRequestException e)
     {
         AppsException a = AppsException.ParseAppsException(e);
         throw (a == null ? e : a);
     }
 }
Ejemplo n.º 2
0
        protected void lbStep2_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrWhiteSpace(ddlDomains.SelectedValue))
            {
                try
                {
                    AppsService      service    = new AppsService(ddlDomains.SelectedValue, UserContext.Current.Organization.GoogleAdminAuthToken);
                    AppsExtendedFeed groupsFeed = service.Groups.RetrieveAllGroups();

                    DataTable dt = new DataTable();
                    dt.Columns.Add(Resources.GoogleIntegrationControl_NameColumn_HeaderText, typeof(string));
                    dt.Columns.Add(Resources.GoogleIntegrationControl_IdColumn_HeaderText, typeof(string));
                    dt.Columns.Add(Resources.GoogleIntegrationControl_DescriptionColumn_HeaderText, typeof(string));
                    dt.Columns.Add(Resources.GoogleIntegrationControl_MembersColumn_HeaderText, typeof(string));

                    for (int i = 0; i < groupsFeed.Entries.Count; i++)
                    {
                        GroupEntry    groupEntry = groupsFeed.Entries[i] as GroupEntry;
                        MemberFeed    memberFeed = service.Groups.RetrieveAllMembers(groupEntry.GroupId);
                        StringBuilder sb         = new StringBuilder();

                        for (int j = 0; j < memberFeed.Entries.Count; j++)
                        {
                            MemberEntry memberEntry = memberFeed.Entries[j] as MemberEntry;
                            if (string.Compare(memberEntry.MemberId, "*", true) == 0)
                            {
                                sb.AppendFormat(Resources.GoogleIntegrationControl_MembersColumn_AllUsersValue);
                            }
                            else
                            {
                                sb.AppendFormat("{0}<br>", memberEntry.MemberId);
                            }
                        }

                        dt.Rows.Add(groupEntry.GroupName, groupEntry.GroupId, groupEntry.Description, sb.ToString());
                    }

                    gvStep2Results.DataSource = dt;
                    gvStep2Results.DataBind();

                    mvStep2.SetActiveView(vwStep2Result);
                }
                catch (AppsException a)
                {
                    lblStep2Error.Text = string.Format(CultureInfo.CurrentCulture, Resources.GoogleIntegrationControl_GoogleAppsError_Text, a.ErrorCode, a.InvalidInput, a.Reason);
                    mvStep2.SetActiveView(vwStep2Error);
                }
                catch (Exception ex)
                {
                    ShowError(ex, lblStep2Error, mvStep2, vwStep2Error);
                }
            }
            else
            {
                lblStep2Error.Text = Resources.GoogleIntegrationControl_DomainMisingError_Text;
                mvStep2.SetActiveView(vwStep2Error);
            }
        }
        /// <summary>
        /// Retrieves a group by its groupId
        /// </summary>
        /// <param name="groupId">The groupId argument identifies the group</param>
        /// <returns>a <code>AppsExtendedEntry</code> containing the results of the
        /// query</returns>
        public AppsExtendedEntry RetrieveGroup(String groupId)
        {
            Uri getGroupUri = new Uri(AppsGroupsNameTable.AppsGoogleGroupsBaseFeedUri + "/"
                                      + domain + "/" + groupId);
            AppsExtendedFeed AppsExtendedFeed = QueryGroups(getGroupUri);

            if (AppsExtendedFeed.Entries.Count > 0)
            {
                return(AppsExtendedFeed.Entries[0] as AppsExtendedEntry);
            }
            return(null);
        }
        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);
            }
        }
        /// <summary>
        /// Retrieves the owner of the group
        /// </summary>
        /// <param name="email">email of the owner to retrieve</param>
        /// <param name="groupId">Groups's id</param>
        /// <returns>a <code>AppsExtendedEntry</code> containing the results of the
        /// query</returns>
        public AppsExtendedEntry RetrieveOwner(String email, String groupId)
        {
            Uri ownerUri = new Uri(AppsGroupsNameTable.AppsGoogleGroupsBaseFeedUri + "/"
                                   + domain + "/" + groupId + "/" + ownerUriSuffix + "/" + email);
            AppsExtendedFeed AppsExtendedFeed = QueryGroups(ownerUri);

            if (AppsExtendedFeed.Entries.Count == 0)
            {
                return(null);
            }
            else
            {
                return(AppsExtendedFeed.Entries[0] as AppsExtendedEntry);
            }
        }
Ejemplo n.º 6
0
        private static void GroupOperations(AppsService service)
        {
            // Create a new group.
            AppsExtendedEntry insertedEntry = service.Groups.CreateGroup(testGroup, testGroup, testGroup, null);

            Console.WriteLine("Created new group '{0}'", insertedEntry.getPropertyByName("groupId").Value);

            // Retrieve the newly-created group.
            AppsExtendedEntry entry = service.Groups.RetrieveGroup(testGroup);

            Console.WriteLine("Retrieved group '{0}'", entry.getPropertyByName("groupId").Value);

            // Add Member To Group
            AppsExtendedEntry newMemberEntry = service.Groups.AddMemberToGroup(testUserName, testGroup);

            Console.WriteLine("User '{0}' was added as member to group '{1}'",
                              newMemberEntry.getPropertyByName("memberId").Value, testGroup);

            // Add Owner to Group
            AppsExtendedEntry newOwnerEntry = service.Groups.AddOwnerToGroup(testUserName, testGroup);

            Console.WriteLine("User '{0}' was added as ownter to group '{1}'",
                              newOwnerEntry.getPropertyByName("email").Value, testGroup);

            // Check if a User is a Group Member
            Console.WriteLine("Is User '{0}' member of group '{1}'? '{2}'",
                              testUserName, testGroup, service.Groups.IsMember(testUserName, testGroup));

            // Check if a User is a Group Member
            Console.WriteLine("Is User '{0}' owner of group '{1}'? '{2}'",
                              testUserName, testGroup, service.Groups.IsOwner(testUserName, testGroup));

            // Remove Member from Group
            service.Groups.RemoveMemberFromGroup(testUserName, testGroup);
            Console.WriteLine("User '{0}' was removed as member to group '{1}'",
                              testUserName, testGroup);

            // Remove Owner from Group
            service.Groups.RemoveOwnerFromGroup(testUserName, testGroup);
            Console.WriteLine("User '{0}' was removed as ownter to group '{1}'",
                              testUserName, testGroup);

            // Retreive all groups
            AppsExtendedFeed groupsFeed = service.Groups.RetrieveAllGroups();

            Console.WriteLine("First Group from All groups: '{0}'",
                              (groupsFeed.Entries[0] as AppsExtendedEntry).getPropertyByName("groupId").Value);
        }
 /// <summary>
 /// Checks if a user or a group is owner of a group.
 /// </summary>
 /// <param name="email">owner's Email to check</param>
 /// <param name="groupId">Groups's id</param>
 /// <returns>a <code>Boolean</code></returns>
 public Boolean IsOwner(String email, String groupId)
 {
     try
     {
         Uri isOwnerUri = new Uri(AppsGroupsNameTable.AppsGoogleGroupsBaseFeedUri + "/"
                                  + domain + "/" + groupId + "/" + ownerUriSuffix + "/" + email);
         AppsExtendedFeed AppsExtendedFeed = QueryGroups(isOwnerUri);
         return(AppsExtendedFeed.Entries.Count > 0);
     }
     catch (AppsException appsException)
     {
         if (appsException.ErrorCode.Equals("1301"))
         {
             return(false);
         }
         else
         {
             throw appsException;
         }
     }
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="service"></param>
        private static void RunSample(OrganizationService service)
        {
            try
            {
                const String testOrgunit            = "TestOrgUnitForSample";
                const String testOrgunitDescription = "Test Organization";

                // Retrieve customer Id
                AppsExtendedEntry entry      = service.RetrieveCustomerId(service.DomainName);
                String            customerId =
                    entry.getPropertyValueByName(AppsOrganizationNameTable.CustomerId);
                Console.WriteLine("CustomerId: " + customerId);

                // Delete, if all already exists
                try
                {
                    service.DeleteOrganizationUnit(customerId, testOrgunit);
                }
                catch
                {
                }

                // Create a new Organization Unit
                Console.WriteLine("\n-----------Creating organization unit-----------");
                entry = service.CreateOrganizationUnit(
                    customerId, testOrgunit, "/", testOrgunitDescription, false);

                Console.WriteLine("Created: " +
                                  entry.getPropertyValueByName(AppsOrganizationNameTable.OrgUnitName));

                // Retrieve Organization Unit and list all properties
                Console.WriteLine("\n-----------Retrieving organization unit---------");
                entry = service.RetrieveOrganizationUnit(customerId, testOrgunit);

                foreach (PropertyElement element in entry.Properties)
                {
                    Console.WriteLine(String.Format("{0} - {1}", element.Name, element.Value));
                }

                // Update organization unit and list all properties
                Console.WriteLine("\n-----------Updating organization unit----");
                IDictionary <OrganizationService.OrgUnitProperty, string> updates =
                    new Dictionary <OrganizationService.OrgUnitProperty, string>();
                updates[OrganizationService.OrgUnitProperty.Description] = "Updated description";
                entry = service.UpdateOrganizationUnit(customerId, testOrgunit, updates);
                foreach (PropertyElement element in entry.Properties)
                {
                    Console.WriteLine(String.Format("{0} - {1}", element.Name, element.Value));
                }

                // Retrieve all organization units and list the names
                Console.WriteLine("\n-----------Retrieving all organization units----");
                AppsExtendedFeed feed = service.RetrieveAllOrganizationUnits(customerId);
                foreach (AppsExtendedEntry unit in feed.Entries)
                {
                    Console.WriteLine(
                        unit.getPropertyValueByName(AppsOrganizationNameTable.OrgUnitName));
                }

                // Retrieve child organization unit of a given unit
                Console.WriteLine("\n-----------Retrieving child organization units----");
                feed = service.RetrieveChildOrganizationUnits(customerId, testOrgunit);
                foreach (AppsExtendedEntry unit in feed.Entries)
                {
                    Console.WriteLine(
                        unit.getPropertyValueByName(AppsOrganizationNameTable.OrgUnitName));
                }

                // Retrieve org user
                Console.WriteLine("\n-----------Retrieving Org User-------------------");
                entry = service.RetrieveOrganizationUser(customerId, testUser);
                Console.WriteLine("Retrieved OrgUser");
                foreach (PropertyElement element in entry.Properties)
                {
                    Console.WriteLine(String.Format("{0} - {1}", element.Name, element.Value));
                }


                // update org user i.e. move from one org unit to another
                Console.WriteLine("\n-----------Updating Org User---------------------");
                entry = service.UpdateOrganizationUser(customerId, testUser, testOrgunit, "/");
                Console.WriteLine("Updated OrgUser");
                foreach (PropertyElement element in entry.Properties)
                {
                    Console.WriteLine(String.Format("{0} - {1}", element.Name, element.Value));
                }

                // Retrieve all org users
                Console.WriteLine("\n-----------Retrieving all Org Users--------------");
                feed = service.RetrieveAllOrganizationUsers(customerId);
                Console.WriteLine("Retrieved User count:  " + feed.Entries.Count);

                //using pagination
                Console.WriteLine("\n--------Retrieving all Org Users(paginated)------");
                feed = service.RetrieveFirstPageOrganizationUsers(customerId);
                Console.WriteLine("Retrieved User count:  " + feed.Entries.Count);
                AtomLink next, prev = null;
                while ((next = feed.Links.FindService("next", null)) != null && prev != next)
                {
                    feed = service.RetrieveNextPageFromResumeKey(next.HRef.ToString());
                    prev = next;
                    Console.WriteLine("Retrieved User count:  " + feed.Entries.Count);
                }


                // Retrieve org users by org unit
                Console.WriteLine("\n-----------Retrieving Org Users by orgunit--------------");
                feed = service.RetrieveAllOrganizationUsersByOrgUnit(customerId, testOrgunit);
                Console.WriteLine("Retrieved User count:  " + feed.Entries.Count);

                //cleanup
                try
                {
                    Console.WriteLine("\nCleaning up...");
                    entry = service.UpdateOrganizationUser(customerId, testUser, "/", testOrgunit);
                    service.DeleteOrganizationUnit(customerId, testOrgunit);
                }
                catch
                {
                }
            }
            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);
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="service"></param>
        private static void RunSample(MultiDomainManagementService service)
        {
            const String testUserPassword     = "******";
            const String testUserFirstName    = "Liz";
            const String testUserLastName     = "Smith";
            const bool   testUserIsAdmin      = true;
            const String testUserNewFirstName = "Elizabeth";
            String       testUserNewEmail     = "liz@" + secondaryDomain;
            String       testUserAliasEmail   = "helpdesk@" + secondaryDomain;

            try
            {
                // Create a new Domain User
                Console.WriteLine("\n-----------Creating domain user-----------");
                AppsExtendedEntry entry = service.CreateDomainUser(primaryDomain, testUserEmail, testUserPassword,
                                                                   testUserFirstName, testUserLastName, testUserIsAdmin);
                Console.WriteLine("Created: " +
                                  entry.getPropertyValueByName(AppsMultiDomainNameTable.UserEmail));

                // Update Domain User and list all properties
                Console.WriteLine("\n-----------Updating domain user----");
                IDictionary <MultiDomainManagementService.MultiDomainUserProperty, string> updates =
                    new Dictionary <MultiDomainManagementService.MultiDomainUserProperty, string>();
                updates[MultiDomainManagementService.MultiDomainUserProperty.FirstName] = testUserNewFirstName;
                entry = service.UpdateDomainUser(primaryDomain, testUserEmail, updates);
                foreach (PropertyElement element in entry.Properties)
                {
                    Console.WriteLine(String.Format("{0} - {1}", element.Name, element.Value));
                }

                // Create a new Domain User to be renamed
                Console.WriteLine("\n-----------Creating domain user to be renamed-----------");
                String tempEmail = "TOBERENAMED@" + primaryDomain;
                entry = service.CreateDomainUser(primaryDomain, tempEmail, testUserPassword,
                                                 testUserFirstName, testUserLastName, testUserIsAdmin);
                Console.WriteLine("Created: " +
                                  entry.getPropertyValueByName(AppsMultiDomainNameTable.UserEmail));

                // Rename Domain User
                Console.WriteLine("\n-----------Renaming domain user---------------------");
                entry = service.RenameDomainUser(primaryDomain, tempEmail, testUserNewEmail);
                Console.WriteLine("Renamed domain user: "******"\n-----------Retrieving domain user----");
                entry = service.RetrieveDomainUser(primaryDomain, testUserEmail);
                String firstName =
                    entry.getPropertyValueByName(AppsMultiDomainNameTable.FirstName);
                Console.WriteLine("FirstName: " + firstName);

                // Retrieve all domain users unit and list the emails
                Console.WriteLine("\n-----------Retrieving all domain users----");
                AppsExtendedFeed feed = service.RetrieveAllDomainUsers(primaryDomain);
                foreach (AppsExtendedEntry unit in feed.Entries)
                {
                    Console.WriteLine(
                        unit.getPropertyValueByName(AppsMultiDomainNameTable.UserEmail));
                }

                // Create a new User Alias
                Console.WriteLine("\n-----------Creating user alias-----------");
                entry = service.CreateDomainUserAlias(primaryDomain, testUserEmail, testUserAliasEmail);
                Console.WriteLine("Created Alias: " +
                                  entry.getPropertyValueByName(AppsMultiDomainNameTable.AliasEmail));

                // Retrieve User Alias
                entry = service.RetrieveDomainUserAlias(primaryDomain, testUserAliasEmail);
                String userEmail =
                    entry.getPropertyValueByName(AppsMultiDomainNameTable.UserEmail);
                Console.WriteLine("UserEmail: " + userEmail);

                // Retrieve all user aliases for the domain
                Console.WriteLine("\n-----------Retrieving all user aliases----");
                feed = service.RetrieveAllDomainUserAlias(primaryDomain);
                foreach (AppsExtendedEntry unit in feed.Entries)
                {
                    Console.WriteLine(
                        unit.getPropertyValueByName(AppsMultiDomainNameTable.UserEmail));
                }

                // Retrieve all aliases for an user
                Console.WriteLine("\n-----------Retrieving all aliases for user----");
                feed = service.RetrieveAllDomainUserAliasForUser(primaryDomain, testUserEmail);
                foreach (AppsExtendedEntry unit in feed.Entries)
                {
                    Console.WriteLine(
                        unit.getPropertyValueByName(AppsMultiDomainNameTable.AliasEmail));
                }

                // Delete User Alias
                Console.WriteLine("\n-----------Deleting alias----");
                service.DeleteDomainUserAlias(primaryDomain, testUserAliasEmail);

                // Delete User
                Console.WriteLine("\n-----------Deleting user----");
                service.DeleteDomainUser(primaryDomain, testUserEmail);
            }
            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);
            }
        }
Ejemplo n.º 10
0
        private static void RunSample(GoogleMailSettingsService service)
        {
            try
            {
                // Create a new Label for the user testUserName
                service.CreateLabel(testUserName, "Test-Label");

                // Retrieve all labels for the user testUserName
                AppsExtendedFeed labels = service.RetrieveLabels(testUserName);
                Console.WriteLine(String.Format("First label: {0}",
                                                ((AppsExtendedEntry)labels.Entries[0]).getPropertyValueByName("label")));

                // Create a filter for emails from [email protected]
                // for the user testUserName and applies the new label "Test-Label"
                service.CreateFilter(testUserName, "test@" + domain, "", "", "", "", "", "Test-Label", "true", "");

                // Create a filter for emails having "important" in the subject
                // for the user testUserName to never send them to Spam and star them
                service.CreateFilter(testUserName, "", "", "important", "", "", "", "", "", "", "true", "true", "", "");

                // Create a new Send As for the user testUserName
                service.CreateSendAs(testUserName, "Test email", testUserName + "@" + domain, "", "");

                // Retrieve all send-as for user testUserName
                AppsExtendedFeed sendas = service.RetrieveSendAs(testUserName);
                Console.WriteLine(String.Format("First send-as: {0}",
                                                ((AppsExtendedEntry)sendas.Entries[0]).getPropertyValueByName("name")));

                // Updates the forwarding rule to forward emails to
                // test@domain for the user testUserName and keeps the email.
                service.UpdateForwarding(testUserName, "true", "test@" + domain, "KEEP");

                // Disable web clip for the user testUserName.
                service.UpdateWebclip(testUserName, "false");

                // Retrieve forwarding settings for user testUserName
                AppsExtendedEntry forwarding = service.RetrieveForwarding(testUserName);
                Console.WriteLine(String.Format("Forwarding to: {0}",
                                                forwarding.getPropertyValueByName("forwardTo")));

                // Deactivate POP for the user testUserName
                service.UpdatePop(testUserName, "false", null, null);

                // Retrieve POP settings for user testUserName
                AppsExtendedEntry pop = service.RetrievePop(testUserName);
                Console.WriteLine(String.Format("POP enabled: {0}",
                                                pop.getPropertyValueByName("enable")));

                // Activate IMAP for the user testUserName
                service.UpdateImap(testUserName, "true");

                // Retrieve IMAP settings for user testUserName
                AppsExtendedEntry imap = service.RetrieveImap(testUserName);
                Console.WriteLine(String.Format("IMAP enabled: {0}",
                                                imap.getPropertyValueByName("enable")));

                // Activate vacation autoresponse for the user testUserName
                service.UpdateVacation(testUserName, "true", "vacation", "vacation text...", "false", "true", "2012-01-15", "2012-01-22");

                // Retrieve vacation responder settings for user testUserName
                AppsExtendedEntry vacation = service.RetrieveVacation(testUserName);
                Console.WriteLine(String.Format("Vacation responder message: {0}",
                                                vacation.getPropertyValueByName("message")));

                // Update the signature for the user testUserName
                service.UpdateSignature(testUserName, "Signature text...");

                // Retrieve signature for user testUserName
                AppsExtendedEntry signature = service.RetrieveSignature(testUserName);
                Console.WriteLine(String.Format("Signature: {0}",
                                                signature.getPropertyValueByName("signature")));

                // Update the language settings to French (fr) for the user testUserName
                service.UpdateLanguage(testUserName, "fr");

                // Update general settings for the user testUserName
                service.UpdateGeneralSettings(testUserName, "50", "false", "false", "false", "false");

                // Create a new Delegate for the user testUserName
                service.CreateDelegate(testUserName, adminEmail);

                // Retrieve all delegates for the user testUserName
                AppsExtendedFeed delegates = service.RetrieveDelegates(testUserName);
                Console.WriteLine(String.Format("First delegate: {0}",
                                                ((AppsExtendedEntry)delegates.Entries[0]).getPropertyValueByName("delegationId")));

                // Delete the Delegate for the user testUserName
                service.DeleteDelegate(testUserName, adminEmail);
            }
            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);
            }
        }