示例#1
0
    public void Init(ConcurrentDictionary <string, object> globals)
    {
        ProgramConfig config  = (ProgramConfig)globals["Config"];
        NetManager    Manager = (NetManager)globals["NetManager"];
        Thread        network = new Thread(() =>
        {
            XeonServer server       = new XeonServer(config.Network.Port, config.Network.Address);
            XeonCommon.Logger Log   = server.Log;
            server.OnClientConnect += (XeonClient client) =>
            {
                Guid guid         = Guid.Parse(client.GUID.ToString());
                client.OnMessage += (string data) =>
                {
                    NetEvent <INetClient> e = new NetEvent <INetClient> {
                        Client = client, Guid = guid, IsDisconnect = false, Payload = data
                    };
                    Manager.Queue.CallNetEvent(e);
                };
                client.OnDisconnect += () =>
                {
                    NetEvent <INetClient> e = new NetEvent <INetClient> {
                        Guid = guid, IsDisconnect = true, Client = null, Payload = null
                    };
                    Manager.Queue.CallNetEvent(e);
                };
                client.OnTelnetDo += (option) =>
                {
                    switch (option)
                    {
                    case Telnet.Option.GMCP:
                        return(true);

                    case Telnet.Option.LineMode:
                        return(true);
                    }
                    return(false);
                };
                client.OnTelnetWill += (option) =>
                {
                    switch (option)
                    {
                    case Telnet.Option.LineMode:
                        return(true);
                    }
                    return(false);
                };
                client.OnTelnetSB += (packet) =>
                {
                    Log.WriteLine($"Unhandled SB from {guid}: {packet.Option} {System.Text.Encoding.UTF8.GetString(packet.Payload)}");
                };
                client.OnGMCP += (gmcp) =>
                {
                    Log.WriteLine($"GMCP from {guid}:\n{gmcp}");
                };
            };
            server.Start();
        });

        network.Start();
    }
示例#2
0
        public MainForm()
        {
            this.InitializeComponent();
            ProgramConfig configSection = ProgramConfig.Get();

            this.configForm = new ProgramConfigForm(configSection);
        }
示例#3
0
        static void Main(string[] args)
        {
            Console.WriteLine("Stress Points Generator");

            DateTime defaultStartDate = new DateTime(2017, 8, 1);

            ProgramConfig config = JsonConvert.DeserializeObject <ProgramConfig>(File.ReadAllText(Path.Combine("conf", "config.json")));

            // Athlete parameters
            AthleteConfig athleteConfig = config.athlete;

            // Strava token
            string stravaToken = config.strava.token;

            // Configuration for Google Sheet
            string            googleAppName = config.google.appName;
            string            sheetId       = config.google.sheetId;
            GoogleSheetOutput output        = new GoogleSheetOutput(googleAppName, sheetId);

            // Try get last date from google sheet data
            DateTime?startDate = output.GetLastDate() ?? defaultStartDate;

            PointsGenerator generator = new PointsGenerator.Builder()
                                        .WithAthleteConfig(athleteConfig)
                                        .WithStravaToken(stravaToken)
                                        .WithOutput(output)
                                        .WithStartDate(startDate.Value)
                                        .Build();

            generator.Run();

            Console.WriteLine("Finished!");
            Console.ReadLine();
        }
示例#4
0
    //-------------------------------------------------------------------------
    static void Main(string[] args)
    {
        GrainClient.Initialize("BaseClientConfiguration.xml");

        Console.Title = "FishingBase";

        ProgramConfig config = new ProgramConfig();

        config.load("./FishingBase.exe.config");

        EsEngineSettings settings;

        settings.NodeType            = 2;
        settings.NodeTypeString      = "Base";
        settings.ListenIp            = config.ListenIp;
        settings.ListenPort          = config.ListenPort;
        settings.RootEntityType      = "EtRoot";
        settings.EnableCoSupersocket = true;
        settings.Log4NetConfigPath   = "../../../Media/Fishing/Config/FishingBase.log4net.config";

        try
        {
            EsEngine e = new EsEngine(ref settings, new EsEngineListener());
            e.run();
        }
        catch (System.Exception ex)
        {
            EbLog.Note(ex.ToString());
        }

        GrainClient.Uninitialize();
    }
示例#5
0
        static void Main(string[] args)
        {
            if (args.Length > 0)
            {
                string path;
                if (Path.GetPathRoot(args[0]) != null)
                {
                    path = args[0];
                }
                else
                {
                    path = Path.Join(AppDir, args[0]);
                }
                Config = XeonProject.Config.LoadConfig(path);
            }
            else
            {
                Config = XeonProject.Config.LoadConfig(Path.GetFullPath("XeonConfig.json", AppDir));
            }

            DataStorage.Setup();
            Network.Start();
            Game.GameThread.Start();
            Events.EventLoop.Start();
            Globals["EventLoop"]  = Events.EventLoop;
            Globals["Database"]   = DataStorage.Database;
            Globals["AppDir"]     = AppDir;
            Globals["Config"]     = Config;
            Globals["Args"]       = args;
            Globals["NetManager"] = Network.Manager;
            Plugins.LoadPlugins();
            Events.EventLoop.Join();
        }
示例#6
0
        bool ISubProgram.Init(MenuUtils menuUtils, ProgramConfig programConfig)
        {
            this.menuUtils = menuUtils;
            try {
                IDeserializer deserializer = new DeserializerBuilder()
                                             .WithTagMapping("tag:yaml.org,2002:directOnlineSourceConfig", typeof(DirectOnlineSourcesConfig))
                                             .WithTagMapping("tag:yaml.org,2002:queriedOnlineSourceConfig", typeof(QueriedOnlineSourceConfig))
                                             .WithTagMapping("tag:yaml.org,2002:storedMappingValue", typeof(StoredMappingValue))
                                             .WithTagMapping("tag:yaml.org,2002:fileUrlBasedMappingValue", typeof(FileUrlBasedMappingValue))
                                             .WithNodeDeserializer(
                    inner => new MenuObjectDeserializer(inner, new DefaultObjectFactory()),
                    s => s.InsteadOf <ObjectNodeDeserializer>()
                    )
                                             .Build();
                using (StreamReader reader = File.OpenText(configFilePath)) {
                    dataComparer = deserializer.Deserialize <DataComparerConfig>(reader);
                }

                dataComparer.Init(programConfig);
                return(true);
            } catch (Exception e) {
                Console.WriteLine("Encountered an exception during parsing of the config!");
                Console.WriteLine("Exception: " + e);
                Console.ReadKey(true);
                return(false);
            }
        }
 public PlayLogger(ProgramConfig config, MongoService mongoSvc, BoardGameGeekService bggSvc, ILogger logger)
 {
     _config   = config;
     _mongoSvc = mongoSvc;
     _bggSvc   = bggSvc;
     _logger   = logger;
 }
        static void Main(string[] args)
        {
            // Configure
            CompositionRoot = ProgramConfig.Configure();

            // Resolve dependencies and run the ConsoleTwitterApp
            CompositionRoot.Resolve <ConsoleTwitterApp>().Run();
        }
        public void TheConnector_ShouldHaveSoapService()
        {
            var manager   = new FakeCredentialManager();
            var config    = new ProgramConfig(() => 0, () => "foo");
            var connector = new Unit4WebConnector(manager, config).Create();

            Assert.That(connector.Datasource, Is.EqualTo(config.Url));
        }
        public void TheConnector_ShouldHaveUsername()
        {
            var manager   = new FakeCredentialManager();
            var config    = new ProgramConfig(() => 0, () => "foo");
            var connector = new Unit4WebConnector(manager, config).Create();

            Assert.That(connector.Authenticator.Name, Is.EqualTo(manager.Credentials.Username));
        }
示例#11
0
 public ProgramConfigForm(ProgramConfig configSection)
 {
     this.InitializeComponent();
     this.destDirComboBox.Text         = configSection.DestDir;
     this.showInputDirCheckBox.Checked = configSection.OmitInputDir;
     this.chbSilentRestart.Checked     = configSection.SilentRestart;
     this.previewPlayerComboBox.Text   = configSection.PlayerPath;
     this.autoChangeAudioSourceFilterCheckBox.Checked = configSection.AutoChangeAudioSourceFilter;
 }
        public void TheConnector_ShouldHaveClient()
        {
            var manager       = new FakeCredentialManager();
            var config        = new ProgramConfig(() => 1234, () => "foo");
            var connector     = new Unit4WebConnector(manager, config).Create();
            var authenticator = connector.Authenticator as AgressoAuthenticator;

            Assert.That(authenticator.Client, Is.EqualTo(config.Client.ToString()));
        }
        public void ConstructorTest()
        {
            AppConfig     appConfig           = new AppConfig(new Uri("http://hiahia"), "hiahia", TestUtility.TestDirectory, null, TimeSpan.Zero, TimeSpan.Zero);
            ProgramConfig config              = new ProgramConfig(ExecutionModes.Install, appConfig);
            TraceLogger   logger              = new TraceLogger(new MockUpTraceEventProvider());
            ServiceFabricUpdateService result = new ServiceFabricUpdateService(config, logger);

            Assert.AreSame(config, result.ServiceConfig);
            Assert.AreSame(logger, result.Logger);
        }
示例#14
0
        public bool UpdateProgram(Guid guid, ProgramConfig config, UInt64 expiration = 0)
        {
            List <byte[]> args = new List <byte[]>();

            args.Add(PutGuid(guid));
            args.Add(PutConfig(config));
            args.Add(PutUInt64(expiration));
            List <byte[]> ret = RemoteExec("UpdateProgram", args);

            return(ret != null?GetBool(ret[0]) : false);
        }
示例#15
0
        private void SaveConfig()
        {
            ProgramConfig config = ProgramConfig.Get();

            config.DestDir       = this.destDirComboBox.Text;
            config.OmitInputDir  = this.showInputDirCheckBox.Checked;
            config.SilentRestart = this.chbSilentRestart.Checked;
            config.PlayerPath    = this.previewPlayerComboBox.Text;
            config.AutoChangeAudioSourceFilter = this.autoChangeAudioSourceFilterCheckBox.Checked;
            ProgramConfig.Save();
        }
        public void TheConnector_ShouldHavePassword()
        {
            var manager       = new FakeCredentialManager();
            var config        = new ProgramConfig(() => 0, () => "foo");
            var connector     = new Unit4WebConnector(manager, config).Create();
            var authenticator = connector.Authenticator as AgressoAuthenticator;

            Assert.That(
                SecureStringHelper.ToString(authenticator.Password),
                Is.EqualTo(SecureStringHelper.ToString(manager.Credentials.Password)));
        }
示例#17
0
        private Program LoadConfig()
        {
            _config =
                new ConfigurationBuilder()
                .AddJsonFile("programsettings.json", optional: false)
                .AddJsonFile("programsettings.local.json", optional: true)
                .AddEnvironmentVariables()
                .Build()
                .Get <ProgramConfig>();

            return(this);
        }
示例#18
0
        public void GetModeTest()
        {
            ExecutionModes result;

            result = ProgramConfig.GetMode(new Dictionary <string, string>());
            Assert.AreEqual(ExecutionModes.Service, result);

            result = ProgramConfig.GetMode(new Dictionary <string, string>()
            {
                { ParameterNames.Install, "true" }
            });
            Assert.AreEqual(ExecutionModes.Install, result);
        }
示例#19
0
        public void IntegrationTest()
        {
            TraceLogger   traceLogger      = new TraceLogger(new MockUpTraceEventProvider());
            Uri           goalStateFileUri = this.PrepareTargetGoalStateFile();
            ProgramConfig config           = new ProgramConfig(
                ProgramParameterDefinitions.ExecutionModes.Service,
                new AppConfig(
                    new Uri("http://localhost", UriKind.Absolute),
                    null,
                    TestUtility.TestDirectory + "\\Data",
                    goalStateFileUri,
                    TimeSpan.FromSeconds(3000),
                    TimeSpan.FromSeconds(3000)));
            UpdateServicelet server = new UpdateServicelet(config, traceLogger);

            server.Start();

            // ensure that the packages have been downloaded
            Thread.Sleep(10000);

            GoalState goalState;

            Assert.IsTrue(GoalState.TryCreate(new Uri("http://localhost/api/files/goalstate", UriKind.Absolute), server.Logger, out goalState));
            string packageDownloadDstDirectory = TestUtility.TestDirectory + "\\DownloadDstDir";

            if (!Directory.Exists(packageDownloadDstDirectory))
            {
                Directory.CreateDirectory(packageDownloadDstDirectory);
            }

            TaskManager tskMgr = new TaskManager(traceLogger);

            foreach (PackageDetails package in goalState.Packages)
            {
                string fileName = new Uri(package.TargetPackageLocation).Segments.Last();
                tskMgr.AddTask(Utility.DownloadFileAsync(package.TargetPackageLocation, packageDownloadDstDirectory + "\\" + fileName));
            }

            Assert.IsTrue(tskMgr.WaitForAllTasks());

            Assert.AreEqual(5, Directory.GetFiles(TestUtility.TestDirectory + "\\Data\\UpdateService\\Packages", "*.cab", SearchOption.TopDirectoryOnly).Length);


            server.Stop();

            Assert.IsFalse(GoalState.TryCreate(new Uri("http://localhost/api/files/goalstat", UriKind.Absolute), server.Logger, out goalState));

            Directory.Delete(TestUtility.TestDirectory + "\\Data", recursive: true);
            File.Delete(TestUtility.TestDirectory + "\\WsusIntegration.json");
            Directory.Delete(packageDownloadDstDirectory, recursive: true);
        }
        private void RealIntegrationTest(ProgramConfig config, TraceLogger traceLogger)
        {
            TelemetryServicelet server = new TelemetryServicelet(config, traceLogger);

            server.Start();

            // ensure that the telemetry data have been uploaded at least twice
            Thread.Sleep(10000);

            Assert.IsTrue(server.Cookie.LastProcessedUtc > DateTime.UtcNow - TimeSpan.FromSeconds(5));
            Assert.AreEqual(4, server.Cookie.TelemetriesLastUploaded);

            server.Stop();
        }
示例#21
0
        public void ConstructorTest()
        {
            AppConfig     appConfig = new AppConfig(null, "hiahia", TestUtility.TestDirectory, null, TimeSpan.Zero, TimeSpan.Zero);
            ProgramConfig result    = new ProgramConfig(ExecutionModes.Install, appConfig);

            Assert.AreEqual(ExecutionModes.Install, result.Mode);
            Assert.AreSame(appConfig, result.AppConfig);

            result = ProgramConfig.Create(new Dictionary <string, string>()
            {
                { ParameterNames.Install, "true" }
            }, appConfig);
            Assert.AreEqual(ExecutionModes.Install, result.Mode);
            Assert.AreSame(appConfig, result.AppConfig);
        }
示例#22
0
 public ProgramHost(
     IOptions <ProgramConfig> options,
     IDataStore store,
     ICacheClient cache,
     IMessageBus messenger,
     IDataDirectoryCollection data,
     IScriptEngine scripting
     )
 {
     _config    = options.Value;
     _store     = store;
     _cache     = cache;
     _messenger = messenger;
     _data      = data;
     _scripting = scripting;
     _acceptors = new List <ITransportAcceptor>();
 }
示例#23
0
        protected override void OnStartup(StartupEventArgs e)
        {
            SplashScreen splash = new SplashScreen("Resources/Images/Splash.jpg");

            splash.Show(true, true);

            base.OnStartup(e);

            var container = ProgramConfig.Configure();

            using (var scope = container.BeginLifetimeScope())
            {
                var        vm     = scope.Resolve <IMainViewModel>();
                MainWindow window = new MainWindow(vm);
                window.Show();
            }
        }
示例#24
0
        private static void ExitNoConfig()
        {
            var bot = new PokeBotState {
                Connection = new SwitchConnectionConfig {
                    IP = "192.168.0.1", Port = 6000
                }, InitialRoutine = PokeRoutineType.FlexTrade
            };
            var cfg = new ProgramConfig {
                Bots = new[] { bot }
            };
            var created = JsonConvert.SerializeObject(cfg, GetSettings());

            File.WriteAllText(ConfigPath, created);
            Console.WriteLine("Created new config file since none was found in the program's path. Please configure it and restart the program.");
            Console.WriteLine("It is suggested to configure this config file using the GUI project if possible, as it will help you assign values correctly.");
            Console.WriteLine("Press any key to exit.");
            Console.ReadKey();
        }
示例#25
0
        public bool UpdateProgram(Guid guid, ProgramConfig config, UInt64 expiration = 0)
        {
            ProgramSet progs;

            if (!ProgramSets.TryGetValue(guid, out progs))
            {
                return(false);
            }
            progs.config = config;

            App.engine.FirewallManager.ApplyRules(progs, expiration);

            Changed?.Invoke(this, new ListEvent()
            {
                guid = progs.guid
            });

            return(true);
        }
示例#26
0
        public void ConstructorTest()
        {
            ProgramConfig svcConfig = new ProgramConfig(
                ProgramParameterDefinitions.ExecutionModes.Service,
                new AppConfig(new Uri("http://hiahia.net:433", UriKind.Absolute), null, TestUtility.TestDirectory, new Uri("http://goalstate"), TimeSpan.FromHours(12), TimeSpan.FromHours(24)));
            TraceLogger      logger = new TraceLogger(new MockUpTraceEventProvider());
            UpdateServicelet result = new UpdateServicelet(svcConfig, logger);

            Assert.IsNotNull(result.ApiHost);
            Assert.AreSame(logger, result.ApiHost.Logger);
            Assert.AreEqual(svcConfig.AppConfig.EndpointBaseAddress.AbsoluteUri, result.ApiHost.BaseAddress);
            Assert.IsNotNull(result.ApiHost.FilePathResolver);

            Assert.IsNotNull(result.PkgMgr);

            string dataRootPath = TestUtility.TestDirectory + "\\UpdateService";

            Assert.IsTrue(Directory.Exists(dataRootPath));
            Directory.Delete(dataRootPath, recursive: true);
        }
示例#27
0
        private void CheckParameter(string optionName, ProgramConfig program, ParameterConfig paramset, string paramname, Func <AnnotationProcessorOptions, string> getFunc, Action <AnnotationProcessorOptions, string> setFunc)
        {
            var value = getFunc(this);

            value = paramset.GetParameter(paramname, value);
            if (string.IsNullOrEmpty(value))
            {
                ParsingErrors.Add(string.Format("{0} {1}. Or you can define the default value at {2}::{3}::{4} in configuration file {5}.",
                                                optionName,
                                                BaseSentenceBuilder.CreateBuiltIn().RequiredOptionMissingText,
                                                program.Name,
                                                paramset.Name,
                                                paramname,
                                                this.Config.ConfigFilename));
            }
            else
            {
                setFunc(this, value);
            }
        }
示例#28
0
        public static void RunBots(ProgramConfig prog)
        {
            IPokeBotRunner env = GetRunner(prog);

            foreach (var bot in prog.Bots)
            {
                bot.Initialize();
                if (!AddBot(env, bot, prog.Mode))
                {
                    Console.WriteLine($"Failed to add bot: {bot}");
                }
            }

            LogUtil.Forwarders.Add((msg, ident) => Console.WriteLine($"{ident}: {msg}"));
            env.StartAll();
            Console.WriteLine($"Started all bots (Count: {prog.Bots.Length}.");
            Console.WriteLine("Press any key to stop execution and quit. Feel free to minimize this window!");
            Console.ReadKey();
            env.StopAll();
        }
        public void ExecuteTest()
        {
            ProgramConfig config;
            TraceLogger   logger = new TraceLogger(new MockUpTraceEventProvider());

            Assert.IsFalse(ServiceController.GetServices().Any(p => p.ServiceName == "ServiceFabricUpdateService"));

            config = new ProgramConfig(ExecutionModes.Install, null);
            WindowsServiceInstaller.Execute(config, logger);
            while (!ServiceController.GetServices().Any(p => p.ServiceName == "ServiceFabricUpdateService"))
            {
                Thread.Sleep(3000);
            }

            TestUtility.UninstallService("ServiceFabricUpdateService");
            while (ServiceController.GetServices().Any(p => p.ServiceName == "ServiceFabricUpdateService"))
            {
                Thread.Sleep(3000);
            }
        }
        private void MockUpIntegrationTest(ProgramConfig config, TraceLogger traceLogger)
        {
            MockUpTelemetryUploader uploader = new MockUpTelemetryUploader();
            TelemetryServicelet     server   = new TelemetryServicelet(config, traceLogger, uploader);

            server.Start();

            // ensure that the telemetry data have been uploaded at least twice
            Thread.Sleep(10000);

            Assert.IsTrue(uploader.TelemetriesUploaded > 8);
            Assert.IsTrue(server.Cookie.LastProcessedUtc > DateTime.UtcNow - TimeSpan.FromSeconds(5));
            Assert.AreEqual(4, server.Cookie.TelemetriesLastUploaded);

            server.Stop();

            int originalUploaded = uploader.TelemetriesUploaded;

            Thread.Sleep(5000);
            Assert.AreEqual(originalUploaded, uploader.TelemetriesUploaded);
        }
 private void CheckParameter(string optionName, ProgramConfig program, ParameterConfig paramset, string paramname, Func<AnnotationProcessorOptions, string> getFunc, Action<AnnotationProcessorOptions, string> setFunc)
 {
   var value = getFunc(this);
   value = paramset.GetParameter(paramname, value);
   if (string.IsNullOrEmpty(value))
   {
     ParsingErrors.Add(string.Format("{0} {1}. Or you can define the default value at {2}::{3}::{4} in configuration file {5}.",
       optionName,
       BaseSentenceBuilder.CreateBuiltIn().RequiredOptionMissingText,
       program.Name,
       paramset.Name,
       paramname,
       this.Config.ConfigFilename));
   }
   else
   {
     setFunc(this, value);
   }
 }
        public void InitializePrograms()
        {
            for (int p = 0; p < NUM_PROGRAMS; p++)
            {
                PROGRAMS[p] = new ProgramConfig();
            }

            for (int i = 0; i < this.NumPresets(); i++)
            {
                _presetNames.Add("Program " + (i+1));
            }
        }