コード例 #1
0
        private void GetJobAttachments()
        {
            AttachmentsBE  attachmentsBE = new AttachmentsBE();
            AttachmentsBAL attachmentBAL = new AttachmentsBAL();

            attachmentsBE.JobDetails = new JobDetailsBE();

            attachmentsBE.Action = "GetJobAttachmentsByJobId";

            if (Request.QueryString["JobId"] != null)
            {
                attachmentsBE.JobDetails.Id = Convert.ToInt32(Request.QueryString["JobId"]);
            }

            List <AttachmentsBE> lstAttachments = attachmentBAL.GetJobAttachmentsBAL(attachmentsBE);

            if (lstAttachments.Count > 0)
            {
                hdnAttachementCount.Value = Convert.ToString(lstAttachments.Count());
                //attachment.InnerHtml = "Attachment " + lstAttachments.Count().ToString();

                foreach (var item in lstAttachments)
                {
                    HyperLink hplnk = new HyperLink();
                    hplnk.Text        = item.Name;
                    hplnk.ID          = Convert.ToString(item.JobAttachmentId);
                    hplnk.CssClass    = "btn btn-link";
                    hplnk.NavigateUrl = "~/ModuleUI/DownloadAttachment.aspx?FilePath=" + item.Path + "&FileName=" + item.Name;
                    pnlAttachment.Controls.Add(hplnk);
                }
            }
        }
コード例 #2
0
        private void GetJobCommentsWithAttachments()
        {
            CommentsBE     commentBE     = new CommentsBE();
            AttachmentsBAL attachmentBAL = new AttachmentsBAL();

            commentBE.JobDetails = new JobDetailsBE();

            StringBuilder sHTML = new StringBuilder();

            commentBE.Action = "GetJobCommentsWithAttachmentsByJobId";

            if (Request.QueryString["JobId"] != null)
            {
                commentBE.JobDetails.Id = Convert.ToInt32(Request.QueryString["JobId"]);
            }

            List <CommentsBE> lstAttachments = attachmentBAL.GetJobCommentsWithAttachmentsBAL(commentBE);

            if (lstAttachments.Count > 0)
            {
                int previous = 0, AttachmentCountByCommentID = 0;

                for (int i = 0; i < lstAttachments.Count(); i++)
                {
                    if (i != 0 && previous != lstAttachments[i].CommentId)
                    {
                        sHTML.Append("</div>");
                        sHTML.Append("</div></div></blockquote>");
                    }

                    if (previous != lstAttachments[i].CommentId)
                    {
                        AttachmentCountByCommentID = lstAttachments.Where(x => x.CommentId == lstAttachments[i].CommentId && x.Attachment.JobAttachmentId > 0).Count();

                        sHTML.Append("<blockquote>");
                        sHTML.Append("<div class='submit-by'> Added By: ");
                        sHTML.Append("<span class='comment-name'>");
                        sHTML.Append(lstAttachments[i].usr.Username);
                        sHTML.Append("</span>");
                        sHTML.Append(" on ");
                        sHTML.Append("<span class='comment-date'>");
                        sHTML.Append(lstAttachments[i].CreatedOn.Value.ToString("MM/dd/yyyy"));
                        sHTML.Append("</span>");
                        sHTML.Append("</div>");
                        sHTML.Append("<div class='row'><div class='col-sm-6 blockquote-body'>");
                        sHTML.Append("<p> <img alt='' src='/images/qoute-icon.png'>");
                        sHTML.Append(lstAttachments[i].Description);
                        sHTML.Append("</p>");
                        sHTML.Append("</div>");
                        sHTML.Append("<div class='col-sm-6 text-right'>");
                        sHTML.Append("<i class='fa fa-paperclip fa-rotate-270' aria-hidden='true'></i>");
                        sHTML.Append("<a class='link-underline' id='link-underline" + (i + 1).ToString() + "' onclick='return ToggleAttachments(this) ';><img alt = '' src='/images/attachment-icon.png' />");
                        sHTML.Append("Attachments " + "[" + AttachmentCountByCommentID + "]");
                        sHTML.Append("</a>");
                        sHTML.Append("<div class='down-attach attachment-download" + (i + 1).ToString() + "' style='display: none'>");

                        previous = lstAttachments[i].CommentId;
                    }

                    if (lstAttachments[i].Attachment.JobAttachmentId > 0)
                    {
                        sHTML.Append(String.Format("<a class='btn btn-link' href='DownloadAttachment.aspx?FilePath={0} &FileName={1}'>", lstAttachments[i].Attachment.Path, lstAttachments[i].Attachment.Name));
                        sHTML.Append(lstAttachments[i].Attachment.Name);
                        sHTML.Append("</a>");
                    }
                }
            }

            if (lstAttachments.Count > 0)
            {
                sHTML.Append("</div></div></blockquote>");
            }

            divComments.InnerHtml = sHTML.ToString();
        }