예제 #1
0
        private void asmx_ClientUpdateFormSettingsCompleted(object sender, ASMX.UpdateFormSettingsCompletedEventArgs e)
        {
            var rsASMX = new ASMX.UpdateFormSettingsResponse();

            Merge(rsASMX.FormSettingsCD, false, MissingSchemaAction.Ignore);
            PrepareDataAfterUpdate();
            ClientUpdateFormSettingsCompleted(this, new EventArgs());
        }
예제 #2
0
        /// <summary>
        /// Client callable code to update FormSettings.
        /// </summary>
        /// <param name="async">Do the update async.</param>
        /// <returns>True if update is successful. If False, check for RowErrors.</returns>
        public bool ClientUpdateFormSettings(bool async)
        {
            if (string.IsNullOrEmpty(_userName) || string.IsNullOrEmpty(_formName))
            {
                throw new Exception("The UserName and/or FormName is null or empty.");
            }

            PrepareDataBeforeUpdate();

            var updatedFormSettings = new FormSettingsCD();

            updatedFormSettings.Merge(Tables["FormSettings"].Select("", "", DataViewRowState.Deleted), false, MissingSchemaAction.Ignore);
            updatedFormSettings.Merge(Tables["FormSettings"].Select("", "", DataViewRowState.Added), false, MissingSchemaAction.Ignore);
            updatedFormSettings.Merge(Tables["FormSettings"].Select("", "", DataViewRowState.ModifiedCurrent), false, MissingSchemaAction.Ignore);

            if (updatedFormSettings.FormSettings.Rows.Count > 0)
            {
                if (UseWcfService)
                {
                    try
                    {
                        var svWCF = new WCF.SettingsContractClient();
                        var rqWCF = new WCF.UpdateFormSettingsRequest {
                            FormSettingsCD = new WCF.FormSettingsCD()
                        };
                        rqWCF.FormSettingsCD.Merge(updatedFormSettings, false, MissingSchemaAction.Ignore);

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

                            svWCF.BeginUpdateFormSettings(rqWCF, wcf_ClientUpdateFormSettingsCompleted, svWCF);
                            return(true);
                        }

                        WCF.UpdateFormSettingsResponse rsWCF = svWCF.UpdateFormSettings(rqWCF);
                        Merge(rsWCF.FormSettingsCD, false, MissingSchemaAction.Ignore);
                        PrepareDataAfterUpdate();
                        return(true);
                    }
                    catch { UseWcfService = false; }                     // ignore if not responding
                }
                if (UseAsmxService)
                {
                    try
                    {
                        var svASMX = new ASMX.SettingsServiceASMX();
                        var rqASMX = new ASMX.UpdateFormSettingsRequest {
                            FormSettingsCD = new ASMX.FormSettingsCD()
                        };
                        rqASMX.FormSettingsCD.Merge(updatedFormSettings, false, MissingSchemaAction.Ignore);

                        if (async)
                        {
                            svASMX.UpdateFormSettingsCompleted += asmx_ClientUpdateFormSettingsCompleted;
                            svASMX.UpdateFormSettingsAsync(rqASMX);
                            return(true);
                        }

                        ASMX.UpdateFormSettingsResponse rsASMX = svASMX.UpdateFormSettings(rqASMX);
                        Merge(rsASMX.FormSettingsCD, false, MissingSchemaAction.Ignore);
                        PrepareDataAfterUpdate();
                        return(true);
                    }
                    catch { UseAsmxService = false; }                     // ignore if not responding
                }
                if (UseClientServer)
                {
                    try
                    {
                        Merge(UpdateFormSettings(updatedFormSettings), false, MissingSchemaAction.Ignore);
                        PrepareDataAfterUpdate();
                        return(true);
                    }
                    catch { UseClientServer = false; }                     // ignore if not responding
                }
            }

            return(false);
        }