/// <summary>
        /// Validates the UFN number against the specified earner ID
        /// </summary>
        /// <param name="logonId">Login ID</param>
        /// <param name="collectionRequest">Collection request</param>
        /// <param name="criteria">Criteria for </param>
        /// <returns></returns>
        public UFNReturnValue UFNValidation(Guid logonId, Guid earnerId, DateTime UFNDate, string UFNNumber)
        {
            UFNReturnValue returnValue = new UFNReturnValue();

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

                    SrvMatter srvMatter = new SrvMatter();
                    string errorMessage = string.Empty;
                    string warningMessage = string.Empty;

                    srvMatter.FeeEarnerMemberId = earnerId;
                    srvMatter.SetDefaultsOnFeeEarnerMemberId();

                    srvMatter.UFNValue = UFNDate.Date.Day.ToString().PadLeft(2, '0') + UFNDate.Date.Month.ToString().PadLeft(2, '0') +
                       UFNDate.Date.Year.ToString().Substring(2, 2) + "/" + UFNNumber;

                    srvMatter.UFNDate = UFNDate;
                    bool isValid = false;

                    if (UFNNumber == null)
                    {
                        isValid = srvMatter.setUniqueFileNumberValuesByDate(out errorMessage, out warningMessage);
                    }
                    else
                    {
                        srvMatter.UFNNumber = UFNNumber;
                        isValid = srvMatter.setUniqueFileNumberValuesByNumber(out errorMessage, out warningMessage);
                    }

                    if (!isValid)
                    {
                        returnValue.Success = false;
                        returnValue.Message = "The system has detected that the UFN reference entered is not valid in this instance. If the user is attempting to edit an existing UFN reference, the system will only permit the next available reference outside of the defined Fee Earner ranges.";
                    }
                    else
                    {
                        returnValue.Id = earnerId;
                        returnValue.Date = srvMatter.UFNDate;
                        returnValue.Number = srvMatter.UFNNumber;
                        returnValue.Value = srvMatter.UFNValue;
                    }
                }
                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>
 /// Validates the UFN number against the specified earner ID
 /// </summary>
 /// <param name="oHostSecurityToken">HostSecurityToken obtained when security provider of IWS is called</param>
 /// <param name="collectionRequest">Collection request</param>
 /// <param name="criteria">Criteria for </param>
 /// <returns></returns>
 public UFNReturnValue UFNValidation(HostSecurityToken oHostSecurityToken, Guid earnerId, DateTime UFNDate, string UFNNumber)
 {
     UFNReturnValue returnValue = null;
     if (Functions.ValidateIWSToken(oHostSecurityToken))
     {
         oMatterService = new MatterService();
         returnValue = oMatterService.UFNValidation(Functions.GetLogonIdFromToken(oHostSecurityToken), earnerId, UFNDate,UFNNumber);
     }
     else
     {
         returnValue = new UFNReturnValue();
         returnValue.Success = false;
         returnValue.Message = "Invalid Token";
     }
     return returnValue;
 }