public static IEnumerable <ApmsMetadata> GetRsD3(byte[] zipContent, string filename, string filterD3 = "RM", bool allowEmpty = false) { var dc = new List <ApmsMetadata>(); if (allowEmpty) { dc.Add(new ApmsMetadata("^^")); } using (var archive = Ionic.Zip.ZipFile.Read(new MemoryStream(zipContent))) { foreach (var entry in archive.Entries.Where(e => e.FileName.EndsWith(filename, StringComparison.OrdinalIgnoreCase))) { using (var reader = new StreamReader(entry.OpenReader())) { var content = reader.ReadToEnd(); content.Split('\n').Where(s => s.StartsWith("D")).ToList().ForEach(l => { var am = new ApmsMetadata(l.Trim()); if (string.Compare(am.D3, filterD3, true) == 0) { am.Nm = string.Format("{0} {1}", am.Nm, am.D2); dc.Add(am); } }); } } } return(dc.OrderBy(s => s.Nm)); }
public static IEnumerable <ApmsMetadata> GetD2D3(byte[] zipContent, string filename, bool allowEmpty = false) { var dc = new List <ApmsMetadata>(); if (allowEmpty) { dc.Add(new ApmsMetadata("^^")); } using (var archive = Ionic.Zip.ZipFile.Read(new MemoryStream(zipContent))) { foreach (var entry in archive.Entries.Where(e => e.FileName.EndsWith(filename, StringComparison.OrdinalIgnoreCase))) { using (var reader = new StreamReader(entry.OpenReader())) { var content = reader.ReadToEnd(); foreach (var l in content.Split('\n').Where(s => s.StartsWith("D")).Distinct().ToList()) { var na = new ApmsMetadata(l.Trim()); if (!dc.Any(r => r.D2 == na.D2 && r.D3 == na.D3)) { dc.Add(na); } } } } } return(dc.OrderBy(s => s.D2)); }