internal static CdcTableTypeModel ConvertItemLinkAsyncToRev(CdcTableTypeModel model)
        {
            Ensure.Not((bool)model.Entity.MetaData[TarantoolItemLinkAsyncModel.IsRev]);

            var proto = Mapper.Map <CdcTableTypeModel, CdcTableTypeModel>(model);

            proto.Entity.Columns[TarantoolItemLinkAsyncModel.Id]       = model.Entity.Columns[TarantoolItemLinkAsyncModel.LinkedId];
            proto.Entity.Columns[TarantoolItemLinkAsyncModel.LinkedId] = model.Entity.Columns[TarantoolItemLinkAsyncModel.Id];
            proto.Entity.InvariantName = TarantoolItemLinkAsyncModel.GetInvariantName((decimal)proto.Entity.MetaData[TarantoolItemLinkAsyncModel.LinkId], true);

            return(proto);
        }
Beispiel #2
0
        public override List <CdcTableTypeModel> ImportCdcData(string fromLsn = null, string toLsn = null)
        {
            return(GetCdcDataTable(fromLsn, toLsn).AsEnumerable().Select(row =>
            {
                try
                {
                    var isRev = Equals(true, row[ItemLinkAsyncColumnName.IsRev]);
                    var isSelf = Equals(true, row[ItemLinkAsyncColumnName.IsSelf]);
                    Ensure.Not(isRev && isSelf, "IsRev and IsSelf flags could not be both flagged as true");

                    var linkId = Convert.ToInt32(row[ItemLinkAsyncColumnName.LinkId]);
                    var leftId = Convert.ToInt32(row[ItemLinkAsyncColumnName.ItemId]);
                    var rightId = Convert.ToInt32(row[ItemLinkAsyncColumnName.LinkedItemId]);
                    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 = TarantoolItemLinkAsyncModel.EntityType,
                            InvariantName = TarantoolItemLinkAsyncModel.GetInvariantName(linkId, isRev),
                            Columns = new Dictionary <string, object>
                            {
                                { TarantoolItemLinkAsyncModel.Id, leftId },
                                { TarantoolItemLinkAsyncModel.LinkedId, rightId }
                            },
                            MetaData = new Dictionary <string, object>
                            {
                                { TarantoolItemLinkAsyncModel.LinkId, linkId },
                                { TarantoolItemLinkAsyncModel.IsRev, isRev },
                                { TarantoolItemLinkAsyncModel.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());
        }