inc_print_bug.aspx

来自「Bug管理系统」· ASPX 代码 · 共 301 行

ASPX
301
字号
<script runat="server">
 
///////////////////////////////////////////////////////////////////////
DataRow get_bug_datarow(int id)
{

	DataSet ds_custom_cols = Util.get_custom_columns (dbutil);
	
	return Util.get_bug_datarow(id, ds_custom_cols, security, dbutil);
}


///////////////////////////////////////////////////////////////////////
void print_comment(HttpResponse Response, DataRow dr, int bug_id, int comment_id)
{

	Response.Write ("<tr><td>");

	if ((string)dr["bc_type"] == "update") // update
	{
		// posted by
		Response.Write ("<span>changed by ");
		Response.Write (Util.format_email_username(
			bug_id,  
			(string) dr["us_email"], 
			(string) dr["us_username"],
			(string) dr["us_fullname"]));
		Response.Write (" on ");
		Response.Write (Util.format_db_date(dr["bc_date"]));
		Response.Write ("</span>");
	}
	else
	{
		if ((string)dr["bc_type"] == "sent" ) // sent email
		{
			Response.Write ("<span>email sent to ");
			Response.Write (Util.format_email_to(
				bug_id,
				(string)dr["bc_email_to"]));
			Response.Write (" by ");
			Response.Write (Util.format_email_username(
				bug_id,
				(string) dr["us_email"],
			(string) dr["us_username"],
			(string) dr["us_fullname"]));
		}
		else if ((string)dr["bc_type"] == "received" ) // received email
		{
			Response.Write ("<span>email received from ");
			Response.Write (Util.format_email_from(
				comment_id,
				(string)dr["bc_email_from"]));
		}
		else
		{
			Response.Write ("<span>comment posted by ");
			Response.Write (Util.format_email_username(
				bug_id,
				(string) dr["us_email"],
				(string) dr["us_username"],
				(string) dr["us_fullname"]));
		}

		Response.Write (" on ");
		Response.Write (Util.format_db_date(dr["bc_date"]));
		Response.Write ("</span>");
	}


	// the text itself
	Response.Write ("<br><br>");
	string s = (string) dr["bc_comment"];
	s = Util.format_comment(s);
	Response.Write (s);
	
}


///////////////////////////////////////////////////////////////////////
void print_comment_attachment(HttpResponse Response, DataRow dr)
{

	Response.Write ("<p><span class=pst>attachment:&nbsp;</span><a target=_blank href=");
	Response.Write (Util.get_setting("AbsoluteUrlPrefix","http://127.0.0.1/"));
	Response.Write ("view_attachment.aspx?id=");
	Response.Write (Convert.ToString(dr["ba_id"]));
	Response.Write ("&bug_id=");
	Response.Write (Convert.ToString(id));
	Response.Write (">");
	Response.Write (dr["ba_file"]);
	Response.Write ("</a>");				
}


///////////////////////////////////////////////////////////////////////
void print_bug (HttpResponse Response, DataRow dr)
{

	Response.Write ("<style>");
	Response.WriteFile(Server.MapPath("./") + "btnet_base.css");
	Response.Write ("\n");
	Response.WriteFile(Server.MapPath("./") + "btnet_custom.css");
	Response.Write ("</style>");
	
	Response.Write ("<body style=background:white>");
	Response.Write ("<b>" 
		+ Util.capitalize_first_letter(Util.get_setting("SingularBugLabel","bug"))	
		+ " ID:&nbsp;<a href=" 
		+ Util.get_setting("AbsoluteUrlPrefix","http://127.0.0.1/")
		+ "edit_bug.aspx?id="
		+ dr["id"].ToString() 
		+ ">" 
		+ dr["id"].ToString() 
		+ "</a><br>");
		
	Response.Write ("Short desc:&nbsp;<a href=" 
		+ Util.get_setting("AbsoluteUrlPrefix","http://127.0.0.1/")
		+ "edit_bug.aspx?id="
		+ dr["id"].ToString() 
		+ ">" 
		+ HttpUtility.HtmlEncode((string)dr["short_desc"])
		+ "</a></b><p>");
		
	Response.Write ("<table border=1 cellpadding=3 cellspacing=0>");
	Response.Write ("<tr><td>Last changed by<td>" 
		+ Util.format_username((string)dr["last_updated_user"],(string)dr["last_updated_fullname"])
		+ "&nbsp;");
	Response.Write ("<tr><td>Reported By<td>" 
		+ Util.format_username((string)dr["reporter"],(string)dr["reporter_fullname"])
		+ "&nbsp");
	Response.Write ("<tr><td>Reported On<td>" + Util.format_db_date(dr["reported_date"]) + "&nbsp;");
	Response.Write ("<tr><td>Project<td>" + dr["current_project"] + "&nbsp;");
	Response.Write ("<tr><td>Category<td>" + dr["category_name"] + "&nbsp;");
	Response.Write ("<tr><td>Priority<td>" + dr["priority_name"] + "&nbsp;");
	Response.Write ("<tr><td>Assigned<td>" 
		+ Util.format_username((string)dr["assigned_to_username"],(string)dr["assigned_to_fullname"])
		+ "&nbsp;");
	Response.Write ("<tr><td>Status<td>" + dr["status_name"] + "&nbsp;");

	if (Util.get_setting("ShowUserDefinedBugAttribute","1") == "1")
	{
		Response.Write ("<tr><td>" 
			+ Util.get_setting("UserDefinedBugAttributeName","YourAttribute") 
			+ "<td>" 
			+ dr["udf_name"] + "&nbsp;");
	}

	// Get custom column info  (There's an inefficiency here - we just did this
	// same call in get_bug_datarow...)
	
	DataSet ds_custom_cols = Util.get_custom_columns(dbutil);


	// Show custom columns	

	foreach (DataRow drcc in ds_custom_cols.Tables[0].Rows)
	{
		Response.Write ("<tr><td>");
		Response.Write (drcc["name"]);
		Response.Write ("<td>");
		
		if ((string)drcc["datatype"] == "datetime")
		{
			object dt = dr[(string)drcc["name"]];
			
			Response.Write (Util.format_db_date(dt));
		}
		else
		{
			string s = Convert.ToString(dr[(string)drcc["name"]]);
			s = HttpUtility.HtmlEncode(s);
			s = s.Replace("\n","<br>");
			s = s.Replace("  ","&nbsp; ");
			s = s.Replace("\t","&nbsp;&nbsp;&nbsp;&nbsp;");
			Response.Write (s);
		}
		Response.Write ("&nbsp;");
	}


	// create project custom dropdowns
	if ((int)dr["project"] != 0)
	{

		sql = @"select 
			isnull(pj_enable_custom_dropdown1,0) [pj_enable_custom_dropdown1],
			isnull(pj_enable_custom_dropdown2,0) [pj_enable_custom_dropdown2],
			isnull(pj_enable_custom_dropdown3,0) [pj_enable_custom_dropdown3],
			isnull(pj_custom_dropdown_label1,'') [pj_custom_dropdown_label1],
			isnull(pj_custom_dropdown_label2,'') [pj_custom_dropdown_label2],
			isnull(pj_custom_dropdown_label3,'') [pj_custom_dropdown_label3]
			from projects where pj_id = $pj";
		
		sql = sql.Replace("$pj", Convert.ToString((int)dr["project"]));
		
		DataRow project_dr = dbutil.get_datarow(sql);
		
		
		if (project_dr != null)
		{
			for (int i = 1; i < 4; i++)
			{
				if ((int)project_dr["pj_enable_custom_dropdown" + Convert.ToString(i)] == 1)
				{
					Response.Write ("<tr><td>");
					Response.Write (project_dr["pj_custom_dropdown_label" + Convert.ToString(i)]);
					Response.Write ("<td>");
					Response.Write (dr["bg_project_custom_dropdown_value"  + Convert.ToString(i)]);
					Response.Write ("&nbsp;");
				}
			}			
		}
	}



	Response.Write("</table><p>");
	

	// Show comments


	if (Util.get_setting("ShowHistoryWithComments", "0") == "1")
	{
		Response.Write ("<b>Comments and Change History</b>");
	}
	else
	{
		Response.Write ("<b>Comments</b>");
	}
	Response.Write ("<p><table border=1 cellspacing=0 cellpadding=4>");

	
	DataSet ds_comments = Util.get_bug_comments((int)dr["id"],dbutil);
	
	int bc_id;
	int prev_bc_id = -1;
	foreach (DataRow dr_comment in ds_comments.Tables[0].Rows)
	{

		bc_id = (int) dr_comment["bc_id"];


		if (bc_id == prev_bc_id)
		{
			// show another attachment
			print_comment_attachment(Response, dr_comment);
		}
		else
		{
			// show the comment and mabye an attachment
			print_comment(Response, dr_comment, (int)dr["id"],bc_id);
			if (Convert.ToString(dr_comment["ba_file"]) != "")
			{
				print_comment_attachment(Response, dr_comment);
			}
			prev_bc_id = bc_id;			
		}

	}
	

	Response.Write ("</table>");

	if (Util.get_setting("PrintHistory", "1") != "0"
	&& Util.get_setting("ShowHistoryWithComments", "0") == "0")
	{
		Response.Write ("<p><b>Change History</b><p><table border=1 cellspacing=0 cellpadding=3>");
		sql = @"select
			bc_comment [change],
			us_username [user],
			bc_date [date]
			from bug_comments
			inner join users on bc_user = us_id
			where bc_bug = $id
			and bc_type = 'update'
			order by bc_date " + Util.get_setting("CommentSortOrder","desc");

		sql = sql.Replace("$id", dr["id"].ToString());

		DataSet ds3 = dbutil.get_dataset(sql);

		foreach (DataRow dr3 in ds3.Tables[0].Rows)
		{
			Response.Write ("<tr><td>");
			Response.Write (dr3["change"]);
			Response.Write ("<td>");
			Response.Write (dr3["user"]);
			Response.Write ("<td>");
			Response.Write (Util.format_db_date(dr3["date"]));
			Response.Write ("</td></tr>");
		}

		Response.Write ("</table>");
	}

	Response.Write ("<div class=align><table border=0><tr><td></table></div></body>");

}
</script>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?