Esempio n. 1
0
        static void Main(string[] args)
        {
            var serviceCollection = new ServiceCollection();

            var serviceProvider = ConfigureLog(serviceCollection);
            var logger          = serviceProvider.GetService <ILogger <Program> >();

            TopperDataMigrationConfig topperDataMigrationConfig = ReadConfiguration(logger, args);

            serviceProvider = ConfigureServices(serviceCollection, topperDataMigrationConfig);

            MigrateData(logger, serviceProvider, topperDataMigrationConfig);
        }
Esempio n. 2
0
 private static void MigrateData(Microsoft.Extensions.Logging.ILogger logger, ServiceProvider serviceProvider, TopperDataMigrationConfig topperDataMigrationConfig)
 {
     using (var itemsRepository = serviceProvider.GetService <IRepository <TopItem> >())
     {
         itemsRepository.OpenConnection();
         int i          = 0;
         var storeLogic = serviceProvider.GetService <IStoreManager>();
         storeLogic.Progress += StoreLogic_Progress;
         IEnumerable <TopItem> dataToMigrate;
         try
         {
             dataToMigrate = ReadFile(topperDataMigrationConfig.InoutFile);
         }
         catch (Exception e)
         {
             logger.LogError(e, "");
             return;
         }
         storeLogic.UpdateItems(dataToMigrate);
     }
 }
Esempio n. 3
0
 private static ServiceProvider ConfigureServices(ServiceCollection serviceCollection, TopperDataMigrationConfig topperDataMigrationConfig)
 {
     serviceCollection.AddSingleton <IRepository <TopItem> >((p) => { return(new Repository <TopItem>(p.GetRequiredService <ILogger <Repository <TopItem> > >(), topperDataMigrationConfig.CosmosDbConfig)); });
     serviceCollection.AddTransient <IStoreManager, StoreManager>();
     return(serviceCollection.BuildServiceProvider());
 }