Esempio n. 1
0
        private static void CurrentDomainOnDomainUnload(object sender,
                                                        EventArgs eventArgs)
        {
            Logger.DebugWithLineNumber("Start CurrentDomainOnDomainUnload.");

            //-------------------------------------------
            // Shut down nodes.
            //-------------------------------------------
            foreach (var appDomainNodeTask in AppDomainNodeTasks)
            {
                appDomainNodeTask.Value.Dispose();
            }

            //-------------------------------------------
            // Shut down managers.
            //-------------------------------------------
            foreach (var appDomainManagerTask in AppDomainManagerTasks)
            {
                appDomainManagerTask.Value.Dispose();
            }

            QuitEvent.Set();

            Logger.DebugWithLineNumber("Finished CurrentDomainOnDomainUnload.");
        }
Esempio n. 2
0
        private static bool ConsoleCtrlCheck(CtrlTypes ctrlType)
        {
            if (ctrlType == CtrlTypes.CtrlCloseEvent ||
                ctrlType == CtrlTypes.CtrlShutdownEvent)
            {
                QuitEvent.Set();

                return(true);
            }

            return(false);
        }
Esempio n. 3
0
        public static void Main(string[] args)
        {
            if (args.Length < 2)
            {
                PokewatchLogger.Log("[-]Missing Arguments. Indeces of account and regions must be specified.", "PokewatchUnknown");
                Environment.Exit(2);
            }
            s_config = ConfigurationManager.ReadConfiguration("Pokewatch");
            if (s_config == null)
            {
                Environment.Exit(2);
            }
            try
            {
                s_account = s_config.PoGoAccounts[int.Parse(args[0])];
                for (int i = 1; i < args.Length; i++)
                {
                    s_regions.Add(s_config.Regions[int.Parse(args[i])]);
                }
            }
            catch
            {
                PokewatchLogger.Log("[-]Arguments do not align with provided configuration: " + string.Join(" ", args), "PokewatchUnknown");
                Environment.Exit(2);
            }

            try
            {
                s_scanAreas = s_regions.SelectMany(r => r.Locations.Select(l => new ScanArea
                {
                    Location   = l,
                    Name       = r.Name,
                    Prefix     = r.Prefix,
                    Suffix     = r.Suffix,
                    Inclusions = r.Inclusions,
                    Exclusions = r.Exclusions
                })).ToList();
                s_currentScan = s_scanAreas.First();
                s_scanIndex   = 0;
            }
            catch
            {
                PokewatchLogger.Log("[-]Invalid Region Configuration", AccountManager.GetAccountName(s_account));
                Environment.Exit(2);
            }

            Console.Title = AccountManager.GetAccountName(s_account) + ": " + string.Join(", ", s_regions.Select(r => r.Name));

            s_pogoSession = AccountManager.SignIn(s_account, s_currentScan.Location);
            if (s_pogoSession == null)
            {
                PokewatchLogger.Log("[-]Unable to sign in to PokemonGo.", AccountManager.GetAccountName(s_account));
                Environment.Exit(3);
            }

            if (!PrepareTwitterClient())
            {
                Environment.Exit(4);
            }

            PokewatchLogger.Log("[+]Sucessfully signed in to twitter.", AccountManager.GetAccountName(s_account));

            if (s_pogoSession.StartupAsync().Result)
            {
                PokewatchLogger.Log("[-]POGO Couldn't start.", "PokewatchUnknown");
                Environment.Exit(2);
            }

            s_pogoSession.AccessTokenUpdated += (sender, eventArgs) =>
            {
                PokewatchLogger.Log("[+]Access token updated.", AccountManager.GetAccountName(s_account));
            };

            s_pogoSession.Map.Update += (sender, eventArgs) =>
            {
                PokewatchLogger.Log("[+]Location Acknowleged. Searching...", AccountManager.GetAccountName(s_account));
                if (Search())
                {
                    UpdateLocation();
                }
            };

            Console.CancelKeyPress += (sender, eArgs) => {
                QuitEvent.Set();
                eArgs.Cancel = true;
            };

            QuitEvent.WaitOne();
        }