// this function checks if the current user is already registerd if not save the user to the data. public InfoObject register() { InfoObject info; if (DataLayerUser2.open(getEmail()) == null) { this.lastBoardClosed = new Board(email, "Main"); myBoards.Add("Main", this.lastBoardClosed); this.boardsCollection = lastBoardClosed.getBoardName(); save(); addColumn(getEmail(), "Backlog"); addColumn(getEmail(), "In progress"); addColumn(getEmail(), "Done"); lastBoardClosed.save(); Log.Info("The user " + getEmail() + " registered."); info = new InfoObject(true, "The user " + getEmail() + " registered."); return(info); } else { Log.Info("The user " + getEmail() + " can't register because this email is already in use."); info = new InfoObject(false, "The user " + getEmail() + " can't register because this email is already in use."); return(info); } }
//this function removing a column from the board public InfoObject removeColumn(String email, String columnName) { InfoObject info; for (int i = 1; i <= columnsHashTable.Count; i = i + 1) { Column column = (Column)columnsHashTable[i]; if (column.getName() == columnName) { if (column.isPossibleToRemove().getIsSucceeded()) { Log.Info("column #" + i + " has been removed"); info = new InfoObject(true, "column #" + i + " has been removed"); this.currColumnCount--; getColumns().Remove(i); updateColumnHash(i + 1, email); DataLayerColumn2.deleteColumn(email, columnName, boardName); return(info); } else { Log.Warn("column #" + i + " has not been removed"); info = new InfoObject(false, "column #" + i + " has not been removed"); return(info); } } } Log.Warn("column " + columnName + " can't be found"); info = new InfoObject(false, "column " + columnName + " can't be found"); return(info); }
//this function moves the colum one index forward public InfoObject moveColumn(int columnNumber, string email) { InfoObject info; if (columnNumber == getColumns().Count) { info = new InfoObject(false, "You can't move the last column"); Log.Error("You can't move the last column"); } else if (columnNumber > getColumns().Count) { info = new InfoObject(false, "You selected illegal column"); Log.Error("You selected illegal column"); } else { Column Forward = (Column)getColumns()[columnNumber]; Forward.setLocation(Forward.getLocation() + 1); DataLayerColumn2.save(Forward.getName(), Forward.getColumnMaxTasks(), email, Forward.getLocation(), boardName); Column Backwards = (Column)getColumns()[columnNumber + 1]; Backwards.setLocation(Backwards.getLocation() - 1); DataLayerColumn2.save(Backwards.getName(), Backwards.getColumnMaxTasks(), email, Backwards.getLocation(), boardName); Forward.updateTaskHash(columnNumber + 1); Backwards.updateTaskHash(columnNumber); getColumns().Remove(columnNumber); getColumns().Remove(columnNumber + 1); getColumns().Add(columnNumber, Backwards); getColumns().Add(columnNumber + 1, Forward); info = new InfoObject(true, "the column #" + columnNumber + " moved forward"); Log.Info("Column #" + columnNumber + " moved forward"); } return(info); }
// this function changes the maximum capacity of a coulmn by updatinig the Max_Tasks field in column class public InfoObject changeColumnCapacity(int columnNumber, int capacity) { InfoObject info; if (columnNumber <= columnsHashTable.Count) { Column column = (Column)columnsHashTable[columnNumber]; if (columnNumber != columnsHashTable.Count) { return(column.setMAX_TASKS(capacity)); } else { Log.Warn("Cant change Capacity of the last coulmn"); info = new InfoObject(false, "Cant change the capacity of the last column"); return(info); } } else { Log.Error("You're trying to change the capacity of an illegal column."); info = new InfoObject(false, "You're trying to change the capacity of an illegal column."); return(info); } }
// this function locate the right column and forward it to Coulmn class public InfoObject addTask(string title, string description, string author, string dueDate, int taskCounter) { Column column = (Column)columnsHashTable[1]; InfoObject info = column.addTask(title, description, dueDate, author, taskCounter); return(info); }
// this function moves the task from one column to another by removing it from it current column and adding it in the other // the add is done by Coulmn class. public InfoObject moveTask(int taskID, int status) { if (status < columnsHashTable.Count) { if (((Column)columnsHashTable[status]).isContainsKey(taskID)) { Task t = ((Column)columnsHashTable[status]).removeTask(taskID); InfoObject info = (((Column)columnsHashTable[status + 1]).addTask(t.getTitle(), t.getDescription(), t.getDueDate(), t.getAuthor(), t.getTaskUID())); if (info.getIsSucceeded()) { t.statusUpdate(); t.save(); Log.Info("Board moving task #" + taskID + " from column #" + status + " to next column."); info.setMessage("Board moving task #" + taskID + " from column #" + status + " to next column."); return(info); } else { info.setIsSucceeded(false); return(info); } } else { Log.Warn("Cant find Task #" + taskID + " to move from column #" + status); InfoObject info3 = new InfoObject(false, "Cant find Task #" + taskID + " to move from column #" + status); return(info3); } } Log.Error("You are not allowed to move task #" + taskID + " because it's in column #" + status); InfoObject info2 = new InfoObject(false, "You are not allowed to move task #" + taskID + " because it's in column #" + status); return(info2); }
//this function moves the colum one index forward public InfoObject moveColumn(int columnNumber) { InfoObject info; if (columnNumber == getColumns().Count) { info = new InfoObject(false, "You can't move the last column"); Log.Error("You can't move the last column"); } else if (columnNumber > getColumns().Count) { info = new InfoObject(false, "You selected illegal column"); Log.Error("You selected illegal column"); } else { Column Forward = (Column)getColumns()[columnNumber]; Column Backwards = (Column)getColumns()[columnNumber + 1]; Forward.updateTaskHash(columnNumber + 1); Backwards.updateTaskHash(columnNumber); getColumns().Remove(columnNumber); getColumns().Remove(columnNumber + 1); getColumns().Add(columnNumber, Backwards); getColumns().Add(columnNumber + 1, Forward); info = new InfoObject(true, "the column #" + columnNumber + " moved forward"); Log.Info("Column #" + columnNumber + " moved forward"); } return(info); }
//this function remove board public InfoObject removeBoard(String boardName) { InfoObject info = null; if (boardName.Equals(lastBoardClosed.getBoardName())) { info = new InfoObject(false, "Can't remove the board you are working on currently"); Log.Error("Board " + boardName + " hasn't been removed beacuse the user currently work on"); } else { if (getBoards()[boardName] != null) { getBoards().Remove(boardName); DataLayerBoard2.deleteBoard(boardName, getEmail(), 0); Log.Info("Board " + boardName + " has been removed"); info = new InfoObject(true, "Board " + boardName + " has been removed"); } else { info = new InfoObject(false, "Couldn't find the board to remove"); Log.Error("Board " + boardName + " hasn't been removed beacuse it's cant be found"); } } return(info); }
public InfoObject moveColumn(int columnNumber) { InfoObject info = this.lastBoardClosed.moveColumn(columnNumber, getEmail()); if (info.getIsSucceeded()) { save(); } return(info); }
// this function forward the input to Board class to remove coulmn. public InfoObject removeColumn(string email, string columnName) { InfoObject info = this.lastBoardClosed.removeColumn(email, columnName); if (info.getIsSucceeded()) { save(); } return(info); }
// this function forward the input to Board class to add new coulmn. public InfoObject addColumn(string author, string columnName) { InfoObject info = this.lastBoardClosed.addColumn(author, columnName); if (info.getIsSucceeded()) { save(); } return(info); }
// this function update the logged_in field to false public InfoObject logout() { InfoObject info; logged_in = false; save(); Log.Info("The user " + getEmail() + " logged out."); info = new InfoObject(true, "The user " + getEmail() + " logged out."); return(info); }
// this function update the logged_in field to true and forward to Board class to open all the tasks. public InfoObject login() { InfoObject info; logged_in = true; save(); Log.Info("The user " + getEmail() + " logged in. "); info = new InfoObject(true, "The user " + getEmail() + " logged in. "); return(info); }
// this function update the logged_in field to true and forward to Board class to open all the tasks. public InfoObject login() { InfoObject info; logged_in = true; setNumberOfTasksAdded(myBoard.open(getEmail())); save(); Log.Info("The user " + getEmail() + " logged in. "); info = new InfoObject(true, "The user " + getEmail() + " logged in. "); return(info); }
// this function forward the input to Board class to add new coulmn. public InfoObject addColumn(string author, string columnName) { InfoObject info = myBoard.addColumn(author, columnName); if (info.getIsSucceeded()) { ExistingColumns = ExistingColumns + "+" + columnName; save(); } return(info); }
// this function checks if the current user is logged in and if he is forwards to Board class. public InfoObject editTaskDescreption(int taskId, int status, string newDescreption) { if (isLoggedIn()) { return(this.lastBoardClosed.editTaskDescreption(taskId, status, newDescreption)); } else { Log.Error("You are not allowed to edit task description, please log in first."); InfoObject info = new InfoObject(false, "You are not allowed to edit task title, please log in first."); return(info); } }
// this function locate the right column and forward it to Coulmn class public InfoObject editTaskTitle(int taskID, int status, string newTitle) { if (status < columnsHashTable.Count) { return(((Column)columnsHashTable[status]).editTaskTitle(taskID, newTitle)); } else { Log.Error("Illegal input of task status. Unable to edit task title."); InfoObject info = new InfoObject(false, "Illegal input of task status. Unable to edit task title."); return(info); } }
// this function locate the right column and forward it to Coulmn class public InfoObject editTaskDescreption(int taskID, int status, string newDescreption) { if (status < columnsHashTable.Count) { return(((Column)columnsHashTable[status]).editDescreption(taskID, newDescreption)); } else { Log.Error("Illegal input of task status. Unable to edit task description."); InfoObject info = new InfoObject(false, "Illegal input of task status. Unable to edit description."); return(info); } }
// this function checks if the current user is logged in and if he is forwards to Board class. public InfoObject editTaskDueDate(int taskId, int status, string newDueDate) { if (isLoggedIn()) { return(myBoard.editTaskDueDate(taskId, status, newDueDate)); } else { Log.Error("You are not allowed to edit task due date, please log in first."); InfoObject info = new InfoObject(false, "You are not allowed to edit task title, please log in first."); return(info); } }
// this function checks if the current user is logged in and if he is forwards it to Board class to move the task to next coulmn. public InfoObject moveTask(int taskId, int status) { if (isLoggedIn()) { return(this.myBoard.moveTask(taskId, status)); } else { Log.Error("You are not allowed to move a task, please log in first."); InfoObject info = new InfoObject(false, "You are not allowed to move a task, please log in first."); return(info); } }
// this function locate the right column and forward it to Coulmn class public InfoObject addTask(string title, string description, string author, string dueDate, int taskCounter) { Column column = (Column)columnsHashTable[1]; InfoObject info; if (column != null) { info = column.addTask(title, description, dueDate, author, taskCounter); } else { info = new InfoObject(false, "there are no columns. Please add column before you add new task."); } return(info); }
public InfoObject moveColumn(int columnNumber) { InfoObject info = myBoard.moveColumn(columnNumber); if (info.getIsSucceeded()) { string moveItForward = myBoard.columnIntToName(columnNumber + 1); string moveItBackwards = myBoard.columnIntToName(columnNumber); string[] split = getExistingColumns().Split('+'); string[] cleanString = new string[split.Length]; for (int k = 0; k < cleanString.Length; k = k + 1) { cleanString[k] = ""; } string newExistingColumns = ""; int i = 0; foreach (string s in split) { if (!s.Equals("")) { cleanString[i] = s; i = i + 1; } } for (int j = 0; j < i; j = j + 1) { if (cleanString[j].Equals(moveItForward)) { string temp = cleanString[j]; cleanString[j] = cleanString[j + 1]; cleanString[j + 1] = temp; j = j + 1; } } for (int j = 0; j < cleanString.Length; j = j + 1) { if (!cleanString[j].Equals("")) { newExistingColumns = newExistingColumns + "+" + cleanString[j]; } } setExistingColumns(newExistingColumns); } save(); return(info); }
//this function checks if this column can be removed public InfoObject isPossibleToRemove() { InfoObject info; if (getCurrentTaskCount() > 0) { Log.Warn("The capacity of column " + COLUMN_NAME + " is " + getCurrentTaskCount() + "and therefor it can't be removed"); info = new InfoObject(false, "The capacity of column " + COLUMN_NAME + " is " + getCurrentTaskCount() + "and therefor it can't be removed"); return(info); } else { Log.Info("column " + COLUMN_NAME + "can be removed"); info = new InfoObject(true, "column " + COLUMN_NAME + "can be removed"); return(info); } }
// this function sets the MAX_TASKS field public InfoObject setMAX_TASKS(int newMAX_TASKS) { InfoObject info; if (getCurrentTaskCount() > newMAX_TASKS) { Log.Warn("The capacity of column #" + newMAX_TASKS + " cant be changed to: " + newMAX_TASKS + ", beacuse there are more tasks than the new capacity number"); info = new InfoObject(false, "The capacity of column #" + newMAX_TASKS + " cant be changed to: " + newMAX_TASKS + ", beacuse there are more tasks than the new capacity number"); return(info); } else { this.MAX_TASKS = newMAX_TASKS; Log.Info("The capacity of column " + COLUMN_NAME + " changed to: " + newMAX_TASKS); info = new InfoObject(true, "The capacity of column " + COLUMN_NAME + " changed to: " + newMAX_TASKS); return(info); } }
// this function checks if the current user is already registerd if not save the user to the data. public InfoObject register() { InfoObject info; if (DataLayerUser.open(getEmail()) == null) { save(); Log.Info("The user " + getEmail() + " registered."); info = new InfoObject(true, "The user " + getEmail() + " registered."); return(info); } else { Log.Info("The user " + getEmail() + " can't register because this email is already in use."); info = new InfoObject(false, "The user " + getEmail() + " can't register because this email is already in use."); return(info); } }
// this function create a new coulmn and adds it to the Hash table that containes all the columns. public InfoObject addColumn(string name) { InfoObject info; if (name != null) { columnsHashTable.Add(columnsHashTable.Count + 1, new Column(name)); this.currColumnCount++; Log.Info("A new Column named " + name + " added. The new column saved as column #" + this.currColumnCount); info = new InfoObject(true, "A new Column named " + name + " added. The new column saved as column number #" + this.currColumnCount); return(info); } else { Log.Warn("The input name is null"); info = new InfoObject(false, "The input name is null"); return(info); } }
// this function sets the MAX_TASKS field public InfoObject setMAX_TASKS(string author, int newMAX_TASKS) { InfoObject info; if (getCurrentTaskCount() > newMAX_TASKS) { Log.Warn("The capacity of column " + getName() + " cant be changed to: " + newMAX_TASKS + ", beacuse there are more tasks than the new capacity number"); info = new InfoObject(false, "The capacity of column " + getName() + " cant be changed to: " + newMAX_TASKS + ", beacuse there are more tasks than the new capacity number"); return(info); } else { this.MAX_TASKS = newMAX_TASKS; DataLayerColumn.save(getName(), newMAX_TASKS, author, "" + getName() + "." + newMAX_TASKS); Log.Info("The capacity of column " + COLUMN_NAME + " changed to: " + newMAX_TASKS); info = new InfoObject(true, "The capacity of column " + COLUMN_NAME + " changed to: " + newMAX_TASKS); return(info); } }
// this function adds new task to the backlog column. public InfoObject addTask(string title, string description, string dueDate, string author, int taskCounter) { InfoObject info; if (this.numOfTaskInCoulmn == MAX_TASKS) { Log.Error("Column " + getName() + " reached its maximum capacity."); info = new InfoObject(false, "Column " + getName() + " reached its maximum capacity."); } else { Task newTask = new Task(title, description, dueDate, author, taskCounter); newTask.save(); taskHash.Add(taskCounter, newTask); numOfTaskInCoulmn++; info = new InfoObject(true, ""); } return(info); }
// this function forwards the inputs to Task class to edit the due date public InfoObject editDueDate(int taskId, string newDueDate) { InfoObject info; Task t = (Task)taskHash[taskId]; if (t != null) { t.dueDateEdit(newDueDate); t.save(); Log.Info("The due date of task #" + taskId + " has been updated."); info = new InfoObject(true, "The due date of task #" + taskId + " has been updated."); return(info); } else { Log.Warn("The due date of task #" + taskId + " has not been updated beacuse there is not task like this"); info = new InfoObject(false, "Can't find task#" + taskId); return(info); } }
// this function locate the right column and forward it to Coulmn class public InfoObject addTask(string title, string description, string author, string dueDate) { Column column = (Column)columnsHashTable[1]; InfoObject info; if (column != null) { info = column.addTask(title, description, dueDate, author, getNumOfTasks()); if (info.getIsSucceeded()) { this.numberOfTasks = numberOfTasks + 1; save(); } } else { info = new InfoObject(false, "there are no columns. Please add column before you add new task."); } return(info); }