public void CreateFileImporter_Always_ReturnFileImporter() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); assessmentSection.Stub(a => a.ReferenceLine).Return(new ReferenceLine()); mocks.ReplayAll(); var failureMechanism = new HeightStructuresFailureMechanism(); var importTarget = new HeightStructuresContext(failureMechanism.HeightStructures, failureMechanism, assessmentSection); using (var plugin = new HeightStructuresPlugin()) { ImportInfo importInfo = GetImportInfo(plugin); // Call IFileImporter importer = importInfo.CreateFileImporter(importTarget, "test"); // Assert Assert.IsInstanceOf <HeightStructuresImporter>(importer); } mocks.VerifyAll(); }
public ImporterHelper() { // Create importer DiagnosticsTextFileImporter = FileImporter .ForTextFile() .WithFixedWidthColumns() .IgnoringFirstLine(false) .HasColumn(0, 5) .HasColumn(6, 7) .HasColumn(14, 1) .HasColumn(16, 60) .HasColumn(77) .AdaptTo <Icd10Diagnostic>((e, columns) => { e.Order = int.Parse(columns[0].Trim()); // Get code and add point var code = columns[1].Trim(); e.Code = (code.Length > 3 ? code.Insert(3, ".") : code); // Boolean is true if marked as "1", which is billable. e.ValidForSubmission = columns[2].Trim() == "1"; // Code Descriptions e.ShortDescription = columns[3].Trim(); e.LongDescription = columns[4].Trim(); }); }
private IEnumerator CoImport(IFileImporter importer, string path) { IRTE rte = IOC.Resolve <IRTE>(); rte.IsBusy = true; IProjectTree projectTree = IOC.Resolve <IProjectTree>(); string targetPath = Path.GetFileNameWithoutExtension(path); if (projectTree != null && projectTree.SelectedItem != null) { ProjectItem folder = projectTree.SelectedItem; targetPath = folder.RelativePath(false) + "/" + targetPath; targetPath = targetPath.TrimStart('/'); IProject project = IOC.Resolve <IProject>(); targetPath = project.GetUniquePath(targetPath, typeof(Texture2D), folder); } yield return(StartCoroutine(importer.Import(path, targetPath))); rte.IsBusy = false; m_parentDialog.Close(); rte.ActivateWindow(RuntimeWindowType.Scene); }
public void CreateFileImporter_WithValidData_ReturnsFileImporter() { // Setup var mocks = new MockRepository(); var mainWindow = mocks.Stub <IMainWindow>(); var gui = mocks.Stub <IGui>(); gui.Stub(g => g.MainWindow).Return(mainWindow); var assessmentSection = mocks.Stub <IAssessmentSection>(); assessmentSection.Stub(a => a.ReferenceLine).Return(new ReferenceLine()); mocks.ReplayAll(); var failureMechanism = new PipingFailureMechanism(); var context = new PipingFailureMechanismSectionsContext(failureMechanism, assessmentSection); using (var plugin = new PipingPlugin()) { plugin.Gui = gui; UpdateInfo updateInfo = GetUpdateInfo(plugin); // Call IFileImporter importer = updateInfo.CreateFileImporter(context, string.Empty); // Assert Assert.IsInstanceOf <FailureMechanismSectionsImporter>(importer); } mocks.VerifyAll(); }
public void CreateFileImporter_Always_ReturnFileImporter() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); assessmentSection.Stub(a => a.ReferenceLine).Return(new ReferenceLine()); mocks.ReplayAll(); var failureMechanism = new SpecificFailureMechanism(); var importTarget = new SpecificFailureMechanismSectionsContext(failureMechanism, assessmentSection); using (var plugin = new RiskeerPlugin()) { UpdateInfo updateInfo = GetUpdateInfo(plugin); // Call IFileImporter importer = updateInfo.CreateFileImporter(importTarget, "test"); // Assert Assert.IsInstanceOf <FailureMechanismSectionsImporter>(importer); } mocks.VerifyAll(); }
public void CreateFileImporter_Always_ReturnFileImporter() { // Setup var mocks = new MockRepository(); IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(mocks); mocks.ReplayAll(); var context = new StabilityPointStructuresCalculationGroupContext(new CalculationGroup(), null, new StabilityPointStructuresFailureMechanism(), assessmentSection); using (var plugin = new StabilityPointStructuresPlugin()) { ImportInfo info = GetImportInfo(plugin); // Call IFileImporter fileImporter = info.CreateFileImporter(context, "test"); // Assert Assert.IsInstanceOf <StabilityPointStructuresCalculationConfigurationImporter>(fileImporter); } mocks.VerifyAll(); }
private IEnumerator CoImport(IFileImporter importer, string path) { IRTE rte = IOC.Resolve <IRTE>(); rte.IsBusy = true; IProjectTree projectTree = IOC.Resolve <IProjectTree>(); string targetPath = Path.GetFileNameWithoutExtension(path); if (projectTree != null && projectTree.SelectedFolder != null) { ProjectItem folder = projectTree.SelectedFolder; targetPath = folder.RelativePath(false) + "/" + targetPath; targetPath = targetPath.TrimStart('/'); IProject project = IOC.Resolve <IProject>(); targetPath = project.GetUniquePath(targetPath, typeof(Texture2D), folder); } yield return(importer.Import(path, targetPath)); rte.IsBusy = false; }
public void CreateFileImporter_Always_ReturnFileImporter() { // Setup var mocks = new MockRepository(); var failureMechanism = mocks.Stub <ICalculatableFailureMechanism>(); var assessmentSection = mocks.Stub <IAssessmentSection>(); assessmentSection.Stub(a => a.ReferenceLine).Return(new ReferenceLine()); mocks.ReplayAll(); var foreshoreProfiles = new ForeshoreProfileCollection(); var importTarget = new ForeshoreProfilesContext(foreshoreProfiles, failureMechanism, assessmentSection); using (var plugin = new RiskeerPlugin()) { ImportInfo importInfo = GetImportInfo(plugin); // Call IFileImporter importer = importInfo.CreateFileImporter(importTarget, "test"); // Assert Assert.IsInstanceOf <ProfilesImporter <ForeshoreProfileCollection> >(importer); } mocks.VerifyAll(); }
public FileImportProcess(IFileImporter fileImporter, IOutputWriter outputWriter, ICalculator calculator, IConfiguration configuration) { _fileImporter = fileImporter ?? throw new ArgumentNullException(nameof(fileImporter)); _outputWriter = outputWriter ?? throw new ArgumentNullException(nameof(outputWriter)); _calculator = calculator ?? throw new ArgumentNullException(nameof(calculator)); _configuration = configuration ?? throw new ArgumentNullException(nameof(configuration)); }
private void RunUpdateActivity(IFileImporter importer, string updateName) { var activity = new FileImportActivity(importer, !string.IsNullOrEmpty(updateName) ? string.Format(Resources.GuiUpdateHandler_RunUpdateActivity_Updating_0_, updateName) : string.Empty); ActivityProgressDialogRunner.Run(dialogParent, activity); }
public async Task Import(DateTime date, string[] files, ImportType importType) { bool sameImportIsNotExecuting = await VerifyImportIsExecuting(date, importType); if (sameImportIsNotExecuting) { IFileImporter importer = fileImporterFactory.FromImportType(importType); await importer.ExecuteAsync(files); } }
public void CreateFileImporter_Always_ReturnFileImporter() { // Setup var importTarget = new MapDataCollectionContext(new MapDataCollection("test"), null); // Call IFileImporter importer = importInfo.CreateFileImporter(importTarget, ""); // Assert Assert.IsInstanceOf <FeatureBasedMapDataImporter>(importer); }
public static bool ImportFile(string filePath) { // Determine & check paths string srcFilePath, targetName, targetDir; PrepareImportFilePaths(filePath, out srcFilePath, out targetName, out targetDir); // Find an importer to handle the file import IFileImporter importer = importers.FirstOrDefault(i => i.CanImportFile(srcFilePath)); if (importer != null) { try { // Assure the directory exists Directory.CreateDirectory(Path.GetDirectoryName(srcFilePath)); // Move file from data directory to source directory if (File.Exists(srcFilePath)) { File.Copy(filePath, srcFilePath, true); File.Delete(filePath); } else { File.Move(filePath, srcFilePath); } } catch (Exception) { return(false); } // Import it try { importer.ImportFile(srcFilePath, targetName, targetDir); } catch (Exception ex) { Log.Editor.WriteError("An error occurred while trying to import file {1}: {0}", Log.Exception(ex), srcFilePath); return(false); } GC.Collect(); GC.WaitForPendingFinalizers(); return(true); } else { return(false); } }
internal static void Init() { foreach (Type genType in DualityEditorApp.GetAvailDualityEditorTypes(typeof(IFileImporter))) { if (genType.IsAbstract) { continue; } IFileImporter gen = genType.CreateInstanceOf() as IFileImporter; if (gen != null) { importers.Add(gen); } } }
public void CreateFileImporter_Always_ReturnFileImporter() { // Setup var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); var importTarget = new ReferenceLineContext(new ReferenceLine(), assessmentSection); // Call IFileImporter importer = importInfo.CreateFileImporter(importTarget, ""); // Assert Assert.IsInstanceOf <ReferenceLineImporter>(importer); }
/// <summary> /// Constructs a new <see cref="FileImportActivity"/>. /// </summary> /// <param name="fileImporter">The <see cref="IFileImporter"/> to use for importing the data.</param> /// <param name="description">The description of the import action.</param> /// <exception cref="ArgumentNullException">Thrown when any input argument is <c>null</c>.</exception> public FileImportActivity(IFileImporter fileImporter, string description) { if (fileImporter == null) { throw new ArgumentNullException(nameof(fileImporter)); } if (description == null) { throw new ArgumentNullException(nameof(description)); } this.fileImporter = fileImporter; Description = description; }
public static bool IsImportFileExisting(string filePath) { string srcFilePath, targetName, targetDir; PrepareImportFilePaths(filePath, out srcFilePath, out targetName, out targetDir); // Does the source file already exist? if (File.Exists(srcFilePath)) { return(true); } // Find an importer and check if one of its output files already exist IFileImporter importer = importers.FirstOrDefault(i => i.CanImportFile(srcFilePath)); return(importer != null && importer.GetOutputFiles(srcFilePath, targetName, targetDir).Any(File.Exists)); }
public static bool DoesImportOverwriteData(string filePath) { string srcFilePath, targetName, targetDir; PrepareImportFilePaths(filePath, out srcFilePath, out targetName, out targetDir); // Does the source file already exist? if (File.Exists(srcFilePath)) { // If they're not the same file, this would overwrite existing data. return(!PathHelper.FilesEqual(filePath, srcFilePath)); } // Find an importer and check if one of its output files already exist IFileImporter importer = importers.FirstOrDefault(i => i.CanImportFile(srcFilePath)); return(importer != null && importer.GetOutputFiles(srcFilePath, targetName, targetDir).Any(File.Exists)); }
public void CreateFileImporter_Always_ReturnFileImporter() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); var failureMechanism = mocks.Stub <IFailureMechanism <FailureMechanismSectionResult> >(); assessmentSection.Stub(a => a.ReferenceLine).Return(new ReferenceLine()); mocks.ReplayAll(); var importTarget = new FailureMechanismSectionsContext(failureMechanism, assessmentSection); // Call IFileImporter importer = importInfo.CreateFileImporter(importTarget, ""); // Assert Assert.IsInstanceOf <FailureMechanismSectionsImporter>(importer); mocks.VerifyAll(); }
public void CreateFileImporter_Always_ReturnFileImporter() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); var failureMechanism = new MacroStabilityInwardsFailureMechanism(); var importTarget = new MacroStabilityInwardsStochasticSoilModelCollectionContext(failureMechanism.StochasticSoilModels, failureMechanism, assessmentSection); // Call IFileImporter importer = importInfo.CreateFileImporter(importTarget, ""); // Assert Assert.IsInstanceOf <StochasticSoilModelImporter <MacroStabilityInwardsStochasticSoilModel> >(importer); mocks.VerifyAll(); }
private static bool IsUsingSourceFile(IFileImporter importer, ContentRef <Resource> resourceRef, string srcFilePath, string srcFileExt) { // Does the Resource or Importer recall to use this file? if (importer.IsUsingSrcFile(resourceRef, srcFilePath)) { return(true); } // Does the system suggest that the Resource would use that file if it was opened for editing? string resourceSourcePath = SelectSourceFilePath(resourceRef, srcFileExt); if (PathHelper.ArePathsEqual(resourceSourcePath, srcFilePath)) { return(true); } // Nope. return(false); }
public void CreateFileImporter_Always_ReturnFileImporter() { // Setup var mocks = new MockRepository(); var inquiryHelper = mocks.Stub <IInquiryHelper>(); var assessmentSection = mocks.Stub <IAssessmentSection>(); assessmentSection.Stub(a => a.ReferenceLine).Return(new ReferenceLine()); mocks.ReplayAll(); var context = new PipingFailureMechanismSectionsContext(new PipingFailureMechanism(), assessmentSection); ImportInfo <PipingFailureMechanismSectionsContext> importInfo = GetImportInfo(inquiryHelper); // Call IFileImporter importer = importInfo.CreateFileImporter(context, ""); // Assert Assert.IsInstanceOf <FailureMechanismSectionsImporter>(importer); mocks.VerifyAll(); }
public void CreateFileImporter_Always_ReturnFileImporter() { // Setup mocks = new MockRepository(); var gui = mocks.Stub <IGui>(); gui.Stub(g => g.ViewCommands).Return(mocks.Stub <IViewCommands>()); gui.Stub(g => g.ProjectOpened += null).IgnoreArguments(); gui.Stub(g => g.ProjectOpened -= null).IgnoreArguments(); mocks.ReplayAll(); var importTarget = new HydraulicBoundaryDatabaseContext(new HydraulicBoundaryDatabase(), new AssessmentSection(AssessmentSectionComposition.Dike)); // Call IFileImporter importer = importInfo.CreateFileImporter(importTarget, ""); // Assert Assert.IsInstanceOf <HydraulicBoundaryDatabaseImporter>(importer); mocks.VerifyAll(); }
public void CreateFileImporter_ValidInput_ReturnFileImporter() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); assessmentSection.Stub(a => a.ReferenceLine).Return(new ReferenceLine()); mocks.ReplayAll(); var failureMechanism = new HeightStructuresFailureMechanism(); var structures = new StructureCollection <HeightStructure>(); var importTarget = new HeightStructuresContext(structures, failureMechanism, assessmentSection); // Call IFileImporter importer = updateInfo.CreateFileImporter(importTarget, "This is valid"); // Assert Assert.IsInstanceOf <HeightStructuresImporter>(importer); mocks.VerifyAll(); }
public void CreateFileImporter_ValidInput_ReturnFileImporter() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); assessmentSection.Stub(a => a.ReferenceLine).Return(new ReferenceLine()); mocks.ReplayAll(); var failureMechanism = new PipingFailureMechanism(); var surfaceLines = new PipingSurfaceLineCollection(); var importTarget = new PipingSurfaceLinesContext(surfaceLines, failureMechanism, assessmentSection); // Call IFileImporter importer = importInfo.CreateFileImporter(importTarget, ""); // Assert Assert.IsInstanceOf <SurfaceLinesCsvImporter <PipingSurfaceLine> >(importer); mocks.VerifyAll(); }
public static bool ImportFile(string filePath) { // Determine & check paths string srcFilePath, targetName, targetDir; PrepareImportFilePaths(filePath, out srcFilePath, out targetName, out targetDir); // Find an importer to handle the file import IFileImporter importer = CorePluginRegistry.GetFileImporter(i => i.CanImportFile(srcFilePath)); if (importer != null) { try { // Assure the directory exists Directory.CreateDirectory(Path.GetDirectoryName(srcFilePath)); // Move file from data directory to source directory if (File.Exists(srcFilePath)) { File.Copy(filePath, srcFilePath, true); File.Delete(filePath); } else { File.Move(filePath, srcFilePath); } } catch (Exception) { return(false); } // Import it importer.ImportFile(srcFilePath, targetName, targetDir); GC.Collect(); GC.WaitForPendingFinalizers(); return(true); } else { return(false); } }
public ValueSetsImporterHelper() { // Create importer ValueSetsTextFileImporter = FileImporter .ForTextFile() .WithPipeDelimitedColumns() .ConsideringMultilineValues() .IgnoringFirstLine() .HasColumn(0, "ValueSetName") .HasColumn(1, "ValueSetOid") .HasColumn(2, "DefinitionVersion") .HasColumn(3, "ExpansionVersion") .HasColumn(4, "PurposeClinicalFocus") .HasColumn(5, "PurposeDataElementScope") .HasColumn(6, "PurposeInclusionCriteria") .HasColumn(7, "PurposeExclusionCriteria") .HasColumn(8, "Code") .HasColumn(9, "Description") .HasColumn(10, "CodeSystem") .HasColumn(11, "CodeSystemOID") .HasColumn(12, "CodeSystemVersion") .AdaptTo <ValueSet>((e, columns) => { e.ValueSetName = ProcessValue(columns["ValueSetName"]); e.ValueSetOid = ProcessValue(columns["ValueSetOid"]); e.DefinitionVersion = ProcessValue(columns["DefinitionVersion"]); e.ExpansionVersion = ProcessValue(columns["ExpansionVersion"]); e.PurposeClinicalFocus = ProcessValue(columns["PurposeClinicalFocus"]); e.PurposeDataElementScope = ProcessValue(columns["PurposeDataElementScope"]); e.PurposeInclusionCriteria = ProcessValue(columns["PurposeInclusionCriteria"]); e.PurposeExclusionCriteria = ProcessValue(columns["PurposeExclusionCriteria"]); e.Code = ProcessValue(columns["Code"]); e.Description = ProcessValue(columns["Description"]); e.CodeSystem = ProcessValue(columns["CodeSystem"]); e.CodeSystemOID = ProcessValue(columns["CodeSystemOID"]); e.CodeSystemVersion = ProcessValue(columns["CodeSystemVersion"]); }); }
public void CreateFileImporter_Always_ReturnFileImporter() { // Setup var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); var mocks = new MockRepository(); IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(mocks); assessmentSection.Stub(section => section.FailureMechanismContribution).Return(new FailureMechanismContribution(0.01, 0.001)); mocks.ReplayAll(); var context = new GrassCoverErosionInwardsCalculationGroupContext(new CalculationGroup(), null, failureMechanism, assessmentSection); // Call IFileImporter importer = importInfo.CreateFileImporter(context, ""); // Assert Assert.IsInstanceOf <GrassCoverErosionInwardsCalculationConfigurationImporter>(importer); mocks.VerifyAll(); }
public IEnumerable <ParsingResult> Import(IFileImporter fileImporter, string handHistoryFileContent, GameInfo gameInfo) { var progress = Substitute.For <IDHProgress>(); var xDocument = XDocument.Parse(handHistoryFileContent); var handHistoryNodes = xDocument.Descendants("HandHistory"); var result = new List <ParsingResult>(); foreach (var handHistoryNode in handHistoryNodes) { var xml = handHistoryNode.ToString(); var betOnlineXmlConverter = new BetOnlineXmlToIPokerXmlConverter(); betOnlineXmlConverter.Initialize(xml); var convertedResult = betOnlineXmlConverter.Convert(); result.AddRange(fileImporter.Import(convertedResult.ConvertedXml, progress, convertedResult.GameInfo)); } return(result); }
public void CreateFileImporter_Always_ReturnFileImporter() { // Setup var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); var mocks = new MockRepository(); IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(failureMechanism, mocks); assessmentSection.Stub(section => section.WaterLevelCalculationsForUserDefinedTargetProbabilities) .Return(new ObservableList <HydraulicBoundaryLocationCalculationsForTargetProbability>()); mocks.ReplayAll(); var context = new GrassCoverErosionOutwardsCalculationGroupContext(new CalculationGroup(), null, failureMechanism, assessmentSection); // Call IFileImporter importer = importInfo.CreateFileImporter(context, ""); // Assert Assert.IsInstanceOf <GrassCoverErosionOutwardsWaveConditionsCalculationConfigurationImporter>(importer); mocks.VerifyAll(); }
private static bool IsUsingSourceFile(IFileImporter importer, ContentRef<Resource> resourceRef, string srcFilePath, string srcFileExt) { // Does the Resource or Importer recall to use this file? if (importer.IsUsingSrcFile(resourceRef, srcFilePath)) return true; // Does the system suggest that the Resource would use that file if it was opened for editing? string resourceSourcePath = SelectSourceFilePath(resourceRef, srcFileExt); if (PathOp.ArePathsEqual(resourceSourcePath, srcFilePath)) return true; // Nope. return false; }