示例#1
0
        private void SelectivelyExtractAnalysisDataFromZip()
        {
            StatusFloater.Invoke(new System.Action(() => StatusFloater.lblStatus.Text = "Extracting zipped files for analysis..."));
            BackgroundWorker bgSelectivelyExtractAnalysisDataFromZip = new BackgroundWorker();

            bgSelectivelyExtractAnalysisDataFromZip.DoWork             += BgSelectivelyExtractAnalysisDataFromZip_DoWork;
            bgSelectivelyExtractAnalysisDataFromZip.RunWorkerCompleted += BgSelectivelyExtractAnalysisDataFromZip_RunWorkerCompleted;
            bgSelectivelyExtractAnalysisDataFromZip.RunWorkerAsync();
        }
示例#2
0
 private void ExtractAllFilesOfType(Ionic.Zip.ZipFile z, string ext)
 {
     foreach (Ionic.Zip.ZipEntry e in z.Entries.Where(f => f.FileName.Contains(ext)))
     {
         StatusFloater.Invoke(new System.Action(() => StatusFloater.lblSubStatus.Text = e.FileName.Substring(e.FileName.LastIndexOf("/") + 1)));
         if (!File.Exists(m_analysisPath + "\\" + e.FileName.Substring(e.FileName.LastIndexOf("/") + 1)))
         {
             FileStream fs = new FileStream(m_analysisPath + "\\" + e.FileName.Substring(e.FileName.LastIndexOf("/") + 1), FileMode.Create);
             e.Extract(fs);
             fs.Close();
         }
     }
 }
示例#3
0
        private void ExtractFileToPath(Ionic.Zip.ZipFile z, string OutputPath, string FileName)
        {
            z.UseZip64WhenSaving = Ionic.Zip.Zip64Option.Always;
            StatusFloater.Invoke(new System.Action(() => StatusFloater.lblSubStatus.Text = FileName));
            FileStream fs;

            if (!File.Exists(OutputPath + "\\" + FileName) && z.Count(ze => ze.FileName.Contains(FileName)) > 0)
            {
                fs = new FileStream(OutputPath + "\\" + FileName, FileMode.Create);
                Ionic.Zip.ZipEntry ze = z.Entries.Where(f => f.FileName.Contains(FileName)).First();
                ze.Extract(fs);
                fs.Flush(true);
                fs.Close();
            }
        }
示例#4
0
        private void BgSelectivelyExtractAnalysisDataFromZip_DoWork(object sender, DoWorkEventArgs e)
        {
            Ionic.Zip.ZipFile z = new Ionic.Zip.ZipFile(m_analysisPath);
            z.UseZip64WhenSaving       = Ionic.Zip.Zip64Option.Always;
            z.ParallelDeflateThreshold = -1;
            // Always extract directly into the current running location.
            // This ensures we don't accidentally fill up a temp drive or something with large files.
            AnalysisTraceID = m_analysisPath.Substring(m_analysisPath.LastIndexOf("\\") + 1).Replace("_SSASDiagOutput", "_SSASDiag").Replace(".zip", "");
            m_analysisPath  = m_analysisPath.Substring(0, m_analysisPath.LastIndexOf("\\") + 1) + AnalysisTraceID;

            if (!Directory.Exists(m_analysisPath))
            {
                Directory.CreateDirectory(m_analysisPath);
            }
            if (!Directory.Exists(m_analysisPath + "\\Analysis"))
            {
                Directory.CreateDirectory(m_analysisPath + "\\Analysis");
            }

            ExtractFileToPath(z, m_analysisPath, "SSASDiag.log");
            AnalysisTraceID = GetAnalysisIDFromLog();

            if (z.Entries.Where(f => f.FileName.Contains(".mdf")).Count() > 0)
            {
                try
                {
                    foreach (Ionic.Zip.ZipEntry ze in z.Entries.Where(f => f.FileName.Contains(".mdf") || f.FileName.Contains(".ldf")).ToList())
                    {
                        ExtractFileToPath(z, m_analysisPath + "\\Analysis", ze.FileName.Substring(ze.FileName.LastIndexOf("/") + 1));
                    }
                }
                catch (Exception ex)
                {
                    // Continue, since if we fail writing these files, it means they do already exist, and we can probably just attach subsequently without failure.
                    LogException(ex);
                }
            }
            else
            if (z.Entries.Where(f => f.FileName == AnalysisTraceID + "/Analysis/" + AnalysisTraceID + ".mdf").Count() == 0 && z.Entries.Where(f => f.FileName.Contains(".trc")).Count() > 0)
            {
                ExtractAllFilesOfType(z, ".trc");
            }
            if (z.Entries.Where(f => f.FileName == AnalysisTraceID + "/Analysis/" + AnalysisTraceID + "_NetworkAnalysis.log").Count() > 0)
            {
                ExtractFileToPath(z, m_analysisPath + "\\Analysis", AnalysisTraceID + "_NetworkAnalysis.log");
            }
            else
            {
                if (z.Entries.Where(f => f.FileName == AnalysisTraceID + ".etl").Count() > 0)
                {
                    ExtractFileToPath(z, m_analysisPath, AnalysisTraceID + ".etl");
                }
                if (z.Entries.Where(f => f.FileName == AnalysisTraceID + ".cab").Count() > 0)
                {
                    ExtractFileToPath(z, m_analysisPath, AnalysisTraceID + ".cab");
                }
            }
            if (z.Entries.Where(f => f.FileName.Contains(".blg")).Count() > 0)
            {
                ExtractAllFilesOfType(z, ".blg");
            }
            if (z.Entries.Where(f => f.FileName.Contains("SSASDiag_MemoryDump_Analysis_")).Count() == 0 &&
                (z.Entries.Where(f => f.FileName.Contains(".mdmp")).Count() > 0))
            {
                ExtractAllFilesOfType(z, ".mdmp");
            }
            if (z.Entries.Where(f => f.FileName.Contains(".evtx")).Count() > 0)
            {
                ExtractAllFilesOfType(z, ".evtx");
            }
            if (z.Entries.Where(f => f.FileName == "msmdsrv.ini").Count() > 0)
            {
                ExtractFileToPath(z, m_analysisPath, "msmdsrv.ini");
            }
            z.Dispose();

            StatusFloater.Invoke(new System.Action(() =>
            {
                StatusFloater.Hide();
            }));
        }