Example #1
0
        public async Task CreateIssueAsync(IssueCreateItem item)
        {
            var issue = new Issue
            {
                Id              = Guid.NewGuid(),
                AssignedToId    = item.AssignedToId,
                AreaId          = item.AreaId,
                CreationTime    = DateTime.Now,
                IssueDescripton = item.Descripton,
                Title           = item.Title,
                IssueTypeId     = item.IssueTypeId,
            };

            if (item.Attachments != null)
            {
                foreach (var attachment in item.Attachments)
                {
                    var ia = new IssueAttachment {
                        Id = Guid.NewGuid(), IssueId = issue.Id, Content = attachment
                    };
                    issue.Attachments.Add(ia);
                }
            }
            await _context.Issues.AddAsync(issue);

            await _context.SaveChangesAsync();
        }
        public bool CreateNewIssueAttachment(int issueId, string creatorUserName, string fileName, string contentType, byte[] attachment, int size, string description)
        {
            if (issueId <= 0)
            {
                throw new ArgumentOutOfRangeException("issueId");
            }

            var projectId = IssueManager.GetById(issueId).ProjectId;

            //authentication checks against user access to project
            if (ProjectManager.GetById(projectId).AccessType == Common.ProjectAccessType.Private && !ProjectManager.IsUserProjectMember(UserName, projectId))
            {
                throw new UnauthorizedAccessException(string.Format(LoggingManager.GetErrorMessageResource("ProjectAccessDenied"), UserName));
            }

            var issueAttachment = new IssueAttachment
            {
                Id                 = Globals.NEW_ID,
                Attachment         = attachment,
                Description        = description,
                DateCreated        = DateTime.Now,
                ContentType        = contentType,
                CreatorDisplayName = string.Empty,
                CreatorUserName    = creatorUserName,
                FileName           = fileName,
                IssueId            = issueId,
                Size               = size
            };

            return(IssueAttachmentManager.SaveOrUpdate(issueAttachment));
        }
Example #3
0
        private void grdAttachments_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
        {
            int attachmentId = (int)grdAttachments.DataKeys[e.Item.ItemIndex];

            IssueAttachment.DeleteIssueAttachment(attachmentId);
            BindAttachments();
        }
Example #4
0
        protected void btnAdd_Click(object sender, System.EventArgs e)
        {
            // Get Posted File
            HttpPostedFile theFile = upAttachment.PostedFile;


            // Check if file was actually uploaded
            if (theFile == null)
            {
                return;
            }

            // Convert Posted File to Byte Array
            int fileSize = theFile.ContentLength;

            byte[]           fileBytes = new byte[fileSize];
            System.IO.Stream myStream  = theFile.InputStream;
            myStream.Read(fileBytes, 0, fileSize);

            // Get file name
            string fileName = Path.GetFileName(theFile.FileName);

            // Create new Issue Attachment
            IssueAttachment newAttachment = new IssueAttachment(IssueId, Page.User.Identity.Name, fileName, theFile.ContentType, fileBytes);

            newAttachment.Save();
            BindAttachments();
        }
        public ActionResult Delete(int id, FormCollection collection)
        {
            try
            {
                IssueAttachment issueAtchmnt = GetIssueAttachmentByID(id);

                if (issueAtchmnt == null)
                {
                    return(RedirectToAction("Index", "Issue"));
                }
                else
                {
                    //delete file from the server
                    FileInfo file = new FileInfo(basePath + issueAtchmnt.Filename);
                    file.Delete();

                    //delete entry from database
                    _dataModel.DeleteObject(issueAtchmnt);
                    _dataModel.SaveChanges();
                }

                return(RedirectToAction("Index", "Issue"));
            }
            catch
            {
                return(RedirectToAction("Index", "Issue"));
            }
        }
        public ActionResult Create([Bind(Exclude = "IssueAttachmentID")] IssueAttachment newIssueAttachment, HttpPostedFileBase file)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            try
            {
                //Save file to server if user selected a file
                if (file != null && file.ContentLength > 0)
                {
                    newIssueAttachment.Filename = Path.GetFileName(file.FileName);
                    newIssueAttachment.MimeType = file.ContentType;
                    var path = Path.Combine(basePath, newIssueAttachment.Filename);
                    file.SaveAs(path);
                }

                newIssueAttachment.DeveloperID = _dataModel.Developers.Single(d => d.UserName == User.Identity.Name).DeveloperID;
                newIssueAttachment.EntryDate   = DateTime.Now;
                _dataModel.AddToIssueAttachments(newIssueAttachment);
                _dataModel.SaveChanges();

                return(RedirectToAction("Index", "Issue"));
            }
            catch
            {
                return(RedirectToAction("Index", "Issue"));
            }
        }
Example #7
0
        public async Task CreateAsync(CreateIssueInputModel input, string userId, string rootPath)
        {
            var citizenId = this.citizensService.GetByUserId(userId).Id;
            var address   = await this.addressesService.CreateAsync(input.Address);

            var issue = new Issue
            {
                Title       = input.Title,
                Description = input.Description,
                Address     = address,
                CategoryId  = input.CategoryId,
                StatusId    = 1,
                CreatorId   = citizenId,
            };

            // Add image to file system
            issue.Pictures.Add(await this.picturesService.CreateFileAsync(userId, rootPath, input.TitlePicture));

            // Add Attachments to file system
            if (input.Attachments != null)
            {
                foreach (var att in input.Attachments)
                {
                    var attExtension = Path.GetExtension(att.FileName);
                    if (!this.allowedAttachmentExtensions.Any(x => attExtension.EndsWith(x)))
                    {
                        throw new Exception($"Format should be .docx or .pdf!");
                    }

                    var attachment = new Attachment
                    {
                        AddedByUserId = userId,
                        Extension     = attExtension,
                    };

                    Directory.CreateDirectory($"{rootPath}/att/issues/");
                    var physicalPath = $"{rootPath}/att/issues/{attachment.Id}{attachment.Extension}";
                    using Stream attFileStream = new FileStream(physicalPath, FileMode.Create);
                    await att.CopyToAsync(attFileStream);

                    await this.attRepo.AddAsync(attachment);

                    var issueAttachment = new IssueAttachment
                    {
                        Attachment = attachment,
                        Issue      = issue,
                    };

                    await this.issueAttRepo.AddAsync(issueAttachment);
                }
            }

            await this.issuesRepo.AddAsync(issue);

            await this.issuesRepo.SaveChangesAsync();

            await this.issueTagsService.CraeteAsync(issue.Id, input.Tags);
        }
        protected CollectionBase  GenerateIssueAttachmentCollectionFromReader(IDataReader returnData)
        {
            IssueAttachmentCollection attCollection = new IssueAttachmentCollection();

            while (returnData.Read())
            {
                IssueAttachment newAttachment = new IssueAttachment((int)returnData["AttachmentId"], (int)returnData["IssueId"], (string)returnData["CreatorUsername"], (string)returnData["CreatorDisplayName"], (DateTime)returnData["DateCreated"], (string)returnData["FileName"]);
                attCollection.Add(newAttachment);
            }
            return(attCollection);
        }
Example #9
0
        protected void SaveAttachement(int issueId, string userName, byte[] fileBytes)
        {
            // Get file name
            string fileName    = issueId.ToString();
            string contentType = "JPG";

            // Create new Issue Attachment
            IssueAttachment newAttachment = new IssueAttachment(issueId, userName, fileName, contentType, fileBytes);

            newAttachment.Save();
        }
Example #10
0
        private void grdAttachments_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                IssueAttachment attachment = (IssueAttachment)e.Item.DataItem;

                LinkButton lnkDelete = (LinkButton)e.Item.FindControl("lnkDelete");
                if (String.Compare(Page.User.Identity.Name, attachment.CreatorUsername) == 0)
                {
                    lnkDelete.Visible = true;
                }
            }
        }
        protected void Page_Load(object sender, System.EventArgs e)
        {
            // Get the attachment
            int             attachmentId = Int32.Parse(Request.QueryString["id"]);
            IssueAttachment attachment   = IssueAttachment.GetIssueAttachmentById(attachmentId);

            // Write out the attachment
            Server.ScriptTimeout = 600;
            Response.Buffer      = true;
            Response.Clear();
            Response.ContentType = "application/octet-stream";
            Response.AddHeader("Content-Disposition", "attachment; filename=\"" + attachment.FileName + "\";");
            Response.AddHeader("Content-Length", attachment.Attachment.Length.ToString());
            Response.BinaryWrite(attachment.Attachment);

            // End the response
            Context.Response.End();
        }
        public ActionResult Create(string Subject, string Priority, string Severity, string Status,
                                   string Description, string IssueCategoryName, int?MilestoneID, int ProjectID, HttpPostedFileBase file)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            try
            {
                Issue issue = new Issue();
                issue.Subject           = Subject;
                issue.Priority          = Priority;
                issue.Severity          = Severity;
                issue.Status            = Status;
                issue.Description       = Description;
                issue.EntryDate         = DateTime.Now;
                issue.IssueCategoryName = IssueCategoryName;
                issue.MilestoneID       = MilestoneID;
                issue.ProjectID         = ProjectID;
                _dataModel.AddToIssues(issue);
                _dataModel.SaveChanges();

                //Save file to server if user selected a file
                if (file != null && file.ContentLength > 0)
                {
                    IssueAttachment issueAttchmnt = new IssueAttachment();
                    issueAttchmnt.Filename = Path.GetFileName(file.FileName);
                    issueAttchmnt.MimeType = file.ContentType;
                    var path = Path.Combine(basePath, issueAttchmnt.Filename);
                    file.SaveAs(path);
                    issueAttchmnt.DeveloperID = _dataModel.Developers.Single(d => d.UserName == User.Identity.Name).DeveloperID;
                    issueAttchmnt.EntryDate   = DateTime.Now;
                    issueAttchmnt.IssueID     = issue.IssueID;
                    _dataModel.AddToIssueAttachments(issueAttchmnt);
                    _dataModel.SaveChanges();
                }
                return(RedirectToAction("Index"));
            }
            catch
            {
                return(RedirectToAction("Index"));
            }
        }
Example #13
0
        public async Task <IActionResult> CreateAttachment([FromBody] CreateAttachmentViewModel model, [FromRoute] int issueId)
        {
            int size = model.Content.Length;

            IssueAttachment attachment = new IssueAttachment
            {
                IssueId = issueId,
                Content = model.Content,
                Comment = model.Comment
            };

            Database.IssueAttachment.Add(attachment);

            int userId = int.Parse(User.Claims.First(c => c.Type == "UserId").Value);

            var user = Database.User
                       .Where(u => u.Id == userId)
                       .FirstOrDefault();

            var issue = Database.Issue
                        .Include(i => i.ProjectVersion)
                        .Where(i => i.Id == issueId)
                        .FirstOrDefault();

            await Database.SaveChangesAsync();

            ProjectActivity activity = new ProjectActivity
            {
                ProjectId = issue.ProjectVersion.ProjectId,
                AuthorId  = userId,
                Content   = $"File attached to issue '#{issue.Id}: {issue.Subject}'"
            };

            Database.ProjectActivity.Add(activity);

            await Database.SaveChangesAsync();

            return(Json(new
            {
                status = true,
                url = Url.Action("Index")
            }));
        }
        //
        // GET: /IssueAttachment/Delete/5

        public ActionResult Delete(int id)
        {
            try
            {
                IssueAttachment issueAttcmt = GetIssueAttachmentByID(id);

                if (issueAttcmt == null)
                {
                    return(RedirectToAction("Index", "Issue"));
                }
                else
                {
                    return(View(issueAttcmt));
                }
            }
            catch
            {
                return(RedirectToAction("Index", "Issue"));
            }
        }
Example #15
0
        public void can_save_new_issue()
        {
            Company company = new Company();
            company.Name = "Test Company";
            company.CreateAndFlush();

            Issue issue = new Issue();
            issue.Title = "Test issue";
            issue.Type = IssueType.Defect;

            IssueNote note = new IssueNote();
            note.Body = "Test note";
            issue.AddNote(note);

            IssueChange change = new IssueChange();
            change.PropertyName = "Test change";
            issue.AddChange(change);

            IssueAttachment att = new IssueAttachment();
            att.Body = new byte[10];
            att.Title = "Test attachment";
            issue.AddAttachment(att);

            Project project = new Project();
            project.Company = company;
            project.AddIssue(issue);
            project.Name = "Test project";
            project.CreateAndFlush();

            using (SessionScope newScope = new SessionScope())
            {
                Issue actual = Issue.Find(issue.Id);
                Assert.AreEqual("Test issue", actual.Title);
                Assert.AreEqual("Test note", actual.Notes[0].Body);
                Assert.AreEqual("Test change", actual.Changes[0].PropertyName);
                Assert.AreEqual("Test attachment", actual.Attachments[0].Title);
            }

            project.DeleteAndFlush();
            company.DeleteAndFlush();
        }
        public ActionResult Edit(int id, FormCollection collection, HttpPostedFileBase file)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            try
            {
                UpdateModel(GetIssueByID(id));
                _dataModel.SaveChanges();

                //Save file to server if user selected a file
                if (file != null && file.ContentLength > 0)
                {
                    //remove old file first
                    IssueAttachment issueAttcmt = GetIssueAttachmentByIssueID(id);
                    var             path        = Path.Combine(basePath, issueAttcmt.Filename);
                    if (issueAttcmt != null && System.IO.File.Exists(path))
                    {
                        System.IO.File.Delete(path);
                    }
                    //save new file
                    issueAttcmt.Filename = Path.GetFileName(file.FileName);
                    issueAttcmt.MimeType = file.ContentType;
                    path = Path.Combine(basePath, issueAttcmt.Filename);
                    file.SaveAs(path);

                    issueAttcmt.EntryDate   = DateTime.Now;
                    issueAttcmt.DeveloperID = _dataModel.Developers.Single(d => d.UserName == User.Identity.Name).DeveloperID;

                    _dataModel.SaveChanges();
                }
                return(RedirectToAction("Index"));
            }
            catch
            {
                return(RedirectToAction("Index"));
            }
        }
        public FilePathResult GetFile(int id)
        {
            IssueAttachment issueAtchmnt = GetIssueAttachmentByID(id);

            if (issueAtchmnt != null)
            {
                try
                {
                    string filename = issueAtchmnt.Filename;
                    return(File(basePath + filename, issueAtchmnt.MimeType));
                }
                catch
                {
                    //TODO: log error - file no longer exists on server
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
Example #18
0
        /// <summary>
        /// Ts the generate issue attachment list from reader.
        /// </summary>
        /// <param name="returnData">The return data.</param>
        /// <param name="issueAttachmentList">The issue attachment list.</param>
        private static void GenerateIssueAttachmentListFromReader(IDataReader returnData,
                                                                  ref List <IssueAttachment> issueAttachmentList)
        {
            while (returnData.Read())
            {
                var attachment = new IssueAttachment
                {
                    Id                 = returnData.GetInt32(returnData.GetOrdinal("IssueAttachmentId")),
                    Attachment         = null,
                    Description        = returnData.GetString(returnData.GetOrdinal("Description")),
                    DateCreated        = returnData.GetDateTime(returnData.GetOrdinal("DateCreated")),
                    ContentType        = returnData.GetString(returnData.GetOrdinal("ContentType")),
                    CreatorDisplayName = returnData.GetString(returnData.GetOrdinal("CreatorDisplayName")),
                    CreatorUserName    = returnData.GetString(returnData.GetOrdinal("CreatorUsername")),
                    FileName           = returnData.GetString(returnData.GetOrdinal("FileName")),
                    IssueId            = returnData.GetInt32(returnData.GetOrdinal("IssueId")),
                    Size               = returnData.GetInt32(returnData.GetOrdinal("FileSize"))
                };

                issueAttachmentList.Add(attachment);
            }
        }
        public ActionResult Edit(int id, HttpPostedFileBase file, FormCollection collection)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            try
            {
                //Save file to server if user selected a file
                if (file != null && file.ContentLength > 0)
                {
                    //remove old file first
                    IssueAttachment issueAttcmt = GetIssueAttachmentByID(id);
                    var             path        = "";
                    if (issueAttcmt != null)
                    {
                        path = Path.Combine(basePath, issueAttcmt.Filename);
                        System.IO.File.Delete(path);
                    }
                    //save new file
                    issueAttcmt.Filename = Path.GetFileName(file.FileName);
                    issueAttcmt.MimeType = file.ContentType;
                    path = Path.Combine(basePath, issueAttcmt.Filename);
                    file.SaveAs(path);

                    _dataModel.SaveChanges();
                }

                return(RedirectToAction("Index", "Issue"));
            }
            catch
            {
                return(RedirectToAction("Index", "Issue"));
            }
        }
        /// <summary>
        /// Saves this instance.
        /// </summary>
        /// <param name="entity">The issue attachment to save.</param>
        /// <returns></returns>
        public static bool SaveOrUpdate(IssueAttachment entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException("entity");
            }
            if (entity.IssueId <= Globals.NEW_ID)
            {
                throw (new ArgumentException("Cannot save issue attachment, the issue id is invalid"));
            }
            if (String.IsNullOrEmpty(entity.FileName))
            {
                throw (new ArgumentException("The attachment file name cannot be empty or null"));
            }

            var invalidReason = String.Empty;

            if (!IsValidFile(entity.FileName, out invalidReason))
            {
                throw new ApplicationException(invalidReason);
            }

            //Start new save attachment code
            if (entity.Attachment.Length > 0)
            {
                // save the file to the upload directory
                var projectId = IssueManager.GetById(entity.IssueId).ProjectId;
                var project   = ProjectManager.GetById(projectId);

                if (project.AllowAttachments)
                {
                    entity.ContentType = entity.ContentType.Replace("/x-png", "/png");

                    if (entity.ContentType == "image/bmp")
                    {
                        using (var ms = new MemoryStream(entity.Attachment, 0, entity.Attachment.Length))
                        {
                            ms.Write(entity.Attachment, 0, entity.Attachment.Length);
                            var img = Image.FromStream(ms);
                            img.Save(ms, ImageFormat.Png);
                            ms.Seek(0, SeekOrigin.Begin);
                            entity.Attachment = ms.ToArray();
                        }

                        entity.ContentType = "image/png";
                        entity.FileName    = Path.ChangeExtension(entity.FileName, "png");
                    }

                    entity.Size = entity.Attachment.Length;

                    if (HostSettingManager.Get(HostSettingNames.AttachmentStorageType, 0) == (int)IssueAttachmentStorageTypes.Database)
                    {
                        //save the attachment record to the database.
                        var tempId = DataProviderManager.Provider.CreateNewIssueAttachment(entity);
                        if (tempId > 0)
                        {
                            entity.Id = tempId;
                            return(true);
                        }
                        return(false);
                    }

                    var projectPath = project.UploadPath;

                    try
                    {
                        if (projectPath.Length == 0)
                        {
                            projectPath = project.Id.ToString();
                        }
                        //throw new ApplicationException(String.Format(LoggingManager.GetErrorMessageResource("UploadPathNotDefined"), project.Name));

                        var attachmentGuid  = Guid.NewGuid();
                        var attachmentBytes = entity.Attachment;
                        entity.Attachment = null;    //set attachment to null
                        entity.FileName   = String.Format("{0}.{1}{2}", Path.GetFileNameWithoutExtension(entity.FileName), attachmentGuid, Path.GetExtension(entity.FileName));

                        var uploadedFilePath = string.Empty;

                        // added by WRH 2012-08-18
                        // this to fix the issue where attachments from the mailbox reader cannot be saved due to the lack of a http context.
                        // we need to supply the actual folder path on the entity
                        if (HttpContext.Current != null)
                        {
                            uploadedFilePath = string.Format(@"{0}\{1}", string.Format("{0}{1}", HostSettingManager.Get(HostSettingNames.AttachmentUploadPath), projectPath), entity.FileName);

                            if (uploadedFilePath.StartsWith("~"))
                            {
                                uploadedFilePath = HttpContext.Current.Server.MapPath(uploadedFilePath);
                            }
                        }
                        else
                        {
                            if (entity.ProjectFolderPath.Trim().Length > 0)
                            {
                                uploadedFilePath = string.Format("{0}\\{1}", entity.ProjectFolderPath, entity.FileName);
                            }
                        }

                        //save the attachment record to the database.
                        var tempId = DataProviderManager.Provider.CreateNewIssueAttachment(entity);

                        if (tempId > 0)
                        {
                            entity.Id = tempId;

                            //save file to file system
                            var fi = new FileInfo(uploadedFilePath);

                            if (!Directory.Exists(fi.DirectoryName))
                            {
                                Directory.CreateDirectory(fi.DirectoryName);
                            }

                            File.WriteAllBytes(uploadedFilePath, attachmentBytes);

                            return(true);
                        }

                        return(false);
                    }
                    catch (DirectoryNotFoundException ex)
                    {
                        if (Log.IsErrorEnabled)
                        {
                            Log.Error(String.Format(LoggingManager.GetErrorMessageResource("UploadPathNotFound"), projectPath), ex);
                        }
                        throw;
                    }
                    catch (Exception ex)
                    {
                        if (Log.IsErrorEnabled)
                        {
                            Log.Error(ex.Message, ex);
                        }
                        throw;
                    }
                }
            }

            return(false);
        }
Example #21
0
        /// <summary>
        /// Saves the mailbox entry.
        /// </summary>
        /// <param name="entry">The entry.</param>
        void SaveMailboxEntry(MailboxEntry entry)
        {
            try
            {
                //load template
                var body = string.Format("<div >Sent by:{1} on: {2}<br/>{0}</div>", entry.Content.Trim(), entry.From, entry.Date);

                if (Config.BodyTemplate.Trim().Length > 0)
                {
                    var data = new Dictionary <string, object> {
                        { "MailboxEntry", entry }
                    };
                    body = NotificationManager.GenerateNotificationContent(Config.BodyTemplate, data);
                }

                var projectId = entry.ProjectMailbox.ProjectId;

                var mailIssue = IssueManager.GetDefaultIssueByProjectId(
                    projectId,
                    entry.Title.Trim(),
                    body.Trim(),
                    entry.ProjectMailbox.AssignToUserName,
                    Config.ReportingUserName);

                if (!IssueManager.SaveOrUpdate(mailIssue))
                {
                    return;
                }

                entry.IssueId      = mailIssue.Id;
                entry.WasProcessed = true;

                var project = ProjectManager.GetById(projectId);

                var projectFolderPath = Path.Combine(Config.UploadsFolderPath, project.UploadPath);

                var doc = new HtmlDocument();
                doc.LoadHtml(mailIssue.Description); // load the issue body to we can process it for inline images (if exist)

                //If there is an attached file present then add it to the database
                //and copy it to the directory specified in the web.config file
                foreach (MIME_Entity mimeEntity in entry.MailAttachments)
                {
                    string fileName;
                    var    isInline    = false;
                    var    contentType = mimeEntity.ContentType.Type.ToLower();

                    var attachment = new IssueAttachment
                    {
                        Id                 = 0,
                        Description        = "File attached by mailbox reader",
                        DateCreated        = DateTime.Now,
                        ContentType        = mimeEntity.ContentType.TypeWithSubtype,
                        CreatorDisplayName = Config.ReportingUserName,
                        CreatorUserName    = Config.ReportingUserName,
                        IssueId            = mailIssue.Id,
                        ProjectFolderPath  = projectFolderPath
                    };

                    switch (contentType)
                    {
                    case "application":
                        attachment.Attachment = ((MIME_b_SinglepartBase)mimeEntity.Body).Data;
                        break;

                    case "attachment":
                    case "image":
                    case "video":
                    case "audio":

                        attachment.Attachment = ((MIME_b_SinglepartBase)mimeEntity.Body).Data;
                        break;

                    case "message":

                        // we need to pull the actual email message out of the entity, and strip the "content type" out so that
                        // email programs will read the file properly
                        var messageBody = mimeEntity.ToString().Replace(mimeEntity.Header.ToString(), "");
                        if (messageBody.StartsWith("\r\n"))
                        {
                            messageBody = messageBody.Substring(2);
                        }

                        attachment.Attachment = Encoding.UTF8.GetBytes(messageBody);

                        break;

                    default:
                        LogWarning(string.Format("MailboxReader: Attachment type could not be processed {0}", mimeEntity.ContentType.Type));
                        break;
                    }

                    if (contentType.Equals("attachment")) // this is an attached email
                    {
                        fileName = mimeEntity.ContentDisposition.Param_FileName;
                    }
                    else if (contentType.Equals("message")) // message has no filename so we create one
                    {
                        fileName = string.Format("Attached_Message_{0}.eml", entry.AttachmentsSavedCount);
                    }
                    else
                    {
                        isInline = true;
                        fileName = string.IsNullOrWhiteSpace(mimeEntity.ContentType.Param_Name) ?
                                   string.Format("untitled.{0}", mimeEntity.ContentType.SubType) :
                                   mimeEntity.ContentType.Param_Name;
                    }

                    attachment.FileName = fileName;

                    var saveFile  = IsAllowedFileExtension(fileName);
                    var fileSaved = false;

                    // can we save the file?
                    if (saveFile)
                    {
                        fileSaved = IssueAttachmentManager.SaveOrUpdate(attachment);

                        if (fileSaved)
                        {
                            entry.AttachmentsSavedCount++;
                        }
                        else
                        {
                            LogWarning("MailboxReader: Attachment could not be saved, please see previous logs");
                        }
                    }

                    if (!entry.IsHtml || !isInline)
                    {
                        continue;
                    }

                    if (string.IsNullOrWhiteSpace(mimeEntity.ContentID))
                    {
                        continue;
                    }

                    var contentId = mimeEntity.ContentID.Replace("<", "").Replace(">", "").Replace("[", "").Replace("]", "");

                    // this is pretty greedy but since people might be sending screenshots I doubt they will send in dozens of images
                    // embedded in the email.  one would hope
                    foreach (var node in doc.DocumentNode.SelectNodes(XpathElementCaseInsensitive("img")).ToList())
                    {
                        var attr = node.Attributes.FirstOrDefault(p => p.Name.ToLowerInvariant() == "src");// get the src attribute

                        if (attr == null)
                        {
                            continue;               // image has no src attribute
                        }
                        if (!attr.Value.Contains(contentId))
                        {
                            continue;                                  // is the attribute value the content id?
                        }
                        // swap out the content of the parent node html will our link to the image
                        var anchor = string.Format("<span class='inline-mail-attachment'>Inline Attachment: <a href='DownloadAttachment.axd?id={0}' target='_blank'>{1}</a></span>", attachment.Id, fileName);

                        // for each image in the body if the file was saved swap out the inline link for a link to the saved attachment
                        // otherwise blank out the content link so we don't get a missing image link
                        node.ParentNode.InnerHtml = fileSaved ? anchor : "";
                    }

                    mailIssue.Description        = doc.DocumentNode.InnerHtml;
                    mailIssue.LastUpdateUserName = mailIssue.OwnerUserName;
                    mailIssue.LastUpdate         = DateTime.Now;

                    IssueManager.SaveOrUpdate(mailIssue);
                }
            }
            catch (Exception ex)
            {
                LogException(ex);
                throw;
            }
        }
Example #22
0
        private bool ProcessNewComment(List <string> recipients, POP3_ClientMessage message, Mail_Message mailHeader, MailboxReaderResult result)
        {
            string messageFrom = string.Empty;

            if (mailHeader.From.Count > 0)
            {
                messageFrom = string.Join("; ", mailHeader.From.ToList().Select(p => p.Address).ToArray()).Trim();
            }

            bool processed = false;

            foreach (var address in recipients)
            {
                Regex isReply      = new Regex(@"(.*)(\+iid-)(\d+)@(.*)");
                Match commentMatch = isReply.Match(address);
                if (commentMatch.Success && commentMatch.Groups.Count >= 4)
                {
                    // we are in a reply and group 4 must contain the id of the original issue
                    int issueId;
                    if (int.TryParse(commentMatch.Groups[3].Value, out issueId))
                    {
                        var _currentIssue = IssueManager.GetById(issueId);

                        if (_currentIssue != null)
                        {
                            var project = ProjectManager.GetById(_currentIssue.ProjectId);

                            var mailbody = Mail_Message.ParseFromByte(message.MessageToByte());

                            bool isHtml;
                            List <MIME_Entity> attachments = null;
                            string             content     = GetMessageContent(mailbody, project, out isHtml, ref attachments);

                            IssueComment comment = new IssueComment
                            {
                                IssueId     = issueId,
                                Comment     = content,
                                DateCreated = mailHeader.Date
                            };

                            // try to find if the creator is valid user in the project, otherwise take
                            // the user defined in the mailbox config
                            var users  = UserManager.GetUsersByProjectId(project.Id);
                            var emails = messageFrom.Split(';').Select(e => e.Trim().ToLower());
                            var user   = users.Find(x => emails.Contains(x.Email.ToLower()));
                            if (user != null)
                            {
                                comment.CreatorUserName = user.UserName;
                            }
                            else
                            {
                                // user not found
                                continue;
                            }

                            var saved = IssueCommentManager.SaveOrUpdate(comment);
                            if (saved)
                            {
                                //add history record
                                var history = new IssueHistory
                                {
                                    IssueId                 = issueId,
                                    CreatedUserName         = comment.CreatorUserName,
                                    DateChanged             = comment.DateCreated,
                                    FieldChanged            = ResourceStrings.GetGlobalResource(GlobalResources.SharedResources, "Comment", "Comment"),
                                    OldValue                = string.Empty,
                                    NewValue                = ResourceStrings.GetGlobalResource(GlobalResources.SharedResources, "Added", "Added"),
                                    TriggerLastUpdateChange = true
                                };
                                IssueHistoryManager.SaveOrUpdate(history);

                                var projectFolderPath = Path.Combine(Config.UploadsFolderPath, project.UploadPath);

                                // save attachments as new files
                                int attachmentsSavedCount = 1;
                                foreach (MIME_Entity mimeEntity in attachments)
                                {
                                    string fileName;
                                    var    contentType = mimeEntity.ContentType.Type.ToLower();

                                    var attachment = new IssueAttachment
                                    {
                                        Id                 = 0,
                                        Description        = "File attached by mailbox reader",
                                        DateCreated        = DateTime.Now,
                                        ContentType        = mimeEntity.ContentType.TypeWithSubtype,
                                        CreatorDisplayName = user.DisplayName,
                                        CreatorUserName    = user.UserName,
                                        IssueId            = issueId,
                                        ProjectFolderPath  = projectFolderPath
                                    };
                                    attachment.Attachment = ((MIME_b_SinglepartBase)mimeEntity.Body).Data;

                                    if (contentType.Equals("attachment")) // this is an attached email
                                    {
                                        fileName = mimeEntity.ContentDisposition.Param_FileName;
                                    }
                                    else if (contentType.Equals("message")) // message has no filename so we create one
                                    {
                                        fileName = string.Format("Attached_Message_{0}.eml", attachmentsSavedCount);
                                    }
                                    else
                                    {
                                        fileName = string.IsNullOrWhiteSpace(mimeEntity.ContentType.Param_Name) ?
                                                   string.Format("untitled.{0}", mimeEntity.ContentType.SubType) :
                                                   mimeEntity.ContentType.Param_Name;
                                    }

                                    attachment.FileName = fileName;

                                    var saveFile  = IsAllowedFileExtension(fileName);
                                    var fileSaved = false;

                                    // can we save the file?
                                    if (saveFile)
                                    {
                                        fileSaved = IssueAttachmentManager.SaveOrUpdate(attachment);

                                        if (fileSaved)
                                        {
                                            attachmentsSavedCount++;
                                        }
                                        else
                                        {
                                            LogWarning("MailboxReader: Attachment could not be saved, please see previous logs");
                                        }
                                    }
                                }

                                processed = true;

                                // add the entry if the save did not throw any exceptions
                                result.MailboxEntries.Add(new MailboxEntry());
                            }
                        }
                    }
                }
            }
            return(processed);
        }
        public async Task <Issue> CreateRepositoryIssueAttachmentAsync(string workspaceId, string repositorySlug, string issueId, IssueAttachment issueAttachment)
        {
            var capturedContent = new CapturedMultipartContent();

            foreach (var propertyInfo in issueAttachment.GetType().GetProperties())
            {
                capturedContent.Add(propertyInfo.Name, new StringContent(propertyInfo.GetValue(issueAttachment).ToString()));
            }

            var response = await GetIssuesUrl(workspaceId, repositorySlug, issueId)
                           .PostMultipartAsync(content => content.AddStringParts(capturedContent))
                           .ConfigureAwait(false);

            return(await HandleResponseAsync <Issue>(response).ConfigureAwait(false));
        }
Example #24
0
 void BindAttachments()
 {
     grdAttachments.DataSource   = IssueAttachment.GetIssueAttachmentsByIssueId(_IssueId);
     grdAttachments.DataKeyField = "Id";
     grdAttachments.DataBind();
 }
        /// <summary>
        /// update
        /// </summary>
        /// <param name="parentId">parentId</param>
        /// <param name="id">id</param>
        /// <param name="data">data</param>
        /// <returns>ApiResultIssueAttachment</returns>
        public ApiResultIssueAttachment UpdateIssueAttachmentOfIssue(long?parentId, long?id, IssueAttachment data)
        {
            // verify the required parameter 'parentId' is set
            if (parentId == null)
            {
                throw new ApiException(400, "Missing required parameter 'parentId' when calling UpdateIssueAttachmentOfIssue");
            }

            // verify the required parameter 'id' is set
            if (id == null)
            {
                throw new ApiException(400, "Missing required parameter 'id' when calling UpdateIssueAttachmentOfIssue");
            }

            // verify the required parameter 'data' is set
            if (data == null)
            {
                throw new ApiException(400, "Missing required parameter 'data' when calling UpdateIssueAttachmentOfIssue");
            }


            var path = "/issues/{parentId}/attachments/{id}";

            path = path.Replace("{format}", "json");
            path = path.Replace("{" + "parentId" + "}", ApiClient.ParameterToString(parentId));
            path = path.Replace("{" + "id" + "}", ApiClient.ParameterToString(id));

            var    queryParams  = new Dictionary <String, String>();
            var    headerParams = new Dictionary <String, String>();
            var    formParams   = new Dictionary <String, String>();
            var    fileParams   = new Dictionary <String, FileParameter>();
            String postBody     = null;

            postBody = ApiClient.Serialize(data);                                     // http body (model) parameter

            // authentication setting, if any
            String[] authSettings = new String[] { "FortifyToken" };

            // make the HTTP request
            IRestResponse response = (IRestResponse)ApiClient.CallApi(path, Method.PUT, queryParams, postBody, headerParams, formParams, fileParams, authSettings);

            if (((int)response.StatusCode) >= 400)
            {
                throw new ApiException((int)response.StatusCode, "Error calling UpdateIssueAttachmentOfIssue: " + response.Content, response.Content);
            }
            else if (((int)response.StatusCode) == 0)
            {
                throw new ApiException((int)response.StatusCode, "Error calling UpdateIssueAttachmentOfIssue: " + response.ErrorMessage, response.ErrorMessage);
            }

            return((ApiResultIssueAttachment)ApiClient.Deserialize(response.Content, typeof(ApiResultIssueAttachment), response.Headers));
        }
Example #26
0
        protected override async Task <SendResult> Send(IWin32Window Owner, Output Output, ImageData ImageData)
        {
            try
            {
                bool   integratedAuthentication = Output.IntegratedAuthentication;
                string userName            = Output.UserName;
                string password            = Output.Password;
                bool   showLogin           = !integratedAuthentication && (string.IsNullOrEmpty(userName) || string.IsNullOrEmpty(password));
                bool   rememberCredentials = false;

                string fileName = AttributeHelper.ReplaceAttributes(Output.FileName, ImageData);

                while (true)
                {
                    if (showLogin)
                    {
                        // Show credentials window
                        Credentials credentials = new Credentials(Output.Url, userName, password, rememberCredentials);

                        var credentialsOwnerHelper = new System.Windows.Interop.WindowInteropHelper(credentials);
                        credentialsOwnerHelper.Owner = Owner.Handle;

                        if (credentials.ShowDialog() != true)
                        {
                            return(new SendResult(Result.Canceled));
                        }

                        userName            = credentials.UserName;
                        password            = credentials.Password;
                        rememberCredentials = credentials.Remember;
                    }

                    ServiceManager gemini;
                    if (integratedAuthentication)
                    {
                        gemini = new ServiceManager(Output.Url);
                    }
                    else
                    {
                        gemini = new ServiceManager(Output.Url, userName, password, string.Empty);
                    }

                    try
                    {
                        // Get active projects
                        List <ProjectDto> allProjects = await Task.Factory.StartNew(() => gemini.Projects.GetProjects());

                        List <ProjectDto> projects = new List <ProjectDto>();
                        foreach (ProjectDto project in allProjects)
                        {
                            if (!project.Entity.Archived)
                            {
                                projects.Add(project);
                            }
                        }

                        // Get issue types
                        List <IssueTypeDto> issueTypes = await Task.Factory.StartNew(() => gemini.Meta.GetIssueTypes());

                        // Show send window
                        Send send = new Send(Output.Url, Output.LastProjectID, Output.LastIssueTypeID, Output.LastIssueID, projects, issueTypes, fileName);

                        var sendOwnerHelper = new System.Windows.Interop.WindowInteropHelper(send);
                        sendOwnerHelper.Owner = Owner.Handle;

                        if (!send.ShowDialog() == true)
                        {
                            return(new SendResult(Result.Canceled));
                        }

                        IFileFormat fileFormat = FileHelper.GetFileFormat(Output.FileFormatID);

                        string fullFileName = String.Format("{0}.{1}", send.FileName, fileFormat.FileExtension);

                        byte[] fileBytes = FileHelper.GetFileBytes(Output.FileFormatID, ImageData);

                        int projectID;
                        int issueTypeID;
                        int issueID;

                        if (send.CreateNewIssue)
                        {
                            projectID   = send.ProjectID;
                            issueTypeID = send.IssueTypeID;

                            UserDto user = await Task.Factory.StartNew(() => gemini.User.WhoAmI());

                            Issue issue = new Issue();
                            issue.ProjectId   = projectID;
                            issue.TypeId      = issueTypeID;
                            issue.Title       = send.IssueTitle;
                            issue.Description = send.Description;
                            issue.ReportedBy  = user.Entity.Id;

                            IssueAttachment attachment = new IssueAttachment();
                            attachment.ContentLength = fileBytes.Length;
                            attachment.ContentType   = fileFormat.MimeType;
                            attachment.Content       = fileBytes;
                            attachment.Name          = fullFileName;
                            issue.Attachments.Add(attachment);

                            IssueDto createdIssue = await Task.Factory.StartNew(() => gemini.Item.Create(issue));

                            issueID = createdIssue.Id;
                        }
                        else
                        {
                            issueID = send.IssueID;

                            IssueDto issue = await Task.Factory.StartNew(() => gemini.Item.Get(issueID));

                            projectID   = issue.Project.Id;
                            issueTypeID = Output.LastIssueTypeID;

                            IssueAttachment attachment = new IssueAttachment();
                            attachment.ProjectId     = projectID;
                            attachment.IssueId       = issueID;
                            attachment.ContentLength = fileBytes.Length;
                            attachment.ContentType   = fileFormat.MimeType;
                            attachment.Content       = fileBytes;
                            attachment.Name          = fullFileName;

                            await Task.Factory.StartNew(() => gemini.Item.IssueAttachmentCreate(attachment));
                        }


                        // Open issue in browser
                        if (Output.OpenItemInBrowser)
                        {
                            WebHelper.OpenUrl(String.Format("{0}/workspace/{1}/item/{2}", Output.Url, projectID, issueID));
                        }

                        return(new SendResult(Result.Success,
                                              new Output(Output.Name,
                                                         Output.Url,
                                                         (rememberCredentials) ? false : Output.IntegratedAuthentication,
                                                         (rememberCredentials) ? userName : Output.UserName,
                                                         (rememberCredentials) ? password : Output.Password,
                                                         Output.FileName,
                                                         Output.FileFormatID,
                                                         Output.OpenItemInBrowser,
                                                         projectID,
                                                         issueTypeID,
                                                         issueID)));
                    }
                    catch (RestException ex) when(ex.StatusCode == System.Net.HttpStatusCode.Forbidden)
                    {
                        // Login failed
                        integratedAuthentication = false;
                        showLogin = true;
                        continue;
                    }
                }
            }
            catch (Exception ex)
            {
                return(new SendResult(Result.Failed, ex.Message));
            }
        }
Example #27
0
        /// <summary>
        /// Uploads the document.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void UploadDocument(object sender, EventArgs e)
        {
            // get the current file
            var uploadFile = AspUploadFile.PostedFile;

            // if there was a file uploaded
            if (uploadFile != null && uploadFile.ContentLength > 0)
            {
                var inValidReason = string.Empty;
                var fileName = Path.GetFileName(uploadFile.FileName);

                var validFile = IssueAttachmentManager.IsValidFile(fileName, out inValidReason);

                if (validFile)
                {
                    byte[] fileBytes;
                    using (var input = uploadFile.InputStream)
                    {
                        fileBytes = new byte[uploadFile.ContentLength];
                        input.Read(fileBytes, 0, uploadFile.ContentLength);
                    }

                    var attachment = new IssueAttachment
                    {
                        Id = Globals.NEW_ID,
                        Attachment = fileBytes,
                        Description = AttachmentDescription.Text.Trim(),
                        DateCreated = DateTime.Now,
                        ContentType = uploadFile.ContentType,
                        CreatorDisplayName = string.Empty,
                        CreatorUserName = Security.GetUserName(),
                        FileName = fileName,
                        IssueId = IssueId,
                        Size = fileBytes.Length
                    };

                    if (!IssueAttachmentManager.SaveOrUpdate(attachment))
                    {
                        AttachmentsMessage.ShowErrorMessage(string.Format(GetGlobalResourceObject("Exceptions", "SaveAttachmentError").ToString(), uploadFile.FileName));
                        if (Log.IsWarnEnabled) Log.Warn(string.Format(GetGlobalResourceObject("Exceptions", "SaveAttachmentError").ToString(), uploadFile.FileName));
                        return;
                    }

                    //add history record and send notifications
                    var history = new IssueHistory
                    {
                        IssueId = IssueId,
                        CreatedUserName = Security.GetUserName(),
                        DateChanged = DateTime.Now,
                        FieldChanged = ResourceStrings.GetGlobalResource(GlobalResources.SharedResources, "Attachment", "Attachment"),
                        OldValue = fileName,
                        NewValue = ResourceStrings.GetGlobalResource(GlobalResources.SharedResources, "Added", "Added"),
                        TriggerLastUpdateChange = true
                    };

                    IssueHistoryManager.SaveOrUpdate(history);

                    var changes = new List<IssueHistory> { history };

                    IssueNotificationManager.SendIssueNotifications(IssueId, changes);

                    BindAttachments();
                }
                else
                    AttachmentsMessage.ShowErrorMessage(inValidReason); 
            }
        }
Example #28
0
        /// <summary>
        /// Saves the issue.
        /// </summary>
        /// <returns></returns>
        private bool SaveIssue()
        {
            decimal estimation;

            decimal.TryParse(txtEstimation.Text.Trim(), out estimation);
            var dueDate = DueDatePicker.SelectedValue ?? DateTime.MinValue;

            var issue = new Issue
            {
                AffectedMilestoneId       = DropAffectedMilestone.SelectedValue,
                AffectedMilestoneImageUrl = string.Empty,
                AffectedMilestoneName     = DropAffectedMilestone.SelectedText,
                AssignedDisplayName       = DropAssignedTo.SelectedText,
                AssignedUserId            = Guid.Empty,
                AssignedUserName          = DropAssignedTo.SelectedValue,
                CategoryId         = DropCategory.SelectedValue,
                CategoryName       = DropCategory.SelectedText,
                CreatorDisplayName = Security.GetDisplayName(),
                CreatorUserId      = Guid.Empty,
                CreatorUserName    = Security.GetUserName(),
                DateCreated        = DateTime.Now,
                Description        = DescriptionHtmlEditor.Text.Trim(),
                Disabled           = false,
                DueDate            = dueDate,
                Estimation         = estimation,
                Id                    = 0,
                IsClosed              = false,
                IssueTypeId           = DropIssueType.SelectedValue,
                IssueTypeName         = DropIssueType.SelectedText,
                IssueTypeImageUrl     = string.Empty,
                LastUpdate            = DateTime.Now,
                LastUpdateDisplayName = Security.GetDisplayName(),
                LastUpdateUserName    = Security.GetUserName(),
                MilestoneDueDate      = null,
                MilestoneId           = DropMilestone.SelectedValue,
                MilestoneImageUrl     = string.Empty,
                MilestoneName         = DropMilestone.SelectedText,
                OwnerDisplayName      = DropOwned.SelectedText,
                OwnerUserId           = Guid.Empty,
                OwnerUserName         = DropOwned.SelectedValue,
                PriorityId            = DropPriority.SelectedValue,
                PriorityImageUrl      = string.Empty,
                PriorityName          = DropPriority.SelectedText,
                Progress              = Convert.ToInt32(ProgressSlider.Text),
                ProjectCode           = string.Empty,
                ProjectId             = ProjectId,
                ProjectName           = string.Empty,
                ResolutionId          = DropResolution.SelectedValue,
                ResolutionImageUrl    = string.Empty,
                ResolutionName        = DropResolution.SelectedText,
                StatusId              = DropStatus.SelectedValue,
                StatusImageUrl        = string.Empty,
                StatusName            = DropStatus.SelectedText,
                Title                 = Server.HtmlEncode(TitleTextBox.Text),
                TimeLogged            = 0,
                Visibility            = chkPrivate.Checked ? 1 : 0,
                Votes                 = 0
            };

            if (!IssueManager.SaveOrUpdate(issue))
            {
                Message1.ShowErrorMessage(Resources.Exceptions.SaveIssueError);
                return(false);
            }

            if (!CustomFieldManager.SaveCustomFieldValues(issue.Id, ctlCustomFields.Values, true))
            {
                Message1.ShowErrorMessage(Resources.Exceptions.SaveCustomFieldValuesError);
                return(false);
            }

            IssueId = issue.Id;

            //add attachment if present.
            if (AspUploadFile.HasFile)
            {
                // get the current file
                var    uploadFile = AspUploadFile.PostedFile;
                string inValidReason;
                var    validFile = IssueAttachmentManager.IsValidFile(uploadFile.FileName, out inValidReason);

                if (validFile)
                {
                    if (uploadFile.ContentLength > 0)
                    {
                        byte[] fileBytes;
                        using (var input = uploadFile.InputStream)
                        {
                            fileBytes = new byte[uploadFile.ContentLength];
                            input.Read(fileBytes, 0, uploadFile.ContentLength);
                        }

                        var issueAttachment = new IssueAttachment
                        {
                            Id                 = Globals.NEW_ID,
                            Attachment         = fileBytes,
                            Description        = AttachmentDescription.Text.Trim(),
                            DateCreated        = DateTime.Now,
                            ContentType        = uploadFile.ContentType,
                            CreatorDisplayName = string.Empty,
                            CreatorUserName    = Security.GetUserName(),
                            FileName           = uploadFile.FileName,
                            IssueId            = issue.Id,
                            Size               = fileBytes.Length
                        };

                        if (!IssueAttachmentManager.SaveOrUpdate(issueAttachment))
                        {
                            Message1.ShowErrorMessage(string.Format(GetGlobalResourceObject("Exceptions", "SaveAttachmentError").ToString(), uploadFile.FileName));
                        }
                    }
                }
                else
                {
                    Message1.ShowErrorMessage(inValidReason);
                    return(false);
                }
            }

            //create a vote for the new issue
            var vote = new IssueVote {
                IssueId = issue.Id, VoteUsername = Security.GetUserName()
            };

            if (!IssueVoteManager.SaveOrUpdate(vote))
            {
                Message1.ShowErrorMessage(Resources.Exceptions.SaveIssueVoteError);
                return(false);
            }

            if (chkNotifyOwner.Checked && !string.IsNullOrEmpty(issue.OwnerUserName))
            {
                var oUser = UserManager.GetUser(issue.OwnerUserName);
                if (oUser != null)
                {
                    var notify = new IssueNotification {
                        IssueId = issue.Id, NotificationUsername = oUser.UserName
                    };
                    IssueNotificationManager.SaveOrUpdate(notify);
                }
            }
            if (chkNotifyAssignedTo.Checked && !string.IsNullOrEmpty(issue.AssignedUserName))
            {
                var oUser = UserManager.GetUser(issue.AssignedUserName);
                if (oUser != null)
                {
                    var notify = new IssueNotification {
                        IssueId = issue.Id, NotificationUsername = oUser.UserName
                    };
                    IssueNotificationManager.SaveOrUpdate(notify);
                }
            }

            //send issue notifications
            IssueNotificationManager.SendIssueAddNotifications(issue.Id);

            return(true);
        }
 // IssueAttachments
 public abstract int CreateNewIssueAttachment(IssueAttachment newAttachment);