protected override void OnStart(string[] args) { try { OptionsManager manager = new OptionsManager(@"D:\Lab4\DataManagerService\bin\Release\AppSettings.xml"); dataManagerOptions = manager.GetOptions <DataManagerOptions>(); errorDb = new Database(dataManagerOptions.ErrorConnectionString); personDb = new Database(dataManagerOptions.ConnectionString); var persons = personDb.GetPersons(dataManagerOptions.SearchCriteria); XmlXsdGenerator <Person> generator = new XmlXsdGenerator <Person>(persons); var xmlString = generator.GenerateXml(); var xsdString = generator.GenerateXsd(); FileManagerService fileManager = new FileManagerService(); fileManager.Launch(); FileTransfer sender = new FileTransfer(dataManagerOptions.FtpSourceFolder); sender.Send(xmlString, xsdString); } catch (Exception ex) { Error error = new Error(ex.Source, ex.Message, ex.StackTrace, DateTime.Now); errorDb.LogError(error); } }
protected override async void OnStart(string[] args) { try { OptionsManager manager = new OptionsManager(@"E:\LR5\DataManagerService\bin\Release\AppSettings.xml"); dataManagerOptions = await manager.GetOptionsAsync <DataManagerOptions>(); errorDb = new Database(dataManagerOptions.ErrorConnectionString); personDb = new Database(dataManagerOptions.ConnectionString); var persons = await personDb.GetPersonsAsync(dataManagerOptions.SearchCriteria); XmlXsdGenerator <Person> generator = new XmlXsdGenerator <Person>(persons); var xmlString = generator.GenerateXml(); var xsdString = generator.GenerateXsd(); FileManagerService filemanager = new FileManagerService(); await filemanager.LaunchAsync(); FileSender sender = new FileSender(dataManagerOptions.FtpSourceFolder); await sender.SendAsync(xmlString, xsdString); } catch (Exception e) { await errorDb.LogErrorAsync(new Error(e.Message, e.Source, e.StackTrace, DateTime.Now)); } }