protected override void DeliverRemote(
            ICacheRefresher refresher,
            MessageType messageType,
            IEnumerable <object> ids = null,
            string json = null)
        {
            var idsA = ids?.ToArray();

            if (GetArrayType(idsA, out var idType) == false)
            {
                throw new ArgumentException("All items must be of the same type, either int or Guid.", nameof(ids));
            }

            var instructions = RefreshInstruction.GetInstructions(refresher, messageType, idsA, idType, json);

            var dto = new CacheInstructionDto
            {
                UtcStamp         = DateTime.UtcNow,
                Instructions     = JsonConvert.SerializeObject(instructions, Formatting.None),
                OriginIdentity   = LocalIdentity,
                InstructionCount = instructions.Sum(x => x.JsonIdCount)
            };

            using (var scope = ScopeProvider.CreateScope())
            {
                scope.Database.Insert(dto);
                scope.Complete();
            }
        }
        protected override void DeliverRemote(
            IEnumerable <IServerAddress> servers,
            ICacheRefresher refresher,
            MessageType messageType,
            IEnumerable <object> ids = null,
            string json = null)
        {
            var idsA = ids == null ? null : ids.ToArray();

            Type idType;

            if (GetArrayType(idsA, out idType) == false)
            {
                throw new ArgumentException("All items must be of the same type, either int or Guid.", "ids");
            }

            var instructions = RefreshInstruction.GetInstructions(refresher, messageType, idsA, idType, json);

            var dto = new CacheInstructionDto
            {
                UtcStamp         = DateTime.UtcNow,
                Instructions     = JsonConvert.SerializeObject(instructions, Formatting.None),
                OriginIdentity   = LocalIdentity,
                InstructionCount = instructions.Sum(x => x.JsonIdCount)
            };

            ApplicationContext.DatabaseContext.Database.Insert(dto);
        }
Example #3
0
 protected bool Equals(RefreshInstruction other)
 {
     return(RefreshType == other.RefreshType &&
            RefresherId.Equals(other.RefresherId) &&
            GuidId.Equals(other.GuidId) &&
            IntId == other.IntId &&
            string.Equals(JsonIds, other.JsonIds) &&
            string.Equals(JsonPayload, other.JsonPayload));
 }
Example #4
0
        protected void BatchMessage(
            IEnumerable <IServerAddress> servers,
            ICacheRefresher refresher,
            MessageType messageType,
            IEnumerable <object> ids = null,
            Type idType = null,
            string json = null)
        {
            var batch = GetBatch(true);

            if (batch == null)
            {
                throw new Exception("Failed to get a batch.");
            }

            batch.Add(new RefreshInstructionEnvelope(servers, refresher,
                                                     RefreshInstruction.GetInstructions(refresher, messageType, ids, idType, json)));
        }