public LinkedList <MeetingNode> FindMeetingsByMeetingTitleKeywords(String keyword) { XElement meetings = XElement.Load(mfile); IEnumerable <XElement> meetingNodes = meetings.Elements(); List <MeetingNode> list = new List <MeetingNode>(); foreach (var meeting in meetingNodes) { if (meeting.Element("Meeting_Title").Value.Contains(keyword)) { MeetingNode currentNode = new MeetingNode(); currentNode.SetMeetingID(meeting.Attribute("ID").Value); currentNode.SetMeetingTitle(meeting.Element("Meeting_Title").Value); currentNode.SetStartTime(meeting.Element("Start_Time").Value); currentNode.SetEndTime(meeting.Element("End_Time").Value); currentNode.SetAttendents(meeting.Element("Attendents").Value); currentNode.SetFiles(meeting.Element("Files").Value); list.Add(currentNode); } } list.Sort((x, y) => y.GetStartTime().CompareTo(x.GetStartTime())); LinkedList <MeetingNode> n = new LinkedList <MeetingNode>(); foreach (MeetingNode item in list) { n.AddLast(item); } return(n); }
//for test main method public static void Main(string[] args) { /* * XMLProcessor x = new XMLProcessor(); * x.Read(); * foreach (FileNode node in x.fileList) * { * Console.WriteLine(node.GetFileName()); * } */ // Uri.IsWellFormedOriginalString(); LinkedList <MeetingNode> meetingList = new LinkedList <MeetingNode>(); LinkedList <FileNode> attachmentList = new LinkedList <FileNode>(); MeetingNode m1 = new MeetingNode(); m1.SetMeetingID("12345"); m1.SetMeetingTitle("ABC"); m1.SetStartTime("2017/04/03 13:13:15"); m1.SetEndTime("2017/04/04 13:13:15"); MeetingNode m2 = new MeetingNode(); m2.SetMeetingID("23456"); m2.SetMeetingTitle("BCD"); m2.SetStartTime("2017/04/07 13:13:15"); m2.SetEndTime("2017/04/08 13:13:15"); MeetingNode m3 = new MeetingNode(); m3.SetMeetingID("34567"); m3.SetMeetingTitle("CDE"); m3.SetStartTime("2017/04/08 13:13:15"); m3.SetEndTime("2017/04/09 13:13:15"); meetingList.AddLast(m1); meetingList.AddLast(m2); meetingList.AddLast(m3); FileNode f1 = new FileNode(); f1.SetFileName("f1a"); f1.AddMeetings("12345"); FileNode f2 = new FileNode(); f2.SetFileName("f2a"); f2.AddMeetings("34567"); FileNode f3 = new FileNode(); f3.SetFileName("f3a"); f3.AddMeetings("34567"); attachmentList.AddLast(f1); attachmentList.AddLast(f2); attachmentList.AddLast(f3); XMLProcessor x = new XMLProcessor(); x.ProcessFileWithMeetingList(meetingList, attachmentList); x.Write(); }
//-----------------------------------------Search Algorithm ------------------------------------------------ //------------------Read information from XML and return linked list of desired data ---------------------------- //find corresponding meeting nodes with a string of meeting IDs //previous condition: no repetitive meeting ids in the string public LinkedList <MeetingNode> FindMeetingsByMeetingIDs(String meetingIDs) { if (meetingIDs == "") { return(new LinkedList <MeetingNode>()); } String[] idList = meetingIDs.Split(';'); XElement meetings = XElement.Load(mfile); IEnumerable <XElement> meetingNodes = meetings.Elements(); List <MeetingNode> list = new List <MeetingNode>(); foreach (var meeting in meetingNodes) { String currentID = meeting.Attribute("ID").Value; Boolean inList = false; for (int i = 0; i < idList.Length && (!inList); i++) { if (currentID == idList[i]) { inList = true; } } if (inList) { MeetingNode currentNode = new MeetingNode(); currentNode.SetMeetingID(currentID); currentNode.SetMeetingTitle(meeting.Element("Meeting_Title").Value); currentNode.SetStartTime(meeting.Element("Start_Time").Value); currentNode.SetEndTime(meeting.Element("End_Time").Value); currentNode.SetAttendents(meeting.Element("Attendents").Value); currentNode.SetFiles(meeting.Element("Files").Value); list.Add(currentNode); } } list.Sort((x, y) => y.GetStartTime().CompareTo(x.GetStartTime())); LinkedList <MeetingNode> n = new LinkedList <MeetingNode>(); foreach (MeetingNode item in list) { n.AddLast(item); } return(n); }
public LinkedList <MeetingNode> FindMeetingsByMeetingPID(String meetingPID) { XElement meetings = XElement.Load(mfile); IEnumerable <XElement> meetingNodes = meetings.Elements(); LinkedList <MeetingNode> list = new LinkedList <MeetingNode>(); foreach (var meeting in meetingNodes) { if ((meeting.Element("Parent_ID").Value == meetingPID) || (meeting.Attribute("ID").Value == meetingPID)) { MeetingNode currentNode = new MeetingNode(); currentNode.SetMeetingID(meeting.Attribute("ID").Value); currentNode.SetMeetingTitle(meeting.Element("Meeting_Title").Value); currentNode.SetStartTime(meeting.Element("Start_Time").Value); currentNode.SetEndTime(meeting.Element("End_Time").Value); currentNode.SetAttendents(meeting.Element("Attendents").Value); currentNode.SetFiles(meeting.Element("Files").Value); list.AddLast(currentNode); } } return(list); }