Пример #1
0
        public void Notify_EmptyChangeMap(SiteModelChangeMapOrigin origin, SiteModelChangeMapOperation operation)
        {
            var notifier = new SiteModelChangeMapDeltaNotifier();

            // The notifier uses the non-transacted storage proxy:
            var proxy = DIContext.Obtain <Func <IStorageProxyCache <ISiteModelChangeBufferQueueKey, ISiteModelChangeBufferQueueItem> > >()();

            proxy.Should().NotBeNull();
            proxy.Clear();

            var projectUid = Guid.NewGuid();
            var insertUtc  = DateTime.UtcNow;

            // Ask the notifier to notify a new item
            notifier.Notify(projectUid, insertUtc, new SubGridTreeSubGridExistenceBitMask(), origin, operation);

            // Check the new item was placed into the cache
            var cachedItem = proxy.Get(new SiteModelChangeBufferQueueKey(projectUid, insertUtc));

            cachedItem.Should().NotBeNull();
            cachedItem.Operation.Should().Be(operation);
            cachedItem.Origin.Should().Be(origin);

            var readMap = new SubGridTreeSubGridExistenceBitMask();

            readMap.FromBytes(cachedItem.Content);

            readMap.CountBits().Should().Be(0);
        }
Пример #2
0
        public override void InternalFromBinary(IBinaryRawReader reader)
        {
            var version = VersionSerializationHelper.CheckVersionByte(reader, VERSION_NUMBER);

            if (version == 1)
            {
                InsertUTC  = DateTime.FromBinary(reader.ReadLong());
                Content    = reader.ReadByteArray();
                ProjectUID = reader.ReadGuid() ?? Guid.Empty;
                MachineUid = reader.ReadGuid() ?? Guid.Empty;
                Operation  = (SiteModelChangeMapOperation)reader.ReadInt();
                Origin     = (SiteModelChangeMapOrigin)reader.ReadInt();
            }
        }
Пример #3
0
        /// <summary>
        /// Creates a change map buffer queue item and places it in to the cache for the service processor to collect
        /// </summary>
        public void Notify(Guid projectUid, DateTime insertUtc, ISubGridTreeBitMask changeMap, SiteModelChangeMapOrigin origin, SiteModelChangeMapOperation operation)
        {
            try
            {
                _log.LogInformation($"Adding site model change map notification for project {projectUid}");

                _queueCache.Put(new SiteModelChangeBufferQueueKey(projectUid, insertUtc),
                                new SiteModelChangeBufferQueueItem
                {
                    ProjectUID = projectUid,
                    InsertUTC  = insertUtc,
                    Operation  = operation,
                    Origin     = origin,
                    Content    = changeMap?.ToBytes()
                });
            }
            catch (Exception e)
            {
                _log.LogError(e, "Exception notifying site model change map");
            }
        }