Пример #1
0
 private void OnMultipleLogFileQuery(object sender, MultipplePLGFilesArgs e)
 {
     if (MultipleLogFilesQuery != null)
     {
         MultipleLogFilesQuery(sender, e);
     }
     else
     {
         throw new InvalidDataException("Multiple process log files in a archive is not supported.");
     }
 }
Пример #2
0
        private string GetUnZippedFilename(string filename)
        {
            string tempFile = m_TempFileManager.GetTempFile();

            using (ZipArchive archive = ZipFile.OpenRead(filename))
            {
                if (archive.Entries == null)
                {
                    throw new IOException("Could not find any plg file.");
                }

                var plgCandidates = archive.Entries.Where(x => x.Name.EndsWith(".plg"));

                if (plgCandidates.Count() > 1)
                {
                    if (MultippleLogFilesQuery == null)
                    {
                        throw new InvalidDataException("Multiple process log files in a archive is not supported.");
                    }

                    MultipplePLGFilesArgs args = new MultipplePLGFilesArgs(plgCandidates.Select(x => x.FullName).ToArray());
                    MultippleLogFilesQuery(this, args);

                    if (args.Cancel)
                    {
                        throw new IOException("Operation aborted by user!");
                    }

                    if (string.IsNullOrEmpty(args.SelectedFilename))
                    {
                        throw new ArgumentException("No filename selected, operation aborted!");
                    }

                    plgCandidates = plgCandidates.Where(x => x.FullName.Equals(args.SelectedFilename));
                }

                if (plgCandidates.Count() == 0)
                {
                    throw new IOException("Could not find any plg file.");
                }

                plgCandidates.First().ExtractToFile(tempFile, true);
            }

            return(tempFile);
        }