// bts - The Bug Tracking System
// Copyright (C) 2004 - Eugene Konkov
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
using System;
using System.Collections;
using System.Text;
using System.Globalization;
namespace ekon.bts.BackEnd{
#region Helper data types
/// <summary>
/// Contains all information about user
/// </summary>
/// <remarks>Not of all fields will fill (ex. Password)</remarks>
public struct UserInfo
{
public bool IsAdmin;
public bool IsTester;
public bool IsDeveloper;
public string FullName;
public string Login;
public string Password;
public string Memo;
public System.Int32 ID;
public override string ToString()
{
return Login+" - "+FullName;
}
}
/// <summary>
/// Contains all information about one project
/// </summary>
public struct ProjectInfo
{
public string Title;
public string Description;
public System.Int32 ID;
public override string ToString()
{
return Title;
}
}
/// <summary>
/// Status of issue
/// Must be reference-based type!!
/// </summary>
public class Status
{
public string Title;
public string Description;
public System.Int32 ID;
public override string ToString()
{
return Title;
}
}
/// <summary>
/// One issue
/// </summary>
public struct Issue
{
public System.Int32 ID;
public System.Int32 PersonID;
public System.Int32 BugID;
public System.Int32 StatusID;
public System.DateTime Date;
public string Message;
public override string ToString()
{
StringBuilder sbTimeStamp=new StringBuilder();
sbTimeStamp.AppendFormat("{0} {1}",Date.ToString("dd.MM.yyyy",DateTimeFormatInfo.InvariantInfo),Date.ToString("T",DateTimeFormatInfo.InvariantInfo));
StringBuilder sb=new StringBuilder();
sb.AppendFormat("BugID [{0}]\tStatus [{1}]\tMessage posted at\t{2}",BugID,StatusTitle,sbTimeStamp.ToString());
sb.AppendFormat("\t From: {0}",FromLogin);
return sb.ToString();
}
public string StatusTitle;
public string FromLogin;
}
/// <summary>
/// A bug
/// </summary>
public struct Bug
{
public System.Int32 ID;
public System.DateTime Date;
public System.Int32 PersonID;
public System.Int32 ProjectID;
public System.Int16 Priority;
public override string ToString()
{
StringBuilder sb=new StringBuilder();
sb.AppendFormat("BugID [{0}] - {1} {2}",ID,Date.ToString("dd.MM.yyyy",DateTimeFormatInfo.InvariantInfo),Date.ToString("T",DateTimeFormatInfo.InvariantInfo));
return sb.ToString();
}
}
#endregion
#region exceptions
/// <summary>
/// Exception for password is not corresponding to login.
/// </summary>
public class InvalidPasswordException : System.ApplicationException
{
}
#endregion
#region IBugTrackDb interface
/// <summary>
/// Interface for operations with bug track database
/// </summary>
public interface IBugTrackDB
{
/// <summary>
/// Retrieve from database all logins
/// </summary>
/// <returns>ArrayList contains logins from db as strings</returns>
ArrayList GetLogins();
/// <summary>
/// Retrieve from database all project titles
/// </summary>
/// <returns>ArrayList of ProjectInfo</returns>
ArrayList GetProjects();
/// <summary>
/// Get all projects for given user
/// </summary>
/// <param name="user">given user</param>
/// <returns>ArrayList of ProjectInfo</returns>
ArrayList GetProjects(UserInfo user);
/// <summary>
/// Check password validity
/// </summary>
/// <param name="login">Login</param>
/// <param name="password">Password</param>
/// <returns>Is password valid</returns>
bool IsValidPassword(string login, string password);
/// <summary>
/// Retrives all user info.
/// </summary>
/// <param name="login">Login</param>
/// <param name="password">Password for specified login</param>
/// <returns>an instance of UserInfo structure properly filled.</returns>
///If password not correspond to login <exception cref="InvalidPasswordException">InvalidPasswordException</exception> will throw
UserInfo GetUserInfo(string login, string password);
/// <summary>
/// Retrives all user info except password.
/// </summary>
/// <param name="login">Login</param>
/// <returns>an instance of UserInfo structure properly filled without password.</returns>
UserInfo GetUserInfo(string login);
/// <summary>
/// Retrives all user info except password.
/// </summary>
/// <param name="login">Login</param>
/// <returns>an instance of UserInfo structure properly filled without password.</returns>
/// <summary>
/// Retrives all user info except password.
/// </summary>
/// <param name="UserID">Unique ID of person (user)</param>
/// <returns>an instance of UserInfo structure properly filled without password.</returns>
UserInfo GetUserInfo(System.Int32 UserID);
/// <summary>
/// Retrives all users from database
/// </summary>
/// <returns>ArrayList of UserInfo</returns>
ArrayList GetUsers();
/// <summary>
/// Retrives user info for users who assigned with specified project
/// </summary>
/// <param name="project"></param>
/// <returns>ArrayList of UserInfo</returns>
ArrayList GetAssignedUsers(ProjectInfo project);
/// <summary>
/// Add project to database
/// </summary>
/// <param name="project">Project to add</param>
void AddProject(ProjectInfo project);
/// <summary>
/// Add user to database
/// </summary>
/// <param name="user">user to add</param>
void AddUser(UserInfo user);
/// <summary>
/// Update user in database
/// </summary>
/// <param name="user">User to update. Identification by ID member.</param>
void UpdateUser(UserInfo user);
/// <summary>
/// Update project in database
/// </summary>
/// <param name="project">Project to update. Identification by ID member.</param>
void UpdateProject(ProjectInfo project);
/// <summary>
/// Update relations between project and list of users
/// </summary>
/// <param name="project">The project</param>
/// <param name="users">List of users (UserInfo instances).</param>
void UpdateXUserProject(ProjectInfo project, ArrayList users);
/// <summary>
/// Get possible statuses for given user, project and prev. status
/// Checks rights for given user in given project.
/// </summary>
/// <param name="user">user for check</param>
/// <param name="project">project to proceed</param>
/// <param name="previous">previous status, if null - for new bug,
/// other cases - add message to existing bug</param>
/// <returns>ArrayList of Status</returns>
ArrayList GetPossibleStatuses(UserInfo user,ProjectInfo project, Status previous);
/// <summary>
/// Get all bugs associated with specified project
/// </summary>
/// <param name="project">project to proceed</param>
/// <returns>ArrayList of Bug</returns>
ArrayList GetAllBugs(ProjectInfo project);
/// <summary>
/// Get all bugs associated with specified project, introduced by specified user
/// </summary>
/// <param name="project">project to proceed</param>
/// <param name="user">who introduced</param>
/// <returns>ArrayList of Bug</returns>
ArrayList GetAllBugs(ProjectInfo project,UserInfo user);
/// <summary>
/// Get all issues (messages) for given bug
/// </summary>
/// <param name="givenbug">given bug</param>
/// <returns>ArrayList of Issue</returns>
ArrayList GetAllIssues(Bug givenbug);
/// <summary>
/// Add new bug
/// </summary>
/// <param name="new_bug">new bug</param>
/// <param name="initial_issue">first message from tester</param>
void AddBug(Bug new_bug, Issue initial_issue);
/// <summary>
/// add issue to existing bug
/// </summary>
/// <param name="exist_bug">existing bug</param>
/// <param name="new_issue">new issue</param>
void AddIssue(Bug exist_bug, Issue new_issue);
/// <summary>
/// Get status for given issue
/// </summary>
/// <param name="anIssue">given issue</param>
/// <returns>status</returns>
Status GetStatus(Issue anIssue);
}
#endregion
}
|