コード例 #1
0
            public int Add(string id, CounterOperation op)
            {
                op.DocumentId = id;
                _list.Add(op);

                return(_list.Count);
            }
コード例 #2
0
        public Task DecrementAsync(string counter, int amount)
        {
            var entity = new CounterOperation(PartitionKeyFor(counter, DecrementKey), amount);
            var op     = TableOperation.Insert(entity);

            return(_table.ExecuteAsync(op));
        }
コード例 #3
0
        public void Increment(string counter, long delta = 1)
        {
            if (string.IsNullOrWhiteSpace(counter))
            {
                throw new ArgumentNullException(nameof(counter));
            }
            var counterOp = new CounterOperation
            {
                Type        = CounterOperationType.Increment,
                CounterName = counter,
                Delta       = delta
            };

            if (Session.DocumentsById.TryGetValue(DocId, out DocumentInfo documentInfo) &&
                Session.DeletedEntities.Contains(documentInfo.Entity))
            {
                ThrowDocumentAlreadyDeletedInSession(DocId, counter);
            }

            if (Session.DeferredCommandsDictionary.TryGetValue((DocId, CommandType.Counters, null), out var command))
            {
                var countersBatchCommandData = (CountersBatchCommandData)command;
                if (countersBatchCommandData.HasDelete(counter))
                {
                    ThrowIncrementCounterAfterDeleteAttempt(DocId, counter);
                }

                countersBatchCommandData.Counters.Operations.Add(counterOp);
            }
コード例 #4
0
 public CountersBatchCommandData(string documentId, CounterOperation counterOperation)
     : this(documentId, new List <CounterOperation>
 {
     counterOperation
 })
 {
     if (counterOperation == null)
     {
         throw new ArgumentNullException(nameof(counterOperation));
     }
 }
コード例 #5
0
ファイル: CountersHandler.cs プロジェクト: renatotkr/ravendb
 public int Add(string id, CounterOperation op, out bool isNew)
 {
     isNew = false;
     if (_dictionary.TryGetValue(id, out var existing) == false)
     {
         isNew = true;
         _dictionary[id] = new List<CounterOperation> { op };
         return 1;
     }
     existing.Add(op);
     return existing.Count;
 }
コード例 #6
0
            private void AddToBatch(CounterDetail counter)
            {
                var counterOp = new CounterOperation
                {
                    Type         = CounterOperationType.Put,
                    CounterName  = counter.CounterName,
                    Delta        = counter.TotalValue,
                    ChangeVector = counter.ChangeVector
                };

                _cmd.Add(counter.DocumentId, counterOp);
                _batchSize++;
            }
コード例 #7
0
            public void Add(string id, CounterOperation op)
            {
                if (_dictionary.TryGetValue(id, out var existing) == false)
                {
                    _dictionary[id] = new List <CounterOperation> {
                        op
                    };
                }

                else
                {
                    existing.Add(op);
                }
            }
コード例 #8
0
            private void AddToBatch(CounterDetail counter)
            {
                var counterOp = new CounterOperation
                {
                    Type         = CounterOperationType.Put,
                    CounterName  = counter.CounterName,
                    Delta        = counter.TotalValue,
                    ChangeVector = counter.ChangeVector
                };

                var countersCount = _cmd.Add(counter.DocumentId, counterOp, out var isNew);

                if (isNew)
                {
                    _docCount++;
                }

                if (countersCount > _countersPerDoc)
                {
                    _countersPerDoc = countersCount;
                }
            }
コード例 #9
0
 private static void ThrowInvalidBatchOperationType(CounterOperation operation)
 {
     throw new ArgumentOutOfRangeException($"Unknown value {operation.Type}");
 }
コード例 #10
0
 public Task UpdateBadgeCounter(string employeeId, string existingBadgeType, CounterOperation couterOperation, int numberOfBadges)
 {
     throw new NotImplementedException();
 }