internal BatchSignInput(string outputPath, Dictionary <FileSignDataEntry, SignInfo> fileSignDataMap, IEnumerable <string> externalFileNames, string publishUri) { OutputPath = outputPath; PublishUri = publishUri; List <FileName> fileNames = fileSignDataMap.Keys.Select(x => new FileName(outputPath, x.FilePath, x.SHA256Hash)).ToList(); // We need to tolerate not being able to find zips in the same path as they were in on the original machine. // As long as we can find a FileName with the same hash for each one, we should be OK. ResolveMissingZipArchives(ref fileNames); ZipContainerNames = fileNames.Where(x => x.IsZipContainer).ToImmutableArray(); // If there's any files we can't find, recursively unpack the zip archives we just made a list of above. UnpackMissingContent(ref fileNames); // After this point, if the files are available execution should be as before. // Use OrderBy to make the output of this tool as predictable as possible. FileNames = fileNames.OrderBy(x => x.RelativePath).ToImmutableArray(); ExternalFileNames = externalFileNames.OrderBy(x => x).ToImmutableArray(); AssemblyNames = FileNames.Where(x => x.IsAssembly).ToImmutableArray(); OtherNames = FileNames.Where(x => !x.IsAssembly && !x.IsZipContainer).ToImmutableArray(); var builder = ImmutableDictionary.CreateBuilder <FileName, FileSignInfo>(); foreach (var name in FileNames) { var data = fileSignDataMap.Keys.Where(k => k.SHA256Hash == name.SHA256Hash).Single(); builder.Add(name, new FileSignInfo(name, fileSignDataMap[data])); } FileSignInfoMap = builder.ToImmutable(); }
static bool CheckFiles(FileNames files) { var headList = files.Select(x => GetFileName(x).Split('_').First()).Distinct().ToList(); foreach (var head in headList) { var test = GetFileName(files.First()).Split('_').Last(); var namelist = files.Where(x => head == GetFileName(x).Split('_').First()).ToList(); // case : only single files exist if (namelist.Count < 2) { return(false); } var thcks = ThckFilter(namelist); var rflts = RfltFilter(namelist); // case : only single rflt and result exist. // prevent 1-1_1_Result.csv and 1-1_2_Result.csv if (thcks.Count() != 1 || rflts.Count() != 1) { return(false); } } return(true); }
internal OrchestratedBatchSignInput(string outputPath, Dictionary <string, SignInfo> fileSignDataMap, IEnumerable <string> externalFileNames, string publishUri) { OutputPath = outputPath; PublishUri = publishUri; // Use order by to make the output of this tool as predictable as possible. var fileNames = fileSignDataMap.Keys; FileNames = fileNames.OrderBy(x => x).Select(x => new FileName(outputPath, x)).ToImmutableArray(); ExternalFileNames = externalFileNames.OrderBy(x => x).ToImmutableArray(); AssemblyNames = FileNames.Where(x => x.IsAssembly).ToImmutableArray(); ZipContainerNames = FileNames.Where(x => x.IsZipContainer).ToImmutableArray(); OtherNames = FileNames.Where(x => !x.IsAssembly && !x.IsZipContainer).ToImmutableArray(); var builder = ImmutableDictionary.CreateBuilder <FileName, FileSignInfo>(); foreach (var name in FileNames) { var data = fileSignDataMap[name.RelativePath]; builder.Add(name, new FileSignInfo(name, data)); } FileSignInfoMap = builder.ToImmutable(); }