Cards: Mark user name of the actions, for auditing purporses.

This commit is contained in:
2015-06-20 10:56:39 +02:00
parent e77cf71998
commit b9e0999c38
3 changed files with 42 additions and 14 deletions

View File

@@ -34,7 +34,15 @@ namespace Scrummer.Code.BusinessLogic
public List<Card> Cards_Status()
{
return _cards;
List<Card> activeCards=new List<Card>();
foreach (Card card in _cards)
{
if (card.Active)
{
activeCards.Add(card);
}
}
return activeCards;
}
public List<ICardEvent> Cards_GetEventList(int idCardEvent)
@@ -62,7 +70,7 @@ namespace Scrummer.Code.BusinessLogic
return _lastIDCard;
}
public int Card_Create(string title, string body, int x, int y)
public int Card_Create(string title, string body, int x, int y, string currentUserName)
{
Card card;
lock (_cards)
@@ -76,6 +84,9 @@ namespace Scrummer.Code.BusinessLogic
Body = body,
X = x,
Y = y,
Active = true,
CreatedBy = currentUserName,
ModifiedBy = currentUserName,
};
_cards.Add(card);
@@ -85,6 +96,7 @@ namespace Scrummer.Code.BusinessLogic
{
IDCardEvent = _lastIDCardEvent,
IDCard = card.IDCard,
UserName = currentUserName,
Title = card.Title,
Body = card.Body,
X = card.X,
@@ -97,7 +109,7 @@ namespace Scrummer.Code.BusinessLogic
return card.IDCard;
}
public bool Card_Move(int idCard, int x, int y)
public bool Card_Move(int idCard, int x, int y, string currentUserName)
{
lock (_cards)
{
@@ -106,6 +118,7 @@ namespace Scrummer.Code.BusinessLogic
if (card == null) { return false; }
card.X = x;
card.Y = y;
card.ModifiedBy = currentUserName;
// Create event
_lastIDCardEvent++;
@@ -113,6 +126,7 @@ namespace Scrummer.Code.BusinessLogic
{
IDCardEvent = _lastIDCardEvent,
IDCard = card.IDCard,
UserName = currentUserName,
X = card.X,
Y = card.Y,
};
@@ -123,7 +137,7 @@ namespace Scrummer.Code.BusinessLogic
return true;
}
public bool Card_Edit(int idCard, string title, string body)
public bool Card_Edit(int idCard, string title, string body, string currentUserName)
{
lock (_cards)
{
@@ -132,6 +146,7 @@ namespace Scrummer.Code.BusinessLogic
if (card == null) { return false; }
card.Title = title;
card.Body = body;
card.ModifiedBy = currentUserName;
// Create event
_lastIDCardEvent++;
@@ -139,6 +154,7 @@ namespace Scrummer.Code.BusinessLogic
{
IDCardEvent = _lastIDCardEvent,
IDCard = card.IDCard,
UserName = currentUserName,
Title = card.Title,
Body = card.Body,
};
@@ -148,22 +164,24 @@ namespace Scrummer.Code.BusinessLogic
}
return true;
}
public bool Card_Delete(int idCard)
public bool Card_Delete(int idCard, string currentUserName)
{
lock (_cards)
{
// Delete card
Card card = GetByID(idCard);
if (card == null) { return false; }
_cards.Remove(card);
card.Active = false;
card.ModifiedBy = currentUserName;
// Create event
_lastIDCardEvent++;
CardDeleteEvent cardDeleteEvent = new CardDeleteEvent()
{
IDCardEvent = _lastIDCardEvent,
IDCard = card.IDCard,
UserName = currentUserName,
};
_cardEvents.Insert(0, cardDeleteEvent);
@@ -181,6 +199,7 @@ namespace Scrummer.Code.BusinessLogic
{
IDCardEvent = lastIDCardEvent,
IDCard = card.IDCard,
UserName = card.ModifiedBy,
Title = card.Title,
Body = card.Body,
X = card.X,
@@ -216,9 +235,12 @@ namespace Scrummer.Code.BusinessLogic
{
_cards = Persistence.LoadList<Card>(String.Format(CardsPersistenceFile, _idBoard));
_lastIDCard = 0;
if (_cards.Count > 0)
foreach (Card card in _cards)
{
_lastIDCard = _cards[0].IDCard;
if (card.IDCard > _lastIDCard)
{
_lastIDCard = card.IDCard;
}
}
_cardEvents = Persistence.LoadList<ICardEvent>(String.Format(EventsPersistenceFile, _idBoard),

View File

@@ -14,5 +14,9 @@ namespace Scrummer.Code.Entities
public int X { get; set; }
public int Y { get; set; }
public bool Active { get; set; }
public string CreatedBy { get; set; }
public string ModifiedBy { get; set; }
}
}

View File

@@ -136,6 +136,8 @@ namespace Scrummer.Controls
private void ProcessEventSender(HttpContext context)
{
Session session = Sessions.Current.Session_GetCurrent(context);
string currentUserName = session.UserName;
string strIDBoard = GetRequestParm(context, "IDBoard");
int idBoard = Convert.ToInt32(string.IsNullOrEmpty(strIDBoard) ? "0" : strIDBoard);
string command = GetRequestParm(context, "Command");
@@ -150,7 +152,7 @@ namespace Scrummer.Controls
string body = GetRequestParm(context, "Body");
int x = Convert.ToInt32(GetRequestParm(context, "X"));
int y = Convert.ToInt32(GetRequestParm(context, "Y"));
idCard = cardBoard.Card_Create(title, body, x, y);
idCard = cardBoard.Card_Create(title, body, x, y, currentUserName);
done = true;
}
if (command == "Move")
@@ -158,7 +160,7 @@ namespace Scrummer.Controls
idCard = Convert.ToInt32(GetRequestParm(context, "IDCard"));
int x = Convert.ToInt32(GetRequestParm(context, "X"));
int y = Convert.ToInt32(GetRequestParm(context, "Y"));
cardBoard.Card_Move(idCard, x, y);
cardBoard.Card_Move(idCard, x, y, currentUserName);
done = true;
}
if (command == "Edit")
@@ -166,13 +168,13 @@ namespace Scrummer.Controls
idCard = Convert.ToInt32(GetRequestParm(context, "IDCard"));
string title = GetRequestParm(context, "Title");
string body = GetRequestParm(context, "Body");
cardBoard.Card_Edit(idCard, title, body);
cardBoard.Card_Edit(idCard, title, body, currentUserName);
done = true;
}
if (command == "Delete")
{
idCard = Convert.ToInt32(GetRequestParm(context, "IDCard"));
cardBoard.Card_Delete(idCard);
cardBoard.Card_Delete(idCard, currentUserName);
done = true;
}
}