private void asmx_ClientGetUserSettingsCompleted(object sender, ASMX.GetUserSettingsCompletedEventArgs e)
 {
     try
     {
         ASMX.GetUserSettingsResponse rsASMX = e.Result;
         PrepareDataAfterGet(rsASMX.UserSettingsCD);
         Merge(rsASMX.UserSettingsCD, false, MissingSchemaAction.Ignore);
         ClientGetUserSettingsCompleted(this, new EventArgs());
     }
     catch { }
 }
        /// <summary>
        /// Client callable code to get UserSettings.
        /// </summary>
        /// <param name="userName">The User name</param>
        /// <param name="async">Do the update async</param>
        /// <returns>True if get successful.</returns>
        public bool ClientGetUserSettings(string userName, bool async)
        {
            if (string.IsNullOrEmpty(userName))
            {
                throw new Exception("The UserName is null or empty.");
            }

            _userName = userName;

            if (UseWcfService)
            {
                try
                {
                    var svWCF = new WCF.SettingsContractClient();
                    var rqWCF = new WCF.GetUserSettingsRequest {
                        UserName = userName
                    };

                    if (async)
                    {
                        if (String.IsNullOrEmpty(svWCF.Ping()))
                        {
                            throw new Exception("WCF is offline.");
                        }

                        svWCF.BeginGetUserSettings(rqWCF, wcf_ClientGetUserSettingsCompleted, svWCF);
                        return(true);
                    }
                    WCF.GetUserSettingsResponse rsWCF = svWCF.GetUserSettings(rqWCF);
                    PrepareDataAfterGet(rsWCF.UserSettingsCD);
                    Merge(rsWCF.UserSettingsCD, false, MissingSchemaAction.Ignore);
                    return(true);
                }
                catch { UseWcfService = false; }                 // ignore if not responding
            }
            if (UseAsmxService)
            {
                try
                {
                    var svASMX = new ASMX.SettingsServiceASMX();
                    var rqASMX = new ASMX.GetUserSettingsRequest {
                        UserName = userName
                    };

                    if (async)
                    {
                        svASMX.GetUserSettingsCompleted += asmx_ClientGetUserSettingsCompleted;
                        svASMX.GetUserSettingsAsync(rqASMX);
                        return(true);
                    }

                    ASMX.GetUserSettingsResponse rsASMX = svASMX.GetUserSettings(rqASMX);
                    PrepareDataAfterGet(rsASMX.UserSettingsCD);
                    Merge(rsASMX.UserSettingsCD, false, MissingSchemaAction.Ignore);
                    return(true);
                }
                catch { UseAsmxService = false; }                 // ignore if not responding
            }
            if (UseClientServer)
            {
                try
                {
                    UserSettingsCD userSettings = GetUserSettings(userName);
                    PrepareDataAfterGet(userSettings);
                    Merge(userSettings, false, MissingSchemaAction.Ignore);
                    return(true);
                }
                catch { UseClientServer = false; }                 // ignore if not responding
            }

            return(false);
        }