Example #1
0
 // Change
 protected override bool InternalChange(Program program, IRow oldRow, IRow newRow, BitArray valueFlags, string columnName)
 {
     if (PropagateChange)
     {
         // select the current row from the base node using the given row
         IRow sourceRow = new Row(program.ValueManager, SourceNode.DataType.RowType);
         try
         {
             newRow.CopyTo(sourceRow);
             IRow currentRow = null;
             if (!program.ServerProcess.ServerSession.Server.IsEngine)
             {
                 currentRow = SourceNode.Select(program, sourceRow);
             }
             try
             {
                 if (currentRow == null)
                 {
                     currentRow = new Row(program.ValueManager, SourceNode.DataType.RowType);
                 }
                 newRow.CopyTo(currentRow);
                 BitArray localValueFlags = valueFlags != null ? new BitArray(currentRow.DataType.Columns.Count) : null;
                 if (localValueFlags != null)
                 {
                     for (int index = 0; index < localValueFlags.Length; index++)
                     {
                         int rowIndex = newRow.DataType.Columns.IndexOfName(currentRow.DataType.Columns[index].Name);
                         localValueFlags[index] = rowIndex >= 0 ? valueFlags[rowIndex] : false;
                     }
                 }
                 bool changed = SourceNode.Change(program, oldRow, currentRow, localValueFlags, columnName);
                 if (changed)
                 {
                     currentRow.CopyTo(newRow);
                 }
                 return(changed);
             }
             finally
             {
                 currentRow.Dispose();
             }
         }
         finally
         {
             sourceRow.Dispose();
         }
     }
     return(false);
 }
Example #2
0
        // Insert
        protected override void InternalExecuteInsert(Program program, IRow oldRow, IRow newRow, BitArray valueFlags, bool uncheckedValue)
        {
            switch (PropagateInsert)
            {
            case PropagateAction.True:
                using (Row insertRow = new Row(program.ValueManager, SourceNode.DataType.RowType, (NativeRow)newRow.AsNative))
                {
                    insertRow.ValuesOwned = false;
                    SourceNode.Insert(program, oldRow, insertRow, valueFlags, uncheckedValue);
                }
                break;

            case PropagateAction.Ensure:
            case PropagateAction.Ignore:
                using (Row insertRow = new Row(program.ValueManager, SourceNode.DataType.RowType, (NativeRow)newRow.AsNative))
                {
                    insertRow.ValuesOwned = false;
                    using (Row sourceRow = new Row(program.ValueManager, SourceNode.DataType.RowType))
                    {
                        insertRow.CopyTo(sourceRow);
                        using (IRow currentRow = SourceNode.Select(program, sourceRow))
                        {
                            if (currentRow != null)
                            {
                                if (PropagateInsert == PropagateAction.Ensure)
                                {
                                    SourceNode.Update(program, currentRow, insertRow, valueFlags, false, uncheckedValue);
                                }
                            }
                            else
                            {
                                SourceNode.Insert(program, oldRow, insertRow, valueFlags, uncheckedValue);
                            }
                        }
                    }
                }
                break;
            }
        }