コード例 #1
0
ファイル: Session.cs プロジェクト: zsg0601/NecroBot
        public Session(GlobalSettings globalSettings, ISettings settings, ILogicSettings logicSettings,
                       IElevationService elevationService, ITranslation translation)
        {
            GlobalSettings          = globalSettings;
            CancellationTokenSource = new CancellationTokenSource();
            Forts             = new List <FortData>();
            VisibleForts      = new List <FortData>();
            Cache             = new MemoryCache("NecroBot2");
            accounts          = new List <AuthConfig>();
            EventDispatcher   = new EventDispatcher();
            LogicSettings     = logicSettings;
            RuntimeStatistics = new Statistics();

            ElevationService = elevationService;

            Settings = settings;

            Translation = translation;
            Reset(settings, LogicSettings);
            Stats = new SessionStats(this);

            AnalyticsService = new AnalyticsService();

            accounts.AddRange(logicSettings.Bots);
            if (!accounts.Any(x => x.AuthType == settings.AuthType && x.Username == settings.Username))
            {
                accounts.Add(new AuthConfig()
                {
                    AuthType = settings.AuthType,
                    Password = settings.Password,
                    Username = settings.Username,
                    AutoExitBotIfAccountFlagged = settings.AutoExitBotIfAccountFlagged,
                    AccountLatitude             = settings.AccountLatitude,
                    AccountLongitude            = settings.AccountLongitude,
                    AccountActive = settings.AccountActive,
                    RunStart      = settings.RunStart,
                    RunEnd        = settings.RunEnd,
                });
            }
            if (File.Exists("runtime.log"))
            {
                var lines = File.ReadAllLines("runtime.log");
                foreach (var item in lines)
                {
                    var arr = item.Split(';');
                    var acc = accounts.FirstOrDefault(p => p.Username == arr[0]);
                    if (acc != null)
                    {
                        acc.RuntimeTotal = Convert.ToDouble(arr[1]);
                    }
                }
            }

            GymState = new GymTeamState();
        }
コード例 #2
0
ファイル: Session.cs プロジェクト: sonvuhung/NecroBot
        public Session(ISettings settings, ILogicSettings logicSettings,
                       IElevationService elevationService, ITranslation translation)
        {
            this.CancellationTokenSource = new CancellationTokenSource();
            this.Forts             = new List <FortData>();
            this.VisibleForts      = new List <FortData>();
            this.Cache             = new MemoryCache("Necrobot2");
            this.accounts          = new List <AuthConfig>();
            this.EventDispatcher   = new EventDispatcher();
            this.LogicSettings     = logicSettings;
            this.RuntimeStatistics = new Statistics();

            this.ElevationService = elevationService;

            this.Settings = settings;

            this.Translation = translation;
            this.Reset(settings, LogicSettings);
            this.Stats = new SessionStats(this);
            this.accounts.AddRange(logicSettings.Bots);
            if (!this.accounts.Any(x => (x.AuthType == AuthType.Ptc && x.PtcUsername == settings.PtcUsername) ||
                                   (x.AuthType == AuthType.Google && x.GoogleUsername == settings.GoogleUsername)
                                   ))
            {
                this.accounts.Add(new AuthConfig()
                {
                    AuthType       = settings.AuthType,
                    GooglePassword = settings.GooglePassword,
                    GoogleUsername = settings.GoogleUsername,
                    PtcPassword    = settings.PtcPassword,
                    PtcUsername    = settings.PtcUsername
                });
            }
            if (File.Exists("runtime.log"))
            {
                var lines = File.ReadAllLines("runtime.log");
                foreach (var item in lines)
                {
                    var arr = item.Split(';');
                    var acc = this.accounts.FirstOrDefault(p => p.PtcUsername == arr[0] || p.GoogleUsername == arr[1]);
                    if (acc != null)
                    {
                        acc.RuntimeTotal = Convert.ToDouble(arr[1]);
                    }
                }
            }

            GymState = new GymTeamState();
        }