/// <summary> /// 获得MongoImportExport命令[必须指定数据集名称!!] /// </summary> /// <param name="mongoImprotExport"></param> /// <returns></returns> public static String GetMongoImportExportCommandLine(StruImportExport mongoImprotExport) { //mongodump.exe 备份程序 String dosCommand; if (mongoImprotExport.Direct == ImprotExport.Import) { dosCommand = @"mongoimport -h @hostaddr:@port -d @dbname"; if (mongoImprotExport.FieldList != String.Empty) { dosCommand += " --fields " + mongoImprotExport.FieldList; } if (mongoImprotExport.FileName != String.Empty) { dosCommand += " --file \"" + mongoImprotExport.FileName + "\""; } } else { dosCommand = @"mongoexport -h @hostaddr:@port -d @dbname"; if (mongoImprotExport.FileName != String.Empty) { dosCommand += " --out \"" + mongoImprotExport.FileName + "\""; } } dosCommand = dosCommand.Replace("@hostaddr", mongoImprotExport.HostAddr); dosCommand = dosCommand.Replace("@port", mongoImprotExport.Port.ToString()); dosCommand = dosCommand.Replace("@dbname", mongoImprotExport.DBName); if (mongoImprotExport.CollectionName != String.Empty) { //-c CollectionName Or --collection CollectionName dosCommand += " --collection " + mongoImprotExport.CollectionName; } return(dosCommand); }
/// <summary> /// 获得MongoImportExport命令[必须指定数据集名称!!] /// </summary> /// <param name="mongoImprotExport"></param> /// <returns></returns> public static string GetMongoImportExportCommandLine(StruImportExport mongoImprotExport) { //mongodump.exe 备份程序 string dosCommand; if (mongoImprotExport.Direct == ImprotExport.Import) { dosCommand = @"mongoimport -h @hostaddr:@port -d @dbname"; if (mongoImprotExport.FieldList != string.Empty) { dosCommand += " --fields " + mongoImprotExport.FieldList; } if (mongoImprotExport.FileName != string.Empty) { dosCommand += " --file " + mongoImprotExport.FileName; } } else { dosCommand = @"mongoexport -h @hostaddr:@port -d @dbname"; if (mongoImprotExport.FileName != string.Empty) { dosCommand += " --out " + mongoImprotExport.FileName; } } dosCommand = dosCommand.Replace("@hostaddr", mongoImprotExport.HostAddr); dosCommand = dosCommand.Replace("@port", mongoImprotExport.Port.ToString()); dosCommand = dosCommand.Replace("@dbname", mongoImprotExport.DBName); if (mongoImprotExport.CollectionName != string.Empty) { //-c CollectionName Or --collection CollectionName dosCommand += " --collection " + mongoImprotExport.CollectionName; } return dosCommand; }