public List <TaskDetails> convertStringIntoTaskDetails(List <String> ListOfCompletedEvents)
        {
            try
            {
                List <TaskDetails> listOfTasksInFile = new List <TaskDetails>();

                for (int j = 0; j < ListOfCompletedEvents.Count(); j++)
                {
                    String      line            = ListOfCompletedEvents[j];
                    int         i               = j + 1;
                    string[]    eventParameters = line.Split(';');
                    TaskDetails task            = new TaskDetails();
                    task.setEventname(eventParameters[0]);
                    task.setlocation(eventParameters[1]);
                    task.setStartDate(eventParameters[2]);
                    task.setEndDate(eventParameters[3]);
                    task.setStartTime(eventParameters[4]);
                    task.setEndTime(eventParameters[5]);
                    task.setDuration(eventParameters[6]);
                    task.setPriority(eventParameters[7]);
                    task.setReminder(eventParameters[8]);
                    task.setID(i.ToString());

                    listOfTasksInFile.Add(task);
                }
                return(listOfTasksInFile);
            }
            catch (Exception e)
            {
                StreamWriter loggingWriter = new StreamWriter("Logging.txt");
                loggingWriter.WriteLine(System.DateTime.Now + e.Message + "\n");
                loggingWriter.Close();
                return(null);
            }
        }
 public /*List<TaskDetails>  */ TaskDetails convertEventsIntoTaskdetails(/*List<Event> */ Event events)
 {
     try
     {
         List <TaskDetails> tasks   = new List <TaskDetails>();
         TaskDetails        taskObj = new TaskDetails();
         // for (int i = 0; i < events.Count(); i++)
         {
             string eventName = events.Event_Name;
             string sDate = events.Start.Trim();
             string eDate = events.End.Trim();
             string sTime = "null", eTime = "null";
             string location = "null";
             if (events.Event_Name.IndexOf("@") != -1)
             {
                 eventName = events.Event_Name.Split('@')[0];
                 location  = events.Event_Name.Split('@')[1];
             }
             if (events.Start.IndexOf(',') != -1)
             {
                 string[] start = events.Start.Split(',');
                 sDate = start[0].Trim();
                 sTime = start[1].Trim();
             }
             if (events.End.IndexOf(',') != -1)
             {
                 string[] end = events.End.Split(',');
                 eDate = end[0].Trim();
                 eTime = end[1].Trim();
             }
             taskObj.setEventname(eventName);
             taskObj.setlocation(location);
             taskObj.setStartDate(sDate);
             taskObj.setEndDate(eDate);
             taskObj.setStartTime(sTime);
             taskObj.setEndTime(eTime);
             taskObj.setPriority(events.Priority);
             taskObj.setReminder(events.Remind_Me_Before);
             taskObj.setID(events.Event_ID);
             tasks.Add(taskObj);
         }
         return(taskObj);
     }
     catch (Exception e)
     {
         StreamWriter loggingWriter = new StreamWriter("Logging.txt");
         loggingWriter.WriteLine(System.DateTime.Now + e.Message + "\n");
         loggingWriter.Close();
         return(null);
     }
 }
Exemple #3
0
        public List <TaskDetails> readFromFile()
        {
            // Create an instance of StreamReader to read from a file.
            // The using statement also closes the StreamReader.
            List <TaskDetails> listOfTasksInFile = new List <TaskDetails>();

            using (StreamReader sr = new StreamReader(filename))
            {
                Debug.Assert(sr != null);
                String line;
                int    i = 1;
                int    j = 1;
                // Read and display lines from the file until the end of
                // the file is reached.

                while ((line = sr.ReadLine()) != null)
                {
                    //Console.WriteLine(line);
                    if (!(line.Contains("*******")) && line.CompareTo("") != 0)
                    {
                        j++;
                        string[]    eventParameters = line.Split(';');
                        TaskDetails task            = new TaskDetails();
                        task.setEventname(eventParameters[0]);
                        task.setlocation(eventParameters[1]);
                        task.setStartDate(eventParameters[2]);
                        task.setEndDate(eventParameters[3]);
                        task.setStartTime(eventParameters[4]);
                        task.setEndTime(eventParameters[5]);
                        task.setDuration(eventParameters[6]);
                        task.setPriority(eventParameters[7]);
                        task.setReminder(eventParameters[8]);
                        task.setID(i.ToString());
                        i++;
                        listOfTasksInFile.Add(task);
                    }
                    else
                    {
                        listOfTasksInFile.RemoveRange(0, listOfTasksInFile.Count());
                    }
                }
                sr.Close();
            }
            return(listOfTasksInFile);
        }
        public List <TaskDetails> readFromFile()
        {
            List <TaskDetails> listOfTasksInFile = new List <TaskDetails>();

            using (StreamReader sr = new StreamReader(this.filename))
            {
                string line;
                int    i = 1;
                int    j = 1;
                while ((line = sr.ReadLine()) != null)
                {
                    if (!(line.Contains("*******") || (line.CompareTo("") == 0)))
                    {
                        j++;
                        string[]    eventParameters = line.Split(new char[] { ';' });
                        TaskDetails task            = new TaskDetails();
                        task.setEventname(eventParameters[0]);
                        task.setlocation(eventParameters[1]);
                        task.setStartDate(eventParameters[2]);
                        task.setEndDate(eventParameters[3]);
                        task.setStartTime(eventParameters[4]);
                        task.setEndTime(eventParameters[5]);
                        task.setDuration(eventParameters[6]);
                        task.setPriority(eventParameters[7]);
                        task.setReminder(eventParameters[8]);
                        task.setID(i.ToString());
                        i++;
                        listOfTasksInFile.Add(task);
                    }
                    else
                    {
                        listOfTasksInFile.RemoveRange(0, listOfTasksInFile.Count <TaskDetails>());
                    }
                }
                sr.Close();
            }
            return(listOfTasksInFile);
        }
Exemple #5
0
        public List <TaskDetails> convertStringIntoTaskDetails(List <string> ListOfCompletedEvents)
        {
            List <TaskDetails> listOfTasksInFile = new List <TaskDetails>();

            for (int j = 0; j < ListOfCompletedEvents.Count <string>(); j++)
            {
                string      line            = ListOfCompletedEvents[j];
                int         i               = j + 1;
                string[]    eventParameters = line.Split(new char[] { ';' });
                TaskDetails task            = new TaskDetails();
                task.setEventname(eventParameters[0]);
                task.setlocation(eventParameters[1]);
                task.setStartDate(eventParameters[2]);
                task.setEndDate(eventParameters[3]);
                task.setStartTime(eventParameters[4]);
                task.setEndTime(eventParameters[5]);
                task.setDuration(eventParameters[6]);
                task.setPriority(eventParameters[7]);
                task.setReminder(eventParameters[8]);
                task.setID(i.ToString());
                listOfTasksInFile.Add(task);
            }
            return(listOfTasksInFile);
        }