Exemplo n.º 1
0
        public async Task SaveTokens(Microsoft.SharePoint.Client.ChangeToken lastChangeToken, Notification notification)
        {
            LastChangeToken = lastChangeToken;

            if (CurrentToken != null)
            {
                if (!CurrentToken.LastChangeToken.Equals(LastChangeToken.StringValue, StringComparison.InvariantCultureIgnoreCase))
                {
                    _logger.LogInformation($"Save latest change token to DB: {LastChangeToken.StringValue}");
                    CurrentToken.LastChangeToken = LastChangeToken.StringValue;
                }
            }
            else
            {
                _logger.LogInformation($"Save new change token to DB: {LastChangeToken.StringValue} for subscription {notification.SubscriptionId}");
                _dbContext.ChangeTokens.Add(new ChangeToken
                {
                    Id              = Guid.Parse(notification.SubscriptionId),
                    ListId          = notification.Resource,
                    WebId           = notification.WebId,
                    LastChangeToken = LastChangeToken.StringValue
                });
            }

            await _dbContext.SaveChangesAsync();
        }
Exemplo n.º 2
0
        public void Process(Notification notification)
        {
            CurrentToken = _dbContext.GetLatestBySubscriptionId(notification.SubscriptionId);

            if (CurrentToken != null)
            {
                _logger.LogInformation($"Get previous change token: {CurrentToken.LastChangeToken}");
                LastChangeToken = new Microsoft.SharePoint.Client.ChangeToken
                {
                    StringValue = CurrentToken.LastChangeToken
                };
            }
        }