コード例 #1
0
        //keyword should not be empty string
        public LinkedList <FileNode> FindFilesByFileNameKeywords(String keyword)
        {
            XElement               fileList  = XElement.Load(ffile);
            List <FileNode>        list      = new List <FileNode>();
            IEnumerable <XElement> fileNodes = fileList.Elements();

            foreach (var file in fileNodes)
            {
                if (file.Element("File_Name").Value.Contains(keyword))
                {
                    FileNode currentNode = new FileNode();
                    currentNode.SetFileID(file.Attribute("ID").Value);
                    currentNode.SetCreatedTime(file.Element("Created_Time").Value);
                    currentNode.SetModifiedTime(file.Element("Modified_Time").Value);
                    currentNode.SetExecuteTime(file.Element("Execute_Time").Value);
                    currentNode.SetFileName(file.Element("File_Name").Value);
                    currentNode.SetFilePath(file.Element("File_Path").Value);
                    currentNode.SetExtension(file.Element("Extension").Value);
                    currentNode.SetMeetings(file.Element("Meetings").Value);
                    currentNode.SetMissing(file.Element("Missing").Value);
                    list.Add(currentNode);
                }
            }
            list.Sort((x, y) => y.GetModifiedTime().CompareTo(x.GetModifiedTime()));
            LinkedList <FileNode> n = new LinkedList <FileNode>();

            foreach (FileNode item in list)
            {
                n.AddLast(item);
            }
            return(n);
        }
コード例 #2
0
        public LinkedList <FileNode> FindFilesByFileIDs(String fileIDs)
        {
            if (fileIDs == "")
            {
                return(new LinkedList <FileNode>());
            }
            String[]               idList    = fileIDs.Split(';');
            XElement               files     = XElement.Load(ffile);
            List <FileNode>        list      = new List <FileNode>();
            IEnumerable <XElement> fileNodes = files.Elements();

            foreach (var file in fileNodes)
            {
                String  currentID = file.Attribute("ID").Value;
                Boolean inList    = false;
                for (int i = 0; i < idList.Length && (!inList); i++)
                {
                    if (currentID == idList[i])
                    {
                        inList = true;
                    }
                }
                if (inList)
                {
                    FileNode currentNode = new FileNode();
                    currentNode.SetFileID(currentID);
                    currentNode.SetCreatedTime(file.Element("Created_Time").Value);
                    currentNode.SetModifiedTime(file.Element("Modified_Time").Value);
                    currentNode.SetExecuteTime(file.Element("Execute_Time").Value);
                    currentNode.SetFileName(file.Element("File_Name").Value);
                    currentNode.SetFilePath(file.Element("File_Path").Value);
                    currentNode.SetExtension(file.Element("Extension").Value);
                    currentNode.SetMeetings(file.Element("Meetings").Value);
                    list.Add(currentNode);
                }
            }

            //the count of the list indicate whether the list is empty
            list.Sort((x, y) => y.GetModifiedTime().CompareTo(x.GetModifiedTime()));
            LinkedList <FileNode> n = new LinkedList <FileNode>();

            foreach (FileNode item in list)
            {
                n.AddLast(item);
            }
            return(n);
        }