コード例 #1
0
        public string CreateZipReport(ExceptionReportInfo reportInfo, string zipFilePath, IList <string> additionalFiles = null)
        {
            if (string.IsNullOrWhiteSpace(zipFilePath))
            {
                return(string.Empty);
            }

            var files = new List <string>();

            if (reportInfo.FilesToAttach.Length > 0)
            {
                files.AddRange(reportInfo.FilesToAttach);
            }
            if (additionalFiles?.Count > 0)
            {
                files.AddRange(additionalFiles);
            }
            try
            {
                if (reportInfo.TakeScreenshot)
                {
                    files.Add(ScreenShooter.TakeScreenShot());
                }
            }
            catch
            {
                /* ignored */
            }

            var filesThatExist = files.Where(f => FileService.Exists(f)).ToList();

            if (filesThatExist.Any())
            {
                Zipper.Zip(zipFilePath, filesThatExist);
            }
            else
            {
                return(string.Empty);
            }

            return(zipFilePath);
        }