/// <summary>
        /// Get documents for deep search
        /// </summary>
        /// <param name="logonId"></param>
        /// <param name="fileListToSearch"></param>
        /// <returns></returns>
        public DocumentSearchReturnValue GetMatterDocumentForDeepSearch(Guid logonId, Guid projectId, DocumentSearchCriteria criteria)
        {
            DocumentSearchReturnValue returnValue = new DocumentSearchReturnValue();
            SrvFileSearcher srvFileSearcher = new SrvFileSearcher();

            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:
                            //Can search for documents
                            if (!SrvMatterCommon.WebAllowedToAccessMatter(projectId))
                                throw new Exception("Access denied");

                            break;
                        default:
                            throw new Exception("Access denied");
                    }

                    DataList<DocumentSearchItem> docs = this.MatterDocumentSearchInternal(projectId);

                    string[] listOfDocuments = null;
                    string fileInfo;
                    string searchFilePath;

                    listOfDocuments = new string[docs.Rows.Count];
                    for (int i = 0; i < docs.Rows.Count; i++)
                    {
                        fileInfo = string.Empty;
                        fileInfo = docs.Rows[i].FilePath;
                        if (fileInfo != string.Empty)
                        {
                            fileInfo += "^" + docs.Rows[i].FileDescription + "^" +
                                docs.Rows[i].Id + "^" +
                                Convert.ToString(docs.Rows[i].CreatedDate.ToString("dd/MM/yyyy")) +
                                "^" + Convert.ToString(docs.Rows[i].FeeEarnerRef);
                            listOfDocuments[i] = fileInfo;
                        }
                    }

                    srvFileSearcher.IgnoreCase = !criteria.IsMatchCase;
                    srvFileSearcher.SearchSubFolders = criteria.IsSubFolderSearch;
                    srvFileSearcher.SearchInFiles = criteria.IsDeepSearch;
                    srvFileSearcher.SearchFilesOfType = (SrvFileSearcher.AvailableFileTypes)criteria.DocumentType;

                    if (string.IsNullOrEmpty(criteria.SearchString))
                    {
                        criteria.SearchString = string.Empty;
                    }

                    srvFileSearcher.SearchSetPaths(listOfDocuments, criteria.SearchString);

                    List<FileInfo> filesFound = srvFileSearcher.FilesFound;
                    DataList<DocumentSearchItem> listDocuments = new DataList<DocumentSearchItem>();
                    foreach (FileInfo info in filesFound)
                    {
                        searchFilePath = string.Empty;

                        DocumentSearchItem item = new DocumentSearchItem();
                        item.FileName = info.Name;

                        string fileDescription = SrvDocumentCommon.GetDocumentDescription(info.Name);

                        item.FileDescription = fileDescription;
                        item.FilePath = info.FullName;

                        foreach (string element in listOfDocuments)
                        {
                            searchFilePath = string.Empty;
                            if (element.Contains("^"))
                            {
                                searchFilePath = element.Split('^')[0];
                                if (info.FullName == searchFilePath)
                                {
                                    item.Id = Convert.ToInt32(element.Split('^')[2]);
                                    item.CreatedDate = Convert.ToDateTime(Convert.ToString(element.Split('^')[3]));
                                    item.FeeEarnerRef = Convert.ToString(Convert.ToString(element.Split('^')[4]));
                                }
                            }
                        }

                        listDocuments.Rows.Add(item);
                    }
                    returnValue.Document = listDocuments;
                    returnValue.Message = srvFileSearcher.ErrorMessage;
                }
                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 = srvFileSearcher.ErrorMessage + "<br />" + ex.Message;
            }

            return returnValue;
        }
        /// <summary>
        /// Get File Types
        /// </summary>
        /// <param name="logonId"></param>
        /// <returns></returns>
        public FileTypeReturnValue GetFileTypes(Guid logonId)
        {
            FileTypeReturnValue returnValue = new FileTypeReturnValue();

            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");
                    }

                    SrvFileSearcher srvFileSearcher = new SrvFileSearcher();
                    List<FileTypeSearchItem> listFileTypeSearchItem = new List<FileTypeSearchItem>();
                    foreach (FileSearcherFileType fileType in srvFileSearcher.AvilableFileTypes)
                    {
                        FileTypeSearchItem fileTypeSearchItem = new FileTypeSearchItem();
                        fileTypeSearchItem.FileExtension = fileType.FileExtension;
                        fileTypeSearchItem.FileDescription = fileType.FileTypeDescription;
                        listFileTypeSearchItem.Add(fileTypeSearchItem);
                    }
                    returnValue.FileType = listFileTypeSearchItem;
                }
                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;
        }