public UpdatePackagesStep UpdateNuspecAndAssemblyInfo()
		{
			var checkPackages =
				new DirectoryInfo(solutionSystemInfo.FolderPath)
					.GetFiles("AssemblyInfo.cs", SearchOption.AllDirectories)
					.Select(Packages.Parse)
					.Where(x => x != null && packagesId.Contains(x.Title))
					.GroupBy(x => x.Title)
					.ToDictionary(k => k.Key, v => new { Versions = v.Select(y => y.PackageVersion), Packages = v.Select(y => y) })
					.Where(x => x.Value.Packages.Any(y => y.HasNuget))
					.ToArray();

			var packagesWithDifferentVersions = checkPackages.Where(x => x.Value.Versions.Distinct().Count() > 1).ToArray();

			if (packagesWithDifferentVersions.Any())
			{
				ConsoleHelper.WriteLine("Packages with different versions to be fixed");

				return new UpdatePackagesStep();
			}

			var packages =
				checkPackages
					.OrderBy(x => x.Key)
					.Select(x => new PackageWithFramework(x.Key, x.Value.Versions.First(), x.Value.Packages))
					.ToArray();

			return new UpdatePackagesStep(solutionSystemInfo, buildAndRevision, packages, previousVersions);
		}
예제 #2
0
 private void StartGrep()
 {
     try
       {
     foreach (var item in options.FilePaths)
     {
       string path = WildcardCharacterHelper.TranslateWildcardDirectoryPath(item);
       if (options.IsSetDirectory)
       {
     GrepDirectory(path);
       }
       else
       {
     if (WildcardCharacterHelper.IsContainsWildcard(path))
     {
       string dir = path;
       if (!path.Contains("\\") && !path.Contains("/"))
       {
         dir = Environment.CurrentDirectory + Path.DirectorySeparatorChar + path;
       }
       FileInfo[] files = new DirectoryInfo(Path.GetDirectoryName(dir)).GetFiles();
       foreach (var file in files.OrderBy(f => f.Name))
       {
         Regex r = new Regex(WildcardCharacterHelper.TranslateWildcardToRegex(path));
         if (r.IsMatch(file.FullName) || r.IsMatch(file.Name))
         {
           GrepFile(file.FullName);
         }
       }
     }
     else
     {
       GrepFile(path);
     }
       }
     }
       }
       catch (ArgumentException ex)
       {
     RaiseCommandLineException(this, new CommandLineException("Path is invalid.", ex));
       }
       catch (CommandLineException ex)
       {
     RaiseCommandLineException(this, ex);
       }
 }
예제 #3
0
        /// <summary>
        /// Gets all files from the specified folder
        /// </summary>
        /// <param name="folder">which folder</param>
        /// <param name="order">sort order</param>
        /// <returns>list of all files</returns>
        private List<FileInfo> getAllFiles(String folder, SortOrder order)
        {
            var retVal = new List<FileInfo>();

            if (Directory.Exists(folder))
            {
                var fileInfo = new DirectoryInfo(folder).GetFiles();

                switch (order)
                {
                    case SortOrder.DateDescending:
                        retVal = fileInfo.OrderByDescending(f => f.LastWriteTime).ToList();
                        break;

                    case SortOrder.DateAscending:
                        retVal = fileInfo.OrderBy(f => f.LastWriteTime).ToList();
                        break;

                    case SortOrder.AtoZ:
                        retVal = fileInfo.OrderBy(f => f.Name).ToList();
                        break;

                    case SortOrder.ZtoA:
                        retVal = fileInfo.OrderByDescending(f => f.Name).ToList();
                        break;

                    default:
                        retVal = fileInfo.ToList();
                        break;
                }
            }

            return retVal;
        }
예제 #4
0
 private void LoadBooks()
 {
     _bookInfos = new List<Book.BookInfo>();
     var bookFolders =  new DirectoryInfo(_path).GetDirectories();//although NTFS may already sort them, that's an implementation detail
     //var orderedBookFolders = bookFolders.OrderBy(f => f.Name);
     var orderedBookFolders = bookFolders.OrderBy(f => f.Name, new NaturalSortComparer<string>());
     foreach (var folder in orderedBookFolders)
     {
         if (Path.GetFileName(folder.FullName).StartsWith("."))//as in ".hg"
             continue;
         if (Path.GetFileName(folder.FullName).ToLower().Contains("xmatter"))
             continue;
         AddBookInfo(folder.FullName);
     }
 }
예제 #5
0
 private List<DirectoryInfo> MakeDirList(DirectoryInfo[] dirs)
 {
     var list = new List<DirectoryInfo>();
     foreach (DirectoryInfo dir in dirs.OrderBy(d => d.Name))
     {
         list.Add(dir);
     }
     return list;
 }
예제 #6
0
        /*
         * Created By: Ryan Causey
         * Created Date: 4/4/13
         * Last Edited By:
         * Last Edited Date:
         */
        /// By: Ryan Causey
        /// Edited Julian Nguyen(5/1/13)
        /// <summary>
        /// Adds all the photos from the library into the *hopefully* already created
        /// Recovery Album.
        /// </summary>
        /// <param name="errorReport">ErrorReport object to be updated</param>
        /// <param name="albumUID">UID of the Recovery Album</param>
        /// <returns>The ErrorReport of this action. </returns>
        private ErrorReport addPhotoBackup(ErrorReport errorReport, Guid albumUID)
        {
            if (albumUID == Guid.Empty)
            {
                setErrorReportToFAILURE("Failed to create recovery album", ref errorReport);
                return errorReport;
            }

            // This method of moving the folder to a new path and copying it back into the library works too
            // I'm not yet able to tell which is faster --BS
            // If you use this method, be sure to uncomment out the directory.delete function at the end of the foreach
            // Note also that DirectoryInfo.*() does not guarantee any order to the files
            //String tmpDir = Path.Combine(libraryPath, "..", "backup");
            //Directory.Move(libraryPath, tmpDir);
            //Directory.CreateDirectory(libraryPath);
            //set up a directory info object from the path
            //FileInfo[] files = new DirectoryInfo(tmpDir).GetFiles();

            IEnumerable<FileInfo> libraryDir = new DirectoryInfo(_imagelibraryDirPath).EnumerateFiles();
            // The files in libraryDir will not be sorted...

            //so we'll sort them here by removing the extension and then sorting them numerically
            IEnumerable<FileInfo> sortedFiles = libraryDir.OrderBy(
                fi => int.Parse(Path.GetFileNameWithoutExtension(fi.Name))
                );

            //set up an array of files
            foreach (FileInfo fi in sortedFiles)
            {
                ComplexPhotoData newPicture = new ComplexPhotoData();

                // Compute the hash for this picture, and then check to make sure it is unique
                newPicture.hash = util_getHashOfFile(fi.FullName);
                if (!util_isImageUniqueToAlbum(albumUID, ByteArrayToString(newPicture.hash)))
                {
                    errorReport.reportStatus = ReportStatus.SUCCESS_WITH_WARNINGS;
                    errorReport.description = "Picture is not unique.";
                    errorReport.warnings.Add("Picture is not unique: " + fi.FullName);
                    return errorReport;
                }

                //probably should check that the file extension is supported...
                newPicture.extension = fi.Extension;

                //get a unique ID for this photo and update its
                //data object to reflect this new UID.
                newPicture.UID = util_getNextUID(_imagesRootXml, "picture", "uid", 1);
                // error checking the call
                if (!util_checkIDIsValid(newPicture.UID))
                {
                    setErrorReportToFAILURE("Failed to get a UID for a new picture.", ref errorReport);
                    return errorReport;
                }

                //Change me if you want to start naming the pictures differently in the library.
                String picNameInLibrary = newPicture.UID.ToString() + fi.Extension;

                // Get the refcount (will get zero if the pic is brand new) and increment it.
                newPicture.refCount = _photoBomb_xml.getPhotoRefCount(ByteArrayToString(newPicture.hash), _imagesRootXml);
                newPicture.refCount++;
                // if this is a new picture, we add it to the db
                if (newPicture.refCount == 1)
                {
                    //rename the file
                    fi.MoveTo(Path.Combine(_imagelibraryDirPath, picNameInLibrary));

                    newPicture.fullPath = fi.FullName;

                    util_addImageToImageDB(errorReport, newPicture);
                }
                else
                {
                    // Otherwise, incremented the refcount, change the xml object in memory and it'll be saved shortly.
                    XElement imageNode = null;
                    if (!_photoBomb_xml.getImageNodeFromImageXml(ByteArrayToString(newPicture.hash), _imagesRootXml, out imageNode))
                    {
                        setErrorReportToFAILURE("Failed to get the image node.", ref errorReport);
                        return errorReport;
                    }
                    imageNode.Attribute("refCount").Value = newPicture.refCount.ToString();
                }

                //if adding to the picture database failed
                if (errorReport.reportStatus == ReportStatus.FAILURE)
                {
                    return errorReport;
                }

                util_addImageToAlbumDB(errorReport, newPicture, albumUID);

                //if adding to the album database failed
                if (errorReport.reportStatus == ReportStatus.FAILURE)
                {
                    return errorReport;
                }

                //save to disk.
                saveImagesXML_backend();
                saveAlbumsXML_backend();

                //when we have the photos collection implemented need to update it here and
                //if necessary blow it out up above.
            }

            //Directory.Delete(tmpDir, true);
            return errorReport;
        }