/// <summary>
        /// Gets the matters for the client.
        /// </summary>
        private void BindDocumentTypes()
        {
            DocumentServiceClient documentTypeService = new DocumentServiceClient();

            try
            {
                CollectionRequest collectionRequest = new CollectionRequest();
                collectionRequest.StartRow = 0;

                DocumentTypeSearchCriteria docTypeCriteria = new DocumentTypeSearchCriteria();
                docTypeCriteria.DocTypeIDs = "1, 3";
                FileTypeReturnValue fileTypeReturnValue = documentTypeService.GetFileTypes(((LogonReturnValue)HttpContext.Current.Session[SessionName.LogonSettings]).LogonId);

                if (fileTypeReturnValue.Success)
                {
                    if (fileTypeReturnValue.FileType != null)
                    {
                        _ddlFileType.DataSource     = fileTypeReturnValue.FileType;
                        _ddlFileType.DataTextField  = "FileDescription";
                        _ddlFileType.DataValueField = "FileDescription";
                        _ddlFileType.DataBind();
                    }
                }
                else
                {
                    throw new Exception(fileTypeReturnValue.Message);
                }
            }
            catch (System.ServiceModel.EndpointNotFoundException)
            {
                _lblError.Text     = DataConstants.WSEndPointErrorMessage;
                _lblError.CssClass = "errorMessage";
            }
            catch (Exception ex)
            {
                _lblError.Text     = ex.Message;
                _lblError.CssClass = "errorMessage";
            }
            finally
            {
                if (documentTypeService.State != System.ServiceModel.CommunicationState.Faulted)
                {
                    documentTypeService.Close();
                }
            }

            _ddlFileType.SelectedIndex = -1;
            _ddlFileType.SelectedIndex = _ddlFileType.Items.Count - 1;
        }
        /// <summary>
        /// Get Document Types for Import Document
        /// </summary>
        /// <param name="logonId"></param>
        /// <param name="criteria"></param>
        /// <param name="collectionRequest"></param>
        /// <returns></returns>
        public DocumentTypeReturnValue GetDocumentTypes(Guid logonId, DocumentTypeSearchCriteria criteria, CollectionRequest collectionRequest)
        {
            DocumentTypeReturnValue returnValue = new DocumentTypeReturnValue();

            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:
                            // Can do everything
                            break;
                        case DataConstants.UserType.Client:
                        case DataConstants.UserType.ThirdParty:
                            throw new Exception("Access denied");
                        default:
                            throw new Exception("Access denied");
                    }

                    // Create a data list creator for a list of matters
                    DataListCreator<DocumentTypeSearchItem> dataListCreator = new DataListCreator<DocumentTypeSearchItem>();

                    // Declare an inline event (annonymous delegate) to read the
                    // dataset if it is required
                    dataListCreator.ReadDataSet += delegate(object sender, ReadDataSetEventArgs e)
                    {
                        e.DataSet = SrvDocumentLookup.GetDocumentTypes(criteria.DocTypeIDs);
                    };

                    // Create the data list
                    returnValue.DocumentType = dataListCreator.Create(logonId,
                        // Give the query a name so it can be cached
                        "DocumentTypeSearch",
                        // 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("Id", "DocTypeID"),
                            new ImportMapping("Description", "DocTypeDescription")
                            }
                        );
                }
                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>
        /// Get Document Types for Import Document
        /// </summary>
        /// <param name="oHostSecurityToken"></param>
        /// <param name="criteria"></param>
        /// <param name="collectionRequest"></param>
        /// <returns></returns>
        public DocumentTypeReturnValue GetDocumentTypes(HostSecurityToken oHostSecurityToken, DocumentTypeSearchCriteria criteria, CollectionRequest collectionRequest)
        {
            DocumentTypeReturnValue ReturnValue = null;

            if (Functions.ValidateIWSToken(oHostSecurityToken))
            {
                oDocumentService = new DocumentService();
                ReturnValue      = oDocumentService.GetDocumentTypes(Functions.GetLogonIdFromToken(oHostSecurityToken), criteria, collectionRequest);
            }
            else
            {
                ReturnValue         = new DocumentTypeReturnValue();
                ReturnValue.Success = false;
                ReturnValue.Message = "Invalid Token";
            }
            return(ReturnValue);
        }
        /// <summary>
        /// Gets the matters for the client.
        /// </summary>
        private void BindDocumentTypes()
        {
            DocumentServiceClient documentTypeService = new DocumentServiceClient();
            try
            {
                CollectionRequest collectionRequest = new CollectionRequest();
                collectionRequest.StartRow = 0;

                DocumentTypeSearchCriteria docTypeCriteria = new DocumentTypeSearchCriteria();
                docTypeCriteria.DocTypeIDs = "1, 3";
                FileTypeReturnValue fileTypeReturnValue = documentTypeService.GetFileTypes(((LogonReturnValue)HttpContext.Current.Session[SessionName.LogonSettings]).LogonId);

                if (fileTypeReturnValue.Success)
                {
                    if (fileTypeReturnValue.FileType != null)
                    {
                        _ddlFileType.DataSource = fileTypeReturnValue.FileType;
                        _ddlFileType.DataTextField = "FileDescription";
                        _ddlFileType.DataValueField = "FileDescription";
                        _ddlFileType.DataBind();
                    }
                }
                else
                {
                    throw new Exception(fileTypeReturnValue.Message);
                }
            }
            catch (System.ServiceModel.EndpointNotFoundException)
            {
                _lblError.Text = DataConstants.WSEndPointErrorMessage;
                _lblError.CssClass = "errorMessage";
            }
            catch (Exception ex)
            {
                _lblError.Text = ex.Message;
                _lblError.CssClass = "errorMessage";
            }
            finally
            {
                if (documentTypeService.State != System.ServiceModel.CommunicationState.Faulted)
                    documentTypeService.Close();
            }

            _ddlFileType.SelectedIndex = -1;
            _ddlFileType.SelectedIndex = _ddlFileType.Items.Count - 1;
        }