internal static CdcTableTypeModel ConvertItemToItemToRev(CdcTableTypeModel model) { Ensure.Not((bool)model.Entity.MetaData[TarantoolItemToItemModel.IsRev]); var proto = Mapper.Map <CdcTableTypeModel, CdcTableTypeModel>(model); proto.Entity.Columns[TarantoolItemToItemModel.Id] = model.Entity.Columns[TarantoolItemToItemModel.LinkedId]; proto.Entity.Columns[TarantoolItemToItemModel.LinkedId] = model.Entity.Columns[TarantoolItemToItemModel.Id]; proto.Entity.InvariantName = TarantoolItemToItemModel.GetInvariantName((decimal)proto.Entity.MetaData[TarantoolItemToItemModel.LinkId], true); return(proto); }
public override List <CdcTableTypeModel> ImportCdcData(string fromLsn = null, string toLsn = null) { return(GetCdcDataTable(fromLsn, toLsn).AsEnumerable().Select(row => { try { var isRev = Equals(true, row[ItemToItemColumnName.IsRev]); var isSelf = Equals(true, row[ItemToItemColumnName.IsSelf]); Ensure.Not(isRev && isSelf, "IsRev and IsSelf flags could not be both flagged as true"); var linkId = Convert.ToInt32(row[ItemToItemColumnName.LinkId]); var leftId = Convert.ToInt32(row[ItemToItemColumnName.LItemId]); var rightId = Convert.ToInt32(row[ItemToItemColumnName.RItemId]); return new CdcTableTypeModel { ChangeType = CdcActionType.Data, Action = (CdcOperationType)Enum.Parse(typeof(CdcOperationType), Convert.ToString(row[CdcCommonConstants.Operation])), TransactionDate = (DateTime)row[CdcCommonConstants.TransactionDate], TransactionLsn = row[CdcCommonConstants.TransactionLsn] as string, SequenceLsn = row[CdcCommonConstants.SequenceLsn] as string, FromLsn = row[CdcCommonConstants.FromLsn] as string, ToLsn = row[CdcCommonConstants.ToLsn] as string, Entity = new CdcEntityModel { EntityType = TarantoolItemToItemModel.EntityType, InvariantName = TarantoolItemToItemModel.GetInvariantName(linkId, isRev), Columns = new Dictionary <string, object> { { TarantoolItemToItemModel.Id, leftId }, { TarantoolItemToItemModel.LinkedId, rightId } }, MetaData = new Dictionary <string, object> { { TarantoolItemToItemModel.LinkId, linkId }, { TarantoolItemToItemModel.IsRev, isRev }, { TarantoolItemToItemModel.IsSelf, isSelf } } } }; } catch (Exception ex) { throw new Exception($"There was an exception for parsing \"{CaptureInstanceName}\" row: {row.ToSimpleDataRow().ToJsonLog()}", ex); } }).OrderBy(cdc => cdc.TransactionLsn).ToList()); }