/// <summary>
        ///  callable code to Delete/Insert/Update Issues
        /// </summary>
        /// <param name="ds">A DataSet of type GridFiltersCD</param>
        public void ClientUpdateGridFiltersAsync(DataSet ds)
        {
            if (ds.Tables["Issues"].Select("", "", DataViewRowState.Deleted).Length > 0 ||
                ds.Tables["Issues"].Select("", "", DataViewRowState.Added).Length > 0 ||
                ds.Tables["Issues"].Select("", "", DataViewRowState.ModifiedCurrent).Length > 0)
            {
                if (UseWcfService)
                {
                    try
                    {
                        var svWCF = new WCF.SettingsContractClient();
                        svWCF.Ping();

                        var rqWCF = new WCF.UpdateGridFiltersRequest {
                            GridFiltersCD = new WCF.GridFiltersCD()
                        };
                        rqWCF.GridFiltersCD.Merge(ds, false, MissingSchemaAction.Ignore);
                        svWCF.BeginUpdateGridFilters(rqWCF, wcf_ClientUpdateGridFiltersCompleted, svWCF);
                    }
                    catch { UseWcfService = false; }                     // ignore if not responding
                }
                if (UseAsmxService)
                {
                    try
                    {
                        var svASMX = new ASMX.SettingsServiceASMX();
// ReSharper disable RedundantNameQualifier
                        var rqASMX = new ASMX.UpdateGridFiltersRequest {
                            GridFiltersCD = new ASMX.GridFiltersCD()
                        };
// ReSharper restore RedundantNameQualifier
                        rqASMX.GridFiltersCD.Merge(ds, false, MissingSchemaAction.Ignore);
                        svASMX.UpdateGridFiltersCompleted += asmx_ClientUpdateGridFiltersCompleted;
                        svASMX.UpdateGridFiltersAsync(rqASMX);
                    }
                    catch { UseAsmxService = false; }                     // ignore if not responding
                }
                if (UseClientServer)
                {
                    try
                    {
                        var issuesCD = new GridFiltersCD();
                        issuesCD.Merge(ds, false, MissingSchemaAction.Ignore);
                        issuesCD = UpdateGridFilters(issuesCD);

// ReSharper disable RedundantNameQualifier
                        var rs = new ASMX.UpdateGridFiltersResponse();
// ReSharper restore RedundantNameQualifier
                        rs.GridFiltersCD.Merge(issuesCD, false, MissingSchemaAction.Ignore);
// ReSharper disable RedundantNameQualifier
                        var e = new ASMX.UpdateGridFiltersCompletedEventArgs(new object[] { rs }, null, false, null);
// ReSharper restore RedundantNameQualifier
                        asmx_ClientUpdateGridFiltersCompleted(null, e);
                    }
                    catch { UseClientServer = false; }                     // ignore if not responding
                }
            }
        }
        /// <summary>
        ///  Client callable code to get all GridFilters async
        /// </summary>
        public void ClientGetGridFiltersAsync(string userName, string gridName)
        {
            if (UseWcfService)
            {
                try
                {
                    var svWCF = new WCF.SettingsContractClient();
                    svWCF.Ping();

                    var rqWCF = new WCF.GetGridFiltersRequest {
                        UserName = userName, GridName = gridName
                    };

                    svWCF.BeginGetGridFilters(rqWCF, wcf_ClientGetGridFiltersCompleted, svWCF);
                }
                catch { UseWcfService = false; }                 // ignore if not responding
            }
            if (UseAsmxService)
            {
                try
                {
                    var svASMX = new ASMX.SettingsServiceASMX();

// ReSharper disable RedundantNameQualifier
                    var rqASMX = new ASMX.GetGridFiltersRequest {
                        UserName = userName, GridName = gridName
                    };
// ReSharper restore RedundantNameQualifier

                    svASMX.GetGridFiltersCompleted += asmx_ClientGetGridFiltersCompleted;
                    svASMX.GetGridFiltersAsync(rqASMX);
                }
                catch { UseAsmxService = false; }                 // ignore if not responding
            }
            if (UseClientServer)
            {
                try
                {
                    DataSet result = GetGridFilters(userName, gridName);
// ReSharper disable RedundantNameQualifier
                    var rs = new ASMX.GetGridFiltersResponse {
                        GridFiltersCD = new ASMX.GridFiltersCD()
                    };
// ReSharper restore RedundantNameQualifier
                    rs.GridFiltersCD.Merge(result, false, MissingSchemaAction.Ignore);
// ReSharper disable RedundantNameQualifier
                    var e = new ASMX.GetGridFiltersCompletedEventArgs(new object[] { rs }, null, false, null);
// ReSharper restore RedundantNameQualifier
                    asmx_ClientGetGridFiltersCompleted(this, e);
                }
                catch { UseClientServer = false; }                 // ignore if not responding
            }
        }
        /// <summary>
        ///  callable code to Delete/Insert/Update Issues
        /// </summary>
        /// <param name="ds">A DataSet of type GridFiltersCD</param>
        /// <returns>A GridFiltersCD DataSet. If ALL OK contains updated data, if not contains the RowErrors</returns>
        public DataSet ClientUpdateGridFilters(DataSet ds)
        {
            if (ds.Tables["Issues"].Select("", "", DataViewRowState.Deleted).Length > 0 ||
                ds.Tables["Issues"].Select("", "", DataViewRowState.Added).Length > 0 ||
                ds.Tables["Issues"].Select("", "", DataViewRowState.ModifiedCurrent).Length > 0)
            {
                if (UseWcfService)
                {
                    try
                    {
                        var svWCF = new WCF.SettingsContractClient();
                        var rqWCF = new WCF.UpdateGridFiltersRequest {
                            GridFiltersCD = new WCF.GridFiltersCD()
                        };
                        rqWCF.GridFiltersCD.Merge(ds, false, MissingSchemaAction.Ignore);
                        WCF.UpdateGridFiltersResponse rsWCF = svWCF.UpdateGridFilters(rqWCF);
                        return(rsWCF.GridFiltersCD);
                    }
                    catch { UseWcfService = false; }                     // ignore if not responding
                }
                if (UseAsmxService)
                {
                    try
                    {
                        var svASMX = new ASMX.SettingsServiceASMX();
// ReSharper disable RedundantNameQualifier
                        var rqASMX = new ASMX.UpdateGridFiltersRequest {
                            GridFiltersCD = new ASMX.GridFiltersCD()
                        };
// ReSharper restore RedundantNameQualifier
                        rqASMX.GridFiltersCD.Merge(ds, false, MissingSchemaAction.Ignore);
                        ASMX.UpdateGridFiltersResponse rsASMX = svASMX.UpdateGridFilters(rqASMX);
                        return(rsASMX.GridFiltersCD);
                    }
                    catch { UseAsmxService = false; }                     // ignore if not responding
                }
                if (UseClientServer)
                {
                    try
                    {
                        var issuesCD = new GridFiltersCD();
                        issuesCD.Merge(ds, false, MissingSchemaAction.Ignore);
                        return(UpdateGridFilters(issuesCD));
                    }
                    catch { UseClientServer = false; }                     // ignore if not responding
                }

                return(ds);                // returns no changes if errors
            }

            return(ds);
        }
        /// <summary>
        /// Client callable code to get GridFilters.
        /// </summary>
        /// <returns>True if get is successful</returns>
        public bool ClientGetGridFilters(string userName, string gridName)
        {
            if (string.IsNullOrEmpty(userName) || string.IsNullOrEmpty(gridName))
            {
                throw new Exception("The UserName and/or GridName is null or empty.");
            }

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

                    WCF.GetGridFiltersResponse rsWCF = svWCF.GetGridFilters(rqWCF);
                    Merge(rsWCF.GridFiltersCD, false, MissingSchemaAction.Ignore);
                    return(true);
                }
                catch { UseWcfService = false; }                 // ignore if not responding
            }
            if (UseAsmxService)
            {
                try
                {
                    var svASMX = new ASMX.SettingsServiceASMX();
// ReSharper disable RedundantNameQualifier
                    var rqASMX = new ASMX.GetGridFiltersRequest {
                        UserName = userName, GridName = gridName
                    };
// ReSharper restore RedundantNameQualifier

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

            return(false);
        }
示例#5
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);
        }
示例#6
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);
        }
        /// <summary>
        /// Client callable code to update UserSettings.
        /// </summary>
        /// <param name="async">Do the update async.</param>
        /// <returns>True if update is successful. If False, check for RowErrors.</returns>
        public bool ClientUpdateUserSettings(bool async)
        {
            if (string.IsNullOrEmpty(_userName))
            {
                throw new Exception("The UserName and/or FormName is null or empty.");
            }

            PrepareDataBeforeUpdate();

            if (UserSettings.Select("", "", DataViewRowState.Deleted).Length > 0 ||
                UserSettings.Select("", "", DataViewRowState.Added).Length > 0 ||
                UserSettings.Select("", "", DataViewRowState.ModifiedCurrent).Length > 0)
            {
                var ds = new UserSettingsCD();
                foreach (UserSettingsRow deletedRow in UserSettings.Select("", "", DataViewRowState.Deleted))
                {
                    ds.UserSettings.ImportRow(deletedRow);
                }
                foreach (UserSettingsRow addedRow in UserSettings.Select("", "", DataViewRowState.Added))
                {
                    ds.UserSettings.ImportRow(addedRow);
                }
                foreach (UserSettingsRow modifiedCurrentRow in UserSettings.Select("", "", DataViewRowState.ModifiedCurrent))
                {
                    ds.UserSettings.ImportRow(modifiedCurrentRow);
                }

                if (UseWcfService)
                {
                    try
                    {
                        var svWCF = new WCF.SettingsContractClient();
                        var rqWCF = new WCF.UpdateUserSettingsRequest {
                            UserSettingsCD = new WCF.UserSettingsCD()
                        };
                        rqWCF.UserSettingsCD.Merge(ds, false, MissingSchemaAction.Ignore);

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

                            svWCF.BeginUpdateUserSettings(rqWCF, wcf_ClientUpdateUserSettingsCompleted, svWCF);
                            return(true);
                        }

                        WCF.UpdateUserSettingsResponse rsWCF = svWCF.UpdateUserSettings(rqWCF);
                        Merge(rsWCF.UserSettingsCD, 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.UpdateUserSettingsRequest {
                            UserSettingsCD = new ASMX.UserSettingsCD()
                        };
                        rqASMX.UserSettingsCD.Merge(ds, false, MissingSchemaAction.Ignore);

                        if (async)
                        {
                            svASMX.UpdateUserSettingsCompleted += asmx_ClientUpdateUserSettingsCompleted;
                            svASMX.UpdateUserSettingsAsync(rqASMX);
                            return(true);
                        }

                        ASMX.UpdateUserSettingsResponse rsASMX = svASMX.UpdateUserSettings(rqASMX);
                        Merge(rsASMX.UserSettingsCD, false, MissingSchemaAction.Ignore);
                        PrepareDataAfterUpdate();
                        return(true);
                    }
                    catch { UseAsmxService = false; }                     // ignore if not responding
                }
                if (UseClientServer)
                {
                    try
                    {
                        Merge(UpdateUserSettings(ds), false, MissingSchemaAction.Ignore);
                        PrepareDataAfterUpdate();
                        return(true);
                    }
                    catch { UseClientServer = false; }                     // ignore if not responding
                }
            }
            return(false);
        }
        /// <summary>
        /// Save the Grid Settings to the database from a DataGridView
        /// </summary>
        /// <param name="dataGridView">The DataGridView to derive the GridSettings from</param>
        /// <param name="async">Do the update async</param>
        /// <returns>true if replaced</returns>
        public bool ClientUpdateGridSettingsFromDataGridView(DataGridView dataGridView, bool async)
        {
            if (dataGridView == null || dataGridView.Columns.Count == 0)
            {
                throw new Exception("The DataGridView is null or empty.");
            }

            if (string.IsNullOrEmpty(_userName) || string.IsNullOrEmpty(_gridName))
            {
                throw new Exception("The UserName and/or GridName is null or empty.");
            }

            var             ds = new GridSettingsCD();
            GridSettingsRow gridSettingsRow;

            for (int i = 0; i < dataGridView.Columns.Count; i++)
            {
                gridSettingsRow = ds.GridSettings.NewGridSettingsRow();
                gridSettingsRow.SetDefaultValues();
                gridSettingsRow.UserName     = SystemInformation.UserName;
                gridSettingsRow.GridName     = _gridName;
                gridSettingsRow.ColumnName   = dataGridView.Columns[i].Name;
                gridSettingsRow.Visible      = dataGridView.Columns[i].Visible;
                gridSettingsRow.DisplayIndex = dataGridView.Columns[i].DisplayIndex;
                gridSettingsRow.Width        = dataGridView.Columns[i].Width;
                ds.GridSettings.AddGridSettingsRow(gridSettingsRow);
            }

            if (UseWcfService)
            {
                try
                {
                    var svWCF = new WCF.SettingsContractClient();
                    var rqWCF = new WCF.ReplaceGridSettingsRequest {
                        GridSettingsCD = new WCF.GridSettingsCD()
                    };
                    rqWCF.GridSettingsCD.Merge(ds, false, MissingSchemaAction.Ignore);

                    if (async)
                    {
                        svWCF.Ping();
                        svWCF.BeginReplaceGridSettings(rqWCF, wcf_ClientReplaceGridSettingsCompleted, svWCF);
                        return(true);
                    }

                    WCF.ReplaceGridSettingsResponse rsWCF = svWCF.ReplaceGridSettings(rqWCF);
                    return(rsWCF.ReplaceSuccessful);
                }
                catch { UseWcfService = false; }                 // ignore if not responding
            }
            if (UseAsmxService)
            {
                try
                {
                    var svASMX = new ASMX.SettingsServiceASMX();
                    var rqASMX = new ASMX.ReplaceGridSettingsRequest {
                        GridSettingsCD = new ASMX.GridSettingsCD()
                    };
                    rqASMX.GridSettingsCD.Merge(ds, false, MissingSchemaAction.Ignore);

                    if (async)
                    {
                        svASMX.ReplaceGridSettingsCompleted += asmx_ClientReplaceGridSettingsCompleted;
                        svASMX.ReplaceGridSettingsAsync(rqASMX);
                        return(true);
                    }

                    ASMX.ReplaceGridSettingsResponse rsASMX = svASMX.ReplaceGridSettings(rqASMX);
                    return(rsASMX.ReplaceSuccessful);
                }
                catch { UseAsmxService = false; }                 // ignore if not responding
            }
            if (UseClientServer)
            {
                try
                {
                    return(ReplaceGridSettings(ds));
                }
                catch { UseClientServer = false; }                 // ignore if not responding
            }

            return(false);
        }