Exemplo n.º 1
0
 public void ProcessRequest(HttpContext context)
 {
     context.Response.ContentType = "text/plain";
     var md = new Markdown();
     var data = context.Request.Form["data"];
     context.Response.Write(md.Transform(data,true));
 }
Exemplo n.º 2
0
        public void Populate(string linkUrl)
        {
            if(TicketToDisplay != null)
            {

                TicketAttachmentsDataSource.WhereParameters["TicketId"].DefaultValue = TicketToDisplay.TicketId.ToString();
                AttachmentsRepeater.DataSourceID = "TicketAttachmentsDataSource";
                AttachmentsRepeater.DataBind();
                TicketId.Text = TicketToDisplay.TicketId.ToString();
                TicketId.NavigateUrl = linkUrl;
                TicketTitle.Text = TicketToDisplay.Title;
                TicketTitle.NavigateUrl = linkUrl;
                if(TicketToDisplay.IsHtml)
                {
                    Details.Text = TicketToDisplay.Details;
                }
                else
                {
                    var md = new Markdown();
                    Details.Text = md.Transform(TicketToDisplay.Details, true);
                }
                Category.Text = TicketToDisplay.Category;
                //Category.NavigateUrl = string.Format("~/TicketCenter.aspx?View=tagsandcategories&Category={0}", TicketToDisplay.Category);
                TicketType.Text = TicketToDisplay.Type;
                TicketType.NavigateUrl = linkUrl;
                CreatedBy.Text = SecurityManager.GetUserDisplayName(TicketToDisplay.CreatedBy);
                CreatedDate.Text = TicketToDisplay.CreatedDate.ToString("g");
                Owner.Text = SecurityManager.GetUserDisplayName(TicketToDisplay.Owner);
                AssignedTo.Text = SecurityManager.GetUserDisplayName(TicketToDisplay.AssignedTo);
                //AssignedTo.NavigateUrl = string.Format("~/TicketCenter.aspx?View=assigned&User={0}", TicketToDisplay.AssignedTo);
                CurrentStatus.Text = TicketToDisplay.CurrentStatus;
                //CurrentStatus.NavigateUrl = string.Format("~/TicketCenter.aspx?View=status&Status={0}", TicketToDisplay.CurrentStatus.Replace(" ", string.Empty).ToLowerInvariant());
                CurrentStatusBy.Text = SecurityManager.GetUserDisplayName(TicketToDisplay.CurrentStatusSetBy);
                CurrentStatusDate.Text = TicketToDisplay.CurrentStatusDate.ToString("g");
                LastUpdateBy.Text = SecurityManager.GetUserDisplayName(TicketToDisplay.LastUpdateBy);
                LastUpdateDate.Text = TicketToDisplay.LastUpdateDate.ToString("g");
                Priority.Text = TicketToDisplay.Priority;

                AffectsCustomer.Text = (TicketToDisplay.AffectsCustomer) ? "Yes" : "No";
                PublishedToKb.Text = (TicketToDisplay.PublishedToKb) ? "Yes" : "No";

                var Tags = from t in TicketToDisplay.TicketTags
                           select new
                           {
                               //Url = string.Format("~/TicketCenter.aspx?View=tagsandcategories&TagName={0}", t.TagName),
                               TagName = t.TagName
                           };
                TagRepeater.DataSource = Tags;
                TagRepeater.DataBind();

                CommentLogRepeater.DataSource = TicketToDisplay.TicketComments.OrderByDescending(tc => tc.CommentedDate);
                CommentLogRepeater.DataBind();
            }
            
            
        }
        public static string GetHTMLBody(Ticket ticket, string url, string userToNotify, int minCommentId)
        {
            string viewTicket = string.Format("ViewTicket.aspx?id={0}", ticket.TicketId.ToString());

            url = url.Replace("NewTicket", viewTicket);

            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append(GetStyle());

            #region Start body
            stringBuilder.Append(@"
<TABLE style=""WIDTH: 100%"">
    <TBODY>
        <TR>
            <TD style=""VERTICAL-ALIGN: top; WIDTH: 75%"">
                <DIV class=Block>");
            #endregion

            //add url {0} and title {1} placeholders
            #region one
            stringBuilder.Append(@"
                    <DIV class=BlockHeader>
                        <A id=TicketType href=""{0}"">{16}</A> : <A id=TicketTitle href=""{0}"">{1}</A> 
                    </DIV>
                    <DIV class=BlockBody style=""HEIGHT: 180px"">
                        <SPAN id=Details>{17}</SPAN> 
                    </DIV>
                </DIV>
            </TD>
");
            #endregion

            //add Ticket number (ticketid) {2}
            #region two
            stringBuilder.Append(@"    
            <TD style=""VERTICAL-ALIGN: top; WIDTH: 25%"">
                <DIV class=Block>
                    <DIV class=BlockHeader>Ticket ID: <A id=TicketId href=""{0}"">{2}</A> </DIV>");
            #endregion

            //add status {3} and priority {4} and category {5}, owner {6), assigned to {7}
            //affects customer {8} and published to kb {9}
            #region three
            stringBuilder.Append(@"
                    <DIV class=BlockBody style=""WHITE-SPACE: nowrap; HEIGHT: 203px"">
                        <TABLE>
                            <TBODY>
                                <TR>
                                    <TD style=""VERTICAL-ALIGN: top; WHITE-SPACE: nowrap; TEXT-ALIGN: right"">Status: </TD>
                                    <TD style=""VERTICAL-ALIGN: top; WHITE-SPACE: nowrap"">
                                        <SPAN id=CurrentStatus>{3}</SPAN> 
                                    </TD>
                                </TR>
                                <TR>
                                    <TD style=""VERTICAL-ALIGN: top; WHITE-SPACE: nowrap; TEXT-ALIGN: right"">Priority: </TD>
                                    <TD style=""VERTICAL-ALIGN: top; WHITE-SPACE: nowrap"">
                                        <SPAN id=Priority>{4}</SPAN> 
                                    </TD>
                                </TR>
                                <TR>
                                    <TD style=""VERTICAL-ALIGN: top; WHITE-SPACE: nowrap; TEXT-ALIGN: right"">Category: </TD>
                                    <TD style=""VERTICAL-ALIGN: top; WHITE-SPACE: nowrap"">
                                        <SPAN id=Category>{5}</SPAN> 
                                    </TD>
                                </TR>
                                <TR>
                                    <TD style=""VERTICAL-ALIGN: top; WHITE-SPACE: nowrap; TEXT-ALIGN: right"">Owned by: </TD>
                                    <TD style=""VERTICAL-ALIGN: top; WHITE-SPACE: nowrap"">
                                        <SPAN id=Owner>{6}</SPAN> 
                                    </TD>
                                </TR>
                                <TR>
                                    <TD style=""VERTICAL-ALIGN: top; WHITE-SPACE: nowrap; TEXT-ALIGN: right"">Assigned to: </TD>
                                    <TD style=""VERTICAL-ALIGN: top; WHITE-SPACE: nowrap"">
                                        <A id=AssignedTo>{7}</A> 
                                    </TD>
                                </TR>
                                <TR>
                                    <TD style=""VERTICAL-ALIGN: top; WHITE-SPACE: nowrap; TEXT-ALIGN: right"">Affects Customer(s): </TD>
                                    <TD style=""VERTICAL-ALIGN: top; WHITE-SPACE: nowrap"">
                                        <SPAN id=AffectsCustomer>{8}</SPAN> 
                                    </TD>
                                </TR>
                                <TR>
                                    <TD style=""VERTICAL-ALIGN: top; WHITE-SPACE: nowrap; TEXT-ALIGN: right"">Published to KB: </TD>
                                    <TD style=""VERTICAL-ALIGN: top; WHITE-SPACE: nowrap"">
                                        <SPAN id=PublishedToKb>{9}</SPAN> 
                                    </TD>
                                </TR>
");
            #endregion

            //add tags
            #region tags
            stringBuilder.Append(@"		
                                <TR>
                                    <TD style=""VERTICAL-ALIGN: top; WHITE-SPACE: nowrap; TEXT-ALIGN: right"">Tags: </TD>
");

            string tagHtml = String.Format(@"          
                                    <TD style=""VERTICAL-ALIGN: top"">
                                        <SPAN id=TagRepeater_ct100_TicketTag>{0}</SPAN> 
                                    </TD>
                                </TR>
",
                                           ticket.TagList);

            stringBuilder.Append(tagHtml);
            #endregion

            //add Created By {10}, created on {11}, current status by {12},
            //current status on {13}, last update by {14}, and last update on {15}
            #region four
            stringBuilder.Append(@"
                                <TR>
                                    <TD style=""VERTICAL-ALIGN: top; WHITE-SPACE: nowrap; TEXT-ALIGN: right"">Created by: </TD>
                                    <TD style=""VERTICAL-ALIGN: top; WHITE-SPACE: nowrap"">
                                        <SPAN id=CreatedBy>{10}</SPAN> on: <SPAN id=CreatedDate>{11}</SPAN> 
                                    </TD>
                                </TR>
                                <TR>
                                    <TD style=""VERTICAL-ALIGN: top; WHITE-SPACE: nowrap; TEXT-ALIGN: right"">Status set by: </TD>
                                    <TD style=""VERTICAL-ALIGN: top; WHITE-SPACE: nowrap"">
                                        <SPAN id=CurrentStatusBy>{12}</SPAN> on: <SPAN id=CurrentStatusDate>{13}</SPAN> 
                                    </TD>
                                </TR>
                                <TR>
                                    <TD style=""VERTICAL-ALIGN: top; WHITE-SPACE: nowrap; TEXT-ALIGN: right"">Updated by: </TD>
                                    <TD style=""VERTICAL-ALIGN: top; WHITE-SPACE: nowrap"">
                                        <SPAN id=LastUpdateBy>{14}</SPAN> on: <SPAN id=LastUpdateDate>{15}</SPAN> 
                                    </TD>
                                </TR>
                            </TBODY>
                        </TABLE>
                    </DIV>
                </DIV>
            </TD>
        </TR>
");
            #endregion

            stringBuilder.Append(GetHTMLAttachments(ticket));

            stringBuilder.Append(GetHTMLComments(ticket, userToNotify, minCommentId));

            string body = stringBuilder.ToString();
            var    md   = new Markdown();
            body = String.Format(body,                                                                    //base string
                                 url,                                                                     // {0}
                                 ticket.Title,                                                            // {1}
                                 ticket.TicketId.ToString(),                                              // {2}
                                 ticket.CurrentStatus,                                                    // {3}
                                 ticket.Priority,                                                         // {4}
                                 ticket.Category,                                                         // {5}
                                 SecurityManager.GetUserDisplayName(ticket.Owner),                        // {6}
                                 SecurityManager.GetUserDisplayName(ticket.AssignedTo),                   // {7}
                                 BoolToYesNo(ticket.AffectsCustomer),                                     // {8}
                                 BoolToYesNo(ticket.PublishedToKb),                                       // {9}
                                 SecurityManager.GetUserDisplayName(ticket.CreatedBy),                    // {10}
                                 ticket.CreatedDate.ToString("g"),                                        // {11}
                                 SecurityManager.GetUserDisplayName(ticket.CurrentStatusSetBy),           // {12}
                                 ticket.CurrentStatusDate.ToString("g"),                                  // {13}
                                 SecurityManager.GetUserDisplayName(ticket.LastUpdateBy),                 // {14}
                                 ticket.LastUpdateDate.ToString("g"),                                     // {15}
                                 ticket.Type,                                                             // {16}
                                 ((!ticket.IsHtml) ? md.Transform(ticket.Details, true) : ticket.Details) // {17}
                                 );

            body = string.Format("{0}{1}{2}",
                                 "<html><head></head><body>",
                                 body,
                                 "</body></html>"
                                 );
            return(body);
        }
        public static string GetHTMLBody(Ticket ticket, string url, string userToNotify, int minCommentId)
        {
            string viewTicket = string.Format("ViewTicket.aspx?id={0}", ticket.TicketId.ToString());

            url = url.Replace("NewTicket", viewTicket);

            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append(GetStyle());

            #region Start body
            stringBuilder.Append(@"
            <TABLE style=""WIDTH: 100%"">
            <TBODY>
            <TR>
            <TD style=""VERTICAL-ALIGN: top; WIDTH: 75%"">
                <DIV class=Block>");
            #endregion

            //add url {0} and title {1} placeholders
            #region one
            stringBuilder.Append(@"
                    <DIV class=BlockHeader>
                        <A id=TicketType href=""{0}"">{16}</A> : <A id=TicketTitle href=""{0}"">{1}</A>
                    </DIV>
                    <DIV class=BlockBody style=""HEIGHT: 180px"">
                        <SPAN id=Details>{17}</SPAN>
                    </DIV>
                </DIV>
            </TD>
            ");
            #endregion

            //add Ticket number (ticketid) {2}
            #region two
            stringBuilder.Append(@"
            <TD style=""VERTICAL-ALIGN: top; WIDTH: 25%"">
                <DIV class=Block>
                    <DIV class=BlockHeader>Ticket ID: <A id=TicketId href=""{0}"">{2}</A> </DIV>");
            #endregion

            //add status {3} and priority {4} and category {5}, owner {6), assigned to {7}
            //affects customer {8} and published to kb {9}
            #region three
            stringBuilder.Append(@"
                    <DIV class=BlockBody style=""WHITE-SPACE: nowrap; HEIGHT: 203px"">
                        <TABLE>
                            <TBODY>
                                <TR>
                                    <TD style=""VERTICAL-ALIGN: top; WHITE-SPACE: nowrap; TEXT-ALIGN: right"">Status: </TD>
                                    <TD style=""VERTICAL-ALIGN: top; WHITE-SPACE: nowrap"">
                                        <SPAN id=CurrentStatus>{3}</SPAN>
                                    </TD>
                                </TR>
                                <TR>
                                    <TD style=""VERTICAL-ALIGN: top; WHITE-SPACE: nowrap; TEXT-ALIGN: right"">Priority: </TD>
                                    <TD style=""VERTICAL-ALIGN: top; WHITE-SPACE: nowrap"">
                                        <SPAN id=Priority>{4}</SPAN>
                                    </TD>
                                </TR>
                                <TR>
                                    <TD style=""VERTICAL-ALIGN: top; WHITE-SPACE: nowrap; TEXT-ALIGN: right"">Category: </TD>
                                    <TD style=""VERTICAL-ALIGN: top; WHITE-SPACE: nowrap"">
                                        <SPAN id=Category>{5}</SPAN>
                                    </TD>
                                </TR>
                                <TR>
                                    <TD style=""VERTICAL-ALIGN: top; WHITE-SPACE: nowrap; TEXT-ALIGN: right"">Owned by: </TD>
                                    <TD style=""VERTICAL-ALIGN: top; WHITE-SPACE: nowrap"">
                                        <SPAN id=Owner>{6}</SPAN>
                                    </TD>
                                </TR>
                                <TR>
                                    <TD style=""VERTICAL-ALIGN: top; WHITE-SPACE: nowrap; TEXT-ALIGN: right"">Assigned to: </TD>
                                    <TD style=""VERTICAL-ALIGN: top; WHITE-SPACE: nowrap"">
                                        <A id=AssignedTo>{7}</A>
                                    </TD>
                                </TR>
                                <TR>
                                    <TD style=""VERTICAL-ALIGN: top; WHITE-SPACE: nowrap; TEXT-ALIGN: right"">Affects Customer(s): </TD>
                                    <TD style=""VERTICAL-ALIGN: top; WHITE-SPACE: nowrap"">
                                        <SPAN id=AffectsCustomer>{8}</SPAN>
                                    </TD>
                                </TR>
                                <TR>
                                    <TD style=""VERTICAL-ALIGN: top; WHITE-SPACE: nowrap; TEXT-ALIGN: right"">Published to KB: </TD>
                                    <TD style=""VERTICAL-ALIGN: top; WHITE-SPACE: nowrap"">
                                        <SPAN id=PublishedToKb>{9}</SPAN>
                                    </TD>
                                </TR>
            ");
            #endregion

            //add tags
            #region tags
            stringBuilder.Append(@"
                                <TR>
                                    <TD style=""VERTICAL-ALIGN: top; WHITE-SPACE: nowrap; TEXT-ALIGN: right"">Tags: </TD>
            ");

            string tagHtml = String.Format(@"
                                    <TD style=""VERTICAL-ALIGN: top"">
                                        <SPAN id=TagRepeater_ct100_TicketTag>{0}</SPAN>
                                    </TD>
                                </TR>
            ",
                                                ticket.TagList);

            stringBuilder.Append(tagHtml);
            #endregion

            //add Created By {10}, created on {11}, current status by {12},
            //current status on {13}, last update by {14}, and last update on {15}
            #region four
            stringBuilder.Append(@"
                                <TR>
                                    <TD style=""VERTICAL-ALIGN: top; WHITE-SPACE: nowrap; TEXT-ALIGN: right"">Created by: </TD>
                                    <TD style=""VERTICAL-ALIGN: top; WHITE-SPACE: nowrap"">
                                        <SPAN id=CreatedBy>{10}</SPAN> on: <SPAN id=CreatedDate>{11}</SPAN>
                                    </TD>
                                </TR>
                                <TR>
                                    <TD style=""VERTICAL-ALIGN: top; WHITE-SPACE: nowrap; TEXT-ALIGN: right"">Status set by: </TD>
                                    <TD style=""VERTICAL-ALIGN: top; WHITE-SPACE: nowrap"">
                                        <SPAN id=CurrentStatusBy>{12}</SPAN> on: <SPAN id=CurrentStatusDate>{13}</SPAN>
                                    </TD>
                                </TR>
                                <TR>
                                    <TD style=""VERTICAL-ALIGN: top; WHITE-SPACE: nowrap; TEXT-ALIGN: right"">Updated by: </TD>
                                    <TD style=""VERTICAL-ALIGN: top; WHITE-SPACE: nowrap"">
                                        <SPAN id=LastUpdateBy>{14}</SPAN> on: <SPAN id=LastUpdateDate>{15}</SPAN>
                                    </TD>
                                </TR>
                            </TBODY>
                        </TABLE>
                    </DIV>
                </DIV>
            </TD>
            </TR>
            ");
            #endregion

            stringBuilder.Append(GetHTMLAttachments(ticket));

            stringBuilder.Append(GetHTMLComments(ticket, userToNotify, minCommentId));

            string body = stringBuilder.ToString();
            var md = new Markdown();
            body = String.Format(body, //base string
                                    url, // {0}
                                    ticket.Title, // {1}
                                    ticket.TicketId.ToString(), // {2}
                                    ticket.CurrentStatus, // {3}
                                    ticket.Priority, // {4}
                                    ticket.Category, // {5}
                                    SecurityManager.GetUserDisplayName(ticket.Owner), // {6}
                                    SecurityManager.GetUserDisplayName(ticket.AssignedTo), // {7}
                                    BoolToYesNo(ticket.AffectsCustomer),  // {8}
                                    BoolToYesNo(ticket.PublishedToKb), // {9}
                                    SecurityManager.GetUserDisplayName(ticket.CreatedBy), // {10}
                                    ticket.CreatedDate.ToString("g"), // {11}
                                    SecurityManager.GetUserDisplayName(ticket.CurrentStatusSetBy), // {12}
                                    ticket.CurrentStatusDate.ToString("g"), // {13}
                                    SecurityManager.GetUserDisplayName(ticket.LastUpdateBy), // {14}
                                    ticket.LastUpdateDate.ToString("g"), // {15}
                                    ticket.Type, // {16}
                                    ((!ticket.IsHtml) ? md.Transform(ticket.Details, true) : ticket.Details) // {17}
                                    );

            body = string.Format("{0}{1}{2}",
                                    "<html><head></head><body>",
                                    body,
                                    "</body></html>"
                                    );
            return body;
        }
Exemplo n.º 5
0
        private void PopulateDisplay()
        {
            if (TicketToDisplay != null)
            {
                DisplayActivityButtons();

                TicketId.Text = TicketToDisplay.TicketId.ToString();

                TicketTitle.Text = TicketToDisplay.Title;

                if (TicketToDisplay.IsHtml)
                {
                    Details.Text = TicketToDisplay.Details;
                }
                else
                {
                    var md = new Markdown();
                    Details.Text =  md.Transform(TicketToDisplay.Details,true);
                }

                Category.Text = TicketToDisplay.Category;
                Category.NavigateUrl = string.Format("~/TicketSearch.aspx?cat={0}", Page.Server.UrlEncode(TicketToDisplay.Category));

                TicketType.Text = TicketToDisplay.Type;

                CreatedBy.Text = SecurityManager.GetUserDisplayName(TicketToDisplay.CreatedBy);

                CreatedDate.Text = TicketToDisplay.CreatedDate.ToString("g");

                Owner.Text = SecurityManager.GetUserDisplayName(TicketToDisplay.Owner);
                if (!string.IsNullOrEmpty(TicketToDisplay.Owner))
                {
                    Owner.NavigateUrl = string.Format("~/TicketSearch.aspx?owner={0}",  Page.Server.UrlEncode(TicketToDisplay.Owner));
                }
                AssignedTo.Text = SecurityManager.GetUserDisplayName(TicketToDisplay.AssignedTo);
                if (!string.IsNullOrEmpty(TicketToDisplay.AssignedTo))
                {
                    AssignedTo.NavigateUrl = string.Format("~/TicketSearch.aspx?assign={0}",  Page.Server.UrlEncode(TicketToDisplay.AssignedTo));
                }
                CurrentStatus.Text = TicketToDisplay.CurrentStatus;
                CurrentStatus.NavigateUrl = string.Format("~/TicketSearch.aspx?status={0}",  Page.Server.UrlEncode(TicketToDisplay.CurrentStatus));

                CurrentStatusBy.Text = SecurityManager.GetUserDisplayName(TicketToDisplay.CurrentStatusSetBy);

                CurrentStatusDate.Text = TicketToDisplay.CurrentStatusDate.ToString("g");

                LastUpdateBy.Text = SecurityManager.GetUserDisplayName(TicketToDisplay.LastUpdateBy);

                LastUpdateDate.Text = TicketToDisplay.LastUpdateDate.ToString("g");

                Priority.Text = TicketToDisplay.Priority;
                if (!string.IsNullOrEmpty(TicketToDisplay.Priority))
                {
                    Priority.NavigateUrl = string.Format("~/TicketSearch.aspx?priority={0}",  Page.Server.UrlEncode(TicketToDisplay.Priority)); ;
                }
                AffectsCustomer.Text = (TicketToDisplay.AffectsCustomer) ? "Yes" : "No";

                TicketAttachmentsControl.Refresh();


                var Tags = from t in TicketToDisplay.TicketTags
                           select new
                           {
                               Url = string.Format("~/TicketSearch.aspx?tag={0}",  Page.Server.UrlEncode(t.TagName)),
                               TagName = t.TagName
                           };
                TagRepeater.DataSource = Tags;
                TagRepeater.DataBind();

                CommentLogRepeater.DataSource = TicketToDisplay.TicketComments.OrderByDescending(tc => tc.CommentedDate);
                CommentLogRepeater.DataBind();
            }
        }