public async Task OnExecute(CommandLineApplication app) { var showDoc = (await _showDocStore.GetAll()).FirstOrDefault(x => x.Name == Name); if (showDoc == null) { Console.WriteLine($"Not Found Project {Name}"); return; } try { var docStr = await HttpClient.GetStringAsync(showDoc.SwaggerUrl); var document = SwaggerParser.ParseString(docStr); var request = document.ToShowDocRequest(); foreach (var item in request) { await ShowDocClient.UpdateByApi(showDoc, item); } Console.WriteLine("Sync Successfully!"); } catch (Exception e) { Console.WriteLine($"Sync failed: {e.StackTrace}"); } }
public async Task OnExecute(CommandLineApplication app) { if ((await _showDocStore.GetAll()).Any(x => x.Name == Name)) { Console.WriteLine($"Project {Name} already exists"); return; } await _showDocStore.AddShowDoc(new ShowDocEntity { AppKey = ApiKey, AppToken = ApiToken, Name = Name, ShowDocUrl = ShowDocUrl, SwaggerUrl = SwaggerUrl }); Console.WriteLine("Add done..."); }
public async Task OnExecute(CommandLineApplication app) { var showDoc = (await _showDocStore.GetAll()).FirstOrDefault(x => x.Name == Name); if (showDoc == null) { Console.WriteLine($"Not Found Project {Name}"); return; } showDoc.Name = Name; showDoc.AppKey = ApiKey; showDoc.AppToken = ApiToken; showDoc.ShowDocUrl = ShowDocUrl; showDoc.SwaggerUrl = SwaggerUrl; await _showDocStore.UpdateShowDoc(showDoc); Console.WriteLine("Update Success"); }
public async Task OnExecute(CommandLineApplication app) { var result = await _showDocStore.GetAll(); if (result.Any()) { foreach (var docEntity in result) { Console.WriteLine(docEntity.Name); Console.WriteLine($"-------- Id : {docEntity.Id}"); Console.WriteLine($"-------- Name : {docEntity.Name}"); Console.WriteLine($"-------- ApiKey : {docEntity.AppKey}"); Console.WriteLine($"-------- ApiToken : {docEntity.AppToken}"); Console.WriteLine($"-------- SwaggerUrl : {docEntity.SwaggerUrl}"); Console.WriteLine($"-------- ShowDocUrl : {docEntity.ShowDocUrl}"); } } else { Console.WriteLine("No items exist"); } }