コード例 #1
0
ファイル: RaidEditor.cs プロジェクト: pbijdens/raidbot
        private void UpdateAddress(DbSet <RaidParticipation> raidCollection, RaidParticipation raid, Location location)
        {
            bool wasInTime = AddressServicie.GetAddress(location.Latitude, location.Longitude).ContinueWith((t) =>
            {
                raid.Raid.Address         = t.Result;
                raid.LastModificationTime = DateTime.UtcNow;
                raidCollection.Update(raid);
            }).Wait(TimeSpan.FromSeconds(5));

            if (wasInTime)
            {
                _log.Trace("Got address in time...");
            }
            else
            {
                _log.Warn("Address arrived too late from Google, not waiting. We'll update when we get it.");
            }
        }
コード例 #2
0
        private void UpdateAddress(User user, Location location)
        {
            // Wait synchronously for 5 seconds for the address service to come back with an answer. If it wasn't in time, return. If it arrives later, fine, use it anyway it will show upon the next update.
            bool wasInTime = AddressServicie.GetAddress(location.Latitude, location.Longitude).ContinueWith((t) =>
            {
                _log.Trace($"Received address: {t.Result}");
                GetOrCreateRaidDescriptionForUser(user, out DbSet <RaidDescription> collection, out RaidDescription record);
                record.Address = t.Result;
                collection.Update(record);
            }).Wait(TimeSpan.FromSeconds(5));

            if (wasInTime)
            {
                _log.Trace("Got address in time...");
            }
            else
            {
                _log.Warn("Address arrived too late from Google, not waiting. We'll update when we get it.");
            }
        }