// this function return User object from the data layer. public static User getByEmail(string email) { UserD openedUser = DataLayerUser2.open(email); User returnedUser = null; if (openedUser != null) { returnedUser = new User(openedUser.getEmail(), openedUser.getPassword()); returnedUser.setIsLoggedIn(openedUser.isLoggedIn()); returnedUser.setNumberOfTasksAdded(openedUser.getNumOfTasksAdded()); //returnedUser.setBoardsCollection(openedUser.getExistingBoards()); LinkedList <BoardD> ListBoardD = DataLayerBoard2.Open(email); String boardsList = ""; foreach (BoardD boardD in ListBoardD) { Board b = new Board(email, boardD.getName()); b.setNumOfTasks(boardD.getNumberOfTasks()); b.open(email); myBoards.Add(b.getBoardName(), b); boardsList += "+" + boardD.getName(); } returnedUser.setBoardsCollection(boardsList); returnedUser.setCurrBoard(openedUser.getLastBoard()); } return(returnedUser); }
// this functins serialize and saves the user. public static Boolean save(string email, string password, Boolean logged_in, int numOfTasksAdded, string ExistingColumns) { UserD newUser = new UserD(email, password, logged_in, numOfTasksAdded, ExistingColumns); Stream myFileStream = File.Create("data." + email); BinaryFormatter serializes = new BinaryFormatter(); serializes.Serialize(myFileStream, newUser); myFileStream.Close(); return(true); }
// this functins deserialize and return the user. public static UserD open(string email) { if (File.Exists("data." + email)) { Stream myOtherFileStream = File.OpenRead("data." + email); BinaryFormatter deserializer = new BinaryFormatter(); UserD user = (UserD)deserializer.Deserialize(myOtherFileStream); myOtherFileStream.Close(); return(user); } Log.Warn("Failed to find user " + email + " in the database."); return(null); }
// this function return User object from the data layer. public static User getByEmail(string email) { UserD openedUser = DataLayerUser.open(email); User returnedUser = null; if (openedUser != null) { returnedUser = new User(openedUser.getEmail(), openedUser.getPassword()); returnedUser.setIsLoggedIn(openedUser.isLoggedIn()); returnedUser.setNumberOfTasksAdded(openedUser.getNumOfTasksAdded()); } return(returnedUser); }