// 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); } }
// constructor - this function construct new board with 3 defulat column (Backlog, In progress and Done) // board_ID initialized with the user email public Board(String email, String password) { columnsHashTable.Add(1, new Column("Backlog")); columnsHashTable.Add(2, new Column("In progress")); columnsHashTable.Add(3, new Column("Done")); if (DataLayerColumn.Open("Backlog", email) == null) { DataLayerColumn.save("Backlog", int.MaxValue, email, "Backlog"); } if (DataLayerColumn.Open("In progress", email) == null) { DataLayerColumn.save("In progress", int.MaxValue, email, "In progress"); } if (DataLayerColumn.Open("Done", email) == null) { DataLayerColumn.save("Done", int.MaxValue, email, "Done"); } this.currColumnCount = 3; this.boardID = email; }
// this function create a new coulmn and adds it to the Hash table that containes all the columns. public InfoObject addColumn(string author, string name) { InfoObject info; if (name != null) { Column column = new Column(name); columnsHashTable.Add(columnsHashTable.Count + 1, column); DataLayerColumn.save(name, int.MaxValue, author, 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 collet all the tasks from data and forward to the specific column they belong to. public int open(string author, string existingColumns) { int numberOfColumns = 1; columnsHashTable = new Hashtable(); this.currColumnCount = 0; string columnID; string[] splited = existingColumns.Split('+'); for (int i = 0; i < splited.Length; i = i + 1) { if (!splited[i].Equals("")) { columnID = splited[i]; ColumnD columnD = DataLayerColumn.Open(columnID, author); Column column = new Column(columnD.getName()); column.setMAX_TASKS(author, columnD.getMaxCapacity()); columnsHashTable.Add(numberOfColumns, column); this.currColumnCount = this.currColumnCount + 1; numberOfColumns = numberOfColumns + 1; Log.Info("Column " + column.getName() + " loaded successfully from the database."); } } int numberOfTasksAdded = 0; TaskD taskD = DataLayerTask.Open(numberOfTasksAdded, author); while (taskD != null) { Column column = (Column)columnsHashTable[taskD.getStatus()]; column.addTask(taskD.getTitle(), taskD.getDescription(), taskD.getStatus(), taskD.getDueDate(), taskD.getCreationTime(), taskD.getAuthor(), taskD.getTaskUID()); Log.Info("Task #" + numberOfTasksAdded + " loaded successfully from the database."); numberOfTasksAdded++; taskD = DataLayerTask.Open(numberOfTasksAdded, author); } return(numberOfTasksAdded); }
// this function changes the maximum capacity of a coulmn by updatinig the Max_Tasks field in column class public InfoObject changeColumnCapacity(string author, int columnNumber, int capacity) { InfoObject info; if (columnNumber <= columnsHashTable.Count) { Column column = (Column)columnsHashTable[columnNumber]; if (columnNumber != columnsHashTable.Count) { string name = column.getName(); info = column.setMAX_TASKS(author, capacity); if (info.getIsSucceeded()) { DataLayerColumn.save(name, capacity, author, name); return(info); } else { return(info); } } 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); } }