Ejemplo n.º 1
0
        public static async Task PerformFullSync()
        {
            var baseUri = (AppSettings.GovDelivery.Server == GovDeliveryServer.Main)
                ? GovDeliveryApiService.MAIN_URI
                : GovDeliveryApiService.STAGING_URI;

            var service = new GovDeliveryApiService(
                baseUri,
                AppSettings.GovDelivery.AccountCode,
                AppSettings.GovDelivery.Username,
                AppSettings.GovDelivery.Password
                );

            var ctx = new GovDeliveryContext();

            Console.WriteLine("Beginning sync...");

            Console.WriteLine("Syncing Topics...");
            await BusinessTasks.SyncTopics(service, ctx);

            Console.WriteLine("Topic sync Successful");

            Console.WriteLine("Syncing Categories...");
            await BusinessTasks.SyncCategories(service, ctx);

            Console.WriteLine("Category sync successful...");

            Console.WriteLine(" Syncing Subscribers and Subscriptions...");
            await BusinessTasks.UpdateSubscribers(service, ctx);

            Console.WriteLine("");
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            using (var reader = File.OpenText($@"{AppContext.BaseDirectory}\appSettings.json"))
            {
                var appSettingsText = reader.ReadToEnd();
                AppSettings = JsonConvert.DeserializeObject <AppSettings>(appSettingsText);
            }

            Service = new GovDeliveryApiService(
                AppSettings.GovDelivery.Server,
                AppSettings.GovDelivery.AccountCode,
                AppSettings.GovDelivery.Username,
                AppSettings.GovDelivery.Password
                );

            var builderOptions = new DbContextOptionsBuilder()
                                 .UseSqlServer(AppSettings.ConnectionStrings.GovDelivery);

            ContextFactory = new GovDeliveryContextFactory(builderOptions);

            Importer = new CsvImporter();

            ConfigureCli(args);
        }