コード例 #1
0
        public void CheckAttachment(string bugName, string fileName, string content, string creationDate)
        {
            var part = GetCreatedAttachmentByName(fileName);

            part.CreateDate.Should(Be.EqualTo(CreateDateConverter.ParseFromBugzillaLocalTime(creationDate)));

            Encoding.ASCII.GetString(Convert.FromBase64String(part.BytesSerializedToBase64)).Should(Be.EqualTo(content));
        }
コード例 #2
0
        private void CreateComment(int?tpBugId, BugzillaComment bugzillaComment)
        {
            if (string.IsNullOrEmpty(bugzillaComment.Body))
            {
                return;
            }

            var userId = ObjectFactory.GetInstance <IUserMapper>().GetTpIdBy(bugzillaComment.Author);

            var comment = new CommentDTO
            {
                Description = DescriptionConverter.FormatDescription(bugzillaComment.Body),
                GeneralID   = tpBugId,
                CreateDate  = CreateDateConverter.ParseFromBugzillaLocalTime(bugzillaComment.DateAdded),
                OwnerID     = userId
            };

            Send(new CreateCommentCommand(comment));
            Data.CommentsToCreateCount++;
        }
コード例 #3
0
        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);
        }
コード例 #4
0
 private bool CommentExists(ExistingBugImportedToTargetProcessMessage <BugzillaBug> message, BugzillaComment comment)
 {
     return(StorageRepository().Get <CommentDTO>(message.TpBugId.ToString())
            .Any(c => c.CreateDate.Value.ToUniversalTime() == CreateDateConverter.ParseToUniversalTime(comment.DateAdded)));
 }