private void asmx_ClientGetGridSettingsCompleted(object sender, ASMX.GetGridSettingsCompletedEventArgs e)
 {
     try
     {
         ASMX.GetGridSettingsResponse rsASMX = e.Result;
         Merge(rsASMX.GridSettingsCD, false, MissingSchemaAction.Ignore);
         PrepareDataAfterGet();
         ClientGetGridSettingsCompleted(this, new EventArgs());
     }
     catch { }
 }
        /// <summary>
        /// Client callable code to get GridSettings.
        /// </summary>
        /// <param name="userName">The User name</param>
        /// <param name="gridName">The Grid name</param>
        /// <param name="async">Do the update async</param>
        /// <returns>True if get successful.</returns>
        public bool ClientGetGridSettings(string userName, string gridName, bool async)
        {
            if (string.IsNullOrEmpty(userName) || string.IsNullOrEmpty(gridName))
            {
                throw new Exception("The UserName and/or GridName is null or empty.");
            }

            _userName = userName;
            _gridName = gridName;

            if (UseWcfService)
            {
                try
                {
                    var svWCF = new WCF.SettingsContractClient();
                    var rqWCF = new WCF.GetGridSettingsRequest {
                        UserName = userName, GridName = gridName
                    };

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

                        svWCF.BeginGetGridSettings(rqWCF, wcf_ClientGetGridSettingsCompleted, svWCF);
                        return(true);
                    }

                    WCF.GetGridSettingsResponse rsWCF = svWCF.GetGridSettings(rqWCF);
                    Merge(rsWCF.GridSettingsCD, false, MissingSchemaAction.Ignore);
                    PrepareDataAfterGet();
                    return(true);
                }
                catch { UseWcfService = false; }                 // ignore if not responding
            }
            if (UseAsmxService)
            {
                try
                {
                    var svASMX = new ASMX.SettingsServiceASMX();
                    var rqASMX = new ASMX.GetGridSettingsRequest {
                        UserName = userName, GridName = gridName
                    };

                    if (async)
                    {
                        svASMX.GetGridSettingsCompleted += asmx_ClientGetGridSettingsCompleted;
                        svASMX.GetGridSettingsAsync(rqASMX);
                        return(true);
                    }

                    ASMX.GetGridSettingsResponse rsASMX = svASMX.GetGridSettings(rqASMX);
                    Merge(rsASMX.GridSettingsCD, false, MissingSchemaAction.Ignore);
                    PrepareDataAfterGet();
                    return(true);
                }
                catch { UseAsmxService = false; }                 // ignore if not responding
            }
            if (UseClientServer)
            {
                try
                {
                    Merge(GetGridSettings(userName, gridName), false, MissingSchemaAction.Ignore);
                    PrepareDataAfterGet();
                    return(true);
                }
                catch { UseClientServer = false; }                 // ignore if not responding
            }

            return(false);
        }