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); }
public static Maybe <List <DPosThckRflt> > GetIPSDatas(string ipsPath, string klaPah) { ipsPath = Path.GetDirectoryName(ipsPath); FileNames filenames = Just(ipsPath) .Bind(GetAllDirs) .Map(GetAllFileNames); if (!CheckFiles(filenames)) { return(None); } var numOfClass = filenames.Select(GetNumOfClass).ToList(); var wave = GetDataWith(ReadWaveLen, RfltFilter, filenames).First().Datas.First().Value; var thckness = GetDataWith(ReadPos, ThckFilter, filenames); var rflts = GetDataWith(ReadReflectivity, RfltFilter, filenames); var Total = thckness.Zip(rflts, (f, s) => f.ToTuple(s)).ToList(); //var Total = ToClsNumWihtThckRflt(numOfClass , thckness , rflts ); List <List <DPosThckRflt> > totallist = new List <List <NumPosThckRflt <double> > >(); //for ( int i = 0 ; i < Total.Count ; i++ ) // loop for each files //{ foreach (var item in Total) { //var item = Total[i]; var thmiss = item.Item1.MissingIndex; var rfmiss = item.Item2.MissingIndex; var missing = thmiss.Concat(rfmiss).Distinct().OrderBy(x => x).Reverse(); foreach (var idx in missing) // remove { //item.Item1.RemoveAt( idx ); item.Item1.Datas.RemoveAt(idx); item.Item2.Datas.RemoveAt(idx); } var newthck = item.Item1.Datas.Select(x => x.Value).ToList(); var newrflt = item.Item2.Datas.Select(x => x.Value).ToList(); if (newthck.Count != newrflt.Count) { return(None); } List <DPosThckRflt> output = new List <DPosThckRflt>(); for (int j = 0; j < newrflt.Count; j++) { var ptrw = ToPosThckRflt(newthck[j][0], newthck[j][1], newthck[j][2], newrflt[j], wave); output.Add(ptrw); } totallist.Add(output); } return(Just(totallist.Flatten().ToList())); }
public void Start() { if (_isWorking) { return; } _isWorking = true; _imageFiles = FileNames.Select(x => new ImageFileInfo { FileName = x, Image = new System.Drawing.Bitmap(x) }).ToList(); _timerForHide.Interval = IntervalForShowImage; _timerForShow.Interval = IntervalBetweenImages; _timerForShow.Start(); }
public async Task ExtractAllAsync(CancellationToken token) { var file = new FileInfo(ContainerPath); var extensions = new[] { ".zip", ".cbz" }; if (!extensions.Contains(file.Extension)) { return; } await Task.Run(() => { using var archive = new ZipArchive(File.OpenRead(ContainerPath)); var entries = FileNames.Select(f => archive.Entries.First(e => e.FullName == f)).ToList(); for (var index = 0; index < entries.Count; index++) { var entry = entries[index]; if (Extracted > index) { continue; } if (token.IsCancellationRequested) { return; } try { var tempFile = GetFileFromUnorderedIndex(index); if (File.Exists(tempFile)) { continue; } var fileStream = File.OpenWrite(tempFile); var zipStream = entry.Open(); zipStream.CopyTo(fileStream); zipStream.Dispose(); fileStream.Dispose(); } finally { Extracted++; UpdateExtracted?.Invoke(nameof(Extracted)); } } }, token); }
public void ExportFileSystem(string fileName) { using (var fStream = new FileStream(fileName, FileMode.Create, FileAccess.Write)) { using (var writer = new BinaryWriter(fStream)) { var count = FileNames.Count; writer.Write(count); var entries = FileNames .Select(x => x.Replace('\\', '/')) .Distinct() .Select(x => new { Hash = x.GetXeHash(), Name = x, Data = Encoding.UTF8.GetBytes(x) }) .OrderBy(x => x.Hash); foreach (var item in entries) { writer.Write(item.Hash); } int offset = 4 + count * 8; foreach (var item in entries) { writer.Write(offset); offset += item.Data.Length + 1; } foreach (var item in entries) { writer.Write(item.Data); writer.Write('\0'); } } } }
/// <summary>Return our input filenames</summary> public IEnumerable <string> GetReferencedFileNames() { return(FileNames.Select(f => f.Trim())); }
public override bool Execute() { if (!(FileNames?.Length > 0)) { return(true); } var extendedProtoPath = new HashSet <string>(ProtoPaths, StringComparer.OrdinalIgnoreCase); foreach (var dir in FileNames .Select(_ => Path.GetDirectoryName(_))) { extendedProtoPath.Add(dir); } var argumentsBuilder = new StringBuilder(); foreach (var path in extendedProtoPath .OrderBy(_ => _)) { argumentsBuilder.Append($" -I {path}"); } if (!string.IsNullOrEmpty(BuildOptions)) { argumentsBuilder.Append($" --csharp_opt={BuildOptions}"); } argumentsBuilder.Append($" --csharp_out={OutputDir}"); foreach (var file in FileNames .OrderBy(_ => _)) { argumentsBuilder.Append($" {file}"); } if (!Directory.Exists(OutputDir)) { Directory.CreateDirectory(OutputDir); } var command = $"{ProtoCompilerToolPath} {argumentsBuilder.ToString()}"; Log.LogMessage(MessageImportance.High, command); using (var p = Process.Start(new ProcessStartInfo { FileName = ProtoCompilerToolPath, Arguments = argumentsBuilder.ToString(), UseShellExecute = false, RedirectStandardOutput = true, RedirectStandardError = true, })) { p.WaitForExit(); StdOut = p.StandardOutput.ReadToEnd(); StdError = p.StandardError.ReadToEnd(); if (!string.IsNullOrEmpty(StdOut)) { Log.LogMessage(MessageImportance.High, StdOut); } if (!string.IsNullOrEmpty(StdError)) { Log.LogError(StdError); } var success = p.ExitCode == 0; return(success); } }
public string Generate() { var csprojFilePath = $"{ProjectDirectory}{NamespaceName}.csproj"; var assemblyReferences = " " + string.Join(Environment.NewLine + " ", References.Select(x => x.Trim()).Distinct()); var fileNames = string.Join(Environment.NewLine + " ", FileNames.Select(fileName => $" <Compile Include=\"{fileName}\" />")); var postBuildEvents = new List <string> { @" copy /y ""$(TargetDir)$(TargetName).*"" ""d:\boa\server\bin\"" " }; if (IsClientDll) { postBuildEvents.Add(@" copy /y ""$(TargetDir)$(TargetName).*"" ""d:\boa\client\bin\"" "); postBuildEvents.Add(@" copy /y ""$(TargetDir)$(TargetName).*"" ""d:\boa\one\"" "); } var content = $@" <?xml version=""1.0"" encoding=""utf-8""?> <Project ToolsVersion=""15.0"" xmlns=""http://schemas.microsoft.com/developer/msbuild/2003""> <Import Project=""$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props"" Condition=""Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')"" /> <PropertyGroup> <Configuration Condition="" '$(Configuration)' == '' "">Debug</Configuration> <Platform Condition="" '$(Platform)' == '' "">AnyCPU</Platform> <OutputType>Library</OutputType> <AppDesignerFolder>Properties</AppDesignerFolder> <RootNamespace>{NamespaceName}</RootNamespace> <AssemblyName>{NamespaceName}</AssemblyName> <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> <FileAlignment>512</FileAlignment> <Deterministic>true</Deterministic> <SccProjectName>SAK</SccProjectName> <SccLocalPath>SAK</SccLocalPath> <SccAuxPath>SAK</SccAuxPath> <SccProvider>SAK</SccProvider> </PropertyGroup> <PropertyGroup Condition="" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ""> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <Optimize>false</Optimize> <OutputPath>bin\Debug\</OutputPath> <DefineConstants>DEBUG;TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>3</WarningLevel> </PropertyGroup> <PropertyGroup Condition="" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ""> <DebugType>pdbonly</DebugType> <Optimize>true</Optimize> <OutputPath>bin\Release\</OutputPath> <DefineConstants>TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>3</WarningLevel> </PropertyGroup> <ItemGroup> " + assemblyReferences + @" </ItemGroup> <ItemGroup> <Compile Include=""Properties\AssemblyInfo.cs"" /> " + fileNames + @" </ItemGroup> <ItemGroup /> <Import Project=""$(MSBuildToolsPath)\Microsoft.CSharp.targets"" /> <PropertyGroup> <PostBuildEvent> " + string.Join(Environment.NewLine, postBuildEvents) + @" </PostBuildEvent> </PropertyGroup> </Project> "; FileSystem.WriteAllText(csprojFilePath, content.Trim()); var assemblyInfoContent = $@" using System.Reflection; using System.Runtime.InteropServices; [assembly: AssemblyTitle(""{NamespaceName}"")] [assembly: AssemblyDescription("""")] [assembly: AssemblyConfiguration("""")] [assembly: AssemblyCompany("""")] [assembly: AssemblyProduct(""{NamespaceName}"")] [assembly: AssemblyCopyright(""Copyright © 2019"")] [assembly: AssemblyTrademark("""")] [assembly: AssemblyCulture("""")] [assembly: ComVisible(false)] [assembly: AssemblyVersion(""1.0.0.0"")] [assembly: AssemblyFileVersion(""1.0.0.0"")] "; var assemblyInfoFilePath = $"{ProjectDirectory}\\Properties\\AssemblyInfo.cs"; FileSystem.WriteAllText(assemblyInfoFilePath, assemblyInfoContent.Trim()); return(csprojFilePath); }