Exemplo n.º 1
0
        /// <summary>
        /// Gets the address types.
        /// </summary>
        /// <param name="oHostSecurityToken">HostSecurityToken obtained when security provider of IWS is called</param>
        /// <param name="collectionRequest">Information about the collection being requested.</param>
        /// <param name="criteria">Address Type search criteria.</param>
        /// <returns></returns>
        public AddressTypeReturnValue GetAddressTypes(HostSecurityToken oHostSecurityToken, CollectionRequest collectionRequest,
                                                      AddressTypeSearchCriteria criteria)
        {
            AddressTypeReturnValue returnValue = null;

            if (Functions.ValidateIWSToken(oHostSecurityToken))
            {
                oContactService = new ContactService();
                returnValue     = oContactService.GetAddressTypes(Functions.GetLogonIdFromToken(oHostSecurityToken), collectionRequest, criteria);
            }
            else
            {
                returnValue         = new AddressTypeReturnValue();
                returnValue.Success = false;
                returnValue.Message = "Invalid Token";
            }
            return(returnValue);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Method to display the available address types.
        /// </summary>
        private void GetAddressTypes()
        {
            ContactServiceClient contactService = null;

            try
            {
                CollectionRequest         collectionRequest = new CollectionRequest();
                AddressTypeSearchCriteria searchCriteria    = new AddressTypeSearchCriteria();
                searchCriteria.MemberId       = _memId;
                searchCriteria.OrganisationId = _orgId;

                contactService = new ContactServiceClient();
                AddressTypeReturnValue returnValue = contactService.GetAddressTypes(_logonId, collectionRequest, searchCriteria);

                if (returnValue.Success)
                {
                    _ddlAddressType.DataSource     = returnValue.AddressTypes.Rows;
                    _ddlAddressType.DataTextField  = "Description";
                    _ddlAddressType.DataValueField = "Id";
                    _ddlAddressType.DataBind();
                }
                else
                {
                    throw new Exception(returnValue.Message);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (contactService != null)
                {
                    if (contactService.State != System.ServiceModel.CommunicationState.Faulted)
                    {
                        contactService.Close();
                    }
                }
            }
        }
        /// <summary>
        /// Method to display the available address types.
        /// </summary>
        private void GetAddressTypes()
        {
            ContactServiceClient contactService = null;
            try
            {
                CollectionRequest collectionRequest = new CollectionRequest();
                AddressTypeSearchCriteria searchCriteria = new AddressTypeSearchCriteria();
                searchCriteria.MemberId = _memId;
                searchCriteria.OrganisationId = _orgId;

                contactService = new ContactServiceClient();
                AddressTypeReturnValue returnValue = contactService.GetAddressTypes(_logonId, collectionRequest, searchCriteria);

                if (returnValue.Success)
                {
                    _ddlAddressType.DataSource = returnValue.AddressTypes.Rows;
                    _ddlAddressType.DataTextField = "Description";
                    _ddlAddressType.DataValueField = "Id";
                    _ddlAddressType.DataBind();
                }
                else
                {
                    throw new Exception(returnValue.Message);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (contactService != null)
                {
                    if (contactService.State != System.ServiceModel.CommunicationState.Faulted)
                        contactService.Close();
                }
            }
        }
        /// <summary>
        /// Gets the address types.
        /// </summary>
        /// <param name="logonId">Logon id obtained when logging on to the logon service.</param>
        /// <param name="collectionRequest">Information about the collection being requested.</param>
        /// <param name="criteria">Address Type search criteria.</param>
        /// <returns></returns>
        public AddressTypeReturnValue GetAddressTypes(Guid logonId, CollectionRequest collectionRequest,
                AddressTypeSearchCriteria criteria)
        {
            AddressTypeReturnValue returnValue = new AddressTypeReturnValue();

            try
            {
                // Get the logged on user from the current logons and add their
                // ApplicationSettings the list of concurrent sessions.
                Host.LoadLoggedOnUser(logonId);

                try
                {
                    Functions.RestrictRekoopIntegrationUser(UserInformation.Instance.DbUid);
                    switch (UserInformation.Instance.UserType)
                    {
                        case DataConstants.UserType.Staff:
                        case DataConstants.UserType.Client:
                        case DataConstants.UserType.ThirdParty:
                            // Can do everything
                            break;
                        default:
                            throw new Exception("Access denied");
                    }

                    // Create a data list creator for a list of address types
                    DataListCreator<AddressType> dataListCreator = new DataListCreator<AddressType>();

                    // Declare an inline event (annonymous delegate) to read the dataset
                    dataListCreator.ReadDataSet += delegate(object Sender, ReadDataSetEventArgs e)
                    {

                        if (criteria.MemberId != DataConstants.DummyGuid)
                        {
                            e.DataSet = SrvAddressLookup.GetAddressTypes(1, 2);
                        }
                        else if (criteria.OrganisationId != DataConstants.DummyGuid)
                        {
                            e.DataSet = SrvAddressLookup.GetAddressTypes(1, 3);
                        }

                        foreach (DataRow r in e.DataSet.Tables[0].Rows)
                        {
                            if (Boolean.Parse(r["AddressTypeArchived"].ToString()))
                            {
                                r.Delete();
                            }
                        }
                        e.DataSet.Tables[0].AcceptChanges();

                    };

                    // Create the data list
                    returnValue.AddressTypes = dataListCreator.Create(logonId,
                        // Give the query a name so it can be cached
                        "AddressTypes",
                        // Tell it the query criteria used so if the cache is accessed
                        // again it knows if it is the same query
                        criteria.ToString(),
                        collectionRequest,
                        // Import mappings to map the dataset row fields to the data
                        // list entity properties
                        new ImportMapping[] {
                            new ImportMapping("Description", "AddressTypeDescription"),
                            new ImportMapping("Id", "AddressTypeID"),
                            }
                        );
                }
                finally
                {
                    // Remove the logged on user's ApplicationSettings from the
                    // list of concurrent sessions
                    Host.UnloadLoggedOnUser();
                }
            }
            catch (System.Data.SqlClient.SqlException)
            {
                returnValue.Success = false;
                returnValue.Message = Functions.SQLErrorMessage;
            }
            catch (Exception Ex)
            {
                returnValue.Success = false;
                returnValue.Message = Ex.Message;
            }

            return returnValue;
        }
 /// <summary>
 /// Gets the address types.
 /// </summary>
 /// <param name="oHostSecurityToken">HostSecurityToken obtained when security provider of IWS is called</param>
 /// <param name="collectionRequest">Information about the collection being requested.</param>
 /// <param name="criteria">Address Type search criteria.</param>
 /// <returns></returns>
 public AddressTypeReturnValue GetAddressTypes(HostSecurityToken oHostSecurityToken, CollectionRequest collectionRequest,
         AddressTypeSearchCriteria criteria)
 {
     AddressTypeReturnValue returnValue = null;
     if (Functions.ValidateIWSToken(oHostSecurityToken))
     {
         oContactService = new ContactService();
         returnValue = oContactService.GetAddressTypes(Functions.GetLogonIdFromToken(oHostSecurityToken), collectionRequest, criteria);
     }
     else
     {
         returnValue = new AddressTypeReturnValue();
         returnValue.Success = false;
         returnValue.Message = "Invalid Token";
     }
     return returnValue;
 }