コード例 #1
0
        private async Task SaveLoginAttempt(AbpLoginResult <SysTenant, SysUser> loginResult, string tenancyName, string userNameOrEmailAddress)
        {
            using (var uow = UnitOfWorkManager.Begin(TransactionScopeOption.Suppress))
            {
                var tenantId = loginResult.Tenant?.Id;
                using (UnitOfWorkManager.Current.SetTenantId(tenantId))
                {
                    var loginAttempt = new UserLoginAttempt
                    {
                        TenantId    = tenantId,
                        TenancyName = tenancyName,

                        UserId = loginResult.User?.Id,
                        UserNameOrEmailAddress = userNameOrEmailAddress,

                        Result = loginResult.Result,

                        BrowserInfo     = ClientInfoProvider.BrowserInfo,
                        ClientIpAddress = ClientInfoProvider.ClientIpAddress,
                        ClientName      = ClientInfoProvider.ComputerName,
                    };

                    await UserLoginAttemptRepository.InsertAsync(loginAttempt);

                    await UnitOfWorkManager.Current.SaveChangesAsync();

                    await uow.CompleteAsync();
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// 记录入登录日志
        /// </summary>
        /// <param name="loginResult"></param>
        /// <param name="tenancyName"></param>
        /// <param name="userName"></param>
        /// <returns></returns>
        protected virtual async Task SaveLoginAttempt(LoginResult loginResult, string tenancyName, string userName)
        {
            using (var uow = UnitOfWorkManager.Begin(TransactionScopeOption.Suppress))
            {
                var tenantId = loginResult.Tenant != null ? loginResult.Tenant.Id : (int?)null;
                using (UnitOfWorkManager.Current.SetTenantId(tenantId))
                {
                    var loginAttempt = new UserLoginAttempt
                    {
                        TenantId    = tenantId,
                        TenancyName = tenancyName,

                        UserId = loginResult.User != null ? loginResult.User.Id : (long?)null,
                        UserNameOrPhoneNumber = userName,

                        Result = loginResult.Result,

                        BrowserInfo     = ClientInfoProvider.BrowserInfo,
                        ClientIpAddress = ClientInfoProvider.ClientIpAddress,
                        ClientName      = ClientInfoProvider.ComputerName,
                    };

                    await UserLoginAttemptRepository.InsertAsync(loginAttempt);

                    await UnitOfWorkManager.Current.SaveChangesAsync();

                    await uow.CompleteAsync();
                }
            }
        }
コード例 #3
0
        protected virtual void SaveLoginAttempt(JTLoginResult <TTenant, TUser> loginResult, string tenancyName, string userNameOrEmailAddress)
        {
            using (var uow = UnitOfWorkManager.Begin(TransactionScopeOption.Suppress))
            {
                var tenantId = loginResult.Tenant != null ? loginResult.Tenant.Id : (int?)null;
                using (UnitOfWorkManager.Current.SetTenantId(tenantId))
                {
                    var loginAttempt = new JTUserLoginAttempt
                    {
                        TenantId    = tenantId,
                        TenancyName = tenancyName,

                        UserId = loginResult.User != null ? loginResult.User.Id : (long?)null,
                        UserNameOrEmailAddress = userNameOrEmailAddress,

                        Result = loginResult.Result,

                        BrowserInfo     = ClientInfoProvider.BrowserInfo,
                        ClientIpAddress = ClientInfoProvider.ClientIpAddress,
                        ClientName      = ClientInfoProvider.ComputerName,
                    };

                    UserLoginAttemptRepository.Insert(loginAttempt);
                    UnitOfWorkManager.Current.SaveChanges();

                    uow.Complete();
                }
            }
        }
コード例 #4
0
        protected virtual async Task SaveLoginAttempt(JKLoginResult <TUser, TUserLogin, TUserClaim, TUserToken> loginResult, string userNameOrEmailAddress, int tenantId)
        {
            using (var uow = UnitOfWorkManager.Begin(TransactionScopeOption.Suppress))
            {
                using (UnitOfWorkManager.Current.SetTenantId(tenantId))
                {
                    var loginAttempt = new TUserLoginAttempt
                    {
                        TenantId = tenantId,

                        UserId   = loginResult.User != null ? loginResult.User.Id : (long?)null,
                        UserName = userNameOrEmailAddress,

                        Result = loginResult.Result,

                        BrowserInfo     = ClientInfoProvider.BrowserInfo,
                        ClientIpAddress = ClientInfoProvider.ClientIpAddress,
                        ClientName      = ClientInfoProvider.ComputerName,
                    };

                    await UserLoginAttemptRepository.InsertAsync(loginAttempt);

                    await UnitOfWorkManager.Current.SaveChangesAsync();

                    await uow.CompleteAsync();
                }
            }
        }
コード例 #5
0
        protected virtual async Task SaveLoginAttempt(SmdLoginResult <TUser> loginResult, string userNameOrEmailAddress)
        {
            var loginAttempt = new UserLoginAttempt
            {
                UserId = loginResult.User != null ? loginResult.User.Id : (long?)null,
                UserNameOrEmailAddress = userNameOrEmailAddress,

                Result = loginResult.Result,

                BrowserInfo     = ClientInfoProvider.BrowserInfo,
                ClientIpAddress = ClientInfoProvider.ClientIpAddress,
                ClientName      = ClientInfoProvider.ComputerName,
            };

            await UserLoginAttemptRepository.InsertAsync(loginAttempt);
        }
コード例 #6
0
        protected virtual async Task SaveLoginAttempt(LoginResult <TUser> loginResult, string userNameOrEmailAddress)
        {
            var loginAttempt = new UserLoginAttempt
            {
                UserId = loginResult.User != null ? loginResult.User.Id : (long?)null,
                UserNameOrEmailAddress = userNameOrEmailAddress,

                Result = loginResult.Result,

                BrowserInfo     = ClientInfoProvider.BrowserInfo,
                ClientIpAddress = ClientInfoProvider.ClientIpAddress,
                ClientName      = ClientInfoProvider.ComputerName,
            };

            await UserLoginAttemptRepository.InsertAsync(loginAttempt);

            _repositoryContext.Commit();
            //await UnitOfWorkManager.Current.SaveChangesAsync();

            //await uow.CompleteAsync();
        }
コード例 #7
0
        protected virtual async Task SaveLoginAttempt(EddoLoginResult <TUser> loginResult, string tenancyName, string userNameOrEmailAddress)
        {
            using (var uow = UnitOfWorkManager.Begin())
            {
                var loginAttempt = new UserLoginAttempt
                {
                    TenantId    = null,
                    TenancyName = tenancyName,

                    UserId = loginResult.User != null ? loginResult.User.Id : (long?)null,
                    UserNameOrEmailAddress = userNameOrEmailAddress,

                    Result = loginResult.Result,

                    BrowserInfo     = ClientInfoProvider.BrowserInfo,
                    ClientIpAddress = ClientInfoProvider.ClientIpAddress,
                    ClientName      = ClientInfoProvider.ComputerName,
                };
                await UserLoginAttemptRepository.AddAsync(loginAttempt);

                await uow.CommitAsync();
            }
        }
コード例 #8
0
        public override async Task <ResultPageDto> GetPageResult(RequestPageDto request)
        {
            var query = await GetPageResultQueryable(request);

            var tenants = await query.Queryable.ToListAsync();

            var data = new List <object>();

            foreach (var o in tenants)
            {
                //var count = await ProcessTaskRepository.GetAll().CountAsync();
                //var taskCount=await ProcessTaskRepository.GetAll()
                //    .Where(p => MESDbContext.GetJsonValueNumber(p.Supplier.Property, "$.TenantId") ==o.Id)
                //    .CountAsync();
                //var reportCount=await ProcessTaskReportRepository.GetAll()
                //    .Where(p=> MESDbContext.GetJsonValueNumber(p.ProcessTask.Supplier.Property, "$.TenantId") == o.Id)
                //      .CountAsync();
                var lastLogin = await UserLoginAttemptRepository.GetAll().IgnoreQueryFilters().Where(u => u.TenantId == o.Id && u.Result == LoginResultType.Success).LastOrDefaultAsync();

                data.Add(new
                {
                    o.Id,
                    o.TenancyName,
                    o.Name,
                    o.IsActive,
                    Edition       = o.Edition?.DisplayName,
                    ExpireDate    = o.GetPropertyValue <DateTime?>("ExpireDate"),
                    LastLoginTime = lastLogin?.CreationTime.ToString("yyyy-MM-dd HH:mm"),
                    //TaskNumber = ProcessTaskRepository.Count(p => p.TenantId == o.Id && p.ProcessTaskStatus != ProcessTaskStatus.Inputed),
                    //ReportNumber = ProcessTaskReportRepository.Count(p => p.TenantId == o.Id),
                    //TaskCount = taskCount,
                    //ReportCount = reportCount,
                    CreationTime = o.CreationTime.ToString("yyyy-MM-dd HH:mm"),
                    Mobile       = o.GetPropertyValue <string>("Mobile"),
                    PersonName   = o.GetPropertyValue <string>("PersonName")
                });
            }

            //var data = tasks.Select( o => {
            //    var lastLogin= UserLoginAttemptRepository.GetAll().Where(u => u.TenantId == o.Id && u.Result == LoginResultType.Success).LastOrDefault();
            //    return new
            //    {
            //        o.Id,
            //        o.TenancyName,
            //        o.Name,
            //        o.IsActive,
            //        LastLoginTime=lastLogin?.CreationTime.ToString("yyyy-MM-dd HH:mm"),
            //        TaskNumber = ProcessTaskRepository.Count(p=>p.TenantId==o.Id && p.ProcessTaskStatus!=ProcessTaskStatus.Inputed),
            //        ReportNumber= ProcessTaskReportRepository.Count(p=>p.TenantId==o.Id),
            //        CreationTime =o.CreationTime.ToString("yyyy-MM-dd HH:mm"),
            //        Mobile=o.GetPropertyValue<string>("Mobile"),
            //        PersonName=o.GetPropertyValue<string>("PersonName")
            //    };
            //});

            var result = new ResultPageDto()
            {
                code  = 0,
                count = query.RowCount,
                data  = data
            };

            return(result);
        }