?? sqldataprovider.cs
字號:
List<Issue> issueList = new List<Issue>();
TExecuteReaderCmd<Issue>(sqlCmd, TGenerateIssueListFromReader<Issue>, ref issueList);
return issueList;
}
/// <summary>
/// Gets the issue by id.
/// </summary>
/// <param name="issueId">The issue id.</param>
/// <returns></returns>
public override BugNET.BusinessLogicLayer.Issue GetIssueById(int issueId)
{
if (issueId <= 0)
throw (new ArgumentOutOfRangeException("issueId"));
SqlCommand sqlCmd = new SqlCommand();
AddParamToSQLCmd(sqlCmd, "@IssueId", SqlDbType.Int, 0, ParameterDirection.Input, issueId);
SetCommandType(sqlCmd, CommandType.StoredProcedure, SP_ISSUE_GETISSUEBYID);
List<Issue> issueList = new List<Issue>();
TExecuteReaderCmd<Issue>(sqlCmd, TGenerateIssueListFromReader<Issue>, ref issueList);
if (issueList.Count > 0)
return issueList[0];
else
return null;
}
/// <summary>
/// Updates the issue.
/// </summary>
/// <param name="issueToUpdate">The issue to update.</param>
/// <returns></returns>
public override bool UpdateIssue(BugNET.BusinessLogicLayer.Issue issueToUpdate)
{
if (issueToUpdate == null)
throw (new ArgumentNullException("issueToUpdate"));
// Execute SQL Command
SqlCommand sqlCmd = new SqlCommand();
AddParamToSQLCmd(sqlCmd, "@ReturnValue", SqlDbType.Int, 0, ParameterDirection.ReturnValue, null);
AddParamToSQLCmd(sqlCmd, "@IssueId", SqlDbType.Int, 0, ParameterDirection.Input, issueToUpdate.Id);
AddParamToSQLCmd(sqlCmd, "@ProjectId", SqlDbType.Int, 0, ParameterDirection.Input, issueToUpdate.ProjectId);
AddParamToSQLCmd(sqlCmd, "@IssueTitle", SqlDbType.NText, 255, ParameterDirection.Input, issueToUpdate.Title);
AddParamToSQLCmd(sqlCmd, "@IssueCategoryId", SqlDbType.Int, 0, ParameterDirection.Input, (issueToUpdate.CategoryId == 0) ? DBNull.Value : (object)issueToUpdate.CategoryId);
AddParamToSQLCmd(sqlCmd, "@IssueStatusId", SqlDbType.Int, 0, ParameterDirection.Input, issueToUpdate.StatusId);
AddParamToSQLCmd(sqlCmd, "@IssuePriorityId", SqlDbType.Int, 0, ParameterDirection.Input, issueToUpdate.PriorityId);
AddParamToSQLCmd(sqlCmd, "@IssueTypeId", SqlDbType.Int, 0, ParameterDirection.Input, issueToUpdate.IssueTypeId);
AddParamToSQLCmd(sqlCmd, "@IssueResolutionId", SqlDbType.Int, 0, ParameterDirection.Input, (issueToUpdate.ResolutionId == 0) ? DBNull.Value : (object)issueToUpdate.ResolutionId);
AddParamToSQLCmd(sqlCmd, "@IssueMilestoneId", SqlDbType.Int, 0, ParameterDirection.Input, (issueToUpdate.MilestoneId == 0) ? DBNull.Value : (object)issueToUpdate.MilestoneId);
AddParamToSQLCmd(sqlCmd, "@IssueAssignedUserName", SqlDbType.NText, 255, ParameterDirection.Input, (issueToUpdate.AssignedUserName == string.Empty) ? DBNull.Value : (object)issueToUpdate.AssignedUserName);
AddParamToSQLCmd(sqlCmd, "@IssueOwnerUserName", SqlDbType.NText, 255, ParameterDirection.Input, (issueToUpdate.OwnerUserName == string.Empty) ? DBNull.Value : (object)issueToUpdate.OwnerUserName);
AddParamToSQLCmd(sqlCmd, "@IssueCreatorUsername", SqlDbType.NText, 255, ParameterDirection.Input, issueToUpdate.CreatorUserName);
AddParamToSQLCmd(sqlCmd, "@IssueDueDate", SqlDbType.DateTime, 0, ParameterDirection.Input, (issueToUpdate.DueDate == DateTime.MinValue) ? DBNull.Value : (object)issueToUpdate.DueDate);
AddParamToSQLCmd(sqlCmd, "@IssueEstimation", SqlDbType.Decimal, 0, ParameterDirection.Input, issueToUpdate.Estimation);
AddParamToSQLCmd(sqlCmd, "@IssueVisibility", SqlDbType.Bit, 0, ParameterDirection.Input, issueToUpdate.Visibility);
AddParamToSQLCmd(sqlCmd, "@IssueDescription", SqlDbType.NText, 0, ParameterDirection.Input, issueToUpdate.Description);
AddParamToSQLCmd(sqlCmd, "@IssueProgress", SqlDbType.Int, 0, ParameterDirection.Input, issueToUpdate.Progress);
SetCommandType(sqlCmd, CommandType.StoredProcedure, SP_ISSUE_UPDATE);
ExecuteScalarCmd(sqlCmd);
int returnValue = (int)sqlCmd.Parameters["@ReturnValue"].Value;
return (returnValue == 0 ? true : false);
}
/// <summary>
/// Creates the new issue.
/// </summary>
/// <param name="issueToCreate">The issue to create.</param>
/// <returns></returns>
public override int CreateNewIssue(BugNET.BusinessLogicLayer.Issue newIssue)
{
// Validate Parameters
if (newIssue == null)
throw (new ArgumentNullException("newIssue"));
// Execute SQL Command
SqlCommand sqlCmd = new SqlCommand();
AddParamToSQLCmd(sqlCmd, "@ReturnValue", SqlDbType.Int, 0, ParameterDirection.ReturnValue, null);
AddParamToSQLCmd(sqlCmd, "@ProjectId", SqlDbType.Int, 0, ParameterDirection.Input, newIssue.ProjectId);
AddParamToSQLCmd(sqlCmd, "@IssueTitle", SqlDbType.NText, 255, ParameterDirection.Input, newIssue.Title);
AddParamToSQLCmd(sqlCmd, "@IssueDescription", SqlDbType.NText, 0, ParameterDirection.Input, newIssue.Description);
AddParamToSQLCmd(sqlCmd, "@IssueCategoryId", SqlDbType.Int, 0, ParameterDirection.Input, (newIssue.CategoryId == 0) ? DBNull.Value : (object)newIssue.CategoryId);
AddParamToSQLCmd(sqlCmd, "@IssueStatusId", SqlDbType.Int, 0, ParameterDirection.Input, newIssue.StatusId);
AddParamToSQLCmd(sqlCmd, "@IssuePriorityId", SqlDbType.Int, 0, ParameterDirection.Input, newIssue.PriorityId);
AddParamToSQLCmd(sqlCmd, "@IssueTypeId", SqlDbType.Int, 0, ParameterDirection.Input, newIssue.IssueTypeId);
AddParamToSQLCmd(sqlCmd, "@IssueResolutionId", SqlDbType.Int, 0, ParameterDirection.Input, (newIssue.ResolutionId == 0) ? DBNull.Value : (object)newIssue.ResolutionId);
AddParamToSQLCmd(sqlCmd, "@IssueMilestoneId", SqlDbType.Int, 0, ParameterDirection.Input, (newIssue.MilestoneId == 0) ? DBNull.Value : (object)newIssue.MilestoneId);
AddParamToSQLCmd(sqlCmd, "@IssueAssignedUserName", SqlDbType.NText, 255, ParameterDirection.Input, (newIssue.AssignedUserName == string.Empty) ? DBNull.Value : (object)newIssue.AssignedUserName);
AddParamToSQLCmd(sqlCmd, "@IssueOwnerUserName", SqlDbType.NText, 255, ParameterDirection.Input, (newIssue.OwnerUserName == string.Empty) ? DBNull.Value : (object)newIssue.OwnerUserName);
AddParamToSQLCmd(sqlCmd, "@IssueCreatorUserName", SqlDbType.NText, 255, ParameterDirection.Input, newIssue.CreatorUserName);
AddParamToSQLCmd(sqlCmd, "@IssueDueDate", SqlDbType.DateTime, 0, ParameterDirection.Input, (newIssue.DueDate == DateTime.MinValue) ? DBNull.Value : (object)newIssue.DueDate);
AddParamToSQLCmd(sqlCmd, "@IssueEstimation", SqlDbType.Decimal, 0, ParameterDirection.Input, newIssue.Estimation);
AddParamToSQLCmd(sqlCmd, "@IssueVisibility", SqlDbType.Bit, 0, ParameterDirection.Input, newIssue.Visibility);
SetCommandType(sqlCmd, CommandType.StoredProcedure, SP_ISSUE_CREATE);
ExecuteScalarCmd(sqlCmd);
return ((int)sqlCmd.Parameters["@ReturnValue"].Value);
}
/// <summary>
/// Gets the issues by relevancy.
/// </summary>
/// <param name="projectId">The project id.</param>
/// <param name="userName">The userName.</param>
/// <returns></returns>
public override System.Collections.Generic.List<BugNET.BusinessLogicLayer.Issue> GetIssuesByRelevancy(int projectId, string userName)
{
if (userName == null)
throw (new ArgumentNullException("userName"));
if (projectId <= 0)
throw (new ArgumentOutOfRangeException("projectId"));
SqlCommand sqlCmd = new SqlCommand();
AddParamToSQLCmd(sqlCmd, "@UserName", SqlDbType.NVarChar, 255, ParameterDirection.Input, userName);
AddParamToSQLCmd(sqlCmd, "@ProjectId", SqlDbType.Int, 0, ParameterDirection.Input, projectId);
SetCommandType(sqlCmd, CommandType.StoredProcedure, SP_ISSUE_GETISSUESBYRELEVANCY);
List<Issue> issueList = new List<Issue>();
TExecuteReaderCmd<Issue>(sqlCmd, TGenerateIssueListFromReader<Issue>, ref issueList);
return issueList;
}
/// <summary>
/// Gets the name of the issues by assigned user.
/// </summary>
/// <param name="projectId">The project id.</param>
/// <param name="assignedUserName">Name of the assigned user.</param>
/// <returns></returns>
public override System.Collections.Generic.List<BugNET.BusinessLogicLayer.Issue> GetIssuesByAssignedUserName(int projectId, string userName)
{
if (userName == null)
throw (new ArgumentNullException("userName"));
if (projectId <= 0)
throw (new ArgumentOutOfRangeException("projectId"));
SqlCommand sqlCmd = new SqlCommand();
AddParamToSQLCmd(sqlCmd, "@UserName", SqlDbType.NVarChar, 255, ParameterDirection.Input, userName);
AddParamToSQLCmd(sqlCmd, "@ProjectId", SqlDbType.Int, 0, ParameterDirection.Input, projectId);
SetCommandType(sqlCmd, CommandType.StoredProcedure, SP_ISSUE_GETISSUESBYASSIGNEDUSERNAME);
List<Issue> issueList = new List<Issue>();
TExecuteReaderCmd<Issue>(sqlCmd, TGenerateIssueListFromReader<Issue>, ref issueList);
return issueList;
}
/// <summary>
/// Gets the name of the issues by creator user.
/// </summary>
/// <param name="projectId">The project id.</param>
/// <param name="userName">Name of the user.</param>
/// <returns></returns>
public override System.Collections.Generic.List<BugNET.BusinessLogicLayer.Issue> GetIssuesByCreatorUserName(int projectId, string userName)
{
if (userName == null)
throw (new ArgumentNullException("userName"));
if (projectId <= 0)
throw (new ArgumentOutOfRangeException("projectId"));
SqlCommand sqlCmd = new SqlCommand();
AddParamToSQLCmd(sqlCmd, "@UserName", SqlDbType.NVarChar, 255, ParameterDirection.Input, userName);
AddParamToSQLCmd(sqlCmd, "@ProjectId", SqlDbType.Int, 0, ParameterDirection.Input, projectId);
SetCommandType(sqlCmd, CommandType.StoredProcedure, SP_ISSUE_GETISSUESBYCREATORUSERNAME);
List<Issue> issueList = new List<Issue>();
TExecuteReaderCmd<Issue>(sqlCmd, TGenerateIssueListFromReader<Issue>, ref issueList);
return issueList;
}
/// <summary>
/// Gets the name of the issues by owner user.
/// </summary>
/// <param name="projectId">The project id.</param>
/// <param name="userName">Name of the user.</param>
/// <returns></returns>
public override System.Collections.Generic.List<BugNET.BusinessLogicLayer.Issue> GetIssuesByOwnerUserName(int projectId, string userName)
{
if (userName == null)
throw (new ArgumentNullException("userName"));
if (projectId <= 0)
throw (new ArgumentOutOfRangeException("projectId"));
SqlCommand sqlCmd = new SqlCommand();
AddParamToSQLCmd(sqlCmd, "@UserName", SqlDbType.NVarChar, 255, ParameterDirection.Input, userName);
AddParamToSQLCmd(sqlCmd, "@ProjectId", SqlDbType.Int, 0, ParameterDirection.Input, projectId);
SetCommandType(sqlCmd, CommandType.StoredProcedure, SP_ISSUE_GETISSUESBYOWNERUSERNAME);
List<Issue> issueList = new List<Issue>();
TExecuteReaderCmd<Issue>(sqlCmd, TGenerateIssueListFromReader<Issue>, ref issueList);
return issueList;
}
/// <summary>
/// Performs the saved query.
/// </summary>
/// <param name="projectId">The project id.</param>
/// <param name="queryId">The query id.</param>
/// <returns></returns>
public override System.Collections.Generic.List<BugNET.BusinessLogicLayer.Issue> PerformSavedQuery(int projectId, int queryId)
{
// Validate Parameters
if (queryId <= Globals.NewId)
throw (new ArgumentOutOfRangeException("queryId"));
if (projectId <= Globals.NewId)
throw (new ArgumentOutOfRangeException("projectId"));
// Get Query Clauses
SqlCommand sqlCmd = new SqlCommand();
AddParamToSQLCmd(sqlCmd, "@QueryId", SqlDbType.Int, 0, ParameterDirection.Input, queryId);
SetCommandType(sqlCmd, CommandType.StoredProcedure, SP_QUERY_GETSAVEDQUERY);
List<QueryClause> queryClauses = new List<QueryClause>();
TExecuteReaderCmd<QueryClause>(sqlCmd, TGenerateQueryClauseListFromReader<QueryClause>, ref queryClauses);
return PerformQuery(projectId, queryClauses);
}
/// <summary>
/// Gets the child issues.
/// </summary>
/// <param name="issueId">The issue id.</param>
/// <returns></returns>
public override System.Collections.Generic.List<BugNET.BusinessLogicLayer.RelatedIssue> GetChildIssues(int issueId)
{
if (issueId <= 0)
throw (new ArgumentOutOfRangeException("issueId"));
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -