public IEnumerable<VersionModel> Get(GetVersionsParameters parameters)
        {
            parameters.Path = Path.GetFullPath(parameters.Path);

            var directory = new DirectoryInfo(parameters.Path);

            if (!directory.Exists)
            {
                throw new ApplicationException("The specified directory '" + parameters.Path + "' does not exist.");
            }

            var subDirectories = directory.GetDirectories().Where(w=>!w.Name.StartsWith("_"));

            subDirectories = subDirectories.Where(w =>
                                    (parameters.Single == null || String.Compare(w.Name, parameters.Single, _stringComparison) == 0) &&
                                    (parameters.Min == null || String.Compare(w.Name, parameters.Min, _stringComparison) >= 0) &&
                                    (parameters.Max == null || String.Compare(w.Name, parameters.Max, _stringComparison) <= 0))
                                    .OrderBy(ob => ob.Name);

            foreach (var subDirectory in subDirectories)
            {
                yield return new VersionModel
                {
                    Database = directory.Name,
                    ID = 0,
                    Name = subDirectory.Name,
                    DownScript = readScript(subDirectory.FullName + "\\" + DOWNSCRIPT),
                    UpScript = readScript(subDirectory.FullName + "\\" + UPSCRIPT)
                };
            }
        }
Exemplo n.º 2
0
        private IEnumerable<VersionModel> getVersions()
        {
            var parameters = new GetVersionsParameters
            {
                Path = _setupParameters.Directory
            };

            if (_versionDirection == VersionDirections.Up)
            {
                parameters.Min = _from;
                parameters.Max = _to;
            }
            else
            {
                parameters.Min = _to;
                parameters.Max = _from;
            }

            var versions = _versionRepository.Get(parameters).Skip(1);

            if (_isAuto)
            {
                versions = new[] { versions.Last() };
            }

            if (_versionDirection == VersionDirections.Up)
            {
                versions = versions.OrderBy(ob => ob.Name);
            }
            else
            {
                versions = versions.OrderByDescending(ob => ob.Name);
            }

            return versions;
        }