private UserContacts GetUserContacts(AccountContactBatchUpdateRecord payload)
        {
            if (!_accountIdToUserId.ContainsKey(payload.AccountId))
            {
                Logger.Error("AccountId '{0}' not found in cache.", payload.AccountId);
                Logger.Info("Existing keys : {0}", string.Join(",", _accountIdToUserId.Keys));
            }

            var userId = _accountIdToUserId[payload.AccountId];

            //I believe that this is serialized and non reentrant, thus thread safe.
            UserContacts userContacts;
            if (!_users.TryGetValue(userId, out userContacts))
            {
                userContacts = new UserContacts(userId);
                _users.Add(userId, userContacts);
            }
            return userContacts;
        }
示例#2
0
        private string GetChangesBatch(Guid userId)
        {
            var changes = _changes.Select(ToAccountContactRecord)
                .ToArray();

            _logger.Trace("Changes.count = {0}", changes.Length);
            var batch = new AccountContactBatchUpdateRecord
            {
                UserId = userId,
                AccountId = _accountId,
                Provider = _provider,
                Contacts = changes
            };
            var payload = batch.ToJson();
            return payload;
        }