Пример #1
0
        static void Main(string[] args)
        {
            // Parameters Check
            if (args == null || args.Length == 0)
            {
                // Error
                Console.WriteLine("No arguments received. Type pass '-h' to receive a list of parameters");
                System.Environment.Exit(-101);
            }

            // Should print help ?
            if (args.Where(t => t == "-h").FirstOrDefault() != null)
            {
                // Printing Help - Parameters
                PrintHelp();
                return;
            }

            // Reading App Config
            LoadConfiguration();

            // Parsing Arguments
            ParseArguments(args);

            Console.WriteLine("Reaching Database");

            // Building Connection Strings
            String sourceConnString = MongoDbContext.BuildConnectionString(_sourceUsername, _sourcePassword, _sourceServer, _authDatabaseName);

            // Reaching Database
            MongoDatabase sourceDatabase = MongoDbContext.GetServer(sourceConnString).GetDatabase(_sourceDatabaseName);

            // Picking which method to use
            switch (_duplicateMode)
            {
            case DuplicateMode.DuplicateCollections:
                Console.WriteLine("Duplicating collection from List");
                Duplicator.CollectionsDuplicate(sourceDatabase, _collections, _insertBatchSize, _copyIndexes, _duplicationSuffix);
                break;

            case DuplicateMode.DuplicateCollectionsWithMask:
                Console.WriteLine("Duplicating Collections that matches : " + _collections.Value.First());
                Duplicator.CollectionsDuplicate(sourceDatabase, _collections.Value.First(), _insertBatchSize, _copyIndexes, _duplicationSuffix);
                break;
            }

            Console.WriteLine("Duplication Finished");
            Console.ReadLine();
        }