Esempio n. 1
0
        internal override void UpdateExisting(IMigrationTransaction trx)
        {
            //ToDo
            throw new NotImplementedException();

            /*
             * Debug.Assert(ActionId > 0);
             *
             * MigrationSqlTransaction sqlTrx = (MigrationSqlTransaction)trx;
             *
             * using (SqlCommand cmd = sqlTrx.CreateCommand())
             * {
             *  cmd.CommandType = CommandType.StoredProcedure;
             *  cmd.CommandText = "prc_iiUpdateActionState";
             *
             *  cmd.Parameters.Add("@ActionId", SqlDbType.Int).Value = ActionId;
             *  cmd.Parameters.Add("@State", SqlDbType.Int).Value = State;
             *
             *  int rows = DataAccessManager.ExecuteNonQuery(cmd);
             *
             *  Debug.Assert(rows == 1);
             *
             *  if (rows != 1)
             *  {
             *      throw new MigrationException(
             *          string.Format(
             *          MigrationToolkitResources.Culture,
             *          MigrationToolkitResources.WrongRowCountUpdatingActions,
             *          rows)
             *          );
             *  }
             * }*/
        }
        internal override void UpdateExisting(IMigrationTransaction trx)
        {
            Debug.Assert(ActionId > 0);

            MigrationSqlTransaction sqlTrx = (MigrationSqlTransaction)trx;

            using (SqlCommand cmd = sqlTrx.CreateCommand())
            {
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "prc_iiUpdateActionState";

                cmd.Parameters.Add("@ActionId", SqlDbType.Int).Value = ActionId;
                cmd.Parameters.Add("@State", SqlDbType.Int).Value    = State;

                int rows = DataAccessManager.ExecuteNonQuery(cmd);

                Debug.Assert(rows == 1);

                if (rows != 1)
                {
                    throw new MigrationException(
                              string.Format(
                                  MigrationToolkitVCResources.Culture,
                                  MigrationToolkitVCResources.WrongRowCountUpdatingActions,
                                  rows)
                              );
                }
            }
        }
 internal override void CreateNew()
 {
     using (IMigrationTransaction trx = DataAccessManager.Current.StartTransaction())
     {
         CreateNew(trx);
         trx.Complete();
     }
 }
 internal override void UpdateExisting()
 {
     using (IMigrationTransaction trx = DataAccessManager.Current.StartTransaction())
     {
         UpdateExisting(trx);
         trx.Complete();
     }
 }
Esempio n. 5
0
 internal override int DemoteInProgressActionsToPending(IMigrationTransaction trx)
 {
     using (RuntimeEntityModel context = RuntimeEntityModel.CreateInstance())
     {
         //context.PromoteChangeGroups(new Guid(Session.SessionUniqueId), SourceId, (int)ChangeStatus.InProgress, (int)ChangeStatus.Pending);
         context.BatchUpdateChangeGroupsStatus(new Guid(Session.SessionUniqueId), SourceId, (int)ChangeStatus.InProgress, (int)ChangeStatus.Pending);
         // ToDo Bugbug, need to return the real value
     }
     return(0);
 }
        internal override void CreateNew(IMigrationTransaction trx)
        {
            Debug.Assert(ActionId == -1);

            MigrationSqlTransaction sqlTrx = (MigrationSqlTransaction)trx;

            /* this should only be run under an existing transaction scope */

            using (SqlCommand cmd = sqlTrx.CreateCommand())
            {
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "prc_iiCreateActionData";

                cmd.Parameters.Add("@ChangeGroupID", SqlDbType.Int).Value = ChangeGroup.ChangeGroupId;

                cmd.Parameters.Add("@Order", SqlDbType.Int).Value = Order;

                cmd.Parameters.Add("@State", SqlDbType.Int).Value = State;

                cmd.Parameters.Add("@SourceItem", SqlDbType.Xml).Value
                    = (SourceItem != null) ? (object)ChangeGroup.Manager.SourceSerializer.SerializeItem(SourceItem) : (object)DBNull.Value;

                cmd.Parameters.Add("@TargetSourceItem", SqlDbType.Xml).Value
                    = (TargetSourceItem != null) ? (object)ChangeGroup.Manager.TargetSerializer.SerializeItem(TargetSourceItem) : (object)DBNull.Value;

                cmd.Parameters.Add("@TargetTargetItem", SqlDbType.Xml).Value
                    = (TargetTargetItem != null) ? (object)ChangeGroup.Manager.TargetSerializer.SerializeItem(TargetTargetItem) : (object)DBNull.Value;

                cmd.Parameters.Add("@BasicAction", SqlDbType.Int).Value = Action;
                cmd.Parameters.Add("@Recursivity", SqlDbType.Bit).Value = Recursive;

                cmd.Parameters.Add("@Label", SqlDbType.NVarChar).Value
                    = (Label != null) ? Label : (object)DBNull.Value;

                cmd.Parameters.Add("@Version", SqlDbType.NVarChar).Value
                    = (Version != null) ? Version : (object)DBNull.Value;

                cmd.Parameters.Add("@MergeVersionTo", SqlDbType.NVarChar).Value
                    = (MergeVersionTo != null) ? MergeVersionTo : (object)DBNull.Value;

                int identity;
                if (DataAccessManager.TryExecuteScalar <int>(cmd, out identity))
                {
                    ActionId = identity;
                }
                else
                {
                    throw new MigrationException(MigrationToolkitVCResources.FailureCreatingNewActionRow);
                }
            }
        }
Esempio n. 7
0
 internal override int PromoteAnalysisToPending(IMigrationTransaction trx)
 {
     return(SqlChangeGroup.PromoteAnalysisToPending(trx, Session.SessionUniqueId, SourceId));
 }
Esempio n. 8
0
 /// <summary>
 /// Updates an exsiting migration action using the provided transactions.
 /// </summary>
 /// <param name="trx">The transaction in which the migration action is updated</param>
 internal abstract void UpdateExisting(IMigrationTransaction trx);
 public static int DemoteInProgressActionsToPending(IMigrationTransaction trx, string sessionId, Guid sourceId)
 {
     //ToDo
     throw new NotImplementedException();
 }
 public static int PromoteAnalysisToPending(IMigrationTransaction trx, string sessionId, Guid sourceId)
 {
     //ToDo
     throw new NotImplementedException();
 }
Esempio n. 11
0
 /// <summary>
 /// Identifies and promotes any change groups in the current session whose status is Analysis
 /// to the Pending state.
 /// This method is called during the analysis phase when the items in the analysis
 /// state are ready for migration.  The promotion occurs in the transaction context provided.
 /// </summary>
 /// <param name="trx">The transaction context to perform the promotion.</param>
 /// <returns>The number of change groups reverted from "Analysis" to "Pending"</returns>
 internal abstract int PromoteAnalysisToPending(IMigrationTransaction trx);
Esempio n. 12
0
 /// <summary>
 /// Identifies and demotes any change groups in the current session whose status is InProgress
 /// to the Pending state.
 /// This method is called as a part of crash recovery to ensure that any pending operations are reverted
 /// so they can be retried.  By default this uses a transactional context returned
 /// by DataAccessManager.Current.StartTransaction().
 /// </summary>
 /// <param name="trx">The transaction context to perform the promotion.</param>
 /// <returns>The number of change groups reverted from "InProgress" to "Pending"</returns>
 internal abstract int DemoteInProgressActionsToPending(IMigrationTransaction trx);