📄 issue.cs
字号:
private string UpdateIssueHistory(List<IssueHistory> issueChanges)
{
string changes = string.Empty;
foreach(IssueHistory issueHistory in issueChanges)
{
issueHistory.Save();
changes += String.Format("\n{2} changed from \"{0}\" to \"{1}\"", issueHistory.OldValue, issueHistory.NewValue, issueHistory.FieldChanged);
}
return changes;
}
/// <summary>
/// Gets the issue changes.
/// </summary>
/// <returns></returns>
private List<IssueHistory> GetIssueChanges()
{
List<IssueHistory> issueChanges = new List<IssueHistory>();
Issue orgIssue = GetIssueById(_Id);
if (orgIssue != null)
{
if (orgIssue.Title.ToLower() != Title.ToLower())
issueChanges.Add(new IssueHistory(_Id,Security.GetUserName(),"Title",orgIssue.Title,Title));
if(orgIssue.Description.ToLower() != Description.ToLower())
issueChanges.Add(new IssueHistory(_Id, Security.GetUserName(), "Description", orgIssue.Description, Description));
if (orgIssue.CategoryId != CategoryId)
issueChanges.Add(new IssueHistory(_Id, Security.GetUserName(), "Category", orgIssue.CategoryName, CategoryName));
if ( orgIssue.PriorityId != PriorityId)
issueChanges.Add(new IssueHistory(_Id, Security.GetUserName(), "Priority", orgIssue.PriorityName, PriorityName));
if (orgIssue.StatusId != StatusId)
issueChanges.Add(new IssueHistory(_Id, Security.GetUserName(), "Status", orgIssue.StatusName, StatusName));
if (orgIssue.MilestoneId != MilestoneId)
issueChanges.Add(new IssueHistory(_Id, Security.GetUserName(), "Milestone", orgIssue.MilestoneName,MilestoneName));
if (orgIssue.IssueTypeId != IssueTypeId)
issueChanges.Add(new IssueHistory(_Id, Security.GetUserName(), "Issue Type", orgIssue.IssueTypeName, IssueTypeName));
if (orgIssue.ResolutionId != ResolutionId)
issueChanges.Add(new IssueHistory(_Id, Security.GetUserName(), "Resolution", orgIssue.ResolutionName, ResolutionName));
if (orgIssue.AssignedUserName != AssignedUserName)
{
_NewAssignee = true;
string OldDisplayName = String.IsNullOrEmpty(orgIssue.AssignedUserName) ? Globals.UnassignedDisplayText : orgIssue.AssignedDisplayName;
string NewDisplayName = String.IsNullOrEmpty(AssignedUserName) ? Globals.UnassignedDisplayText : AssignedDisplayName;
issueChanges.Add(new IssueHistory(_Id, Security.GetUserName(), "Assigned to", OldDisplayName, NewDisplayName));
}
if (orgIssue.OwnerUserName != OwnerUserName)
issueChanges.Add(new IssueHistory(_Id, Security.GetUserName(), "Owner", orgIssue.OwnerDisplayName, OwnerDisplayName));
if (orgIssue.Estimation != Estimation)
issueChanges.Add(new IssueHistory(_Id, Security.GetUserName(), "Estimation", EstimationToString(orgIssue.Estimation), EstimationToString(Estimation)));
if(orgIssue.Visibility != Visibility)
issueChanges.Add(new IssueHistory(_Id, Security.GetUserName(), "Visibility", orgIssue.Visibility == 0 ? Boolean.FalseString : Boolean.TrueString, Visibility == 0 ? Boolean.FalseString : Boolean.TrueString));
if (orgIssue.DueDate != DueDate)
issueChanges.Add(new IssueHistory(_Id, Security.GetUserName(), "Due Date", orgIssue.DueDate == DateTime.MinValue ? string.Empty : orgIssue.DueDate.ToShortDateString(), DueDate.ToShortDateString()));
if (orgIssue.Progress != Progress)
issueChanges.Add(new IssueHistory(_Id, Security.GetUserName(), "Percent complete", string.Format("{0}%",orgIssue.Progress),string.Format("{0}%",Progress)));
}
else
{
throw new Exception("Unable to retrieve original issue data");
}
return issueChanges;
}
#endregion
#region Static Methods
/// <summary>
/// Gets the issue by id.
/// </summary>
/// <param name="issueId">The issue id.</param>
/// <returns></returns>
public static Issue GetIssueById(int issueId)
{
if (issueId <= DefaultValues.GetIssueIdMinValue())
throw (new ArgumentOutOfRangeException("issueId"));
return (DataProviderManager.Provider.GetIssueById(issueId));
}
/// <summary>
/// Gets the bugs by project id.
/// </summary>
/// <param name="projectId">The project id.</param>
/// <returns></returns>
public static List<Issue> GetIssuesByProjectId(int projectId)
{
if (projectId <= DefaultValues.GetProjectIdMinValue())
throw (new ArgumentOutOfRangeException("projectId"));
return (DataProviderManager.Provider.GetIssuesByProjectId(projectId));
}
/// <summary>
/// Gets the bug status count by project.
/// </summary>
/// <param name="projectId">The project id.</param>
/// <returns></returns>
public static List<IssueCount> GetIssueStatusCountByProject(int projectId)
{
if (projectId <= DefaultValues.GetProjectIdMinValue())
throw (new ArgumentOutOfRangeException("projectId"));
return DataProviderManager.Provider.GetIssueStatusCountByProject(projectId);
}
/// <summary>
/// Gets the bug version count by project.
/// </summary>
/// <param name="projectId">The project id.</param>
/// <returns></returns>
public static List<IssueCount> GetIssueMilestoneCountByProject(int projectId)
{
if (projectId <= DefaultValues.GetProjectIdMinValue())
throw (new ArgumentOutOfRangeException("projectId"));
return DataProviderManager.Provider.GetIssueMilestoneCountByProject(projectId);
}
/// <summary>
/// Gets the bug priority count by project.
/// </summary>
/// <param name="projectId">The project id.</param>
/// <returns></returns>
public static List<IssueCount> GetIssuePriorityCountByProject(int projectId)
{
if (projectId <= DefaultValues.GetProjectIdMinValue())
throw (new ArgumentOutOfRangeException("projectId"));
return DataProviderManager.Provider.GetIssuePriorityCountByProject(projectId);
}
/// <summary>
/// Gets the bug user count by project.
/// </summary>
/// <param name="projectId">The project id.</param>
/// <returns></returns>
public static List<IssueCount> GetIssueUserCountByProject(int projectId)
{
if (projectId <= DefaultValues.GetProjectIdMinValue())
throw (new ArgumentOutOfRangeException("projectId"));
return DataProviderManager.Provider.GetIssueUserCountByProject(projectId);
}
/// <summary>
/// Gets the issue unassigned count by project.
/// </summary>
/// <param name="projectId">The project id.</param>
/// <returns></returns>
public static int GetIssueUnassignedCountByProject(int projectId)
{
if (projectId <= DefaultValues.GetProjectIdMinValue())
throw (new ArgumentOutOfRangeException("projectId"));
return DataProviderManager.Provider.GetIssueUnassignedCountByProject(projectId);
}
/// <summary>
/// Gets the issue unscheduled milestone count by project.
/// </summary>
/// <param name="projectId">The project id.</param>
/// <returns></returns>
public static int GetIssueUnscheduledMilestoneCountByProject(int projectId)
{
if (projectId <= DefaultValues.GetProjectIdMinValue())
throw (new ArgumentOutOfRangeException("projectId"));
return DataProviderManager.Provider.GetIssueUnscheduledMilestoneCountByProject(projectId);
}
/// <summary>
/// Gets the bug type count by project.
/// </summary>
/// <param name="projectId">The project id.</param>
/// <returns></returns>
public static List<IssueCount> GetIssueTypeCountByProject(int projectId)
{
if (projectId <= DefaultValues.GetProjectIdMinValue())
throw (new ArgumentOutOfRangeException("projectId"));
return DataProviderManager.Provider.GetIssueTypeCountByProject(projectId);
}
/// <summary>
/// Gets the issue count by project and category.
/// </summary>
/// <param name="projectId">The project id.</param>
/// <param name="categoryId">The category id.</param>
/// <returns></returns>
public static int GetIssueCountByProjectAndCategory(int projectId,int categoryId)
{
if (projectId <= DefaultValues.GetProjectIdMinValue())
throw (new ArgumentOutOfRangeException("projectId"));
return DataProviderManager.Provider.GetIssueCountByProjectAndCategory(projectId,categoryId);
}
/// <summary>
/// Gets the bugs by criteria.
/// </summary>
/// <param name="projectId">The project id.</param>
/// <param name="componentId">The component id.</param>
/// <param name="versionId">The version id.</param>
/// <param name="IssueTypeId">The type id.</param>
/// <param name="priorityId">The priority id.</param>
/// <param name="statusId">The status id.</param>
/// <param name="AssignedToUserName">Name of the assigned to user.</param>
/// <param name="resolutionId">The resolution id.</param>
/// <param name="keywords">The keywords.</param>
/// <param name="excludeClosed">if set to <c>true</c> [exclude closed].</param>
/// <returns></returns>
public static List<Issue> GetIssuesByCriteria(int projectId,int componentId,int versionId,int IssueTypeId,
int priorityId,int statusId,string AssignedToUserName,
int resolutionId,string keywords,bool excludeClosed)
{
return Issue.GetIssuesByCriteria(projectId, componentId, versionId, IssueTypeId,
priorityId, statusId, AssignedToUserName,
resolutionId, keywords, excludeClosed, string.Empty,-1);
}
/// <summary>
/// Gets the bugs by criteria.
/// </summary>
/// <param name="projectId">The project id.</param>
/// <param name="componentId">The component id.</param>
/// <param name="versionId">The version id.</param>
/// <param name="IssueTypeId">The type id.</param>
/// <param name="priorityId">The priority id.</param>
/// <param name="statusId">The status id.</param>
/// <param name="AssignedToUserName">Name of the assigned to user.</param>
/// <param name="resolutionId">The resolution id.</param>
/// <param name="keywords">The keywords.</param>
/// <param name="excludeClosed">if set to <c>true</c> [exclude closed].</param>
/// <param name="reporterUserName">Name of the reporter user.</param>
/// <param name="fixedInVersionId">The fixed in version id.</param>
/// <returns></returns>
public static List<Issue> GetIssuesByCriteria(int projectId, int componentId, int versionId, int IssueTypeId,
int priorityId, int statusId, string AssignedToUserName,
int resolutionId, string keywords, bool excludeClosed,string reporterUserName, int fixedInVersionId)
{
throw new NotImplementedException();
//return DataProviderManager.Provider.GetIssuesByCriteria(projectId, componentId, versionId, IssueTypeId,
// priorityId, statusId, AssignedToUserName, resolutionId, keywords, excludeClosed,reporterUserName,fixedInVersionId);
}
/// <summary>
/// Gets the monitored bugs by user.
/// </summary>
/// <param name="userName">Name of the user.</param>
/// <returns></returns>
public static List<Issue> GetMonitoredIssuesByUser(string userName)
{
if (string.IsNullOrEmpty(userName))
throw (new ArgumentOutOfRangeException("userName"));
throw new NotImplementedException();
//return DataProviderManager.Provider.GetMonitoredIssuesByUser(userName);
}
/// <summary>
/// Gets the recently added bugs by project id.
/// </summary>
/// <param name="projectId">The project id.</param>
/// <returns></returns>
public static List<Issue> GetRecentlyAddedIssuesByProjectId(int projectId)
{
if (projectId <= DefaultValues.GetProjectIdMinValue())
throw (new ArgumentOutOfRangeException("projectId"));
throw new NotImplementedException();
//return DataProviderManager.Provider.GetRecentlyAddedIssuesByProjectId(projectId);
}
/// <summary>
/// Deletes the issue
/// </summary>
/// <param name="issueId">The issue id.</param>
/// <returns></returns>
public static bool DeleteIssue(int issueId)
{
if (issueId <= DefaultValues.GetIssueIdMinValue())
throw (new ArgumentOutOfRangeException("issueId"));
return DataProviderManager.Provider.DeleteIssue(issueId); ;
}
/// <summary>
/// Gets the issues by assigned username.
/// </summary>
/// <param name="projectId">The project id.</param>
/// <param name="username">The username.</param>
/// <returns></returns>
public static List<Issue> GetIssuesByAssignedUserName(int projectId, string username)
{
if (projectId <= DefaultValues.GetProjectIdMinValue())
throw (new ArgumentOutOfRangeException("projectId"));
if (username == null || username.Length == 0)
throw (new ArgumentOutOfRangeException("username"));
return (DataProviderManager.Provider.GetIssuesByAssignedUserName(projectId, username));
}
/// <summary>
/// Gets the issues by creator username.
/// </summary>
/// <param name="projectId">The project id.</param>
/// <param name="username">The username.</param>
/// <returns></returns>
public static List<Issue> GetIssuesByCreatorUserName(int projectId, string username)
{
if (projectId <= DefaultValues.GetProjectIdMinValue())
throw (new ArgumentOutOfRangeException("projectId"));
if (username == null || username.Length == 0)
throw (new ArgumentOutOfRangeException("username"));
return (DataProviderManager.Provider.GetIssuesByCreatorUserName(projectId, username));
}
/// <summary>
/// Gets the issues by owner username.
/// </summary>
/// <param name="projectId">The project id.</param>
/// <param name="username">The username.</param>
/// <returns></returns>
public static List<Issue> GetIssuesByOwnerUserName(int projectId, string username)
{
if (projectId <= DefaultValues.GetProjectIdMinValue())
throw (new ArgumentOutOfRangeException("projectId"));
if (username == null || username.Length == 0)
throw (new ArgumentOutOfRangeException("username"));
return DataProviderManager.Provider.GetIssuesByOwnerUserName(projectId, username);
}
/// <summary>
/// Gets the issues by relevancy.
/// </summary>
/// <param name="projectId">The project id.</param>
/// <param name="username">The username.</param>
/// <returns></returns>
public static List<Issue> GetIssuesByRelevancy(int projectId, string username)
{
if (projectId <= DefaultValues.GetProjectIdMinValue())
throw (new ArgumentOutOfRangeException("projectId"));
if (username == null || username.Length == 0)
throw (new ArgumentOutOfRangeException("username"));
return (DataProviderManager.Provider.GetIssuesByRelevancy(projectId, username));
}
/// <summary>
/// Performs the query.
/// </summary>
/// <param name="projectId">The project id.</param>
/// <param name="queryClauses">The query clauses.</param>
/// <returns></returns>
public static List<Issue> PerformQuery(int projectId, List<QueryClause> queryClauses)
{
if (queryClauses.Count == 0)
throw new ArgumentOutOfRangeException("queryClauses");
return DataProviderManager.Provider.PerformQuery(projectId, queryClauses);
}
/// <summary>
/// Performs the saved query.
/// </summary>
/// <param name="projectId">The project id.</param>
/// <param name="queryId">The query id.</param>
/// <returns></returns>
public static List<Issue> PerformSavedQuery(int projectId, int queryId)
{
if (queryId <= DefaultValues.GetQueryIdMinValue())
throw (new ArgumentOutOfRangeException("queryId"));
return DataProviderManager.Provider.PerformSavedQuery(projectId, queryId);
}
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -