public IEnumerable<string> TryImport(ImagesToImport modelFromClinImIm) { var errorMessages = new List<string>(); if (string.IsNullOrWhiteSpace(_model.Destination)) { errorMessages.Add("You must supply a destination directory."); } else if (!Directory.Exists(_model.Destination)) { errorMessages.Add("The destination directory must exist."); } try { var path = Path.Combine(_model.Destination ?? string.Empty, string.Concat(modelFromClinImIm.PatientImagesAreOf.Identifier, "_", DateTime.Now.Ticks)); var dir = Directory.CreateDirectory(path); foreach (var currImage in modelFromClinImIm.Images) { var currFile = new FileInfo(currImage); if (!currFile.Exists) { errorMessages.Add(string.Format("Unable to copy file '{0}' because it does not exist", currImage)); } else { var dest = Path.Combine(dir.FullName, currFile.Name); if (_model.DeleteImages) { currFile.MoveTo(dest); } else { currFile.CopyTo(dest); } } } } catch (Exception ex) { _log.Error(ex); errorMessages.Add(ex.Message); } return errorMessages; }
public ImportImagesView(ImagesToImport model) { InitializeComponent(); _model = model; }
internal static void MakeImagesToImportInvalidNoImages(ImagesToImport item) { item.Images.Clear(); Assert.IsTrue(!String.IsNullOrWhiteSpace(item.Error)); }
internal static void MakeImagesToImportValid(ImagesToImport item) { item.Images.Clear(); item.Images.Add("C:\test.jpg"); Assert.IsTrue(String.IsNullOrWhiteSpace(item.Error)); }
public IEnumerable<string> TryImport(ImagesToImport model) { return _viewModel.TryImport(model); }