Beispiel #1
0
        /// <summary>
        /// Creates package record based on protocol record.
        /// </summary>
        /// <param name="packageSession">The package session.</param>
        /// <param name="protocolRecord">The protocol record.</param>
        /// <param name="targetNode">The target node.</param>
        /// <returns>Package record</returns>
        public static PackageRecord CreateForProtocolRecord(PackageSession packageSession,
                                                            ProtocolRecord protocolRecord, ReplicationNode targetNode)
        {
            var destinationSession = packageSession.Session;
            var result             = new PackageRecord(destinationSession)
            {
                PackageSession = packageSession,
                UserName       = protocolRecord.UserName,
                Description    = protocolRecord.Description,
                ModifiedOn     = protocolRecord.ModifiedOn,
                NewBlobValue   = protocolRecord.NewBlobValue,
                PropertyName   = protocolRecord.PropertyName,
                NewValue       = protocolRecord.NewValue,
                OldValue       = protocolRecord.OldValue,
                OperationType  = protocolRecord.OperationType
            };

            if (protocolRecord.AuditedObject != null && protocolRecord.AuditedObject.Target != null)
            {
                result.AuditedObject =
                    PackageObjectReference.CreatePackageObjectReference(protocolRecord.AuditedObject.Target,
                                                                        destinationSession, targetNode);

                result.AuditedObject.ReplicationKey = protocolRecord.ReplicationKey;
            }


            if (protocolRecord.NewObject != null)
            {
                result.NewObject = PackageObjectReference.CreatePackageObjectReference(protocolRecord.NewObject.Target,
                                                                                       destinationSession, targetNode);
            }

            if (protocolRecord.OldObject != null)
            {
                result.OldObject = PackageObjectReference.CreatePackageObjectReference(protocolRecord.OldObject.Target,
                                                                                       destinationSession, targetNode);
            }

            return(result);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="LoadPackageRecordContext"/> class.
 /// </summary>
 /// <param name="context">The context.</param>
 /// <param name="packageRecord">The package record.</param>
 /// <param name="activeObjectSpaces">The active object spaces.</param>
 public LoadPackageRecordContext(LoadPackageSessionContext context, 
     PackageRecord packageRecord, Dictionary<Guid, IObjectSpace> activeObjectSpaces)
     : base(context, context.PackageSession)
 {
     PackageRecord = packageRecord;
     ActiveObjectSpaces = activeObjectSpaces;
 }
Beispiel #3
0
        /// <summary>
        /// Creates for package record.
        /// </summary>
        /// <param name="objectSpace">The object space.</param>
        /// <param name="record">The record.</param>
        /// <param name="nodeId">The node id.</param>
        /// <returns></returns>
        public static ProtocolRecord CreateForPackageRecord(IObjectSpace objectSpace,
            PackageRecord record, string nodeId)
        {
            if (objectSpace == null) throw new ArgumentNullException("objectSpace");
            if (record == null) throw new ArgumentNullException("record");

            var session = ((ObjectSpace)objectSpace).Session;
            var result = objectSpace.CreateObject<ProtocolRecord>();

            if (record.AuditedObject != null && record.AuditedObject.IsAssigned)
                result.AuditedObject = new AuditedObjectWeakReference(session,
                    OidMap.FindApplicationObject(objectSpace, record.AuditedObject, nodeId));

            result.OperationType = record.OperationType;
            result.ModifiedOn = record.ModifiedOn;
            result.Description = record.Description;
            result.NewBlobValue = record.NewBlobValue;

            if (record.NewObject != null)
                result.NewObject = new XPWeakReference(session,
                    OidMap.FindApplicationObject(objectSpace, record.NewObject, nodeId));

            if (record.OldObject != null)
                result.OldObject = new XPWeakReference(session,
                    OidMap.FindApplicationObject(objectSpace, record.OldObject, nodeId));

            result.NewValue = record.NewValue;
            result.OldValue = record.OldValue;
            result.PropertyName = record.PropertyName;

            if (record.AuditedObject != null && record.AuditedObject.IsAssigned)
                result.ReplicationKey = record.AuditedObject.ReplicationKey;

            return result;
        }
Beispiel #4
0
        /// <summary>
        /// Creates package record based on protocol record.
        /// </summary>
        /// <param name="packageSession">The package session.</param>
        /// <param name="protocolRecord">The protocol record.</param>
        /// <param name="targetNode">The target node.</param>
        /// <returns>Package record</returns>
        public static PackageRecord CreateForProtocolRecord(PackageSession packageSession, 
            ProtocolRecord protocolRecord, ReplicationNode targetNode)
        {
            var destinationSession = packageSession.Session;
            var result = new PackageRecord(destinationSession)
            {
                PackageSession = packageSession,
                UserName = protocolRecord.UserName,
                Description = protocolRecord.Description,
                ModifiedOn = protocolRecord.ModifiedOn,
                NewBlobValue = protocolRecord.NewBlobValue,
                PropertyName = protocolRecord.PropertyName,
                NewValue = protocolRecord.NewValue,
                OldValue = protocolRecord.OldValue,
                OperationType = protocolRecord.OperationType
            };

            if(protocolRecord.AuditedObject != null && protocolRecord.AuditedObject.Target != null)
            {
                result.AuditedObject =
                    PackageObjectReference.CreatePackageObjectReference(protocolRecord.AuditedObject.Target,
                        destinationSession, targetNode);

                result.AuditedObject.ReplicationKey = protocolRecord.ReplicationKey;
            }

            if (protocolRecord.NewObject != null)
                result.NewObject = PackageObjectReference.CreatePackageObjectReference(protocolRecord.NewObject.Target,
                    destinationSession, targetNode);

            if (protocolRecord.OldObject != null)
                result.OldObject = PackageObjectReference.CreatePackageObjectReference(protocolRecord.OldObject.Target,
                    destinationSession, targetNode);

            return result;
        }