private void Run() { Log.Logger = new LoggerConfiguration() .ReadFrom.AppSettings() .Enrich.WithExceptionDetails() .Enrich.FromLogContext() .MinimumLevel.Debug() .WriteTo.File("logs\\log-.txt", rollingInterval: RollingInterval.Day) .MinimumLevel.Is(options.LogLevel) .WriteTo.Console() .CreateLogger(); try { config = ConfigFactory.Default.LoadFromFile(options.IntegrationConfigFile); if (options.ListJobs) { ListJobs(); } else { RunJob(); } } catch (InvalidConfigurationException ex) { Console.WriteLine($"Failed to load configuration: {ex.Message}"); } catch (Exception ex) { Log.Fatal(ex, "Exception while running job {Job}", options.Job); } }
void InitConvertConfigs() { if (defaultKeywords == null) { integrationConfigs = new List <IntegrationConfig> (); defaultKeywords = new string [] { "_MICROSPLAT", "_BRANCHSAMPLES", "_BRANCHSAMPLESAGR", "_USEGRADMIP" }; // INTERGRATIONS { var c = new IntegrationConfig(); c.name = "Enviro"; c.assetLink = "https://assetstore.unity.com/packages/tools/particles-effects/enviro-sky-and-weather-33963?aid=25047"; c.keywords = new string [] { #if __MICROSPLAT_SNOW__ "_SNOW", "_USEGLOBALSNOWLEVEL", #endif #if __MICROSPLAT_STREAMS__ "_WETNESS", "_GLOBALWETNESS", #endif }; #if ENVIRO_HD || ENVIRO_LW || ENVIRO_PRO c.assetInstalled = true; #endif RequireStreams(c.missingModules); RequireSnow(c.missingModules); integrationConfigs.Add(c); } { var c = new IntegrationConfig(); c.name = "Weather Maker"; c.keywords = new string [] { #if __MICROSPLAT_SNOW__ "_SNOW", "_USEGLOBALSNOWLEVEL", #endif #if __MICROSPLAT_STREAMS__ "_WETNESS", "_GLOBALWETNESS", #endif }; c.assetLink = "https://assetstore.unity.com/packages/tools/particles-effects/weather-maker-unity-weather-system-sky-water-volumetric-clouds-a-60955?aid=25047"; c.keywords = new string [] { }; RequireStreams(c.missingModules); RequireSnow(c.missingModules); #if WEATHER_MAKER_PRESENT c.assetInstalled = true; #endif integrationConfigs.Add(c); } } }
/// <summary> /// Called upon object initialization. /// </summary> void Awake() { Instance = this; var configs = new IntegrationConfig[] { _steam, _discord }; var integrations = new List <IIntegrationClient>(); foreach (var config in configs) { if (!config.Enabled) { continue; } try { var client = config.CreateClient(); integrations.Add(client); Debug.Log($"Initialized integration: {config.IntegrationName}"); } catch (Exception e) { Debug.LogError($"Failed to load integration ({config.IntegrationName}:\n{e}"); } } _integrations = integrations.ToArray(); Integrations = Array.AsReadOnly(_integrations); }
public ILocations GetLocationsAll() { Locations locations = new Locations(); string text = System.IO.File.ReadAllText(IntegrationConfig.GetBackupFilePath() + locations.GetType().ToString() + IntegrationConfig.GetBackupFileType()); return(_serializer.Deserialize <Locations>(text)); }
public void RegisterServices(IServiceCollection services) { services.AddScoped <IEscolaService, EscolaService>(); services.AddScoped <ITurmaService, TurmaService>(); services.AddScoped <IAlunoService, AlunoService>(); var integrationConfig = new IntegrationConfig(this.Configuration["API_URL"]); services.AddSingleton <IntegrationConfig>(integrationConfig); }
public List <IRoute> GetRouteWith1Stop(ITripParams tripParams) { Route route = new Route(); string text = System.IO.File.ReadAllText(IntegrationConfig.GetBackupFilePath() + route.GetType().ToString() + IntegrationConfig.GetBackupFileType()); return(new List <IRoute>() { _serializer.Deserialize <Route>(text) }); }
public List <IFlight> GetDirectFlightsByTripParams(ITripParams tripParams) { Flight flight = new Flight(); string text = System.IO.File.ReadAllText(IntegrationConfig.GetBackupFilePath() + flight.GetType().ToString() + IntegrationConfig.GetBackupFileType()); return(new List <IFlight>() { _serializer.Deserialize <Flight>(text) }); }
public string GetTestFlightResults() { try { _result = System.IO.File.ReadAllText(IntegrationConfig.GetFileSystemDir() + "test_flight" + IntegrationConfig.GetTestFileType()); } catch (Exception ex) { return(ex.Message); } return(_result); }
public async Task EnsureGzipCompressedMessageCanSend() { IntegrationConfig.NoDebugLog.InfoFormat(IntegrationConfig.Highlight("start EnsureGzipCompressedMessageCanSend")); using (var conn = GetKafkaConnection()) { conn.SendAsync(new MetadataRequest { Topics = new List <string>(new[] { IntegrationConfig.IntegrationCompressionTopic }) }) .Wait(TimeSpan.FromSeconds(10)); } using (var router = new BrokerRouter(_options)) { IntegrationConfig.NoDebugLog.InfoFormat(IntegrationConfig.Highlight("start RefreshMissingTopicMetadata")); await router.RefreshMissingTopicMetadata(IntegrationConfig.IntegrationCompressionTopic); IntegrationConfig.NoDebugLog.InfoFormat(IntegrationConfig.Highlight("end RefreshMissingTopicMetadata")); var conn = router.SelectBrokerRouteFromLocalCache(IntegrationConfig.IntegrationCompressionTopic, 0); var request = new ProduceRequest { Acks = 1, TimeoutMS = 1000, Payload = new List <Payload> { new Payload { Codec = MessageCodec.CodecGzip, Topic = IntegrationConfig.IntegrationCompressionTopic, Partition = 0, Messages = new List <Message> { new Message("0", "1"), new Message("1", "1"), new Message("2", "1") } } } }; IntegrationConfig.NoDebugLog.InfoFormat(IntegrationConfig.Highlight("start SendAsync")); var response = conn.Connection.SendAsync(request).Result; IntegrationConfig.NoDebugLog.InfoFormat("end SendAsync"); Assert.That(response.First().Error, Is.EqualTo(0)); IntegrationConfig.NoDebugLog.InfoFormat("start dispose"); } IntegrationConfig.NoDebugLog.InfoFormat(IntegrationConfig.Highlight("end EnsureGzipCompressedMessageCanSend")); }
private string GetFlagImageString(string countryCode) { Image image = null; try { image = Image.FromFile(IntegrationConfig.GetFlagsFilePath() + countryCode.ToLower() + IntegrationConfig.GetFlagsFileType()); } catch (Exception e) { _logger.LogObject("Exception caught: {0}", e); return(""); } return(_imageConverter.ImageToString(image)); }
public void ConsumerShouldBeAbleToSeekBackToEarlierOffset() { var expected = new List <string> { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19" }; var testId = Guid.NewGuid().ToString(); using (var router = new BrokerRouter(new KafkaOptions(IntegrationConfig.IntegrationUri))) using (var producer = new Producer(router)) { var offsets = producer.GetTopicOffsetAsync(IntegrationConfig.IntegrationTopic).Result .Select(x => new OffsetPosition(x.PartitionId, x.Offsets.Max())).ToArray(); using (var consumer = new Consumer(new ConsumerOptions(IntegrationConfig.IntegrationTopic, router) { MaxWaitTimeForMinimumBytes = TimeSpan.Zero }, offsets)) { for (int i = 0; i < 20; i++) { producer.SendMessageAsync(IntegrationConfig.IntegrationTopic, new[] { new Message(i.ToString(), testId) }).Wait(); } var sentMessages = consumer.Consume().Take(20).ToList(); //ensure the produced messages arrived IntegrationConfig.NoDebugLog.InfoFormat(IntegrationConfig.Highlight("Message order: {0}", string.Join(", ", sentMessages.Select(x => x.Value.ToUtf8String()).ToList()))); Assert.That(sentMessages.Count, Is.EqualTo(20)); Assert.That(sentMessages.Select(x => x.Value.ToUtf8String()).ToList(), Is.EqualTo(expected)); Assert.That(sentMessages.Any(x => x.Key.ToUtf8String() != testId), Is.False); //seek back to initial offset consumer.SetOffsetPosition(offsets); var resetPositionMessages = consumer.Consume().Take(20).ToList(); //ensure all produced messages arrive again IntegrationConfig.NoDebugLog.InfoFormat(IntegrationConfig.Highlight("Message order: {0}", string.Join(", ", resetPositionMessages.Select(x => x.Value).ToList()))); Assert.That(resetPositionMessages.Count, Is.EqualTo(20)); Assert.That(resetPositionMessages.Select(x => x.Value.ToUtf8String()).ToList(), Is.EqualTo(expected)); Assert.That(resetPositionMessages.Any(x => x.Key.ToUtf8String() != testId), Is.False); } } }
public void TemplatePipelineExecutionExampleTest() { // Use this test pattern if you wish to test your handlers on a full pipeline. // Create Handler List. var handlers = new List <IntegrationConfigPipelineHandler>(); // Add the Load Work Queue Handler IntegrationConfigPipelineHandler mockHandlerConfig = new IntegrationConfigPipelineHandler() { Active = "true", Id = "ErpReadConfig", Type = "Primavera.Hurakan.Handlers.ErpReadConfig", Behavior = "Reader", Order = "0", ConfigStr = @"" }; handlers.Add(mockHandlerConfig); // Insert more handlers as required. // Create the pipeline. IntegrationConfig mockIntegrationConfig = new IntegrationConfig() { Pipelines = new IntegrationConfigPipeline[1] // one pipeline only for example purposes { new IntegrationConfigPipeline() { Active = "true", Id = "123", Handlers = handlers.ToArray() } } }; // Create mock integration message IMessage msg = new IntegrationMessage(); // Create pipeline engine and execute it. using (PipelineEngine engine = new PipelineEngine("pipelineId", mockIntegrationConfig)) { msg = engine.Execute(msg); } }
public static bool PreSync(bool isError) { try { IntegrationConfig.ResetConfiguration(); ShipIntegrationConfig.ResetConfiguration(); WarehouseIntegrationConfig.ResetConfiguration(); } catch (Exception ex) { EventNotificationClient.Instance.PostMessage(string.Format("{0}.{1}.Error", MethodBase.GetCurrentMethod().ReflectedType.Name, MethodBase.GetCurrentMethod().Name), IntegrationConfig.InstanceID, CategoryType.Error, ex.Message, new Variable("ex", ex)); isError = true; } return(isError); }
public AlunoService(IntegrationConfig integrationConfig) : base(integrationConfig) { }
public string GetTestConnResults() { return(AsyncHelper.RunSync(() => WebApiClient.Call(IntegrationConfig.GetRebusCoreUri() + "testconn"))); }
public string GetAdmin(int userid, string amount) { return(AsyncHelper.RunSync(() => WebApiClient.Call(IntegrationConfig.GetRebusNeoUri() + "balanceadmin?userid=" + userid + "&amount=" + amount))); }
public string GetFlight(ulong flightId) { return(AsyncHelper.RunSync(() => WebApiClient.Call(IntegrationConfig.GetRebusCoreUri() + "flight?flightid=" + flightId))); }
private void WriteToFile(string data, string name) { System.IO.File.WriteAllText(IntegrationConfig.GetBackupFilePath() + name + IntegrationConfig.GetBackupFileType(), data); }
public string GetAllLocationResults() { return(AsyncHelper.RunSync(() => WebApiClient.Call(IntegrationConfig.GetRebusCoreUri() + "alllocations"))); }
public string Get(string userName, string action) { return(AsyncHelper.RunSync(() => WebApiClient.Call(IntegrationConfig.GetRebusNeoUri() + "banuser?username="******"&action=" + action))); }
public TurmaService(IntegrationConfig integrationConfig) : base(integrationConfig) { }
/// <summary> /// order Should remain in the same ack leve and partition /// </summary> /// <returns></returns> public async Task ConsumerShouldConsumeInSameOrderAsAsyncProduced() { int partition = 0; int numberOfMessage = 200; IntegrationConfig.NoDebugLog.InfoFormat(IntegrationConfig.Highlight("create BrokerRouter")); var router = new BrokerRouter(new KafkaOptions(IntegrationConfig.IntegrationUri)); int causesRaceConditionOldVersion = 2; var producer = new Producer(router, causesRaceConditionOldVersion) { BatchDelayTime = TimeSpan.Zero }; //this is slow on purpose //this is not slow var producer = new Producer(router); IntegrationConfig.NoDebugLog.InfoFormat(IntegrationConfig.Highlight("create producer")); List <OffsetResponse> offsets = await producer.GetTopicOffsetAsync(IntegrationConfig.IntegrationTopic); IntegrationConfig.NoDebugLog.InfoFormat(IntegrationConfig.Highlight("request Offset")); List <Task> sendList = new List <Task>(numberOfMessage); for (int i = 0; i < numberOfMessage; i++) { var sendTask = producer.SendMessageAsync(IntegrationConfig.IntegrationTopic, new[] { new Message(i.ToString()) }, 1, null, MessageCodec.CodecNone, partition); sendList.Add(sendTask); } await Task.WhenAll(sendList.ToArray()); IntegrationConfig.NoDebugLog.InfoFormat(IntegrationConfig.Highlight("done send")); IntegrationConfig.NoDebugLog.InfoFormat(IntegrationConfig.Highlight("create Consumer")); ConsumerOptions consumerOptions = new ConsumerOptions(IntegrationConfig.IntegrationTopic, router); consumerOptions.PartitionWhitelist = new List <int> { partition }; Consumer consumer = new Consumer(consumerOptions, offsets.Select(x => new OffsetPosition(x.PartitionId, x.Offsets.Max())).ToArray()); int expected = 0; IntegrationConfig.NoDebugLog.InfoFormat(IntegrationConfig.Highlight("start Consume")); await Task.Run((() => { var results = consumer.Consume().Take(numberOfMessage).ToList(); Assert.IsTrue(results.Count() == numberOfMessage, "not Consume all ,messages"); IntegrationConfig.NoDebugLog.InfoFormat(IntegrationConfig.Highlight("done Consume")); foreach (Message message in results) { Assert.That(message.Value.ToUtf8String(), Is.EqualTo(expected.ToString()), "Expected the message list in the correct order."); expected++; } })); IntegrationConfig.NoDebugLog.InfoFormat(IntegrationConfig.Highlight("start producer Dispose")); producer.Dispose(); IntegrationConfig.NoDebugLog.InfoFormat(IntegrationConfig.Highlight("start consumer Dispose")); consumer.Dispose(); IntegrationConfig.NoDebugLog.InfoFormat(IntegrationConfig.Highlight("start router Dispose")); router.Dispose(); }
public EscolaService(IntegrationConfig integrationConfig) : base(integrationConfig) { }
public string Get() { return(AsyncHelper.RunSync(() => WebApiClient.Call(IntegrationConfig.GetRebusNeoUri() + "report"))); }
public async Task ConsumerShouldConsumeInSameOrderAsAsyncProduced_dataLoad(int numberOfMessage, int timeoutInMs) { int partition = 0; Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); IntegrationConfig.NoDebugLog.InfoFormat(IntegrationConfig.Highlight("create BrokerRouter ,time Milliseconds:{0}", stopwatch.ElapsedMilliseconds)); var router = new BrokerRouter(new KafkaOptions(IntegrationConfig.IntegrationUri) { Log = IntegrationConfig.NoDebugLog }); stopwatch.Restart(); var producer = new Producer(router) { BatchDelayTime = TimeSpan.FromMilliseconds(10), BatchSize = numberOfMessage / 10 }; IntegrationConfig.NoDebugLog.InfoFormat(IntegrationConfig.Highlight("create producer ,time Milliseconds:{0}", stopwatch.ElapsedMilliseconds)); stopwatch.Restart(); List <OffsetResponse> offsets = await producer.GetTopicOffsetAsync(IntegrationConfig.IntegrationTopic); IntegrationConfig.NoDebugLog.InfoFormat(IntegrationConfig.Highlight("request Offset,time Milliseconds:{0}", stopwatch.ElapsedMilliseconds)); stopwatch.Restart(); List <Task> sendList = new List <Task>(numberOfMessage); for (int i = 0; i < numberOfMessage; i++) { var sendTask = producer.SendMessageAsync(IntegrationConfig.IntegrationTopic, new[] { new Message(i.ToString()) }, 1, null, MessageCodec.CodecNone, partition); sendList.Add(sendTask); } TimeSpan maxTimeToRun = TimeSpan.FromMilliseconds(timeoutInMs); var doneSend = Task.WhenAll(sendList.ToArray()); await Task.WhenAny(doneSend, Task.Delay(maxTimeToRun)); Assert.IsTrue(doneSend.IsCompleted, "not done to send in time"); IntegrationConfig.NoDebugLog.InfoFormat(IntegrationConfig.Highlight("done send ,time Milliseconds:{0}", stopwatch.ElapsedMilliseconds)); stopwatch.Restart(); ConsumerOptions consumerOptions = new ConsumerOptions(IntegrationConfig.IntegrationTopic, router); consumerOptions.PartitionWhitelist = new List <int> { partition }; consumerOptions.MaxWaitTimeForMinimumBytes = TimeSpan.Zero; Consumer consumer = new Consumer(consumerOptions, offsets.Select(x => new OffsetPosition(x.PartitionId, x.Offsets.Max())).ToArray()); int expected = 0; IntegrationConfig.NoDebugLog.InfoFormat(IntegrationConfig.Highlight("start Consume ,time Milliseconds:{0}", stopwatch.ElapsedMilliseconds)); IEnumerable <Message> messages = null; var doneConsume = Task.Run((() => { stopwatch.Restart(); messages = consumer.Consume().Take(numberOfMessage).ToArray(); IntegrationConfig.NoDebugLog.InfoFormat(IntegrationConfig.Highlight("done Consume ,time Milliseconds:{0}", stopwatch.ElapsedMilliseconds)); stopwatch.Restart(); })); await Task.WhenAny(doneConsume, Task.Delay(maxTimeToRun)); Assert.IsTrue(doneConsume.IsCompleted, "not done to Consume in time"); Assert.IsTrue(messages.Count() == numberOfMessage, "not Consume all ,messages"); foreach (Message message in messages) { Assert.That(message.Value.ToUtf8String(), Is.EqualTo(expected.ToString()), "Expected the message list in the correct order."); expected++; } stopwatch.Restart(); IntegrationConfig.NoDebugLog.InfoFormat(IntegrationConfig.Highlight("start producer Dispose ,time Milliseconds:{0}", stopwatch.ElapsedMilliseconds)); producer.Dispose(); IntegrationConfig.NoDebugLog.InfoFormat(IntegrationConfig.Highlight("start consumer Dispose ,time Milliseconds:{0}", stopwatch.ElapsedMilliseconds)); consumer.Dispose(); stopwatch.Restart(); IntegrationConfig.NoDebugLog.InfoFormat(IntegrationConfig.Highlight("start router Dispose,time Milliseconds:{0}", stopwatch.ElapsedMilliseconds)); router.Dispose(); }
private PaymentProcessor CreatePaymentProcessor() { var bluePay = new BluePayProcessor(BluePayClient, new WebEnvironment(), new RandomGenerator(), IntegrationConfig.GetBluePaySandBoxConfig()); var creditCard = new CreditCardProcessor(bluePay); var invoiceSender = new InvoiceSender(MockEmail); return(new PaymentProcessor(MockEmail, CurrencyConverter, OntraProcessor, invoiceSender, creditCard, null, new RandomGenerator())); }
void InitConvertConfigs() { if (convertConfigs == null) { integrationConfigs = new List <IntegrationConfig> (); convertConfigs = new List <ConvertConfig> (); convertBtnStyle = new GUIStyle(GUI.skin.button); convertBtnStyle.padding = new RectOffset(0, 0, 0, 0); convertSelectionImg = Resources.Load <Texture2D> ("microsplat_prefab_selected"); { var c = new ConvertConfig(); c.name = "Performance"; c.image = Resources.Load <Texture2D>("microsplat_preset_performance"); c.keywords = new string [] { "_BRANCHSAMPLES", "_BRANCHSAMPLESARG" }; convertConfigs.Add(c); } { var c = new ConvertConfig(); c.name = "Balanced"; c.image = Resources.Load <Texture2D> ("microsplat_preset_balanced"); c.keywords = new string [] { #if __MICROSPLAT_DETAILRESAMPLE__ "_NORMALNOISE", "_DISTANCERESAMPLE", #endif #if __MICROSPLAT_TRIPLANAR__ "_TRIPLANAR", #endif "_BRANCHSAMPLESARG", "_BRANCHSAMPLES" }; convertConfigs.Add(c); RequireTriplanar(c.missingModules); RequireAntiTile(c.missingModules); } { var c = new ConvertConfig(); c.name = "Quality"; c.image = Resources.Load <Texture2D> ("microsplat_preset_quality"); c.keywords = new string [] { #if __MICROSPLAT_TEXTURECLUSTERS__ "_STOCHASTIC", #endif #if __MICROSPLAT_DETAILRESAMPLE__ "_DISTANCERESAMPLE", #endif #if __MICROSPLAT_TRIPLANAR__ "_TRIPLANAR", #endif #if __MICROSPLAT_TESSELLATION__ "_TESSDISTANCE", #endif "_BRANCHSAMPLES", "_BRANCHSAMPLESAGR" }; convertConfigs.Add(c); RequireTriplanar(c.missingModules); RequireAntiTile(c.missingModules); RequireTessellation(c.missingModules); RequireTextureClusters(c.missingModules); } // INTERGRATIONS { var c = new IntegrationConfig(); c.name = "Enviro"; c.assetLink = "https://assetstore.unity.com/packages/tools/particles-effects/enviro-sky-and-weather-33963?aid=25047"; c.keywords = new string [] { #if __MICROSPLAT_SNOW__ "_SNOW", "_USEGLOBALSNOWLEVEL", #endif #if __MICROSPLAT_STREAMS__ "_WETNESS", "_GLOBALWETNESS", #endif }; #if ENVIRO_HD || ENVIRO_LW || ENVIRO_PRO c.assetInstalled = true; #endif RequireStreams(c.missingModules); RequireSnow(c.missingModules); integrationConfigs.Add(c); } { var c = new IntegrationConfig(); c.name = "Weather Maker"; c.keywords = new string [] { #if __MICROSPLAT_SNOW__ "_SNOW", "_USEGLOBALSNOWLEVEL", #endif #if __MICROSPLAT_STREAMS__ "_WETNESS", "_GLOBALWETNESS", #endif }; c.assetLink = "https://assetstore.unity.com/packages/tools/particles-effects/weather-maker-unity-weather-system-sky-water-volumetric-clouds-a-60955?aid=25047"; c.keywords = new string [] { }; RequireStreams(c.missingModules); RequireSnow(c.missingModules); #if WEATHER_MAKER_PRESENT c.assetInstalled = true; #endif integrationConfigs.Add(c); } } }
public string GetTestConnResults() { return(System.IO.File.ReadAllText(IntegrationConfig.GetFileSystemDir() + "test.txt")); }
public string GetJourney(string parameters) { return(AsyncHelper.RunSync(() => WebApiClient.Call(IntegrationConfig.GetRebusCoreUri() + "journey" + parameters))); }