예제 #1
0
        private async Task SyncDbs(Dictionary <string, Session> localSessions, Dictionary <string, Session> remoteSessions)
        {
            foreach (var key in localSessions.Keys)
            {
                if (remoteSessions.ContainsKey(key))
                {
                    if (localSessions[key].EndUTC > remoteSessions[key].EndUTC)
                    {
                        _logger.LogDebug($"Upsert {key} to server");
                        await _remoteSessionRepo.UpsertSession(localSessions[key]);
                    }
                    else
                    {
                        await _localSessionRepo.UpsertSession(remoteSessions[key]);

                        _logger.LogDebug($"Getting {key} from server to save locally");
                    }
                }
                else
                {
                    _logger.LogDebug($"Upsert {key} to server");
                    await _remoteSessionRepo.UpsertSession(localSessions[key]);
                }
            }

            foreach (var key in remoteSessions.Keys)
            {
                if (localSessions.ContainsKey(key))
                {
                    continue;
                }

                await _localSessionRepo.UpsertSession(remoteSessions[key]);

                _logger.LogDebug($"Getting {key} from server to save locally");
            }
        }
예제 #2
0
        public override async Task <UpsertResponse> Upsert(UpsertRequest request, ServerCallContext context)
        {
            await _localSessionRepo.UpsertSession(request.Session);

            return(new UpsertResponse());
        }