public int addEvent(string title) { Node temp = new Node(title); //add the event into list sorted by startTime if (eventList.Count != 0) { int j = 0; LinkedList<Node>.Enumerator e = eventList.GetEnumerator(); while (e.MoveNext() && j != 1) { trash1 = DateTime.Parse(temp.getStart()); trash2 = DateTime.Parse(e.Current.getStart()); if (trash1 <= trash2) { //check the end time if (!e.Current.checkRepeat(temp.getStart(), temp.getEnd())) { return -1; } //add to non-first and non-last point in list trash1 = DateTime.Parse(e.Current.getStart()); trash2 = DateTime.Parse(eventList.First.Value.getStart()); if (trash1 != trash2) { eventList.AddBefore(eventList.Find(e.Current), temp); return 1; } else { //add to first point in list eventList.AddFirst(temp); return 1; } } j = 1; } if (j != 1) { //add to end of list and check the end time if (!e.Current.checkRepeat(temp.getStart(), temp.getEnd())) { return -1; } eventList.AddLast(temp); return 1; } } eventList.AddFirst(temp); return 1; }
private string getExtra(Node temp) { if (temp.getType() == 1) { return temp.getHTML(); } if (temp.getType() == 2) { return temp.getGPS(); } if (temp.getType() == 3) { return temp.getPhone().ToString(); } if (temp.getType() == 0) { return "none"; } return "none"; }
public int addEvent(string istartTime, string iendTime, string title, int type, string extra, string detail) { DateTime startTime = DateTime.Parse(istartTime); DateTime endTime = DateTime.Parse(iendTime); //create event based on given data trash1 = new DateTime(1, 1, 1, 1, 1, 1); trash2 = new DateTime(9, 9, 9, 9, 9, 9); Node temp = new Node("EXAMPLE", trash1.ToString(), trash2.ToString()); if (detail == null && type == 0) { temp = new Node(title, startTime.ToString(), endTime.ToString()); } else if (type == 0) { temp = new Node(title, detail, startTime.ToString(), endTime.ToString()); } else if (detail == null) { temp = new Node(title, startTime.ToString(), endTime.ToString(), type, extra); } else { temp = new Node(title, detail, startTime.ToString(), endTime.ToString(), type, extra); } //add the event into list sorted by startTime if (eventList.Count != 0) { int j = 0; LinkedList<Node>.Enumerator e = eventList.GetEnumerator(); while (e.MoveNext() && j != 1) { trash1 = DateTime.Parse(temp.getStart()); trash2 = DateTime.Parse(e.Current.getStart()); if (trash1 <= trash2) { //check the end time if (!e.Current.checkRepeat(temp.getStart(), temp.getEnd())) { return -1; } //add to non-first and non-last point in list trash1 = DateTime.Parse(e.Current.getStart()); trash2 = DateTime.Parse(eventList.First.Value.getStart()); if (trash1 != trash2) { eventList.AddBefore(eventList.Find(e.Current), temp); return 1; } else { //add to first point in list eventList.AddFirst(temp); return 1; } } j = 1; } if (j == 1) { //add to end of list and check the end time if (!e.Current.checkRepeat(temp.getStart(), temp.getEnd())) { return -1; } eventList.AddLast(temp); return 1; } } else { eventList.AddFirst(temp); return 1; } return 1; }