Ejemplo n.º 1
0
        /// <summary>
        /// Execute additional logic after each write function call.
        /// </summary>
        /// <param name="writeResult">
        /// The result of the write function Result.
        /// </param>
        /// <param name="transaction">
        /// The transaction.
        /// </param>
        /// <param name="partition">
        /// The partition.
        /// </param>
        /// <param name="thing">
        /// The thing.
        /// </param>
        /// <param name="container">
        /// The container.
        /// </param>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        public new bool AfterWrite(bool writeResult, NpgsqlTransaction transaction, string partition, Thing thing, Thing container)
        {
            var result = base.AfterWrite(writeResult, transaction, partition, thing, container);

            var engineeringModelSetup = (EngineeringModelSetup)thing;

            // insert the engineeringmodel schema
            var replacementInfo = new List <Tuple <string, string> >();

            replacementInfo.Add(new Tuple <string, string>(
                                    "EngineeringModel_REPLACE",
                                    string.Format("{0}", Utils.GetEngineeringModelSchemaName(engineeringModelSetup.EngineeringModelIid))));

            // support iteration sub partition (schema) which will have the same engineeringmodel identifier applied
            replacementInfo.Add(new Tuple <string, string>(
                                    "Iteration_REPLACE",
                                    string.Format("{0}", Utils.GetEngineeringModelIterationSchemaName(engineeringModelSetup.EngineeringModelIid))));

            using (var command = new NpgsqlCommand())
            {
                command.ReadSqlFromResource(
                    "CDP4Orm.AutoGenStructure.EngineeringModelDefinition.sql",
                    replace: replacementInfo);

                command.Connection  = transaction.Connection;
                command.Transaction = transaction;

                this.ExecuteAndLogCommand(command);
            }

            return(result);
        }