Example #1
0
        private void truncateSyncTable()
        {
            if (Synchronization != null)
            {
                using (var sync = Synchronization.CreateConnection())
                {
                    using (var truncate = sync.CreateCommand())
                    {
                        truncate.CommandText = String.Format("TRUNCATE TABLE [{0}].[{1}].[SyncItem];", syncDBCatalog, ConnectionsAccess.Profile.LoginName.nullToEmpty());
                        int rowsAffected;
                        try
                        {
                            sync.Open();
                            rowsAffected = truncate.ExecuteNonQuery();
                        }
                        finally
                        {
                            sync.Close();
                        }

                        _Log.InfoFormat("Sync table truncated. {0} rows affected", rowsAffected);
                    }
                }
            }
            else
            {
                _Log.Error("Cannot truncate sync table. Sync Serializer is null.");
            }
        }
        public bool truncateSyncTable()
        {
            if (stateHasFlag(State, ConnectionState.ConnectedToSynchronization) && Synchronization != null)
            {
                using (var sync = Synchronization.CreateConnection())
                {
                    using (var truncate = sync.CreateCommand())
                    {
                        truncate.CommandText = String.Format("TRUNCATE TABLE [{0}].[{1}].[SyncItem];", SYNCDB_CATALOG, _userName);
                        int rowsAffected;
                        try
                        {
                            sync.Open();
                            rowsAffected = truncate.ExecuteNonQuery();
                        }
                        catch (Exception ex)
                        {
                            _Log.ErrorFormat("Exception truncating Sync Table: [{0}]", ex);
                            return(false);
                        }
                        finally
                        {
                            sync.Close();
                        }

                        _Log.InfoFormat("Sync table truncated. {0} rows affected", rowsAffected);

                        return(true);
                    }
                }
            }
            else
            {
                _Log.Info("Cannot Truncate SyncTable, No Connection");
            }

            return(false);
        }