Пример #1
0
 private void asmx_ClientGetFormSettingsCompleted(object sender, ASMX.GetFormSettingsCompletedEventArgs e)
 {
     ASMX.GetFormSettingsResponse rsASMX = e.Result;
     Merge(rsASMX.FormSettingsCD, false, MissingSchemaAction.Ignore);
     PrepareDataAfterGet();
     ClientGetFormSettingsCompleted(this, new EventArgs());
 }
Пример #2
0
        /// <summary>
        /// Client callable code to get FormSettings.
        /// </summary>
        /// <param name="userName">The User name</param>
        /// <param name="formName">The Form name</param>
        /// <param name="async">Do the update async</param>
        /// <returns>True if get successful.</returns>
        public bool ClientGetFormSettings(string userName, string formName, bool async)
        {
            if (string.IsNullOrEmpty(userName) || string.IsNullOrEmpty(formName))
            {
                throw new Exception("The UserName and/or FormName is null or empty.");
            }

            _userName = userName;
            _formName = formName;

            if (UseWcfService)
            {
                try
                {
                    var svWCF = new WCF.SettingsContractClient();
                    var rqWCF = new WCF.GetFormSettingsRequest {
                        UserName = userName, FormName = formName
                    };

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

                        svWCF.BeginGetFormSettings(rqWCF, wcf_ClientGetFormSettingsCompleted, svWCF);
                        return(true);
                    }

                    WCF.GetFormSettingsResponse rsWCF = svWCF.GetFormSettings(rqWCF);
                    Merge(rsWCF.FormSettingsCD, 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.GetFormSettingsRequest {
                        UserName = userName, FormName = formName
                    };

                    if (async)
                    {
                        svASMX.GetFormSettingsCompleted += asmx_ClientGetFormSettingsCompleted;
                        svASMX.GetFormSettingsAsync(rqASMX);
                        return(true);
                    }

                    ASMX.GetFormSettingsResponse rsASMX = svASMX.GetFormSettings(rqASMX);
                    Merge(rsASMX.FormSettingsCD, false, MissingSchemaAction.Ignore);
                    PrepareDataAfterGet();
                    return(true);
                }
                catch { UseAsmxService = false; }                 // ignore if not responding
            }
            if (UseClientServer)
            {
                try
                {
                    Merge(GetFormSettings(userName, formName), false, MissingSchemaAction.Ignore);
                    PrepareDataAfterGet();
                    return(true);
                }
                catch { UseClientServer = false; }                 // ignore if not responding
            }

            return(false);
        }