示例#1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Starting program...");


            var environmentName = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");

            var configuration = new ConfigurationBuilder()
                                .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
                                .AddJsonFile($"appsettings.{environmentName}.json", optional: true, reloadOnChange: true)
                                .Build();

            var keys = new KontentKeys();

            ConfigurationBinder.Bind(configuration.GetSection("KontentKeys"), keys);

            MovieListing      movieListing = new MovieListing(keys);
            TaxonomyPredictor predictor    = new TaxonomyPredictor();
            TaxonomyImporter  importer     = new TaxonomyImporter(keys);

            var movies = movieListing.GetMovies();

            foreach (Movie movie in movies.Result.Items)
            {
                if (movie.ListedIn.Count() < 1)
                {
                    string formatted_prediction = predictor.GetTaxonomy(movie);
                    var    upsertResponse       = importer.UpsertTaxonomy(movie, formatted_prediction).Result;

                    Console.WriteLine(upsertResponse);
                }
            }

            Console.WriteLine("Program finished.");
        }
示例#2
0
 public MovieListing(KontentKeys keys)
 {
     client = DeliveryClientBuilder
              .WithOptions(builder => builder
                           .WithProjectId(keys.ProjectId)
                           .UsePreviewApi(keys.PreviewApiKey)
                           .Build())
              .Build();
 }
示例#3
0
        public TaxonomyImporter(KontentKeys keys)
        {
            ManagementOptions options = new ManagementOptions
            {
                ProjectId = keys.ProjectId,
                ApiKey    = keys.ManagementApiKey,
            };

            // Initializes an instance of the ManagementClient client
            client = new ManagementClient(options);
        }