コード例 #1
0
        private static void read_file_info(XmlNode FilesNode, FDA_Report_Data ReportData)
        {
            // Declare some variables for all the files
            ArrayList storage_nodes = new ArrayList();

            // Step through all the individual files
            foreach (XmlNode fileNode in FilesNode)
            {
                // Clear the values
                string dfid = String.Empty;
                string global = String.Empty;
                string origin = String.Empty;
                string path = String.Empty;
                string preservation = String.Empty;
                string size = String.Empty;
                storage_nodes.Clear();

                // Parse the attributes associated with this file
                if (fileNode.Attributes != null)
                {
                    foreach (XmlAttribute fileAttribute in fileNode.Attributes)
                    {
                        switch (fileAttribute.Name)
                        {
                            case "DFID":
                                dfid = fileAttribute.Value;
                                break;

                            case "GLOBAL":
                                global = fileAttribute.Value;
                                break;

                            case "ORIGIN":
                                origin = fileAttribute.Value;
                                break;

                            case "PATH":
                                path = fileAttribute.Value;
                                break;

                            case "PRESERVATION":
                                preservation = fileAttribute.Value;
                                break;

                            case "SIZE":
                                size = fileAttribute.Value;
                                break;
                        }
                    }
                }

                // Is this a NON-GLOBAL and DEPOSITOR originated file?
                if ((global.ToLower() == "false") && (origin.ToUpper() == "DEPOSITOR"))
                {
                    // This is a valid file to save
                    FDA_File file = new FDA_File
                                        {ID = dfid, Name = path, Preservation = preservation, XML_Node = fileNode};
                    ReportData.Files.Add(file);

                    // Get the size
                    long size_numeric;
                    if (Int64.TryParse(size, out size_numeric))
                        file.Size = size_numeric;

                    // Step through the subnodes associated with this file
                    foreach (XmlNode subNode in fileNode)
                    {
                        // Collect the checksums for this file
                        if (subNode.Name == "MESSAGE_DIGEST")
                        {
                            if (subNode.Attributes != null)
                            {
                                if ((subNode.Attributes.Count > 0) && (subNode.Attributes[0].Value == "MD5"))
                                {
                                    file.MD5_Checksum = subNode.InnerText.Trim();
                                }
                                if ((subNode.Attributes.Count > 0) && (subNode.Attributes[0].Value == "SHA-1"))
                                {
                                    file.SHA1_Checksum = subNode.InnerText.Trim();
                                }
                            }
                        }

                        // Collect the STORAGE subnodes to remove later
                        if ( subNode.Name == "STORAGE" )
                        {
                            storage_nodes.Add( subNode );
                        }

                        // Count the number of warnings, and save them at the file level
                        if (subNode.Name == "WARNING")
                        {
                            // Increment the warning count
                            ReportData.Warnings++;

                            // Get the information about this warning
                            if (( subNode.Attributes != null ) && (subNode.Attributes.Count > 0) && (subNode.Attributes[0].Name == "CODE"))
                            {
                                // Add this warning to the file
                                file.Add_Warning(subNode.Attributes[0].Value, subNode.InnerText);
                            }
                        }

                        // Get the NOTE from any EVENT listed
                        if (subNode.Name == "EVENT")
                        {
                            // Look for the NOTE subnode
                            foreach (XmlNode eventNode in subNode.ChildNodes)
                            {
                                if (eventNode.Name == "NOTE")
                                {
                                    file.Event = file.Event + eventNode.InnerText + ". ";
                                }
                            }
                        }
                    }

                    // Remove all the storage nodes
                    foreach (XmlNode deleteNode in storage_nodes)
                    {
                        fileNode.RemoveChild(deleteNode);
                    }
                }
            }
        }
コード例 #2
0
        private static void read_file_info(XmlNode filesNode, FDA_Report_Data report_data)
        {
            // Declare some variables for all the files
            ArrayList storage_nodes = new ArrayList();

            // Step through all the individual files
            foreach (XmlNode fileNode in filesNode)
            {
                // Clear the values
                string dfid         = String.Empty;
                string global       = String.Empty;
                string origin       = String.Empty;
                string path         = String.Empty;
                string preservation = String.Empty;
                string size         = String.Empty;
                storage_nodes.Clear();

                // Parse the attributes associated with this file
                if (fileNode.Attributes != null)
                {
                    foreach (XmlAttribute fileAttribute in fileNode.Attributes)
                    {
                        switch (fileAttribute.Name)
                        {
                        case "DFID":
                            dfid = fileAttribute.Value;
                            break;

                        case "GLOBAL":
                            global = fileAttribute.Value;
                            break;

                        case "ORIGIN":
                            origin = fileAttribute.Value;
                            break;

                        case "PATH":
                            path = fileAttribute.Value;
                            break;

                        case "PRESERVATION":
                            preservation = fileAttribute.Value;
                            break;

                        case "SIZE":
                            size = fileAttribute.Value;
                            break;
                        }
                    }
                }

                // Is this a NON-GLOBAL and DEPOSITOR originated file?
                if ((global.ToLower() == "false") && (origin.ToUpper() == "DEPOSITOR"))
                {
                    // This is a valid file to save
                    FDA_File file = new FDA_File
                    {
                        ID = dfid, Name = path, Preservation = preservation, XML_Node = fileNode
                    };
                    report_data.Files.Add(file);

                    // Get the size
                    long size_numeric;
                    if (Int64.TryParse(size, out size_numeric))
                    {
                        file.Size = size_numeric;
                    }

                    // Step through the subnodes associated with this file
                    foreach (XmlNode subNode in fileNode)
                    {
                        // Collect the checksums for this file
                        if (subNode.Name == "MESSAGE_DIGEST")
                        {
                            if (subNode.Attributes != null)
                            {
                                if ((subNode.Attributes.Count > 0) && (subNode.Attributes[0].Value == "MD5"))
                                {
                                    file.MD5_Checksum = subNode.InnerText.Trim();
                                }
                                if ((subNode.Attributes.Count > 0) && (subNode.Attributes[0].Value == "SHA-1"))
                                {
                                    file.SHA1_Checksum = subNode.InnerText.Trim();
                                }
                            }
                        }

                        // Collect the STORAGE subnodes to remove later
                        if (subNode.Name == "STORAGE")
                        {
                            storage_nodes.Add(subNode);
                        }

                        // Count the number of warnings, and save them at the file level
                        if (subNode.Name == "WARNING")
                        {
                            // Increment the warning count
                            report_data.Warnings++;

                            // Get the information about this warning
                            if ((subNode.Attributes != null) && (subNode.Attributes.Count > 0) && (subNode.Attributes[0].Name == "CODE"))
                            {
                                // Add this warning to the file
                                file.Add_Warning(subNode.Attributes[0].Value, subNode.InnerText);
                            }
                        }

                        // Get the NOTE from any EVENT listed
                        if (subNode.Name == "EVENT")
                        {
                            // Look for the NOTE subnode
                            foreach (XmlNode eventNode in subNode.ChildNodes)
                            {
                                if (eventNode.Name == "NOTE")
                                {
                                    file.Event = file.Event + eventNode.InnerText + ". ";
                                }
                            }
                        }
                    }

                    // Remove all the storage nodes
                    foreach (XmlNode deleteNode in storage_nodes)
                    {
                        fileNode.RemoveChild(deleteNode);
                    }
                }
            }
        }