Exemplo n.º 1
0
        private async Task RecordLogin(AccountEntity account, UCenterErrorCode code, string comments = null)
        {
            var record = new LoginRecordEntity
            {
                AccountName = account.AccountName,
                AccountId   = account.Id,
                Code        = code,
                LoginTime   = DateTime.UtcNow,
                UserAgent   = Request.Headers.UserAgent.ToString(),
                ClientIp    = this.GetClientIp(Request),
                Comments    = comments
            };

            await this.DatabaseContext.Bucket.InsertSlimAsync(record, false);
        }
Exemplo n.º 2
0
        private async Task RecordLogin(
            AccountEntity account,
            UCenterErrorCode code,
            string comments         = null,
            CancellationToken token = default(CancellationToken))
        {
            var clientIp       = IPHelper.GetClientIpAddress(Request);
            var ipInfoResponse = await IPHelper.GetIPInfoAsync(clientIp, CancellationToken.None);

            string area;

            if (ipInfoResponse != null && ipInfoResponse.Code == IPInfoResponseCode.Success)
            {
                area = string.Format(
                    CultureInfo.InvariantCulture,
                    "{0}-{1}",
                    ipInfoResponse.Content.Country,
                    ipInfoResponse.Content.City ?? ipInfoResponse.Content.County);
            }
            else
            {
                area = string.Empty;
            }

            var record = new LoginRecordEntity
            {
                Id          = Guid.NewGuid().ToString(),
                AccountName = account.AccountName,
                AccountId   = account.Id,
                Code        = code,
                LoginTime   = DateTime.UtcNow,
                UserAgent   = Request.Headers.UserAgent.ToString(),
                ClientIp    = clientIp,
                LoginArea   = area,
                Comments    = comments
            };

            await this.Database.LoginRecords.InsertAsync(record, token);
        }
Exemplo n.º 3
0
 public CreateEvent(long id, LoginRecordEntity record)
 {
     Id          = id;
     Record      = record;
     AggregateId = id.ToString();
 }