/// <summary>
        ///     Reconciles the paths to the
        /// </summary>
        /// <param name="path"></param>
        private void ReconcilePaths(string path)
        {
            var files = Directory.GetFiles(path);
            var nameMap = new Dictionary<string, string>();
            // Map the names of the files to the dictionary
            foreach (var file in files)
            {
                var filenameOnly = Path.GetFileName(file);
                if (filenameOnly == null)
                    continue;

                if (nameMap.ContainsKey(filenameOnly))
                    continue;

                nameMap.Add(filenameOnly, file);
            }

            var newPaths = new List<DatasetResolveMatchViewModel>();
            foreach (var dataset in Datasets)
            {
                if (dataset.Dataset.RawPath == null)
                    continue;

                var filename = Path.GetFileName(dataset.Dataset.RawPath);
                if (nameMap.ContainsKey(filename))
                {
                    var newPath = nameMap[filename];
                    var model = new DatasetResolveMatchViewModel(dataset, newPath);
                    newPaths.Add(model);
                }
            }

            if (newPaths.Count > 0)
            {
                var view = new DatasetResolveView();
                var viewModel = new DatasetResolveCollectionViewModel(newPaths);
                view.DataContext = viewModel;

                var result = view.ShowDialog();

                if (result == true)
                {
                    foreach (var match in newPaths)
                    {
                        if (match.IsSelected)
                        {
                            match.Dataset.Dataset.RawPath = match.NewPath;
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        ///     Reconciles the paths to the
        /// </summary>
        /// <param name="path"></param>
        private void ReconcilePaths(string path)
        {
            var files   = Directory.GetFiles(path);
            var nameMap = new Dictionary <string, string>();

            // Map the names of the files to the dictionary
            foreach (var file in files)
            {
                var filenameOnly = Path.GetFileName(file);
                if (filenameOnly == null)
                {
                    continue;
                }

                if (nameMap.ContainsKey(filenameOnly))
                {
                    continue;
                }

                nameMap.Add(filenameOnly, file);
            }

            var newPaths = new List <DatasetResolveMatchViewModel>();

            foreach (var dataset in Datasets)
            {
                if (dataset.Dataset.RawFile.Path == null)
                {
                    continue;
                }


                var filename = Path.GetFileName(dataset.Dataset.RawFile.Path);
                if (nameMap.ContainsKey(filename))
                {
                    var newPath = nameMap[filename];
                    var model   = new DatasetResolveMatchViewModel(dataset, newPath);
                    newPaths.Add(model);
                }
            }

            if (newPaths.Count > 0)
            {
                var view      = new DatasetResolveView();
                var viewModel = new DatasetResolveCollectionViewModel(newPaths);
                view.DataContext = viewModel;

                var result = view.ShowDialog();

                if (result == true)
                {
                    foreach (var match in newPaths)
                    {
                        if (match.IsSelected)
                        {
                            match.Dataset.Dataset.RawFile.Path = match.NewPath;
                        }
                    }
                }
            }
        }