/// <summary>
        /// 获取投注信息
        /// </summary>
        /// <param name="db">数据库连接对象</param>
        /// <returns>返回投注信息</returns>
        public PageResult<BettingExport> GetBettings(IModelToDbContextOfLottery db)
        {
            if (this.PageIndex < 1) { this.PageIndex = 1; }
            SettingOfBase settingOfBase = new SettingOfBase(db);
            int startRow = settingOfBase.PageSizeForAdmin * (this.PageIndex - 1);

            Expression<Func<Betting, bool>> predicate1 = x => x.Id > 0;
            Expression<Func<Betting, bool>> predicate2 = x => x.Id > 0;
            Expression<Func<Betting, bool>> predicate3 = x => x.Id > 0;
            Expression<Func<Betting, bool>> predicate4 = x => x.Id > 0;
            Expression<Func<Betting, bool>> predicate5 = x => x.Id > 0;

            if (this.KeywordForUsername != null)
            {
                this.KeywordForUsername = VerifyHelper.EliminateSpaces(this.KeywordForUsername);
                string[] keywords = this.KeywordForUsername.Split(new char[] { ' ' });
                predicate1 = x => keywords.All(kw => x.Owner.Username.Contains(kw));
            }
            if (this.OwnerId != null)
            {
                int ownerId = (int)this.OwnerId;
                predicate2 = x => x.Owner.Id == ownerId;
            }
            if (this.BeginTime != null)
            {
                DateTime beginTime = (DateTime)this.BeginTime;
                predicate3 = x => x.CreatedTime >= beginTime;
            }
            if (this.EndTime != null)
            {
                DateTime endTime = (DateTime)this.EndTime;
                predicate4 = x => x.CreatedTime < endTime;
            }
            if (this.Status != null)
            {
                BettingStatus status = (BettingStatus)this.Status;
                predicate5 = x => x.Status == status;
            }

            int countOfAllMessages = db.Bettings
                .Where(predicate1)
                .Where(predicate2)
                .Where(predicate3)
                .Where(predicate4)
                .Where(predicate5)
                .Count();
            var tList = db.Bettings
                .Where(predicate1)
                .Where(predicate2)
                .Where(predicate3)
                .Where(predicate4)
                .Where(predicate5)
                .OrderByDescending(x => x.CreatedTime)
                .Skip(startRow)
                .Take(settingOfBase.PageSizeForAdmin)
                .ToList()
                .ConvertAll(x => new BettingExport(x));

            return new PageResult<BettingExport>(this.PageIndex, countOfAllMessages, settingOfBase.PageSizeForAdmin, tList);
        }
        /// <summary>
        /// 保持心跳
        /// </summary>
        /// <param name="db">数据库存储指针</param>
        public void KeepHeartbeat(IModelToDbContextOfAdministrator db)
        {
            SettingOfBase setting = new SettingOfBase(db);
            int s = setting.HeartbeatInterval * 3;

            this.Timeout = DateTime.Now.AddSeconds(s);
        }
        /// <summary>
        /// 获取充值奖励的计划
        /// </summary>
        /// <param name="db">数据库连接对象</param>
        /// <returns>返回充值奖励的计划</returns>
        public PageResult<RewardForRechargePlanExport> GetRewardForRechargePlans(IModelToDbContextOfActivity db)
        {
            if (this.PageIndex < 1) { this.PageIndex = 1; }
            SettingOfBase settingOfBase = new SettingOfBase(db);
            int startRow = settingOfBase.PageSizeForAdmin * (this.PageIndex - 1);

            Expression<Func<RewardForRechargePlan, bool>> predicate1 = x => x.EndTime > DateTime.Now;
            Expression<Func<RewardForRechargePlan, bool>> predicate2 = x => x.Id > 0;

            if (this.KeywordForTitle != null)
            {
                this.KeywordForTitle = VerifyHelper.EliminateSpaces(this.KeywordForTitle);
                string[] keywords = this.KeywordForTitle.Split(new char[] { ' ' });
                predicate2 = x => keywords.All(kw => x.Title.Contains(kw));
            }

            int countOfAllMessages = db.RewardForRechargePlans
                .Where(predicate1)
                .Where(predicate2)
                .Count();
            var tList = db.RewardForRechargePlans
                .Where(predicate1)
                .Where(predicate2)
                .OrderByDescending(x => x.CreatedTime)
                .Skip(startRow)
                .Take(settingOfBase.PageSizeForAdmin)
                .ToList()
                .ConvertAll(x => new RewardForRechargePlanExport(x));

            return new PageResult<RewardForRechargePlanExport>(this.PageIndex, countOfAllMessages, settingOfBase.PageSizeForAdmin, tList);
        }
        /// <summary>
        /// 获取管理员组信息的分页列表
        /// </summary>
        /// <param name="db">数据库连接对象</param>
        /// <returns>返回管理员组信息的分页列表</returns>
        public PageResult<AdministratorGroupExport> GetAdministratorGroups(IModelToDbContextOfAdministrator db)
        {
            if (this.PageIndex < 1) { this.PageIndex = 1; }
            SettingOfBase settingOfBase = new SettingOfBase(db);
            int startRow = settingOfBase.PageSizeForAdmin * (this.PageIndex - 1);


            Expression<Func<AdministratorGroup, bool>> predicate1 = x => x.Id > 0;

            if (this.KeywordForGroupName != null)
            {
                this.KeywordForGroupName = VerifyHelper.EliminateSpaces(this.KeywordForGroupName);
                string[] keywords = this.KeywordForGroupName.Split(new char[] { ' ' });
                predicate1 = x => keywords.All(kw => x.Name.Contains(kw));
            }

            int countOfAllMessages = db.AdministratorGroups
                .Where(predicate1)
                .Count();
            var tList = db.AdministratorGroups
                .Where(predicate1)
                .OrderBy(x => x.Name)
                .Skip(startRow)
                .Take(settingOfBase.PageSizeForAdmin)
                .ToList()
                .ConvertAll(x => new AdministratorGroupExport(x));

            return new PageResult<AdministratorGroupExport>(this.PageIndex, countOfAllMessages, settingOfBase.PageSizeForAdmin, tList);
        }
        /// <summary>
        /// 获取系统设置
        /// </summary>
        /// <param name="db">数据库连接对象</param>
        /// <returns>返回系统设置</returns>
        public NormalResult<SettingExport> GetSetting(IModelToDbContextOfAuthor db)
        {
            SettingOfBase settingOfBase = new SettingOfBase(db);
            SettingOfAuthor settingOfAuthor = new SettingOfAuthor(db);
            SettingOfLottery settingOfLottery = new SettingOfLottery(db);

            var s = new SettingExport(settingOfBase, settingOfAuthor, settingOfLottery);
            return new NormalResult<SettingExport>(s);
        }
 /// <summary>
 /// 基础的系统设置
 /// </summary>
 /// <param name="model">基础的系统设置的数据模型</param>
 public SettingOfBaseExport(SettingOfBase model)
 {
     this.PageSizeForClient = model.PageSizeForClient;
     this.PageSizeForAdmin = model.PageSizeForAdmin;
     this.HeartbeatInterval = model.HeartbeatInterval;
     this.WorkingHour_Begin = model.WorkingHour_Begin;
     this.WorkingHour_End = model.WorkingHour_End;
     this.VirtualQueuing = model.VirtualQueuing;
     this.CollectionRunning = model.CollectionRunning;
 }
        /// <summary>
        /// 实例化一个新的管理员的登陆信息
        /// </summary>
        /// <param name="db">数据库存储指针</param>
        /// <param name="administratorId">管理员信息的存储指针</param>
        public AdministratorLoginInfo(IModelToDbContextOfAdministrator db, int administratorId)
        {
            SettingOfBase setting = new SettingOfBase(db);
            int s = setting.HeartbeatInterval * 3;

            this.Token = Guid.NewGuid().ToString("N");
            this.AdministratorId = administratorId;
            this.LoginTime = DateTime.Now;
            this.Timeout = this.LoginTime.AddSeconds(s);
        }
        /// <summary>
        /// 设置并保存
        /// </summary>
        /// <param name="db">数据库连接对象</param>
        public void SetAndSave(IModelToDbContextOfAdministrator db)
        {
            SettingOfBase setting = new SettingOfBase(db);

            setting.PageSizeForClient = this.PageSizeForClient;
            setting.PageSizeForAdmin = this.PageSizeForAdmin;
            setting.HeartbeatInterval = this.HeartbeatInterval;
            setting.WorkingHour_Begin = this.WorkingHour_Begin;
            setting.WorkingHour_End = this.WorkingHour_End;
            setting.VirtualQueuing = this.VirtualQueuing;
            setting.CollectionRunning = this.CollectionRunning;

            setting.Save(db);
        }
        /// <summary>
        /// 获取银行账户信息
        /// </summary>
        /// <param name="db">数据库连接对象</param>
        /// <returns>返回银行账户信息</returns>
        public PageResult<SystemBankAccountExport> GetSystemBankAccounts(IModelToDbContextOfAuthor db)
        {
            if (this.PageIndex < 1) { this.PageIndex = 1; }
            SettingOfBase settingOfBase = new SettingOfBase(db);
            int startRow = settingOfBase.PageSizeForAdmin * (this.PageIndex - 1);

            int countOfAllMessages = db.SystemBankAccounts
                .Count();
            var tList = db.SystemBankAccounts
                .OrderBy(x => x.Order)
                .Skip(startRow)
                .Take(settingOfBase.PageSizeForAdmin)
                .ToList()
                .ConvertAll(x => new SystemBankAccountExport(x));

            return new PageResult<SystemBankAccountExport>(this.PageIndex, countOfAllMessages, settingOfBase.PageSizeForAdmin, tList);
        }
        /// <summary>
        /// 获取提现记录
        /// </summary>
        /// <param name="db">数据库连接对象</param>
        /// <returns>返回提现记录</returns>
        public PageResult<WithdrawalsRecordExport> GetWithdrawDetails(IModelToDbContextOfAuthor db)
        {
            if (this.PageIndex < 1) { this.PageIndex = 1; }
            SettingOfBase settingOfBase = new SettingOfBase(db);
            int startRow = settingOfBase.PageSizeForClient * (this.PageIndex - 1);

            Expression<Func<WithdrawalsRecord, bool>> predicate1 = x => x.Id == this.Self.Id;
            Expression<Func<WithdrawalsRecord, bool>> predicate2 = x => x.Id > 0;
            Expression<Func<WithdrawalsRecord, bool>> predicate3 = x => x.Id > 0;
            Expression<Func<WithdrawalsRecord, bool>> predicate4 = x => x.Id > 0;
            if (this.BeginTime != null)
            {
                DateTime beginTime = (DateTime)this.BeginTime;
                predicate2 = x => x.CreatedTime >= beginTime;
            }
            if (this.EndTime != null)
            {
                DateTime endTime = (DateTime)this.EndTime;
                predicate3 = x => x.CreatedTime < endTime;
            }
            if (this.Status != null)
            {
                WithdrawalsStatus status = (WithdrawalsStatus)this.Status;
                predicate4 = x => x.Status == status;
            }

            int countOfAllMessages = db.WithdrawalsRecords
                .Where(predicate1)
                .Where(predicate2)
                .Where(predicate3)
                .Where(predicate4)
                .Count();
            var tList = db.WithdrawalsRecords
                .Where(predicate1)
                .Where(predicate2)
                .Where(predicate3)
                .Where(predicate4)
                .OrderByDescending(x => x.CreatedTime)
                .Skip(startRow)
                .Take(settingOfBase.PageSizeForClient)
                .ToList()
                .ConvertAll(x => new WithdrawalsRecordExport(x));

            return new PageResult<WithdrawalsRecordExport>(this.PageIndex, countOfAllMessages, settingOfBase.PageSizeForClient, tList);
        }
        /// <summary>
        /// 获取用户信息列表
        /// </summary>
        /// <param name="db">数据库连接对象</param>
        /// <returns>返回用户信息列表</returns>
        public PageResult<BasicAuthorExport> GetUsers(IModelToDbContextOfAuthor db)
        {
            if (this.PageIndex < 1) { this.PageIndex = 1; }
            SettingOfBase settingOfBase = new SettingOfBase(db);
            SettingOfAuthor settingOfAuthor = new SettingOfAuthor(db);
            int startRow = settingOfBase.PageSizeForClient * (this.PageIndex - 1);

            Expression<Func<Author, bool>> predicate1 = x => x.Id > 0;
            Expression<Func<Author, bool>> predicate2 = x => x.Id > 0;
            Expression<Func<Author, bool>> predicate3 = x => x.Relatives.Any(r => r.NodeId == this.Self.Id);

            if (this.KeywordForUsername != null)
            {
                this.KeywordForUsername = VerifyHelper.EliminateSpaces(this.KeywordForUsername);
                string[] keywords = this.KeywordForUsername.Split(new char[] { ' ' });
                predicate1 = x => keywords.All(kw => x.Username.Contains(kw));
            }
            if (this.OnlyImmediate == true)
            {
                predicate2 = x => x.Layer == this.Self.Layer + 1;
            }

            int countOfAllMessages = db.Authors
                .Where(predicate1)
                .Where(predicate2)
                .Where(predicate3)
                .Count();
            var tList = db.Authors
                .Where(predicate1)
                .Where(predicate2)
                .Where(predicate3)
                .OrderByDescending(x => x.Layer)
                .Skip(startRow)
                .Take(settingOfBase.PageSizeForClient)
                .ToList()
                .ConvertAll(x =>
                {
                    UserGroup group = db.UserGroups.FirstOrDefault(g => g.LowerOfConsumption <= x.Consumption && g.CapsOfConsumption > x.Consumption);
                    return new BasicAuthorExport(x, group);
                });

            return new PageResult<BasicAuthorExport>(this.PageIndex, countOfAllMessages, settingOfBase.PageSizeForClient, tList);
        }
        /// <summary>
        /// 获取转账记录
        /// </summary>
        /// <param name="db">数据库连接对象</param>
        /// <returns>返回转账记录</returns>
        public PageResult<TransferRecordExport> GetTransferRecords(IModelToDbContextOfAuthor db)
        {
            if (this.PageIndex < 1) { this.PageIndex = 1; }
            SettingOfBase settingOfBase = new SettingOfBase(db);
            int startRow = settingOfBase.PageSizeForAdmin * (this.PageIndex - 1);

            Expression<Func<TransferRecord, bool>> predicate1 = x => x.Id > 0;
            Expression<Func<TransferRecord, bool>> predicate2 = x => x.Id > 0;
            Expression<Func<TransferRecord, bool>> predicate3 = x => x.Id > 0;

            if (this.BeginTime != null)
            {
                DateTime beginTime = (DateTime)this.BeginTime;
                predicate1 = x => x.CreatedTime >= beginTime;
            }
            if (this.EndTime != null)
            {
                DateTime endtime = (DateTime)this.EndTime;
                predicate2 = x => x.CreatedTime <= endtime;
            }
            if (this.Status != null)
            {
                TransferStatus status = (TransferStatus)this.Status;
                predicate3 = x => x.Status == status;
            }

            int countOfAllMessages = db.TransferRecords
                .Where(predicate1)
                .Where(predicate2)
                .Where(predicate3)
                .Count();
            var tList = db.TransferRecords
                .Where(predicate1)
                .Where(predicate2)
                .Where(predicate3)
                .OrderByDescending(x => x.CreatedTime)
                .Skip(startRow)
                .Take(settingOfBase.PageSizeForAdmin)
                .ToList()
                .ConvertAll(x => new TransferRecordExport(x));

            return new PageResult<TransferRecordExport>(this.PageIndex, countOfAllMessages, settingOfBase.PageSizeForAdmin, tList);
        }
        /// <summary>
        /// 获取追号信息
        /// </summary>
        /// <param name="db">数据库连接对象</param>
        /// <returns>返回追号信息</returns>
        public PageResult<ChasingExport> GetChasings(IModelToDbContextOfLottery db)
        {
            if (this.PageIndex < 1) { this.PageIndex = 1; }
            SettingOfBase settingOfBase = new SettingOfBase(db);
            int startRow = settingOfBase.PageSizeForClient * (this.PageIndex - 1);

            Expression<Func<Chasing, bool>> predicate1 = x => x.Owner.Id == this.Self.Id;
            Expression<Func<Chasing, bool>> predicate2 = x => x.Id > 0;
            Expression<Func<Chasing, bool>> predicate3 = x => x.Id > 0;

            if (this.BeginTime != null)
            {
                DateTime beginTime = (DateTime)this.BeginTime;
                predicate2 = x => x.CreatedTime >= beginTime;
            }
            if (this.EndTime != null)
            {
                DateTime endTime = (DateTime)this.EndTime;
                predicate3 = x => x.CreatedTime < endTime;
            }

            int countOfAllMessages = db.Chasings
                .Where(predicate1)
                .Where(predicate2)
                .Where(predicate3)
                .Count();
            var tList = db.Chasings
                .Where(predicate1)
                .Where(predicate2)
                .Where(predicate3)
                .OrderByDescending(x => x.CreatedTime)
                .Skip(startRow)
                .Take(settingOfBase.PageSizeForClient)
                .ToList()
                .ConvertAll(x =>
                {
                    List<BettingWithChasing> bettings = db.BettingWithChasings.Where(b => b.Chasing.Id == x.Id).ToList();
                    return new ChasingExport(x, bettings);
                });

            return new PageResult<ChasingExport>(this.PageIndex, countOfAllMessages, settingOfBase.PageSizeForClient, tList);
        }
        /// <summary>
        /// 获取积分兑换的参与记录
        /// </summary>
        /// <param name="db">数据库连接对象</param>
        /// <returns>返回积分兑换的参与记录</returns>
        public PageResult<RedeemRecordExport> GetRedeemRecords(IModelToDbContextOfActivity db)
        {
            if (this.PageIndex < 1) { this.PageIndex = 1; }
            SettingOfBase settingOfBase = new SettingOfBase(db);
            int startRow = settingOfBase.PageSizeForClient * (this.PageIndex - 1);

            Expression<Func<RedeemRecord, bool>> predicate1 = x => x.Owner.Id == this.Self.Id;
            Expression<Func<RedeemRecord, bool>> predicate2 = x => x.Id > 0;
            Expression<Func<RedeemRecord, bool>> predicate3 = x => x.Id > 0;

            if (this.BeginTime != null)
            {
                DateTime beginTime = (DateTime)this.BeginTime;
                predicate2 = x => x.CreatedTime >= beginTime;
            }
            if (this.EndTime != null)
            {
                DateTime endtime = (DateTime)this.EndTime;
                predicate3 = x => x.CreatedTime <= endtime;
            }

            int countOfAllMessages = db.RedeemRecords
                .Where(predicate1)
                .Where(predicate2)
                .Where(predicate3)
                .Count();
            var tList = db.RedeemRecords
                .Where(predicate1)
                .Where(predicate2)
                .Where(predicate3)
                .OrderByDescending(x => x.CreatedTime)
                .Skip(startRow)
                .Take(settingOfBase.PageSizeForClient)
                .ToList()
                .ConvertAll(x => new RedeemRecordExport(x));

            return new PageResult<RedeemRecordExport>(this.PageIndex, countOfAllMessages, settingOfBase.PageSizeForClient, tList);
        }
        /// <summary>
        /// 获取虚拟排行信息
        /// </summary>
        /// <param name="db">数据库连接对象</param>
        /// <returns>返回虚拟排行信息</returns>
        public PageResult<VirtualBonusExport> GetVirtualBonus(IModelToDbContextOfLottery db)
        {
            if (this.PageIndex < 1) { this.PageIndex = 1; }
            SettingOfBase settingOfBase = new SettingOfBase(db);
            int startRow = settingOfBase.PageSizeForAdmin * (this.PageIndex - 1);

            Expression<Func<VirtualBonus, bool>> predicate1 = x => x.Id > 0;
            Expression<Func<VirtualBonus, bool>> predicate2 = x => x.Id > 0;

            if (this.KeywordForTicketName != null)
            {
                this.KeywordForTicketName = VerifyHelper.EliminateSpaces(this.KeywordForTicketName);
                string[] keywords = this.KeywordForTicketName.Split(new char[] { ' ' });
                predicate1 = x => keywords.All(kw => x.Ticket.Name.Contains(kw));
            }
            if (this.TicketId != null)
            {
                int ticketId = (int)this.TicketId;
                predicate2 = x => x.Ticket.Id == ticketId;
            }

            int countOfAllMessages = db.VirtualBonuss
                .Where(predicate1)
                .Where(predicate2)
                .Count();
            var tList = db.VirtualBonuss
                .Where(predicate1)
                .Where(predicate2)
                .OrderBy(x => x.Ticket.Order)
                .Skip(startRow)
                .Take(settingOfBase.PageSizeForAdmin)
                .ToList()
                .ConvertAll(x => new VirtualBonusExport(x));

            return new PageResult<VirtualBonusExport>(this.PageIndex, countOfAllMessages, settingOfBase.PageSizeForAdmin, tList);
        }
        /// <summary>
        /// 获取积分兑换奖励的计划
        /// </summary>
        /// <param name="db">数据库连接对象</param>
        /// <returns>返回积分兑换奖励的计划</returns>
        public PageResult<RedeemPlanExport> GetRedeemPlans(IModelToDbContextOfActivity db)
        {
            if (this.PageIndex < 1) { this.PageIndex = 1; }
            SettingOfBase settingOfBase = new SettingOfBase(db);
            int startRow = settingOfBase.PageSizeForClient * (this.PageIndex - 1);

            Expression<Func<RedeemPlan, bool>> predicate1 = x => x.EndTime > DateTime.Now;
            Expression<Func<RedeemPlan, bool>> predicate2 = x => x.Hide == false;

            int countOfAllMessages = db.RedeemPlans
                .Where(predicate1)
                .Where(predicate2)
                .Count();
            var tList = db.RedeemPlans
                .Where(predicate1)
                .Where(predicate2)
                .OrderByDescending(x => x.CreatedTime)
                .Skip(startRow)
                .Take(settingOfBase.PageSizeForClient)
                .ToList()
                .ConvertAll(x => new RedeemPlanExport(x));

            return new PageResult<RedeemPlanExport>(this.PageIndex, countOfAllMessages, settingOfBase.PageSizeForClient, tList);
        }
        /// <summary>
        /// 获取私人/团队报表
        /// </summary>
        /// <param name="db">数据库连接对象</param>
        /// <returns>返回私人/团队报表</returns>
        public PageResult<RersonalAndTeamReportExport> GetRersonalAndTeamReports(IModelToDbContextOfReport db)
        {
            if (this.PageIndex < 1) { this.PageIndex = 1; }
            SettingOfBase settingOfBase = new SettingOfBase(db);
            int startRow = settingOfBase.PageSizeForClient * (this.PageIndex - 1);

            if (this.TOS == TeamOrSelf.Self)
            {
                if (this.MOD == MonthOrDay.Month)
                {
                    #region 单月个人报表

                    Expression<Func<RersonalReportForOneMonth, bool>> predicate1 = x => x.Owner.Id == this.Self.Id;

                    int countOfAllMessages = db.RersonalReportForOneMonths
                        .Where(predicate1)
                        .Count();
                    var tList = db.RersonalReportForOneMonths
                        .Where(predicate1)
                        .OrderByDescending(x => x.Id)
                        .Skip(startRow)
                        .Take(settingOfBase.PageSizeForClient)
                        .ToList()
                        .ConvertAll(x => new RersonalAndTeamReportExport(x));

                    return new PageResult<RersonalAndTeamReportExport>(this.PageIndex, countOfAllMessages, settingOfBase.PageSizeForClient, tList);

                    #endregion
                }
                else
                {
                    #region 单日个人报表

                    Expression<Func<RersonalReportForOneDay, bool>> predicate1 = x => x.Owner.Id == this.Self.Id;

                    int countOfAllMessages = db.RersonalReportForOneDays
                        .Where(predicate1)
                        .Count();
                    var tList = db.RersonalReportForOneDays
                        .Where(predicate1)
                        .OrderByDescending(x => x.Id)
                        .Skip(startRow)
                        .Take(settingOfBase.PageSizeForClient)
                        .ToList()
                        .ConvertAll(x => new RersonalAndTeamReportExport(x));

                    return new PageResult<RersonalAndTeamReportExport>(this.PageIndex, countOfAllMessages, settingOfBase.PageSizeForClient, tList);

                    #endregion
                }
            }
            else
            {
                if (this.MOD == MonthOrDay.Month)
                {
                    #region 单月团队人报表

                    Expression<Func<TeamReportForOneMonth, bool>> predicate1 = x => x.Owner.Id == this.Self.Id;

                    int countOfAllMessages = db.TeamReportForOneMonths
                        .Where(predicate1)
                        .Count();
                    var tList = db.TeamReportForOneMonths
                        .Where(predicate1)
                        .OrderByDescending(x => x.Id)
                        .Skip(startRow)
                        .Take(settingOfBase.PageSizeForClient)
                        .ToList()
                        .ConvertAll(x => new RersonalAndTeamReportExport(x));

                    return new PageResult<RersonalAndTeamReportExport>(this.PageIndex, countOfAllMessages, settingOfBase.PageSizeForClient, tList);

                    #endregion
                }
                else
                {
                    #region 单月团队人报表

                    Expression<Func<TeamReportForOneDay, bool>> predicate1 = x => x.Owner.Id == this.Self.Id;

                    int countOfAllMessages = db.TeamReportForOneDays
                        .Where(predicate1)
                        .Count();
                    var tList = db.TeamReportForOneDays
                        .Where(predicate1)
                        .OrderByDescending(x => x.Id)
                        .Skip(startRow)
                        .Take(settingOfBase.PageSizeForClient)
                        .ToList()
                        .ConvertAll(x => new RersonalAndTeamReportExport(x));

                    return new PageResult<RersonalAndTeamReportExport>(this.PageIndex, countOfAllMessages, settingOfBase.PageSizeForClient, tList);

                    #endregion
                }
            }
        }
        /// <summary>
        /// 获取站点统计
        /// </summary>
        /// <param name="db">数据库连接对象</param>
        /// <returns>返回站点统计</returns>
        public PageResult<SiteReportExpot> GetSiteReports(IModelToDbContextOfReport db)
        {
            if (this.PageIndex < 1) { this.PageIndex = 1; }
            SettingOfBase settingOfBase = new SettingOfBase(db);
            int startRow = settingOfBase.PageSizeForAdmin * (this.PageIndex - 1);

            if (this.MOD == MonthOrDay.Month)
            {
                #region 单月报表

                Expression<Func<SiteReportForOneMonth, bool>> predicate1 = x => x.Id > 0;
                Expression<Func<SiteReportForOneMonth, bool>> predicate2 = x => x.Id > 0;

                if (this.BeginTime != null)
                {
                    DateTime beginTime = (DateTime)this.BeginTime;
                    predicate1 = x => x.Time >= beginTime;
                }
                if (this.EndTime != null)
                {
                    DateTime endtime = (DateTime)this.EndTime;
                    predicate2 = x => x.Time <= endtime;
                }

                int countOfAllMessages = db.SiteReportForOneMonths
                    .Where(predicate1)
                    .Where(predicate2)
                    .Count();
                var tList = db.SiteReportForOneMonths
                    .Where(predicate1)
                    .Where(predicate2)
                    .OrderByDescending(x => x.Id)
                    .Skip(startRow)
                    .Take(settingOfBase.PageSizeForAdmin)
                    .ToList()
                    .ConvertAll(x => new SiteReportExpot(x));

                return new PageResult<SiteReportExpot>(this.PageIndex, countOfAllMessages, settingOfBase.PageSizeForAdmin, tList);

                #endregion
            }
            else
            {
                #region 单日报表

                Expression<Func<SiteReportForOneDay, bool>> predicate1 = x => x.Id > 0;
                Expression<Func<SiteReportForOneDay, bool>> predicate2 = x => x.Id > 0;

                if (this.BeginTime != null)
                {
                    DateTime beginTime = (DateTime)this.BeginTime;
                    predicate1 = x => x.Time >= beginTime;
                }
                if (this.EndTime != null)
                {
                    DateTime endtime = (DateTime)this.EndTime;
                    predicate2 = x => x.Time <= endtime;
                }

                int countOfAllMessages = db.SiteReportForOneDays
                    .Where(predicate1)
                    .Where(predicate2)
                    .Count();
                var tList = db.SiteReportForOneDays
                    .Where(predicate1)
                    .Where(predicate2)
                    .OrderByDescending(x => x.Id)
                    .Skip(startRow)
                    .Take(settingOfBase.PageSizeForAdmin)
                    .ToList()
                    .ConvertAll(x => new SiteReportExpot(x));

                return new PageResult<SiteReportExpot>(this.PageIndex, countOfAllMessages, settingOfBase.PageSizeForAdmin, tList);

                #endregion
            }
        }
        /// <summary>
        /// 获取私人/团队报表
        /// </summary>
        /// <param name="db">数据库连接对象</param>
        /// <returns>返回私人/团队报表</returns>
        public PageResult<RersonalAndTeamReportExport> GetRersonalAndTeamReports(IModelToDbContextOfReport db)
        {
            if (this.PageIndex < 1) { this.PageIndex = 1; }
            SettingOfBase settingOfBase = new SettingOfBase(db);
            int startRow = settingOfBase.PageSizeForAdmin * (this.PageIndex - 1);

            if (this.TOS == TeamOrSelf.Self)
            {
                if (this.MOD == MonthOrDay.Month)
                {
                    #region 单月个人报表

                    Expression<Func<RersonalReportForOneMonth, bool>> predicate1 = x => x.Id > 0;
                    Expression<Func<RersonalReportForOneMonth, bool>> predicate2 = x => x.Id > 0;
                    Expression<Func<RersonalReportForOneMonth, bool>> predicate3 = x => x.Id > 0;
                    Expression<Func<RersonalReportForOneMonth, bool>> predicate4 = x => x.Id > 0;

                    if (this.KeywordOfUsername != null)
                    {
                        this.KeywordOfUsername = VerifyHelper.EliminateSpaces(this.KeywordOfUsername);
                        string[] keywords = this.KeywordOfUsername.Split(new char[] { ' ' });
                        predicate1 = x => keywords.All(kw => x.Owner.Username.Contains(kw));
                    }
                    if (this.UserId != null)
                    {
                        int userId = (int)this.UserId;
                        predicate2 = x => x.Owner.Id == userId;
                    }
                    if (this.BeginTime != null)
                    {
                        DateTime beginTime = (DateTime)this.BeginTime;
                        predicate3 = x => x.Time >= beginTime;
                    }
                    if (this.EndTime != null)
                    {
                        DateTime endtime = (DateTime)this.EndTime;
                        predicate4 = x => x.Time <= endtime;
                    }

                    int countOfAllMessages = db.RersonalReportForOneMonths
                        .Where(predicate1)
                        .Where(predicate2)
                        .Where(predicate3)
                        .Where(predicate4)
                        .Count();
                    var tList = db.RersonalReportForOneMonths
                        .Where(predicate1)
                        .Where(predicate2)
                        .Where(predicate3)
                        .Where(predicate4)
                        .OrderByDescending(x => x.Id)
                        .Skip(startRow)
                        .Take(settingOfBase.PageSizeForAdmin)
                        .ToList()
                        .ConvertAll(x => new RersonalAndTeamReportExport(x));

                    return new PageResult<RersonalAndTeamReportExport>(this.PageIndex, countOfAllMessages, settingOfBase.PageSizeForAdmin, tList);

                    #endregion
                }
                else
                {
                    #region 单日个人报表

                    Expression<Func<RersonalReportForOneDay, bool>> predicate1 = x => x.Id > 0;
                    Expression<Func<RersonalReportForOneDay, bool>> predicate2 = x => x.Id > 0;
                    Expression<Func<RersonalReportForOneDay, bool>> predicate3 = x => x.Id > 0;
                    Expression<Func<RersonalReportForOneDay, bool>> predicate4 = x => x.Id > 0;

                    if (this.KeywordOfUsername != null)
                    {
                        this.KeywordOfUsername = VerifyHelper.EliminateSpaces(this.KeywordOfUsername);
                        string[] keywords = this.KeywordOfUsername.Split(new char[] { ' ' });
                        predicate1 = x => keywords.All(kw => x.Owner.Username.Contains(kw));
                    }
                    if (this.UserId != null)
                    {
                        int userId = (int)this.UserId;
                        predicate2 = x => x.Owner.Id == userId;
                    }
                    if (this.BeginTime != null)
                    {
                        DateTime beginTime = (DateTime)this.BeginTime;
                        predicate3 = x => x.Time >= beginTime;
                    }
                    if (this.EndTime != null)
                    {
                        DateTime endtime = (DateTime)this.EndTime;
                        predicate4 = x => x.Time <= endtime;
                    }

                    int countOfAllMessages = db.RersonalReportForOneDays
                        .Where(predicate1)
                        .Where(predicate2)
                        .Where(predicate3)
                        .Where(predicate4)
                        .Count();
                    var tList = db.RersonalReportForOneDays
                        .Where(predicate1)
                        .Where(predicate2)
                        .Where(predicate3)
                        .Where(predicate4)
                        .OrderByDescending(x => x.Id)
                        .Skip(startRow)
                        .Take(settingOfBase.PageSizeForAdmin)
                        .ToList()
                        .ConvertAll(x => new RersonalAndTeamReportExport(x));

                    return new PageResult<RersonalAndTeamReportExport>(this.PageIndex, countOfAllMessages, settingOfBase.PageSizeForAdmin, tList);

                    #endregion
                }
            }
            else
            {
                if (this.MOD == MonthOrDay.Month)
                {
                    #region 单月团队人报表

                    Expression<Func<TeamReportForOneMonth, bool>> predicate1 = x => x.Id > 0;
                    Expression<Func<TeamReportForOneMonth, bool>> predicate2 = x => x.Id > 0;
                    Expression<Func<TeamReportForOneMonth, bool>> predicate3 = x => x.Id > 0;
                    Expression<Func<TeamReportForOneMonth, bool>> predicate4 = x => x.Id > 0;

                    if (this.KeywordOfUsername != null)
                    {
                        this.KeywordOfUsername = VerifyHelper.EliminateSpaces(this.KeywordOfUsername);
                        string[] keywords = this.KeywordOfUsername.Split(new char[] { ' ' });
                        predicate1 = x => keywords.All(kw => x.Owner.Username.Contains(kw));
                    }
                    if (this.UserId != null)
                    {
                        int userId = (int)this.UserId;
                        predicate2 = x => x.Owner.Id == userId;
                    }
                    if (this.BeginTime != null)
                    {
                        DateTime beginTime = (DateTime)this.BeginTime;
                        predicate3 = x => x.Time >= beginTime;
                    }
                    if (this.EndTime != null)
                    {
                        DateTime endtime = (DateTime)this.EndTime;
                        predicate4 = x => x.Time <= endtime;
                    }

                    int countOfAllMessages = db.TeamReportForOneMonths
                        .Where(predicate1)
                        .Where(predicate2)
                        .Where(predicate3)
                        .Where(predicate4)
                        .Count();
                    var tList = db.TeamReportForOneMonths
                        .Where(predicate1)
                        .Where(predicate2)
                        .Where(predicate3)
                        .Where(predicate4)
                        .OrderByDescending(x => x.Id)
                        .Skip(startRow)
                        .Take(settingOfBase.PageSizeForAdmin)
                        .ToList()
                        .ConvertAll(x => new RersonalAndTeamReportExport(x));

                    return new PageResult<RersonalAndTeamReportExport>(this.PageIndex, countOfAllMessages, settingOfBase.PageSizeForAdmin, tList);

                    #endregion
                }
                else
                {
                    #region 单月团队人报表

                    Expression<Func<TeamReportForOneDay, bool>> predicate1 = x => x.Id > 0;
                    Expression<Func<TeamReportForOneDay, bool>> predicate2 = x => x.Id > 0;
                    Expression<Func<TeamReportForOneDay, bool>> predicate3 = x => x.Id > 0;
                    Expression<Func<TeamReportForOneDay, bool>> predicate4 = x => x.Id > 0;

                    if (this.KeywordOfUsername != null)
                    {
                        this.KeywordOfUsername = VerifyHelper.EliminateSpaces(this.KeywordOfUsername);
                        string[] keywords = this.KeywordOfUsername.Split(new char[] { ' ' });
                        predicate1 = x => keywords.All(kw => x.Owner.Username.Contains(kw));
                    }
                    if (this.UserId != null)
                    {
                        int userId = (int)this.UserId;
                        predicate2 = x => x.Owner.Id == userId;
                    }
                    if (this.BeginTime != null)
                    {
                        DateTime beginTime = (DateTime)this.BeginTime;
                        predicate3 = x => x.Time >= beginTime;
                    }
                    if (this.EndTime != null)
                    {
                        DateTime endtime = (DateTime)this.EndTime;
                        predicate4 = x => x.Time <= endtime;
                    }

                    int countOfAllMessages = db.TeamReportForOneDays
                        .Where(predicate1)
                        .Where(predicate2)
                        .Where(predicate3)
                        .Where(predicate4)
                        .Count();
                    var tList = db.TeamReportForOneDays
                        .Where(predicate1)
                        .Where(predicate2)
                        .Where(predicate3)
                        .Where(predicate4)
                        .OrderByDescending(x => x.Id)
                        .Skip(startRow)
                        .Take(settingOfBase.PageSizeForAdmin)
                        .ToList()
                        .ConvertAll(x => new RersonalAndTeamReportExport(x));

                    return new PageResult<RersonalAndTeamReportExport>(this.PageIndex, countOfAllMessages, settingOfBase.PageSizeForAdmin, tList);

                    #endregion
                }
            }
        }
        /// <summary>
        /// 设置
        /// </summary>
        /// <param name="settingOfBase">基本设置</param>
        /// <param name="settingOfAuthor">用户设置</param>
        /// <param name="settingOfLottery">彩票设置</param>
        public SettingExport(SettingOfBase settingOfBase, SettingOfAuthor settingOfAuthor, SettingOfLottery settingOfLottery)
        {
            this.PageSizeForClient = settingOfBase.PageSizeForClient;
            this.PageSizeForAdmin = settingOfBase.PageSizeForAdmin;
            this.HeartbeatInterval = settingOfBase.HeartbeatInterval;
            this.WorkingHour_Begin = settingOfBase.WorkingHour_Begin;
            this.WorkingHour_End = settingOfBase.WorkingHour_End;
            this.VirtualQueuing = settingOfBase.VirtualQueuing;
            this.CollectionRunning = settingOfBase.CollectionRunning;

            this.LowerRebate = settingOfAuthor.LowerRebate;
            this.CapsRebate = settingOfAuthor.CapsRebate;
            this.LowerRebateOfHigh = settingOfAuthor.LowerRebateOfHigh;
            this.CapsRebateOfHigh = settingOfAuthor.CapsRebateOfHigh;
            this.RechargeRecordTimeout = settingOfAuthor.RechargeRecordTimeout;
            this.SpreadRecordTimeout = settingOfAuthor.SpreadRecordTimeout;
            this.ForgotPasswordRecordTimeout = settingOfAuthor.ForgotPasswordRecordTimeout;
            this.DaysOfDividend = settingOfAuthor.DaysOfDividend;
            this.TimesOfWithdrawal = settingOfAuthor.TimesOfWithdrawal;
            this.MinimumWithdrawalAmount = settingOfAuthor.MinimumWithdrawalAmount;
            this.MaximumWithdrawalAmount = settingOfAuthor.MaximumWithdrawalAmount;
            this.Commission_A = settingOfAuthor.Commission_A;
            this.Commission_B = settingOfAuthor.Commission_B;
            this.LowerConsumptionForCommission = settingOfAuthor.LowerConsumptionForCommission;
            this.Dividend_A = settingOfAuthor.Dividend_A;
            this.Dividend_B = settingOfAuthor.Dividend_B;
            this.LowerConsumptionForDividend = settingOfAuthor.LowerConsumptionForDividend;
            this.ClearUser_DaysOfInactive = settingOfAuthor.ClearUser_DaysOfInactive;
            this.ClearUser_DaysOfUnSetIn = settingOfAuthor.ClearUser_DaysOfUnSetIn;
            this.ClearUser_LowerOfMoney = settingOfAuthor.ClearUser_LowerOfMoney;
            this.ClearUser_DaysOfUnMoneyChange = settingOfAuthor.ClearUser_DaysOfUnMoneyChange;

            this.UnitPrice = settingOfLottery.UnitPrice;
            this.PayoutBase = settingOfLottery.PayoutBase;
            this.LineForProhibitBetting = settingOfLottery.LineForProhibitBetting;
            this.MaximumPayout = settingOfLottery.MaximumPayout;
            this.ConversionRates = settingOfLottery.ConversionRates;
            this.MaximumBetsNumber = settingOfLottery.MaximumBetsNumber;
            this.ClosureSingleTime = settingOfLottery.ClosureSingleTime;
        }
        /// <summary>
        /// 获取用户信息列表
        /// </summary>
        /// <param name="db">数据库连接对象</param>
        /// <returns>返回用户信息列表</returns>
        public PageResult<AuthorExport> GetUsers(IModelToDbContextOfAuthor db)
        {
            if (this.PageIndex < 1) { this.PageIndex = 1; }
            SettingOfBase settingOfBase = new SettingOfBase(db);
            SettingOfAuthor settingOfAuthor = new SettingOfAuthor(db);
            int startRow = settingOfBase.PageSizeForAdmin * (this.PageIndex - 1);

            Expression<Func<Author, bool>> predicate1 = x => x.Id > 0;
            Expression<Func<Author, bool>> predicate2 = x => x.Id > 0;
            Expression<Func<Author, bool>> predicate3 = x => x.Id > 0;

            if (this.KeywordForUsername != null)
            {
                this.KeywordForUsername = VerifyHelper.EliminateSpaces(this.KeywordForUsername);
                string[] keywords = this.KeywordForUsername.Split(new char[] { ' ' });
                predicate1 = x => keywords.All(kw => x.Username.Contains(kw));
            }
            if (this.GroupId != null)
            {
                int groupId = (int)this.GroupId;
                UserGroup group = db.UserGroups.Find(groupId);
                predicate2 = x => x.Consumption >= group.LowerOfConsumption
                    && x.Consumption < group.CapsOfConsumption;
            }
            if (this.BelongingUserId != null)
            {
                int belongingUserId = (int)this.BelongingUserId;
                predicate3 = x => x.Relatives.Any(r => r.NodeId == belongingUserId);
            }

            int countOfAllMessages = db.Authors
                .Where(predicate1)
                .Where(predicate2)
                .Where(predicate3)
                .Count();
            var tList = db.Authors
                .Where(predicate1)
                .Where(predicate2)
                .Where(predicate3)
                .OrderBy(x => x.Username)
                .Skip(startRow)
                .Take(settingOfBase.PageSizeForAdmin)
                .ToList()
                .ConvertAll(x =>
                {
                    UserGroup group = db.UserGroups.FirstOrDefault(g => g.LowerOfConsumption <= x.Consumption && g.CapsOfConsumption > x.Consumption);
                    SystemQuota systemQuota = db.SystemQuotas.FirstOrDefault(s => s.Rebate == x.PlayInfo.Rebate_Normal);
                    var t = db.SystemQuotas.ToList();
                    if (systemQuota == null)
                    {
                        systemQuota = new SystemQuota(x.PlayInfo.Rebate_Normal, new List<SystemQuotaDetail>());
                        for (double i = settingOfAuthor.LowerRebateOfHigh; i <= settingOfAuthor.CapsRebateOfHigh; i += 0.1)
                        {
                            SystemQuotaDetail sqd = new SystemQuotaDetail(i, 0);
                            systemQuota.Details.Add(sqd);
                        }
                    }
                    Author parent = db.Authors.FirstOrDefault(p => x.Relatives.Any(r => r.NodeId == p.Id) && p.Layer == x.Layer - 1);
                    return new AuthorExport(x, parent, group, systemQuota.Details);
                });

            return new PageResult<AuthorExport>(this.PageIndex, countOfAllMessages, settingOfBase.PageSizeForAdmin, tList);
        }