示例#1
0
        /// <summary>
        /// Insert the specified <paramref name="maintainable"/> to the mapping store with <paramref name="state"/>
        /// </summary>
        /// <param name="state">
        /// The MAPPING STORE connection and transaction state
        /// </param>
        /// <param name="maintainable">
        /// The maintainable.
        /// </param>
        /// <param name="artefactStoredProcedure">
        /// The artefact Stored Procedure.
        /// </param>
        /// <param name="setupCommand">
        /// The setup Command. Use it to make additional changes to the command
        /// </param>
        /// <returns>
        /// The <see cref="ArtefactImportStatus"/>.
        /// </returns>
        protected ArtefactImportStatus InsertArtefactInternal(DbTransactionState state, T maintainable, ArtefactProcedurebase artefactStoredProcedure, Action <DbCommand> setupCommand)
        {
            ArtefactImportStatus artefactImportStatus;

            using (DbCommand command = artefactStoredProcedure.CreateCommandWithDefaults(state))
            {
                if (setupCommand != null)
                {
                    setupCommand(command);
                }

                artefactImportStatus = this.RunArtefactCommand(maintainable, command, artefactStoredProcedure);
            }

            return(artefactImportStatus);
        }
示例#2
0
 /// <summary>
 /// Insert the specified <paramref name="maintainable"/> to the mapping store with <paramref name="state"/>
 /// </summary>
 /// <param name="state">
 /// The MAPPING STORE connection and transaction state
 /// </param>
 /// <param name="maintainable">
 /// The maintainable.
 /// </param>
 /// <param name="artefactStoredProcedure">
 /// The artefact Stored Procedure.
 /// </param>
 /// <returns>
 /// The <see cref="ArtefactImportStatus"/>.
 /// </returns>
 protected ArtefactImportStatus InsertArtefactInternal(DbTransactionState state, T maintainable, ArtefactProcedurebase artefactStoredProcedure)
 {
     return(this.InsertArtefactInternal(state, maintainable, artefactStoredProcedure, null));
 }
示例#3
0
        /// <summary>
        /// Run common artefact import command.
        /// </summary>
        /// <param name="artefact">
        /// The artefact.
        /// </param>
        /// <param name="command">
        /// The command.
        /// </param>
        /// <param name="artefactStoredProcedure">
        /// The artefact stored procedure.
        /// </param>
        /// <returns>
        /// The <see cref="long"/>.
        /// </returns>
        protected long RunIdentifiableArterfactCommand(IIdentifiableObject artefact, DbCommand command, ArtefactProcedurebase artefactStoredProcedure)
        {
            DbParameter idParameter = artefactStoredProcedure.CreateIdParameter(command);

            idParameter.Value = artefact.Id ?? (object)DBNull.Value;

            DbParameter outputParameter = artefactStoredProcedure.CreateOutputParameter(command);

            command.ExecuteNonQuery();

            var artID = (long)outputParameter.Value;

            _annotationInsertEngine.Insert(new DbTransactionState(command.Transaction, this._database), artID, _insertArtefactAnnotation, artefact.Annotations);

            return(artID);
        }
示例#4
0
        /// <summary>
        /// Run common artefact import command.
        /// </summary>
        /// <param name="artefact">
        /// The artefact.
        /// </param>
        /// <param name="command">
        /// The command.
        /// </param>
        /// <param name="artefactStoredProcedure">
        /// The artefact stored procedure.
        /// </param>
        /// <returns>
        /// The <see cref="ArtefactImportStatus"/>.
        /// </returns>
        protected long RunNameableArtefactCommand(INameableObject artefact, DbCommand command, ArtefactProcedurebase artefactStoredProcedure)
        {
            var artID = this.RunIdentifiableArterfactCommand(artefact, command, artefactStoredProcedure);

            DbTransactionState state = new DbTransactionState(command.Transaction, this._database);

            _localisedStringInsertEngine.InsertForArtefact(artID, artefact, state.Database);

            return(artID);
        }
示例#5
0
        /// <summary>
        /// Run common artefact import command.
        /// </summary>
        /// <param name="artefact">
        /// The artefact.
        /// </param>
        /// <param name="command">
        /// The command.
        /// </param>
        /// <param name="artefactStoredProcedure">
        /// The artefact stored procedure.
        /// </param>
        /// <returns>
        /// The <see cref="ArtefactImportStatus"/>.
        /// </returns>
        protected ArtefactImportStatus RunArtefactCommand(IMaintainableObject artefact, DbCommand command, ArtefactProcedurebase artefactStoredProcedure)
        {
            DbParameter versionParameter = artefactStoredProcedure.CreateVersionParameter(command);

            versionParameter.Value = artefact.Version ?? (object)DBNull.Value;

            DbParameter agencyParameter = artefactStoredProcedure.CreateAgencyParameter(command);

            agencyParameter.Value = artefact.AgencyId ?? (object)DBNull.Value;

            DbParameter validFromParameter = artefactStoredProcedure.CreateValidFromParameter(command);

            if (artefact.StartDate != null)
            {
                validFromParameter.Value = artefact.StartDate.Date;
            }

            DbParameter validToParameter = artefactStoredProcedure.CreateValidToParameter(command);

            if (artefact.EndDate != null)
            {
                validToParameter.Value = artefact.EndDate.Date;
            }

            DbParameter uriParameter = artefactStoredProcedure.CreateUriParameter(command);

            if (artefact.Uri != null)
            {
                uriParameter.Value = artefact.Uri.ToString();
            }

            DbParameter isFinalParameter = artefactStoredProcedure.CreateIsFinalParameter(command);

            isFinalParameter.Value = artefact.IsFinal.IsTrue ? 1 : 0;

            var artID = this.RunNameableArtefactCommand(artefact, command, artefactStoredProcedure);

            // "Inserted artefact with ID:" + artefactGetID + " VERSION:" + artefact.version + " AGENCY:" + artefact.agencyID + Environment.NewLine;
            var structureReference = artefact.AsReference;
            var importMessage      = new ImportMessage(
                ImportMessageStatus.Success,
                structureReference,
                string.Format("Success: {0} was inserted.{1}", structureReference.GetAsHumanReadableString(), Environment.NewLine));

            return(new ArtefactImportStatus(artID, importMessage));
        }