Beispiel #1
0
        /// <summary>
        /// Output File: Absolute path stays unchanged, relative path will be relative to current executing directory (usually the /bin folder)
        /// </summary>
        public static ProcessOutput Export(string binariesDirectory, int port, string database, string collection, string outputFile)
        {
            string finalPath = FolderSearch.FinalizePath(outputFile);

            string fileName  = @"{0}\{1}".Formatted(binariesDirectory, MongoDbDefaults.MongoExportExecutable);
            string arguments = @"--host localhost --port {0} --db {1} --collection {2} --out ""{3}""".Formatted(port, database, collection, finalPath);

            Process process = ProcessControl.ProcessFactory(fileName, arguments);

            string windowTitle = "mongoexport | port: {0} db: {1} collection: {2} file {3}".Formatted(port, database, collection, outputFile);

            return(ProcessControl.StartAndWaitForExit(process, windowTitle));
        }
Beispiel #2
0
        private string ResolveBinariesDirectory()
        {
            var searchDirectories = new[]
            {
                // First search from the additional search directory, if provided
                _additionalSearchDirectory,
                // Then search from the project directory
                FolderSearch.CurrentExecutingDirectory(),
                // Finally search from the nuget cache directory
                _nugetCacheDirectory
            };

            return(FindBinariesDirectory(searchDirectories.Where(x => !string.IsNullOrWhiteSpace(x)).ToList()));
        }
Beispiel #3
0
        private string ResolveBinariesDirectory()
        {
            var binariesFolder =
                // First try path when installed via nuget
                FolderSearch.CurrentExecutingDirectory().FindFolderUpwards(Path.Combine(_nugetPrefix, _searchPattern)) ??
                // second try path when started from solution
                FolderSearch.CurrentExecutingDirectory().FindFolderUpwards(_searchPattern);

            if (binariesFolder == null)
            {
                throw new MonogDbBinariesNotFoundException(string.Format(
                                                               "Could not find Mongo binaries using the search pattern of \"{0}\". We walked up to root directory from {1} and {2}.  You can override the search pattern when calling MongoDbRunner.Start.  We have detected the OS as {3}",
                                                               _searchPattern,
                                                               FolderSearch.CurrentExecutingDirectory(),
                                                               Path.Combine(_nugetPrefix, _searchPattern),
                                                               RuntimeInformation.OSDescription));
            }
            return(binariesFolder);
        }
Beispiel #4
0
        private string ResolveBinariesDirectory()
        {
            var binariesFolder =
                // First try path when installed via nuget
                FolderSearch.CurrentExecutingDirectory().FindFolderUpwards(Path.Combine(_nugetPrefix, _searchPattern)) ??
                // second try path when started from solution
                FolderSearch.CurrentExecutingDirectory().FindFolderUpwards(_searchPattern);

            if (binariesFolder == null)
            {
                throw new MonogDbBinariesNotFoundException(string.Format(
                                                               "Could not find Mongo binaries using the search pattern of \"{0}\". We walked up the directories {1} levels from {2} and {3}.  You can override the search pattern when calling MongoDbRunner.Start.  We have detected the OS as {4}",
                                                               _searchPattern,
                                                               FolderSearch.MaxLevelOfRecursion,
                                                               FolderSearch.CurrentExecutingDirectory(),
                                                               Path.Combine(_nugetPrefix, _searchPattern),
                                                               Environment.OSVersion.Platform));
            }
            return(binariesFolder);
        }
Beispiel #5
0
        /// <summary>
        /// Input File: Absolute path stays unchanged, relative path will be relative to current executing directory (usually the /bin folder)
        /// </summary>
        public static ProcessOutput Import(string binariesDirectory, int port, string database, string collection, string inputFile, bool drop)
        {
            string finalPath = FolderSearch.FinalizePath(inputFile);

            if (!File.Exists(finalPath))
            {
                throw new FileNotFoundException("File not found", finalPath);
            }

            string fileName  = @"{0}\{1}".Formatted(binariesDirectory, MongoDbDefaults.MongoImportExecutable);
            string arguments = @"--host localhost --port {0} --db {1} --collection {2} --file ""{3}""".Formatted(port, database, collection, finalPath);

            if (drop)
            {
                arguments += " --drop";
            }

            Process process = ProcessControl.ProcessFactory(fileName, arguments);

            string windowTitle = "mongoimport | port: {0} db: {1} collection: {2} file {3}".Formatted(port, database, collection, inputFile);

            return(ProcessControl.StartAndWaitForExit(process, windowTitle));
        }