Ejemplo n.º 1
0
        public void AttachFiles(IAttach attacher)
        {
            var files = new List <string>();

            if (_config.FilesToAttach.Length > 0)
            {
                files.AddRange(_config.FilesToAttach);
            }
            if (_config.ScreenshotAvailable)
            {
                files.Add(ScreenshotTaker.GetImageAsFile(_config.ScreenshotImage));
            }

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

            // attach external zip files separately - admittedly weak detection using just file extension
            filesThatExist.Where(f => f.EndsWith(ZIP)).ToList().ForEach(attacher.Attach);

            // now zip & attach all specified files (ie config FilesToAttach) plus screenshot, if taken
            var filesToZip = filesThatExist.Where(f => !f.EndsWith(ZIP)).ToList();

            if (filesToZip.Any())
            {
                var zipFile = File.TempFile(_config.AttachmentFilename);
                Zipper.Zip(zipFile, filesToZip);
                attacher.Attach(zipFile);
            }
        }
Ejemplo n.º 2
0
 private void AttachMapiScreenshotIfRequired(Mapi mapi)
 {
     if (_reportInfo.ScreenshotAvailable)
     {
         mapi.Attach(ScreenshotTaker.GetImageAsFile(_reportInfo.ScreenshotImage));
     }
 }
Ejemplo n.º 3
0
 private void AttachSmtpScreenshotIfRequired(MailMessage mailMessage)
 {
     if (_reportInfo.ScreenshotAvailable)
     {
         mailMessage.Attachments.Add(new Attachment(ScreenshotTaker.GetImageAsFile(_reportInfo.ScreenshotImage),
                                                    ScreenshotTaker.ScreenshotMimeType));
     }
 }
Ejemplo n.º 4
0
        private void AddMapiAttachments(Mapi mapi)
        {
            if (_reportInfo.ScreenshotAvailable)
            {
                mapi.Attach(ScreenshotTaker.GetImageAsFile(_reportInfo.ScreenshotImage));
            }

            foreach (string file in _reportInfo.FilesToAttach)
            {
                mapi.Attach(file);
            }
        }