Exemplo n.º 1
0
        /// <summary>
        /// Creates PackageSession for protocol session.
        /// </summary>
        /// <param name="session">The session.</param>
        /// <param name="protocolSession">The protocol session.</param>
        /// <param name="nodeId"></param>
        /// <returns>Package session</returns>
        public static PackageSession CreateForProtocolSession(Session session, ProtocolSession protocolSession, string nodeId)
        {
            var result = session.FindObject <PackageSession>(PersistentCriteriaEvaluationBehavior.InTransaction,
                                                             CriteriaOperator.Parse("SessionId = ?", protocolSession.SessionId));

            if (result == null)
            {
                result = new PackageSession(session)
                {
                    SessionId  = protocolSession.SessionId,
                    StartedOn  = protocolSession.StartedOn,
                    CommitedOn = protocolSession.CommitedOn
                };

                if (protocolSession is ExternalProtocolSession)
                {
                    result.Route = ((ExternalProtocolSession)protocolSession).Route;
                }

                result.Route += '\n' + nodeId;

                if (protocolSession.Parent != null)
                {
                    result.Parent = CreateForProtocolSession(session, protocolSession.Parent, nodeId);
                }
            }

            return(result);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Creates for package session.
 /// </summary>
 /// <param name="objectSpace">The object space.</param>
 /// <param name="packageSession">The package session.</param>
 /// <returns>New external protocol session</returns>
 public static ExternalProtocolSession CreateForPackageSession(IObjectSpace objectSpace, PackageSession packageSession)
 {
     var result = objectSpace.CreateObject<ExternalProtocolSession>();
     result.SessionId = packageSession.SessionId;
     result.Route = packageSession.Route;
     result.StartedOn = packageSession.StartedOn;
     return result;
 }
Exemplo n.º 3
0
 /// <summary>
 /// Gets the session.
 /// </summary>
 /// <param name="objectSpace">The object space.</param>
 /// <param name="packageSession">The package session.</param>
 /// <returns>New external protocol session</returns>
 public static ExternalProtocolSession GetSession(IObjectSpace objectSpace, PackageSession packageSession)
 {
     var result =
         objectSpace.FindObject<ExternalProtocolSession>(
             CriteriaOperator.Parse("SessionId = ?", packageSession.SessionId), true);
     if(result == null)
     {
         result = objectSpace.CreateObject<ExternalProtocolSession>();
         result.SessionId = packageSession.SessionId;
         result.Route = packageSession.Route;
         result.StartedOn = packageSession.StartedOn;
         result.CommitedOn = packageSession.CommitedOn;
         if (packageSession.Parent != null)
             result.Parent = GetSession(objectSpace, packageSession.Parent);
     }
     return result;
 }
Exemplo n.º 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);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Creates PackageSession for protocol session.
        /// </summary>
        /// <param name="session">The session.</param>
        /// <param name="protocolSession">The protocol session.</param>
        /// <param name="nodeId"></param>
        /// <returns>Package session</returns>
        public static PackageSession CreateForProtocolSession(Session session, ProtocolSession protocolSession, string nodeId)
        {
            var result = session.FindObject<PackageSession>(PersistentCriteriaEvaluationBehavior.InTransaction,
                CriteriaOperator.Parse("SessionId = ?", protocolSession.SessionId));

            if (result == null)
            {

                result = new PackageSession(session)
                             {
                                 SessionId = protocolSession.SessionId,
                                 StartedOn = protocolSession.StartedOn,
                                 CommitedOn = protocolSession.CommitedOn
                             };

                if (protocolSession is ExternalProtocolSession)
                    result.Route = ((ExternalProtocolSession) protocolSession).Route;

                result.Route += '\n' + nodeId;

                if (protocolSession.Parent != null)
                    result.Parent = CreateForProtocolSession(session, protocolSession.Parent, nodeId);
            }

            return result;
        }
 /// <summary>
 /// Gets the playback object space.
 /// </summary>
 /// <param name="packageSession">The package session.</param>
 /// <param name="activeObjectSpaces">The active object spaces.</param>
 /// <returns></returns>
 private IObjectSpace getPlaybackObjectSpace(PackageSession packageSession, 
     Dictionary<Guid, IObjectSpace> activeObjectSpaces)
 {
     IObjectSpace result;
     if(!activeObjectSpaces.TryGetValue(packageSession.SessionId, out result))
     {
         if (packageSession.Parent != null)
         {
             var parentObs = getPlaybackObjectSpace(packageSession.Parent, activeObjectSpaces);
             result = parentObs.CreateNestedObjectSpace();
         }
         else
         {
             result = XafDeltaModule.XafApp.CreateObjectSpace();
         }
         activeObjectSpaces.Add(packageSession.SessionId, result);
     }
     return result;
 }
 public LoadPackageSessionContext(LoadPackageContext context, PackageSession packageSession)
     : base(context.Package, context.Worker, context.ObjectSpace, context.CurrentNodeId)
 {
     PackageSession = packageSession;
 }
Exemplo n.º 8
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;
        }