Example #1
0
        public UnitloadSnapshot GetSnapshot(Unitload unitload)
        {
            UnitloadSnapshot snapshot = _unitloadSnapshotFactory.CreateUnitloadSnapshot();

            CopyUtil.CopyProperties(unitload, snapshot, new[]
            {
                nameof(UnitloadSnapshot.UnitloadSnapshotId),
                nameof(UnitloadSnapshot.SnapshotTime),
                nameof(UnitloadSnapshot.Items)
            });
            snapshot.SnapshotTime = DateTime.Now;

            foreach (var item in unitload.Items)
            {
                UnitloadItemSnapshot itemSnapshot = _unitloadSnapshotFactory.CreateUnitloadItemSnapshot();
                CopyUtil.CopyProperties(item, itemSnapshot, new[]
                {
                    nameof(UnitloadItemSnapshot.UnitloadItemSnapshotId),
                    nameof(UnitloadItemSnapshot.Unitload),
                });
                snapshot.AddItem(itemSnapshot);
            }
            _logger.Information("已获取 {unitload} 的快照", unitload);

            return(snapshot);
        }
Example #2
0
 public virtual void RemoveItem(UnitloadItemSnapshot item)
 {
     item.Unitload = null;
     this.Items.Remove(item);
 }
Example #3
0
 public virtual void AddItem(UnitloadItemSnapshot item)
 {
     item.Unitload = this;
     this.Items.Add(item);
 }