public static async Task Main(string[] args)
        {
            SyncfusionLicenseProvider.RegisterLicense("MjY0ODk0QDMxMzgyZTMxMmUzMEx6Vkt0M1ZIRFVPRWFqMEcwbWVrK3dqUldkYzZiaXA3TGFlWDFORDFNSms9");

            switch (IpConfigurationChecker.CheckConfiguration())
            {
            case null:
                Environment.ExitCode = -1;
                return;

            case true:
                await ActorApplication.Create(args)
                .ConfigurateNode()
                .ConfigureLogging((context, configuration) => configuration.WriteTo.Sink <SeriLogViewerSink>())
                .ConfigurateAkkaSystem((context, system) => system.RegisterLocalization())
                .ConfigurateAkkaSystem((context, system) => KillSwitch.Subscribe(system, KillRecpientType.Frontend))
                .ConfigurateAkkaSystem(
                    (context, system) =>
                    Cluster.Get(system)
                    .RegisterOnMemberUp(
                        () => ServiceRegistry.GetRegistry(system).RegisterService(new RegisterService(context.HostEnvironment.ApplicationName, Cluster.Get(system).SelfUniqueAddress))))
                .ConfigureAutoFac(cb => cb.RegisterModule <CoreModule>())
                .UseWpf <MainWindow>(configuration => configuration.WithAppFactory(() => new App()))
                .Build().Run();

                break;

            case false:
                Process.Start(System.Windows.Forms.Application.ExecutablePath.Replace(".dll", ".exe"), Environment.CommandLine);
                break;
            }
        }
        public static IApplicationBuilder StartNode(string[] args, KillRecpientType type)
        {
            //Assemblys.WireUp();
            return(ActorApplication.Create(args)
                   .ConfigureAutoFac(cb =>
            {
                cb.RegisterType <ConsoleAppRoute>().Named <IAppRoute>("default");
                cb.RegisterType <KillHelper>().As <IStartUpAction>();
            })
                   .ConfigurateNode()
                   .ConfigureLogging((context, configuration) =>
            {
                Console.Title = context.HostEnvironment.ApplicationName;

                configuration.WriteTo.ColoredConsole();
            })
                   .ConfigurateAkkaSystem((context, system) =>
            {
                if (type == KillRecpientType.Seed)
                {
                    KillSwitch.Setup(system);
                }
                else
                {
                    KillSwitch.Subscribe(system, type);
                }
            }));
        }
Exemplo n.º 3
0
        public void Reset(ISettings settings, ILogicSettings logicSettings)
        {
            ApiFailureStrategy _apiStrategy = new ApiFailureStrategy(this);

            Client = new Client(Settings, _apiStrategy);
            // ferox wants us to set this manually
            Inventory  = new Inventory(Client, logicSettings);
            Navigation = new Navigation(Client);
            KillSwitch = new KillSwitch();
        }
Exemplo n.º 4
0
        public static IHostBuilder StartNode(this IHostBuilder builder, KillRecpientType type, IpcApplicationType ipcType, Action <IActorApplicationBuilder>?build = null, bool consoleLog = false)
        {
            var masterReady = false;

            if (ipcType != IpcApplicationType.NoIpc)
            {
                masterReady = SharmComunicator.MasterIpcReady(IpcName);
            }
            var ipc = new IpcConnection(masterReady, ipcType,
                                        (s, exception) => LogManager.GetCurrentClassLogger().Error(exception, "Ipc Error: {Info}", s));

            return(builder.ConfigureLogging((context, configuration) =>
            {
                System.Console.Title = context.HostingEnvironment.ApplicationName;
                if (consoleLog)
                {
                    configuration.AddConsole();
                }
            })
                   .ConfigurateNode(ab =>
            {
                ab.ConfigureAutoFac(cb =>
                {
                    cb.RegisterType <NodeAppService>().As <IHostedService>();
                    cb.RegisterType <KillHelper>().As <IStartUpAction>();
                    cb.RegisterInstance(ipc).As <IIpcConnection>();
                })
                .ConfigureAkkaSystem((_, system) =>
                {
                    switch (type)
                    {
                    case KillRecpientType.Seed:
                        KillSwitch.Setup(system);
                        break;

                    default:
                        KillSwitch.Subscribe(system, type);
                        break;
                    }
                });

                build?.Invoke(ab);
            }));
        }
Exemplo n.º 5
0
        public sealed override void OnExit(MethodExecutionArgs args)
        {
            if (!OldContextSynchronizationSwitch.Enabled)
            {
                Console.WriteLine("OldContextSynchronization not enabled.");
                return;
            }

            if (args.Exception != null)
            {
                Console.WriteLine("Method exited in error state.");
                return;
            }

            try
            {
                if (args.Instance == null)
                {
                    throw new Exception("SynchronizeOldContext requires method to belong to an object instance.");
                }

                if (args.ReturnValue == null)
                {
                    throw new Exception("SynchronizeOldContext requires method return value.");
                }

                ExecuteByConvention(_newContextMethod, args);
            }
            catch (Exception ex)
            {
                KillSwitch.Engage();
                var synchronizeException = new SynchronizeOldContextException(args, ex);
                Console.WriteLine(synchronizeException.Message);
                throw synchronizeException;
            }
        }
Exemplo n.º 6
0
 public virtual ActionResult ShutDown(ShutDownModel values)
 {
     KillSwitch.Engage();
     return(RedirectToAction(MVC.Home.SiteStatus()));
 }
Exemplo n.º 7
0
 public virtual ActionResult Startup()
 {
     KillSwitch.Disengage();
     return(RedirectToAction(MVC.Home.SiteStatus()));
 }
 public MasterCommandHandlerActor()
     : base(MasterCommands.MasterPalette)
 {
     Process(MasterCommands.Kill.Name, command => KillSwitch.KillCluster());
     Process(MasterCommands.ListServices.Name, ListServices);
 }
Exemplo n.º 9
0
        public void Main()
        {
            Task.Run(() =>
            {
                Console.Clear();
                if (KillSwitch.CheckKillSwitch())
                {
                    return;
                }
                ExportReferences();
                LoadConfigurations();
                ShowActiveBots();
                Console.Title = Culture.GetTranslation(TranslationString.Title,
                                                       Variables.ProgramName, Variables.CurrentVersion, Variables.By
                                                       );
                Helper(Console.Arguments.Length != 0);
                CheckNecroBots(Console.Arguments.Length != 1);
                //Console.Arguments = new string[] { "msniper://Ivysaur/-33.890835,151.223859" };//for debug mode
                //args = new string[] { "-registerp" };//for debug mode
                //Console.Arguments = new string[] { "msniper://Staryu/8694528382595630333/89c258978a1/40.781605427526415,-73.961284780417373/51.31" };
                if (Console.Arguments.Length == 1)
                {
                    RunningNormally = false;
                    switch (Console.Arguments.First())
                    {
                    case "-register":
                        Runas(Variables.ExecutablePath, "-registerp");
                        break;

                    case "-registerp":
                        Protocol.Register();
                        Console.WriteLine(Culture.GetTranslation(TranslationString.ProtocolRegistered), Config.Success);
                        break;

                    case "-remove":
                        Runas(Variables.ExecutablePath, "-removep");
                        break;

                    case "-removep":
                        Protocol.Delete();
                        Console.WriteLine(Culture.GetTranslation(TranslationString.ProtocolDeleted), Config.Success);
                        break;

                    case "-resetallsnipelist":
                        RemoveAllSnipeMsjson();
                        break;

                    default:
                        var re0  = "(msniper://)";                     //protocol
                        var re1  = "((?:\\w+))";                       //pokemon name
                        var re2  = "(\\/)";                            //separator
                        var re3  = "(\\d+)";
                        var re4  = "(\\/)";                            //separator
                        var re5  = "((?:[a-zA-Z0-9]*))";
                        var re6  = "(\\/)";                            //separator
                        var re7  = "([+-]?\\d*\\.\\d+)(?![-+0-9\\.])"; //lat
                        var re8  = "(,)";                              //separator
                        var re9  = "([+-]?\\d*\\.\\d+)(?![-+0-9\\.])"; //lon
                        var re10 = "(\\/)";                            //separator
                        var re11 = "(\\d*(\\.)?\\d+)";

                        var r = new Regex(re0 + re1 + re2 + re3 + re4 + re5 + re6 + re7 + re8 + re9 + re10 + re11, RegexOptions.IgnoreCase | RegexOptions.Singleline);
                        var m = r.Match(Console.Arguments.First());
                        if (m.Success)
                        {
                            Snipe(m);
                            break;
                        }
                        re0 = "(msniper://|pokesniper2://)";     //protocol
                        r   = new Regex(re0 + re1 + re6 + re7 + re8 + re9, RegexOptions.IgnoreCase | RegexOptions.Singleline);
                        m   = r.Match(Console.Arguments.First());
                        if (m.Success)
                        {
                            Snipe(m, true);
                            break;
                        }

                        Console.WriteLine(Culture.GetTranslation(TranslationString.UnknownLinkFormat), Config.Error);

                        break;
                    }
                }
                else if (Console.Arguments.Length == 0)
                {
                    //RunningNormally = true;
                    //Console.WriteLine("manual snipe disabled - please use http://msniper.com", System.Drawing.Color.Green);
                    //Console.WriteLine("--------------------------------------------------------");
                    //RunningNormally = true;
                    Console.WriteLine(Culture.GetTranslation(TranslationString.CustomPasteDesc));
                    Console.WriteLine(Culture.GetTranslation(TranslationString.CustomPasteFormat));
                    Console.WriteLine("--------------------------------------------------------");
                    do
                    {
                        Console.WriteLine(Culture.GetTranslation(TranslationString.WaitingDataMsg), Config.Highlight);
                        var snipping = Console.ReadLine();
                        CheckNecroBots(true);
                        //snipping = "dragonite 37.766627 , -122.403677";//for debug mode (spaces are ignored)
                        if (snipping.ToLower() == "e")
                        {
                            break;
                        }
                        snipping = "msniper://" + snipping;
                        snipping = snipping.Replace("\r\n", "\r\nmsniper://");
                        var re0  = "(msniper://)";                     //protocol
                        var re1  = "((?:\\w+\\s*))";                   //pokemon name
                        var re6  = "( )";                              //separator
                        var re7  = "([+-]?\\d*\\.\\d+)(?![-+0-9\\.])"; //lat
                        var re8  = "(\\s*,\\s*)";                      //separator
                        var re9  = "([+-]?\\d*\\.\\d+)(?![-+0-9\\.])"; //lon

                        var r = new Regex(re0 + re1 + re6 + re7 + re8 + re9, RegexOptions.IgnoreCase | RegexOptions.Singleline);

                        var error = true;
                        foreach (Match m in r.Matches(snipping))
                        {
                            if (!m.Success)
                            {
                                continue;
                            }
                            var pokemonN = m.Groups[2].ToString().Replace(" ", "");
                            error        = false;
                            var prkmnm   = PokemonId.Abra;
                            var verified = Enum.TryParse <PokemonId>(pokemonN, true, out prkmnm);
                            if (verified)
                            {
                                Snipe(m, true);
                            }
                            else
                            {
                                Console.WriteLine(Culture.GetTranslation(TranslationString.WrongPokemonName, pokemonN), Config.Error);
                            }
                        }
                        if (error)
                        {
                            Console.WriteLine(Culture.GetTranslation(TranslationString.CustomPasteWrongFormat), Config.Error);
                        }
                    }while (true);
                }
                Shutdown();
            });
        }