/// <summary>
 /// Initializes a new instance of the <see cref="LoadPackageContext"/> class.
 /// </summary>
 /// <param name="package">The package.</param>
 /// <param name="worker">The worker.</param>
 /// <param name="objectSpace">The object space.</param>
 /// <param name="currentNodeId">The current node id.</param>
 public LoadPackageContext(Package package, ActionWorker worker, 
     IObjectSpace objectSpace, string currentNodeId)
 {
     CurrentNodeId = currentNodeId;
     Package = package;
     Worker = worker;
     ObjectSpace = objectSpace;
 }
Beispiel #2
0
 /// <summary>
 /// Creates ticket for log record.
 /// </summary>
 /// <param name="objectSpace">The object space.</param>
 /// <param name="logRecord">The log record.</param>
 /// <param name="package">The package.</param>
 /// <returns>New ticket</returns>
 public static Ticket CreateForLogRecord(IObjectSpace objectSpace, 
     PackageLogRecord logRecord, Package package)
 {
     var result = objectSpace.CreateObject<Ticket>();
     result.PackageEventType = logRecord.PackageEventType;
     result.Package = package;
     result.Comments = logRecord.Comments;
     return result;
 }
Beispiel #3
0
 /// <summary>
 /// Loads the package.
 /// </summary>
 /// <param name="worker">The worker.</param>
 /// <param name="package">The package.</param>
 public bool LoadPackage(ActionWorker worker, Package package)
 {
     bool result;
     Interlocked.Increment(ref loadNesting);
     try
     {
         using (var applicationObjectSpace = XafDeltaModule.XafApp.CreateObjectSpace())
         {
             var currentNodeId = ReplicationNode.GetCurrentNodeId(applicationObjectSpace);
             result = LoadPackage(new LoadPackageContext(package, worker,
                     applicationObjectSpace, currentNodeId));
             applicationObjectSpace.CommitChanges();
         }
         var packageObjectSpace = ObjectSpace.FindObjectSpaceByObject(package);
         packageObjectSpace.CommitChanges();
     }
     finally
     {
         Interlocked.Decrement(ref loadNesting);
     }
     return result;
 }
Beispiel #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LoadPackageEventArgs"/> class.
 /// </summary>
 /// <param name="package">The package.</param>
 public LoadPackageEventArgs(Package package)
 {
     Package = package;
 }
Beispiel #5
0
 /// <summary>
 /// Gets the instance.
 /// </summary>
 /// <param name="session">The session.</param>
 /// <param name="package"></param>
 /// <returns>Package marker singleton for specified object space</returns>
 public static PackageMarker GetInstance(Session session, Package package)
 {
     var result = session.FindObject<PackageMarker>(null, true) ?? CreateForPackage(session, package);
     return result;
 }
Beispiel #6
0
        /// <summary>
        /// Creates marker for package.
        /// </summary>
        /// <param name="session">The session.</param>
        /// <param name="package">The package.</param>
        /// <returns>Package marker</returns>
        public static PackageMarker CreateForPackage(Session session, Package package)
        {
            var result = new PackageMarker(session)
                             {
                                 ApplicationName = package.ApplicationName,
                                 SenderNodeId = package.SenderNodeId,
                                 RecipientNodeId = package.RecipientNodeId,
                                 PackageId = package.PackageId,
                                 PackageType = package.PackageType,
                                 PackageDateTime = package.PackageDateTime.ToUniversalTime(),
                                 UserName = package.UserName
                             };

            if(package.PackageType == PackageType.Snapshot)
            {
                var recipient = ReplicationNode.FindNode(package.Session, result.RecipientNodeId);
                var sender = ReplicationNode.GetCurrentNode(package.Session);
                var num = XafDeltaModule.Instance.RoutingType == RoutingType.BroadcastRouting
                              ? sender.LastSavedPackageNumber
                              : recipient.LastSavedPackageNumber;
                if (recipient != null)
                    result.LastSavedPackageNumber = num;
            }
            return result;
        }