Exemple #1
0
        static async Task Main(string[] args)
        {
            var iConfig          = GetIConfigurationRoot();
            var performMigration = false;

            _databaseSettings = iConfig.GetSection("DatabaseSettings").Get <CosmosConfig.DatabaseSettings>();
            _nthUserSettings  = iConfig.GetSection("NthUserSettings").Get <CosmosConfig.NthUserSettings>();

            var oldDataFromAzure = await GetLegacyData();

            var newDataModel = ConvertToNewModel(oldDataFromAzure);

            if (performMigration)
            {
                var newQuestionDataAfterUpdate = await MigrateData <Question>(newDataModel.Questions, _databaseSettings.TargetQuestionContainer, "/id");

                var newAnswerDataAfterUpdate = await MigrateData <Answer>(newDataModel.Answers, _databaseSettings.TargetAnswerContainer, "/questionId");

                Assert.True(newQuestionDataAfterUpdate.Count > 0);
                Assert.True(newAnswerDataAfterUpdate.Count > 0);

                //verify the contents of the containers.
                var newQuestionData = await GetNewData <Question>(_databaseSettings.TargetQuestionContainer);

                var newAnswerData = await GetNewData <Answer>(_databaseSettings.TargetAnswerContainer);

                Assert.True(newQuestionData.Count > 0);
                Assert.True(newAnswerData.Count > 0);
            }
        }
Exemple #2
0
        static async Task Main(string[] args)
        {
            try
            {
                PrintCommands();
                Program p       = new Program();
                var     iConfig = GetIConfigurationRoot();

                _databaseSettings = iConfig.GetSection("DatabaseSettings").Get <CosmosConfig.DatabaseSettings>();
                _nthUserSettings  = iConfig.GetSection("NthUserSettings").Get <CosmosConfig.NthUserSettings>();
                await p.InitializeDatabaseConnection();

                while (true)
                {
                    Console.Write("Enter command, then press ENTER: ");
                    string decision = Console.ReadLine();
                    switch (decision.ToLower())
                    {
                    case "1":
                        //await p.GetStartedUserDBsync();
                        break;

                    case "2":
                        await p.ExecuteCommand("");

                        break;

                    case "help":
                        Program.PrintCommands();
                        break;

                    case "3":
                        await p.ExecuteCommand("_Hindi");

                        break;

                    case "4":
                        await p.ExecuteCommand("_Chinese");

                        break;

                    case "5":
                        await p.ExecuteCommand("_Deutsch");

                        break;

                    case "6":
                        await p.ExecuteCommand("_Korean");

                        break;

                    case "exit":
                        return;

                    default:
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("Invalid command. Enter 'help' to show a list of commands.");
                        Console.ResetColor();
                        break;
                    }

                    Console.ResetColor();
                }
            }
            catch (CosmosException de)
            {
                Exception baseException = de.GetBaseException();
                Console.WriteLine("{0} error occurred: {1}", de.StatusCode, de);
            }
            catch (Exception ex)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine($"An error occurred: {ex}");
                Console.ResetColor();
            }
            Console.ReadLine();
        }