// See https://aka.ms/new-console-template for more information using DynamicData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Diagnostics; using ZymonicServices; using zTSMServices; using Microsoft.Extensions.Logging; class Program { static ZymonicTestClient _client = new ZymonicTestClient(); static async Task Main(string[] args) { await _client.GetData(); return 0; } } class ZymonicTestClient { public Dictionary testSettings { get; set; } = new Dictionary { {"baseUri", "https://md5.zednax.com/zymonicmp"}, {"systemName", "ztsm"}, {"username", "alexm"}, {"password", "testing9999"}, {"client_id", "75fcc6794cdcc977d0d5afaa784421ee"}, {"client_secret", "testing123"}, {"scope", "general_api"} }; private readonly ZymonicSettings _settings; private readonly ZymonicDbContextFactory _testDbContextFactory; private readonly IZymonicAA _authService; private readonly IZymonicLogger _logger; // The automatic DBset creation only works on objects that have been instantiated before the DB context private List results = new List(); public ZymonicTestClient() { using ILoggerFactory factory = LoggerFactory.Create(builder => builder.AddConsole()); _logger = (IZymonicLogger)new ZymonicLogger(factory.CreateLogger()); _testDbContextFactory = new ZymonicDbContextFactory(new DbContextOptionsBuilder().UseSqlite($"Data Source=cboslookup.sqlite").Options); _settings = new ZymonicSettings(_testDbContextFactory, testSettings["baseUri"], testSettings["systemName"]); _settings.Setting("ClientId", testSettings["client_id"]); _settings.Setting("ClientSecret", testSettings["client_secret"]); _settings.Setting("Scope", testSettings["scope"]); _authService = new ZymonicAA(_settings, _logger); } public async Task GetData() { await _authService.Login(testSettings["username"], testSettings["password"]); CbosFilStockLookup cfl = new CbosFilStockLookup(_logger, _testDbContextFactory, _settings, _authService); IObservable> resultObservable = cfl.Connect(); results = cfl.GetAll(); foreach (CbosFilStockLookupResult result in results) { Console.WriteLine(result.ToString()); } await cfl.Search(true); results = cfl.GetAll(); foreach (CbosFilStockLookupResult result in results) { Console.WriteLine(result.ToString()); } return true; } }