Created
February 27, 2018 05:55
-
-
Save talkingdotnet/d4cc22a85570c23ef2225e4263abb65b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var services = new ServiceCollection(); | |
ConfigureServices(services); | |
var provider = services.BuildServiceProvider(); | |
Console.WriteLine("** Welcome to Data Transfer tool **"); | |
Console.WriteLine("** Please select one of the following option **"); | |
Console.WriteLine("** [1] - Enter 1 for extracting data from SQL Server Data **"); | |
Console.WriteLine("** [2] - Enter 2 for inserting data in MySQL Database **"); | |
var input = Console.ReadLine(); | |
try | |
{ | |
switch (input) | |
{ | |
case "1": | |
var deService = provider.GetRequiredService<DataExtractor>(); | |
deService.ExtractData(); | |
break; | |
case "2": | |
var mySQLService = provider.GetRequiredService<MySQLDataImport>(); | |
mySQLService.Import(); | |
break; | |
default: | |
break; | |
} | |
Console.WriteLine("** Process Completed.. Press any key to exit. **"); | |
} | |
catch (Exception ex) | |
{ | |
Console.WriteLine("** Exception Occured.. **"); | |
Console.WriteLine(ex.ToString()); | |
} | |
Console.ReadLine(); | |
} | |
private static void ConfigureServices(IServiceCollection serviceCollection) | |
{ | |
serviceCollection.AddTransient<DataExtractor>(); | |
serviceCollection.AddTransient<MySQLDataImport>(); | |
var configuration = new ConfigurationBuilder() | |
.SetBasePath(Directory.GetCurrentDirectory()) | |
.AddJsonFile("appsetting.json", false) | |
.Build(); | |
serviceCollection.AddSingleton<IConfigurationRoot>(configuration); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment