From b9e0999c38b75c820965651f86f490cc925686e9 Mon Sep 17 00:00:00 2001 From: "Valeriano A.R" Date: Sat, 20 Jun 2015 10:56:39 +0200 Subject: [PATCH] Cards: Mark user name of the actions, for auditing purporses. --- Scrummer/Code/BusinessLogic/CardBoard.cs | 42 ++++++++++++++++++------ Scrummer/Code/Entities/Card.cs | 4 +++ Scrummer/Controls/CardBoardHandler.cs | 10 +++--- 3 files changed, 42 insertions(+), 14 deletions(-) diff --git a/Scrummer/Code/BusinessLogic/CardBoard.cs b/Scrummer/Code/BusinessLogic/CardBoard.cs index e004546..a1f7be4 100644 --- a/Scrummer/Code/BusinessLogic/CardBoard.cs +++ b/Scrummer/Code/BusinessLogic/CardBoard.cs @@ -34,7 +34,15 @@ namespace Scrummer.Code.BusinessLogic public List Cards_Status() { - return _cards; + List activeCards=new List(); + foreach (Card card in _cards) + { + if (card.Active) + { + activeCards.Add(card); + } + } + return activeCards; } public List 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(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(String.Format(EventsPersistenceFile, _idBoard), diff --git a/Scrummer/Code/Entities/Card.cs b/Scrummer/Code/Entities/Card.cs index f2e31fd..878391f 100644 --- a/Scrummer/Code/Entities/Card.cs +++ b/Scrummer/Code/Entities/Card.cs @@ -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; } } } \ No newline at end of file diff --git a/Scrummer/Controls/CardBoardHandler.cs b/Scrummer/Controls/CardBoardHandler.cs index 6b8b711..5611799 100644 --- a/Scrummer/Controls/CardBoardHandler.cs +++ b/Scrummer/Controls/CardBoardHandler.cs @@ -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; } }