public List <Reports> GetFileStartAndEndSingleCopy(List <string> str, string TapeNo) { try { var _tapeNo = TapeNo.TrimStart(); List <string> result = new List <string>(); List <Reports> reports = new List <Reports>(); List <string> st; string firstessemble; string lastessemble = null; string filesize = null; int startpos; int endpos; int nosfile = 0; int filestart = 0; int fileend = 0; Reports _reports = new Reports(); if (!CheckIfSegDData(str)) { st = str.SkipWhile(x => !x.Contains("Command: Copy to deof")) // skips everything before .Skip(1) // and <rs:data> itself .TakeWhile(x => !x.Contains($"Command: Unload nowait input")) // and take up to </rs:data> .ToList(); firstessemble = st.FirstOrDefault(c => c.Contains("Length = ") || c.Contains("Length = 2432") && !c.Contains("Length = 7680 "))?.Replace("Length = ", "").TrimStart(); if (firstessemble != null) { firstessemble = firstessemble.Substring(0, firstessemble.LastIndexOf(" ID = ", StringComparison.Ordinal)); lastessemble = st.LastOrDefault(c => c.Contains("Length = "))?.Replace("Length = ", "").TrimStart(); if (lastessemble != null) { lastessemble = lastessemble.Substring(0, lastessemble.LastIndexOf(" ID = ", StringComparison.Ordinal)); filesize = st.FirstOrDefault(c => c.Contains("Transfer total")); if (filesize != null) { startpos = filesize.IndexOf("Mb,", StringComparison.Ordinal); endpos = filesize.LastIndexOf("G", StringComparison.Ordinal) + 1; filesize = filesize.Substring(startpos + 3).Trim(); nosfile = int.Parse(lastessemble) - int.Parse(firstessemble); filestart = int.Parse(firstessemble); fileend = int.Parse(lastessemble); _reports = new Reports { TapeId = _tapeNo, NumberOfFiles = nosfile, FileNumStart = filestart, FileNumEnd = fileend, DataSize = filesize, FileFormat = "SEGD" }; } } } reports.Add(_reports); } else { st = str.SkipWhile(x => !x.Contains("Length = 3200")) // skips everything before .Skip(1) // and <rs:data> itself .TakeWhile(x => !x.Contains($"Command: Unload nowait input")) // and take up to </rs:data> .ToList(); firstessemble = st.FirstOrDefault(c => c.Contains("Length = "))?.Replace("Length = ", "").TrimStart(); if (firstessemble != null) { firstessemble = firstessemble.Substring(0, firstessemble.LastIndexOf(" ID = ", StringComparison.Ordinal)); lastessemble = st.LastOrDefault(c => c.Contains("Length = ")) ?.Replace("Length = ", "") .TrimStart(); if (lastessemble != null) { lastessemble = lastessemble.Substring(0, lastessemble.LastIndexOf(" ID = ", StringComparison.Ordinal)); filesize = st.FirstOrDefault(c => c.Contains("Transfer total")); if (filesize != null) { startpos = filesize.IndexOf("Mb,", StringComparison.Ordinal); filesize = filesize.Substring(startpos + 3).Trim(); } nosfile = int.Parse(lastessemble) - int.Parse(firstessemble); } filestart = int.Parse(firstessemble); } if (lastessemble != null) { fileend = int.Parse(lastessemble); } _reports = new Reports { TapeId = _tapeNo, NumberOfFiles = nosfile, FileNumStart = filestart, FileNumEnd = fileend, DataSize = filesize, FileFormat = "SEGY" }; reports.Add(_reports); } return(reports); } catch (ReportErrorHandler) { throw new ReportErrorHandler(); } }
public List <Reports> GetFileStartAndEnd(List <string> str, List <string> TapeNo) { try { var _tapeNo = TapeNo.ToArray(); List <string> result = new List <string>(); List <Reports> reports = new List <Reports>(); string firstessemble; string lastessemble; string filesize; int startpos; int endpos; int nosfile; int filestart; int fileend; Reports _reports = new Reports(); if (CheckIfSegDData(str)) { foreach (var tape in _tapeNo) { var st = str.SkipWhile(x => !BatchChecker(x, tape)) // skips everything before .Skip(1) // and <rs:data> itself .TakeWhile(x => !x.Contains($"BATCHCOPY - Unloading input tape {tape}")) // and take up to </rs:data> .ToList(); firstessemble = st.Where(c => c.Contains("Copied SEGY ensemble")).FirstOrDefault().Replace("Copied SEGY ensemble ", ""); firstessemble = firstessemble.Substring(0, firstessemble.LastIndexOf(", f")); lastessemble = st.Where(c => c.Contains("Copied SEGY ensemble")).LastOrDefault().Replace("Copied SEGY ensemble ", ""); lastessemble = lastessemble.Substring(0, lastessemble.LastIndexOf(", f")); filestart = int.Parse(firstessemble); fileend = int.Parse(lastessemble); _reports.FileNumStart = filestart; _reports.FileNumEnd = fileend; _reports.TapeId = tape; _reports.FileFormat = "SEGY"; filesize = st.FirstOrDefault(c => c.Contains("Transfer total")); if (filesize != null) { startpos = filesize.IndexOf("Mb,", StringComparison.Ordinal); filesize = filesize.Substring(startpos + 3).Trim(); nosfile = int.Parse(lastessemble) - int.Parse(firstessemble); _reports.NumberOfFiles = nosfile; _reports.DataSize = filesize; } reports.Add(_reports); } } foreach (var tape in _tapeNo) { var st = str.SkipWhile(x => !BatchChecker(x, tape)) // skips everything before .Skip(1) // and <rs:data> itself .TakeWhile(x => !x.Contains($"BATCHCOPY - Unloading input tape {tape}")) // and take up to </rs:data> .ToList(); firstessemble = st .FirstOrDefault(c => c.Contains("Length = ") || c.Contains("Length = 2432") && !c.Contains("Length = 7680 ")).Replace("Length = ", "").TrimStart(); firstessemble = firstessemble.Substring(0, firstessemble.LastIndexOf(" ID = ")); lastessemble = st.LastOrDefault(c => c.Contains("Length = ")).Replace("Length = ", "").TrimStart(); lastessemble = lastessemble.Substring(0, lastessemble.LastIndexOf(" ID = ")); filesize = st.FirstOrDefault(c => c.Contains("Transfer total")); if (filesize != null) { startpos = filesize.IndexOf("Mb,", StringComparison.Ordinal); filesize = filesize.Substring(startpos + 3).Trim(); nosfile = int.Parse(lastessemble) - int.Parse(firstessemble); filestart = int.Parse(firstessemble); fileend = int.Parse(lastessemble); _reports = new Reports { TapeId = tape, NumberOfFiles = nosfile, FileNumStart = filestart, FileNumEnd = fileend, DataSize = filesize, FileFormat = "SEGD" }; } reports.Add(_reports); } return(reports); } catch (Exception) { throw new ReportErrorHandler(); } }