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;
        }
示例#2
0
 public ImportImagesView(ImagesToImport model)
 {
     InitializeComponent();
     _model = model;
 }
示例#3
0
 internal static void MakeImagesToImportInvalidNoImages(ImagesToImport item)
 {
     item.Images.Clear();
     Assert.IsTrue(!String.IsNullOrWhiteSpace(item.Error));
 }
示例#4
0
 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);
 }