public string GetConvertedContent(DocToConvert docToConvert) { // zavolat API /* * var responseText = zavolat API a získat json text * deserializovat na ConvertedResult * ConvertedResult typedBody = Newtonsoft.Json.JsonConvert.DeserializeObject<ConvertedResult>(responseText, JsonSerializerSettings); */ return(@"{json obsah, base64 dle TargetFormatType"); }
static void Main(string[] args) { Console.WriteLine("Hello World!"); // vstupy od někud StorageType storageType = StorageType.FileSystem; string sourceFileName = "url nebo filePath Document1.xml"; string targetFileName = "url na cil, nebo filePath"; TargetFormatType targetFormat = TargetFormatType.Json; // v reálu přes nějaké DI ProxyClientAPIFormatConvertor proxyClient = new ProxyClientAPIFormatConvertor(); // podle typu storage var factory = new BlobStorageFactory(); ISourceBlobStorage sourceStorage = factory.CreateBlobStorage(storageType); IPersistBlobStorage persistBlobStorage = factory.CreatePersistBlobStorage(storageType); // podle ciloveho typu persist storage ISerializedResultStorage serializedResultStorage = new SerializedResultStorageFactory().CreateSerializedResultStorage(targetFormat, sourceStorage, persistBlobStorage); string input; try { input = sourceStorage.ReadAsString(sourceFileName); DocToConvert docToConvert = new DocToConvert { TargetFormat = targetFormat, XmlContent = input, }; // API provede konverzi string convertedResult = proxyClient.GetConvertedContent(docToConvert); serializedResultStorage.SaveConvertedContent(convertedResult, targetFileName); } catch (Exception ex) { // TODO ILogger logger // zalogovat včetně StackTrace // logger.LogException(ex); // výše poslat jen stručné info throw new Exception("Něco se nepovedlo"); } }