Ejemplo n.º 1
0
        /// <summary>
        /// Service callable code to Delete/Insert/Update Grid Filters
        /// </summary>
        /// <param name="ds">A DataSet of type GridFiltersCD</param>
        /// <returns>A GridFiltersCD. If ALL updated OK contains updated data, if not contains the RowErrors</returns>
        public static GridFiltersCD UpdateGridFilters(DataSet ds)
        {
            if (ds == null || ds.Tables["GridFilters"] == null)
            {
                throw new Exception("The DataSet and/or DataTable is null.");
            }

            var clientDataSet = new GridFiltersCD();

            clientDataSet.Merge(ds, false, MissingSchemaAction.Ignore);

            #region Update GridFilters

            if (clientDataSet.GridFilters.Select("", "", DataViewRowState.Added).Length > 0)
            {
                var gridFiltersTD = new GridFiltersTD();
                gridFiltersTD.GridFilters.BeginLoadData();
                gridFiltersTD.GridFilters.Merge(clientDataSet.GridFilters, false, MissingSchemaAction.Ignore);

                using (var ts = new TransactionScope(TransactionScopeOption.Required))
                {
                    GridFiltersTD.UpdateGridFilters(gridFiltersTD);
                    ts.Complete();
                }
            }
            #endregion

            return(clientDataSet);
        }
Ejemplo n.º 2
0
        /// <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
                }
            }
        }
Ejemplo n.º 3
0
        /// <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);
        }