public void Handle(ExistingBugImportedToTargetProcessMessage <BugzillaBug> message)
        {
            var newAttachments =
                message.ThirdPartyBug.attachmentCollection.Where(attachment => !AttachmentExists(message, attachment)).ToList();

            AttachmentFolder.Delete(message.ThirdPartyBug.attachmentCollection.Except(newAttachments).Select(x => x.FileId));

            PushAttachmentsToTp(message.TpBugId, message.ThirdPartyBug, newAttachments);
        }
示例#2
0
        public void Handle(TargetProcessExceptionThrownMessage message)
        {
            _logger.Error("Error occured", new Exception(message.ExceptionString));

            if (Data.CreatingBug)
            {
                AttachmentFolder.Delete(Data.ThirdPartyBug.attachmentCollection.Select(x => x.FileId));
            }
            MarkAsComplete();
        }
        private List <LocalStoredAttachment> CreateAttachments(IEnumerable <attachment> attachments)
        {
            var storedAttachments = new List <LocalStoredAttachment>();

            foreach (var attachment in attachments.Where(a => a.isobsolete == isobsolete._0 && a.data.Value != null))
            {
                var    attachmentFileName = GetAttachmentFileName(attachment);
                FileId fileId             = null;

                try
                {
                    fileId = SaveAttachmentFile(attachment);

                    var localAttachment = new LocalStoredAttachment
                    {
                        FileId      = fileId,
                        FileName    = attachmentFileName,
                        Description = attachment.desc,
                        OwnerId     = ObjectFactory.GetInstance <IUserMapper>().GetTpIdBy(attachment.attacher),
                        CreateDate  = CreateDateConverter.ParseFromBugzillaLocalTime(attachment.date)
                    };

                    storedAttachments.Add(localAttachment);
                }
                catch (Exception ex)
                {
                    ObjectFactory.GetInstance <IActivityLogger>().Error(
                        string.Format("Cannot import attachment. Bugzilla Bug ID: {1}; File name: {0}", attachmentFileName, bug_id), ex);

                    if (fileId != null && File.Exists(AttachmentFolder.GetAttachmentFileFullPath(fileId)))
                    {
                        AttachmentFolder.Delete(new[] { fileId });
                    }
                }
            }

            return(storedAttachments);
        }
 private void CompleteSaga()
 {
     AttachmentFolder.Delete(Data.EmailReceivedMessage.Mail.EmailAttachments.Select(a => a.FileId));
     MarkAsComplete();
 }