コード例 #1
0
        // this functins serialize and saves the task.
        public static void save(string title, string description, int status, string dueDate, string author, int taskID)
        {
            Log.Info("Saving task #" + taskID + ". Title: " + title);
            TaskD           taskToSave   = new TaskD(title, description, status, dueDate, author, taskID);
            Stream          myFileStream = File.Create("Task" + author + taskID);
            BinaryFormatter serializes   = new BinaryFormatter();

            serializes.Serialize(myFileStream, taskToSave);
            myFileStream.Close();
        }
コード例 #2
0
 // this function deserialize and return task
 public static TaskD Open(int taskID, string author)
 {
     if (File.Exists("Task" + author + taskID))
     {
         Stream          myOtherFileStream = File.OpenRead("Task" + author + taskID);
         BinaryFormatter deserializer      = new BinaryFormatter();
         TaskD           taskToOpen        = (TaskD)deserializer.Deserialize(myOtherFileStream);
         myOtherFileStream.Close();
         return(taskToOpen);
     }
     Log.Warn("Failed to find task #" + taskID + " in the database.");
     return(null);
 }
コード例 #3
0
        // 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);
        }