Пример #1
0
        /// <summary>
        /// Get a specific Object's definition, this includes any attributes and supporting object properties.
        /// In this case retrieve the table definition along with any columns and the definition of each.
        /// </summary>
        /// <param name="methodInput">Method Input which includes an 'ObjectName'
        /// property to determine the object to retrieve the definition for.</param>
        /// <returns>Method Result which will either include error information or the
        /// Object Definition of the 'ObjectName' specified in the MethodInput properties</returns>
        public MethodResult GetObjectDefinition(MethodInput methodInput)
        {
            //Create a new instance of the method result to
            //fill with meta data information
            MethodResult result = new MethodResult();

            //create a new instance of the metadata access class and
            //pass the data access instance allong with it
            OleDbMetadataAccess metadataAccess = new OleDbMetadataAccess(_dataAccess);

            // Use LogMethodExecution to add entry and exit tracing to a method.
            // When wrapped in a using statement, the exit point
            //is written during garbage collection.
            using (new LogMethodExecution(
                       Globals.ConnectorName, "GetObjectDefinitionMethod"))
            {
                //get the name of the object in the input properties
                string objectName = GetPropertyValue(
                    "ObjectName", methodInput.Input.Properties);

                //using the meta data access get the definitions
                //for each of the columns in the table
                DataTable tableColumnDefinitions =
                    metadataAccess.GetColumnDefinitions(objectName);

                //using the meta data access get the definition for
                //the table indexes (primary and foreign keys)
                DataTable tableIndexDefinition =
                    metadataAccess.GetTableIndexInformation(objectName);

                //check that both sets of data have been
                //returned from the meta data access layer
                if ((tableColumnDefinitions != null &&
                     tableColumnDefinitions.Rows.Count != 0) &&
                    (tableIndexDefinition != null &&
                     tableIndexDefinition.Rows.Count != 0))
                {
                    //create a new replication service object
                    RSObjectDefinition rsObjectDefinition = new RSObjectDefinition()
                    {
                        Name = objectName,
                        RSPropertyDefinitions = new List <RSPropertyDefinition>()
                    };

                    List <string> tablePrimaryKeys =
                        GetTablePrimaryKeys(rsObjectDefinition.Name, metadataAccess);

                    //parse through each column return from the column definitions and
                    //add a new replication service property definition to the newly created
                    //replication service object definition for each column in the table
                    foreach (DataRow columnDefinition in tableColumnDefinitions.Rows)
                    {
                        //process the column definition and set it
                        //to the resplication service property definition
                        RSPropertyDefinition rsPropertyDefinition =
                            ProcessColumnDefinition(columnDefinition);

                        //check if this is the default last
                        //modified column and set the object property
                        if (rsPropertyDefinition.Name == LastModifiedFieldName)
                        {
                            rsObjectDefinition.ModificationDateFullName =
                                rsPropertyDefinition.Name;
                        }

                        //check if the property is a primary key value
                        rsPropertyDefinition.InPrimaryKey =
                            tablePrimaryKeys.Contains(rsPropertyDefinition.Name);

                        //add the property definition to the object definition
                        rsObjectDefinition.RSPropertyDefinitions.Add(rsPropertyDefinition);
                    }

                    //Convert the replication service object definition to a Data Entity
                    //set the result return value to the replication service object defintion
                    //set the result success to true
                    result = new MethodResult {
                        Success = true, Return = rsObjectDefinition.ToDataEntity()
                    };
                }
                else
                {
                    result = new MethodResult {
                        Success = false, ErrorInfo = new ErrorResult {
                            Description = ErrorCodes.ObjectNotFound.Description, Number = ErrorCodes.ObjectNotFound.Number
                        }
                    };
                }
            }

            //return the method result
            return(result);
        }
Пример #2
0
        /// <summary>
        /// Get a specific Object's definition, this includes any attributes and
        /// supporting object properties.
        /// In this case retrieve the table definition along with any columns and
        /// the definition of each.
        /// </summary>
        /// <param name="methodInput">Method Input which includes an 'ObjectName'
        /// property to determine the object to retrieve the definition.</param>
        /// <returns>Method Result, which will either include error information or the
        /// Object Definition of the 'ObjectName' specified in the
        /// MethodInput properties.</returns>
        public MethodResult GetObjectDefinition(MethodInput methodInput)
        {
            //Create a new instance of the method result to fill with
            //meta data information
            MethodResult result = null;

            //Create a new instance of the metadata access class and pass the
            //data access instance along with it
            OleDbMetadataAccess metadataAccess = new OleDbMetadataAccess(_dataAccess);

            // Use LogMethodExecution to add entry and exit tracing to a method.
            // When wrapped in a using statement, the exit point
            // is written during garbage collection.
            using (new LogMethodExecution(
                       Globals.ConnectorName, "GetObjectDefinition"))
            {
                //Get the name of the object in the input properties.
                string objectName =
                    GetPropertyValueName("ObjectName", methodInput.Input.Properties);

                //Use the metadata access to get the
                //definitions for each of the columns in the table.
                DataTable tableColumnDefinitions =
                    metadataAccess.GetColumnDefinitions(objectName);

                //Using the meta data access get the definition for the
                //table indexes (primary and foreign keys)
                DataTable tableIndexDefinition =
                    metadataAccess.GetTableIndexInformation(objectName);

                //Check that both sets of data have been returned
                //from the meta data access layer
                if ((tableColumnDefinitions != null &&
                     tableColumnDefinitions.Rows.Count != 0) &&
                    (tableIndexDefinition != null &&
                     tableIndexDefinition.Rows.Count != 0))
                {
                    //Create a new replication service object
                    RSObjectDefinition rsObjectDefinition = new RSObjectDefinition()
                    {
                        Name = objectName,
                        RSPropertyDefinitions = new List <RSPropertyDefinition>()
                    };

                    //If this is the change history table set the hidden attribute.
                    //Note: this is how to prevent an object from being replicated.
                    rsObjectDefinition.Hidden = objectName == Globals.ChangeHistoryTableName;

                    List <string> tablePrimaryKeys =
                        GetTablePrimaryKeys(rsObjectDefinition.Name, metadataAccess);

                    //Parse each column returned from the column definitions.
                    //For each column, add a new replication service property definition
                    //to the newly created replication service object definition.
                    foreach (DataRow columnDefinition in tableColumnDefinitions.Rows)
                    {
                        //Process the column definition and set it to the
                        //resplication service property definition.
                        RSPropertyDefinition rsPropertyDefinition =
                            ProcessColumnDefinition(columnDefinition);

                        //Check if this is the default last modified column and
                        //set the object property.
                        if (rsPropertyDefinition.Name == LastModifiedFieldName)
                        {
                            rsObjectDefinition.ModificationDateFullName =
                                rsPropertyDefinition.Name;
                        }

                        //Check if the property is a primary key value.
                        rsPropertyDefinition.InPrimaryKey =
                            tablePrimaryKeys.Contains(rsPropertyDefinition.Name);

                        //Add the property definition to the object definition.
                        rsObjectDefinition.RSPropertyDefinitions.Add(rsPropertyDefinition);
                    }

                    //Convert the replication service object definition to a Data Entity.
                    //Set the result return value to the
                    //replication service object definition.
                    //Set the result Success to true.
                    result = new MethodResult
                    {
                        Success = true, Return = rsObjectDefinition.ToDataEntity()
                    };
                }
                else
                {
                    //Set the proper error information in the method result in the
                    //event of a null table or column definitions.
                    result = SetErrorMethodResult(
                        ErrorCodes.NoObjectsFound.Number,
                        ErrorCodes.NoObjectsFound.Description);
                }
            }

            //Return the method result.
            return(result);
        }
Пример #3
0
        /// <summary>
        /// Get a specific Object's definition, this includes any attributes and supporting object properties.
        /// In this case retrieve the table definition along with any columns and the definition of each.
        /// </summary>
        /// <param name="methodInput">Method Input which includes an 'ObjectName' 
        /// property to determine the object to retrieve the definition for.</param>
        /// <returns>Method Result which will either include error information or the 
        /// Object Definition of the 'ObjectName' specified in the MethodInput properties</returns>
        public MethodResult GetObjectDefinition(MethodInput methodInput)
        {
            //Create a new instance of the method result to
            //fill with meta data information
            MethodResult result = new MethodResult();

            //create a new instance of the metadata access class and
            //pass the data access instance allong with it
            OleDbMetadataAccess metadataAccess = new OleDbMetadataAccess(_dataAccess);

            // Use LogMethodExecution to add entry and exit tracing to a method.
            // When wrapped in a using statement, the exit point
            //is written during garbage collection.
            using (new LogMethodExecution(
                Globals.ConnectorName, "GetObjectDefinitionMethod"))
            {
                //get the name of the object in the input properties
                string objectName = GetPropertyValue(
                    "ObjectName", methodInput.Input.Properties);

                //using the meta data access get the definitions
                //for each of the columns in the table
                DataTable tableColumnDefinitions =
                    metadataAccess.GetColumnDefinitions(objectName);

                //using the meta data access get the definition for
                //the table indexes (primary and foreign keys)
                DataTable tableIndexDefinition =
                    metadataAccess.GetTableIndexInformation(objectName);

                //check that both sets of data have been
                //returned from the meta data access layer
                if ((tableColumnDefinitions != null
                    && tableColumnDefinitions.Rows.Count != 0)
                    && (tableIndexDefinition != null
                    && tableIndexDefinition.Rows.Count != 0))
                {
                    //create a new replication service object
                    RSObjectDefinition rsObjectDefinition = new RSObjectDefinition()
                    {
                        Name = objectName,
                        RSPropertyDefinitions = new List<RSPropertyDefinition>()
                    };

                    List<string> tablePrimaryKeys =
                        GetTablePrimaryKeys(rsObjectDefinition.Name, metadataAccess);

                    //parse through each column return from the column definitions and
                    //add a new replication service property definition to the newly created
                    //replication service object definition for each column in the table
                    foreach (DataRow columnDefinition in tableColumnDefinitions.Rows)
                    {
                        //process the column definition and set it
                        //to the resplication service property definition
                        RSPropertyDefinition rsPropertyDefinition =
                            ProcessColumnDefinition(columnDefinition);

                        //check if this is the default last
                        //modified column and set the object property
                        if (rsPropertyDefinition.Name == LastModifiedFieldName)
                        {
                            rsObjectDefinition.ModificationDateFullName =
                                rsPropertyDefinition.Name;
                        }

                        //check if the property is a primary key value
                        rsPropertyDefinition.InPrimaryKey =
                            tablePrimaryKeys.Contains(rsPropertyDefinition.Name);

                        //add the property definition to the object definition
                        rsObjectDefinition.RSPropertyDefinitions.Add(rsPropertyDefinition);
                    }

                    //Convert the replication service object definition to a Data Entity
                    //set the result return value to the replication service object defintion
                    //set the result success to true
                    result = new MethodResult { Success = true, Return = rsObjectDefinition.ToDataEntity() };
                }
                else
                {
                    result = new MethodResult { Success = false, ErrorInfo = new ErrorResult { Description = ErrorCodes.ObjectNotFound.Description, Number = ErrorCodes.ObjectNotFound.Number } };
                }
            }

            //return the method result
            return result;
        }
Пример #4
0
        /// <summary>
        /// Get a specific Object's definition, this includes any attributes and
        /// supporting object properties.
        /// In this case retrieve the table definition along with any columns and
        /// the definition of each.
        /// </summary>
        /// <param name="methodInput">Method Input which includes an 'ObjectName' 
        /// property to determine the object to retrieve the definition.</param>
        /// <returns>Method Result, which will either include error information or the 
        /// Object Definition of the 'ObjectName' specified in the 
        /// MethodInput properties.</returns>
        public MethodResult GetObjectDefinition(MethodInput methodInput)
        {
            //Create a new instance of the method result to fill with
            //meta data information
            MethodResult result = null;

            //Create a new instance of the metadata access class and pass the
            //data access instance along with it
            OleDbMetadataAccess metadataAccess = new OleDbMetadataAccess(_dataAccess);

            // Use LogMethodExecution to add entry and exit tracing to a method.
            // When wrapped in a using statement, the exit point
            // is written during garbage collection.
            using (new LogMethodExecution(
                Globals.ConnectorName, "GetObjectDefinition"))
            {
                //Get the name of the object in the input properties.
                string objectName =
                    GetPropertyValueName("ObjectName", methodInput.Input.Properties);

                //Use the metadata access to get the
                //definitions for each of the columns in the table.
                DataTable tableColumnDefinitions =
                    metadataAccess.GetColumnDefinitions(objectName);

                //Using the meta data access get the definition for the
                //table indexes (primary and foreign keys)
                DataTable tableIndexDefinition =
                    metadataAccess.GetTableIndexInformation(objectName);

                //Check that both sets of data have been returned
                //from the meta data access layer
                if ((tableColumnDefinitions != null
                    && tableColumnDefinitions.Rows.Count != 0) &&
                    (tableIndexDefinition != null
                    && tableIndexDefinition.Rows.Count != 0))
                {
                    //Create a new replication service object
                    RSObjectDefinition rsObjectDefinition = new RSObjectDefinition()
                    {
                        Name = objectName,
                        RSPropertyDefinitions = new List<RSPropertyDefinition>()
                    };

                    //If this is the change history table set the hidden attribute.
                    //Note: this is how to prevent an object from being replicated.
                    rsObjectDefinition.Hidden = objectName == Globals.ChangeHistoryTableName;

                    List<string> tablePrimaryKeys =
                        GetTablePrimaryKeys(rsObjectDefinition.Name, metadataAccess);

                    //Parse each column returned from the column definitions.
                    //For each column, add a new replication service property definition
                    //to the newly created replication service object definition.
                    foreach (DataRow columnDefinition in tableColumnDefinitions.Rows)
                    {
                        //Process the column definition and set it to the
                        //resplication service property definition.
                        RSPropertyDefinition rsPropertyDefinition =
                            ProcessColumnDefinition(columnDefinition);

                        //Check if this is the default last modified column and
                        //set the object property.
                        if (rsPropertyDefinition.Name == LastModifiedFieldName)
                        {
                            rsObjectDefinition.ModificationDateFullName =
                                rsPropertyDefinition.Name;
                        }

                        //Check if the property is a primary key value.
                        rsPropertyDefinition.InPrimaryKey =
                            tablePrimaryKeys.Contains(rsPropertyDefinition.Name);

                        //Add the property definition to the object definition.
                        rsObjectDefinition.RSPropertyDefinitions.Add(rsPropertyDefinition);
                    }

                    //Convert the replication service object definition to a Data Entity.
                    //Set the result return value to the
                    //replication service object definition.
                    //Set the result Success to true.
                    result = new MethodResult
                    { Success = true, Return = rsObjectDefinition.ToDataEntity() };
                }
                else
                {
                    //Set the proper error information in the method result in the
                    //event of a null table or column definitions.
                    result = SetErrorMethodResult(
                        ErrorCodes.NoObjectsFound.Number,
                        ErrorCodes.NoObjectsFound.Description);
                }

            }

            //Return the method result.
            return result;
        }