예제 #1
0
 internal static Exception InvalidSyncTableName(string tableName)
 {
     return((Exception)SyncExpt.Argument(SyncResource.FormatString("InvalidTableName", new object[1]
     {
         (object)tableName
     })));
 }
예제 #2
0
        internal void Validate(int index, SyncColumnMapping item)
        {
            if (item == null)
            {
                throw SyncExpt.ArgumentNull("item");
            }
            if (item.Parent != null && this != item.Parent)
            {
                throw SyncExpt.Argument("", "item.Parent");
            }
            string serverColumn1 = item.ServerColumn;

            if (SyncUtil.IsEmpty(serverColumn1))
            {
                index = 1;
                string serverColumn2;
                do
                {
                    serverColumn2 = "ServerColumn" + index.ToString((IFormatProvider)CultureInfo.InvariantCulture);
                    ++index;
                }while (-1 != this.IndexOfServerColumn(serverColumn2));
                item.ServerColumn = serverColumn2;
            }
            else
            {
                this.ValidateServerColumn(index, serverColumn1);
            }
            string clientColumn = item.ClientColumn;

            this.ValidateClientColumn(index, clientColumn);
        }
예제 #3
0
 internal static void CheckArgumentNull(object value, string parameterName)
 {
     if (value == null)
     {
         throw SyncExpt.ArgumentNull(parameterName);
     }
 }
예제 #4
0
 internal static ArgumentException ParameterNotSet(string parameter)
 {
     return(SyncExpt.Argument(SyncResource.FormatString("ParameterNotSet", new object[1]
     {
         (object)parameter
     })));
 }
예제 #5
0
 internal static ArgumentException MaxSyncAnchorSize(int maxAnchorSize)
 {
     return(SyncExpt.Argument(SyncResource.FormatString("MaxSyncAnchorSize", new object[1]
     {
         (object)maxAnchorSize.ToString((IFormatProvider)CultureInfo.InvariantCulture)
     })));
 }
예제 #6
0
 internal static Exception SyncTableBelongsToDifferentCollection(string tableName)
 {
     return((Exception)SyncExpt.Argument(SyncResource.FormatString("SyncTableParentExists", new object[1]
     {
         (object)tableName
     })));
 }
예제 #7
0
 internal static Exception SqlChangeTrackingNotEnabled(string tableName)
 {
     return((Exception)SyncExpt.Argument(SyncResource.FormatString("SqlChangeTrackingNotEnabled", new object[1]
     {
         (object)tableName
     })));
 }
예제 #8
0
 internal static ArgumentException MaxNumberOfCustomParameters(int maxCustomParameters)
 {
     return(SyncExpt.Argument(SyncResource.FormatString("MaxNumberOfCustomParameters", new object[1]
     {
         (object)maxCustomParameters.ToString((IFormatProvider)CultureInfo.InvariantCulture)
     })));
 }
예제 #9
0
 internal static Exception DuplicateSyncParameterName(string parameterName)
 {
     return((Exception)SyncExpt.Argument(SyncResource.FormatString("DuplicateParamName", new object[1]
     {
         (object)parameterName
     })));
 }
예제 #10
0
 internal static Exception DuplicateSyncAdapter(string tableName)
 {
     return((Exception)SyncExpt.Argument(SyncResource.FormatString("SyncAdapterAlreadyExists", new object[1]
     {
         (object)tableName
     })));
 }
예제 #11
0
        internal void ValidateClientColumn(int index, string value)
        {
            int num = this.IndexOfClientColumn(value);

            if (-1 != num && index != num)
            {
                throw SyncExpt.Argument("not unique");
            }
        }
예제 #12
0
        internal static bool OpenConnection(IDbConnection connection)
        {
            SyncExpt.CheckArgumentNull((object)connection, "connection");
            bool flag = false;

            switch (connection.State)
            {
            case ConnectionState.Closed:
                if (SyncTracer.IsVerboseEnabled())
                {
                    if (connection is SqlConnection)
                    {
                        SqlConnectionStringBuilder connectionStringBuilder = new SqlConnectionStringBuilder();
                        connectionStringBuilder.ConnectionString = connection.ConnectionString;
                        if (!string.IsNullOrEmpty(connectionStringBuilder.Password))
                        {
                            connectionStringBuilder.Password = "******";
                        }
                        SyncTracer.Verbose("Connecting using string: {0}", new object[1]
                        {
                            (object)connectionStringBuilder.ConnectionString
                        });
                    }
                    else
                    {
                        SyncTracer.Verbose("Connecting to database: {0}", new object[1]
                        {
                            (object)connection.Database
                        });
                    }
                }
                if (connection is SqlConnection || connection is IConnectionWrapper)
                {
                    SyncUtil.TryOpenConnection(connection);
                }
                else
                {
                    connection.Open();
                }
                flag = true;
                goto case ConnectionState.Open;

            case ConnectionState.Open:
                return(flag);

            case ConnectionState.Broken:
                SyncTracer.Verbose("Closing broken connection");
                connection.Close();
                goto case ConnectionState.Closed;

            default:
                throw new DbSyncException(SyncResource.FormatString("UnhandledConnectionState", new object[1]
                {
                    (object)((object)connection.State).ToString()
                }));
            }
        }
예제 #13
0
 internal void MapFromClientToServer(DataTable dataTable)
 {
     SyncExpt.CheckArgumentNull((object)dataTable, "dataTable");
     if (this.ColumnMappings == null)
     {
         return;
     }
     foreach (DataColumn dataColumn in (InternalDataCollectionBase)dataTable.Columns)
     {
         int index = this.ColumnMappings.IndexOfClientColumn(dataColumn.ColumnName);
         if (index >= 0)
         {
             dataColumn.ColumnName = this.ColumnMappings[index].ServerColumn;
         }
     }
 }
예제 #14
0
 internal static Exception InvalidSyncParameterObject()
 {
     return((Exception)SyncExpt.Argument(SyncResource.GetString("InvalidParamObject")));
 }
예제 #15
0
 internal static ArgumentException MaxSizeOfCustomParameter()
 {
     return(SyncExpt.Argument(SyncResource.GetString("MaxSizeOfCustomParameter")));
 }
예제 #16
0
 internal static ArgumentException ColumnNotInTable(string table, string column)
 {
     return(SyncExpt.Argument(SyncResource.FormatString("SyncSchema_ColumnNotInTable", (object)column, (object)table)));
 }
예제 #17
0
 internal static ArgumentException InvalidConnectionArgument()
 {
     return(SyncExpt.Argument(SyncResource.GetString("InvalidConnectionArgument")));
 }
예제 #18
0
 internal static ArgumentOutOfRangeException InvalidEnumerationValue(Type type, int value)
 {
     return(SyncExpt.ArgumentOutOfRange(SyncResource.FormatString("InvalidEnumValue", (object)type.ToString(), (object)value.ToString((IFormatProvider)CultureInfo.InvariantCulture))));
 }
예제 #19
0
 internal static Exception DuplicateSyncTable(string tableName, string syncGroupName)
 {
     return((Exception)SyncExpt.Argument(SyncResource.FormatString("SyncTableAlreadyExists", (object)tableName, (object)syncGroupName)));
 }
예제 #20
0
 internal static Exception InvalidScopeIdType(string command, string parameterName, string parameterType)
 {
     return((Exception)SyncExpt.Argument(SyncResource.FormatString("InvalidScopeIdType", (object)command, (object)parameterName, (object)parameterType)));
 }
예제 #21
0
 internal static ArgumentOutOfRangeException InvalidCatalogLocation(CatalogLocation value)
 {
     return(SyncExpt.InvalidEnumerationValue(typeof(CatalogLocation), (int)value));
 }
예제 #22
0
 internal static Exception InvalidSyncAdapterObject()
 {
     return((Exception)SyncExpt.Argument(SyncResource.GetString("SyncAdapterCollection_Add_InvalidType")));
 }
예제 #23
0
        /// <summary>
        /// Populates the schema information for the table that is specified in <see cref="P:Microsoft.Synchronization.Data.Server.SyncAdapter.TableName"/>.
        /// </summary>
        ///
        /// <returns>
        /// A <see cref="T:System.Data.DataTable"/> that contains the schema information.
        /// </returns>
        /// <param name="dataTable">The <see cref="T:System.Data.DataTable"/> to be populated with schema information.</param><param name="connection">An <see cref="T:System.Data.IDbConnection"/> object that is used to connect to the server database.</param><exception cref="T:System.ArgumentNullException"><paramref name="connection"/> is a null.</exception><exception cref="T:Microsoft.Synchronization.Data.SchemaException"><see cref="P:Microsoft.Synchronization.Data.Server.SyncAdapter.SelectIncrementalInsertsCommand"/> or <see cref="P:Microsoft.Synchronization.Data.Server.SyncAdapter.SelectIncrementalUpdatesCommand"/>  is a null, or the schema could not be retrieved.</exception>
        public DataTable FillSchema(DataTable dataTable, IDbConnection connection)
        {
            SyncExpt.CheckArgumentNull((object)connection, "connection");
            bool flag = SyncUtil.OpenConnection(connection);

            if (this.SelectIncrementalInsertsCommand == null && this.SelectIncrementalUpdatesCommand == null)
            {
                throw SyncExpt.MissingSelectStatementError(this.TableName, "ServerSyncProvider", "http://www.microsoft.com/sql/");
            }
            IDbCommand cmd = this.SelectIncrementalInsertsCommand == null ? this.SelectIncrementalUpdatesCommand : this.SelectIncrementalInsertsCommand;

            SetDummySessionParameters(cmd);
            cmd.Connection = connection;
            SyncDbAdapter syncDbAdapter = new SyncDbAdapter();

            syncDbAdapter.SelectCommand = (DbCommand)cmd;
            if (dataTable == null)
            {
                dataTable        = new DataTable();
                dataTable.Locale = CultureInfo.InvariantCulture;
            }
            syncDbAdapter.FillSchema(dataTable, SchemaType.Source);
            IDataReader dataReader = cmd.ExecuteReader(CommandBehavior.SchemaOnly | CommandBehavior.KeyInfo);

            try
            {
                DataTable schemaTable = dataReader.GetSchemaTable();
                if (schemaTable == null)
                {
                    throw SyncExpt.FillSchemaError(dataTable.TableName, "ServerSyncProvider", "http://www.microsoft.com/sql/", (Exception)null);
                }
                if (schemaTable.Columns.Contains("DataTypeName"))
                {
                    foreach (DataRow dataRow in (InternalDataCollectionBase)schemaTable.Rows)
                    {
                        string name = (string)dataRow["ColumnName"];
                        if (dataTable.Columns.Contains(name))
                        {
                            DataColumn column = dataTable.Columns[name];
                            if (column != null)
                            {
                                object obj1 = dataRow["DataTypeName"];
                                if (obj1 != null)
                                {
                                    SetDataColumnExtendedProperty(column, "DataTypeName", (object)obj1.ToString());
                                }
                                if (column.DataType.Equals(Type.GetType("System.Decimal")))
                                {
                                    object obj2 = dataRow["NumericPrecision"];
                                    if (obj2 != null)
                                    {
                                        SetDataColumnExtendedProperty(column, "NumericPrecision", obj2);
                                    }
                                    object obj3 = dataRow["NumericScale"];
                                    if (obj3 != null)
                                    {
                                        SetDataColumnExtendedProperty(column, "NumericScale", obj3);
                                    }
                                }
                                object obj4 = dataRow["ColumnSize"];
                                if (obj4 != null)
                                {
                                    if ((int.MaxValue == (int)obj4 || 1073741823 == (int)obj4) && (column.DataType.Equals(Type.GetType("System.String")) || column.DataType.Equals(Type.GetType("System.Byte[]"))))
                                    {
                                        SetDataColumnExtendedProperty(column, "ColumnLength", (object)-1);
                                    }
                                    else
                                    {
                                        SetDataColumnExtendedProperty(column, "ColumnLength", obj4);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (DbException ex)
            {
                throw SyncExpt.FillSchemaError(dataTable.TableName, "ServerSyncProvider", "http://www.microsoft.com/sql/", (Exception)ex);
            }
            finally
            {
                dataReader.Close();
            }
            if (flag)
            {
                connection.Close();
            }
            this.MapFromServerToClient(dataTable);
            return(dataTable);
        }
예제 #24
0
 internal static Exception InvalidSyncGroupName()
 {
     return((Exception)SyncExpt.Argument(SyncResource.GetString("InvalidGroupName"), "GroupName"));
 }