예제 #1
0
        /// <summary>
        /// Binds association roles
        /// </summary>
        private void BindAssociationRoles()
        {
            ContactServiceClient contactService = new ContactServiceClient();

            try
            {
                CollectionRequest collectionRequest = new CollectionRequest();

                AssociationRoleSearchCriteria associationRoleCriteria = new AssociationRoleSearchCriteria();
                //PMS
                associationRoleCriteria.ApplicationId = 1;

                AssociationRoleSearchReturnValue associationRoleReturnValue =
                    contactService.AssociationRoleForApplicationSearch(_logonSettings.LogonId,
                                                                       collectionRequest,
                                                                       associationRoleCriteria);
                if (associationRoleReturnValue.Success)
                {
                    if (associationRoleReturnValue.AssociationRole != null)
                    {
                        //Sort based on AssociationRoleDescription
                        IEnumerable <AssociationRoleSearchItem> assocRolesSorted =
                            associationRoleReturnValue.AssociationRole.Rows.OrderBy(role => role.AssociationRoleDescription);

                        _ddlRole.DataSource     = assocRolesSorted;
                        _ddlRole.DataTextField  = "AssociationRoleDescription";
                        _ddlRole.DataValueField = "AssociationRoleID";
                        _ddlRole.DataBind();
                    }
                }
                else
                {
                    throw new Exception(associationRoleReturnValue.Message);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (contactService.State != System.ServiceModel.CommunicationState.Faulted)
                {
                    contactService.Close();
                }
            }
        }
        /// <summary>
        /// Binds association roles
        /// </summary>
        private void BindAssociationRoles()
        {
            ContactServiceClient contactService = new ContactServiceClient();

            try
            {
                CollectionRequest collectionRequest = new CollectionRequest();

                AssociationRoleSearchCriteria associationRoleCriteria = new AssociationRoleSearchCriteria();
                //PMS
                associationRoleCriteria.ApplicationId = 1;

                AssociationRoleSearchReturnValue associationRoleReturnValue =
                                            contactService.AssociationRoleForApplicationSearch(_logonSettings.LogonId,
                                                                                 collectionRequest,
                                                                                 associationRoleCriteria);
                if (associationRoleReturnValue.Success)
                {
                    if (associationRoleReturnValue.AssociationRole != null)
                    {
                        //Sort based on AssociationRoleDescription
                        IEnumerable<AssociationRoleSearchItem> assocRolesSorted =
                            associationRoleReturnValue.AssociationRole.Rows.OrderBy(role => role.AssociationRoleDescription);

                        _ddlRole.DataSource = assocRolesSorted;
                        _ddlRole.DataTextField = "AssociationRoleDescription";
                        _ddlRole.DataValueField = "AssociationRoleID";
                        _ddlRole.DataBind();
                    }
                }
                else
                {
                    throw new Exception(associationRoleReturnValue.Message);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (contactService.State != System.ServiceModel.CommunicationState.Faulted)
                    contactService.Close();
            }
        }