Beispiel #1
0
        public static ISO11783_LinkList ReadXML(XmlNode linkListNode, string baseFolder)
        {
            ISO11783_LinkList linkList = new ISO11783_LinkList();

            linkList.VersionMajor = linkListNode.GetXmlNodeValueAsInt("@VersionMajor");
            linkList.VersionMinor = linkListNode.GetXmlNodeValueAsInt("@VersionMinor");
            linkList.ManagementSoftwareManufacturer = linkListNode.GetXmlNodeValue("@ManagementSoftwareManufacturer") ?? string.Empty;
            linkList.ManagementSoftwareVersion      = linkListNode.GetXmlNodeValue("@ManagementSoftwareVersion") ?? string.Empty;
            linkList.TaskControllerManufacturer     = linkListNode.GetXmlNodeValue("@TaskControllerManufacturer") ?? string.Empty;
            linkList.TaskControllerVersion          = linkListNode.GetXmlNodeValue("@TaskControllerVersion") ?? string.Empty;
            linkList.DataTransferOriginInt          = linkListNode.GetXmlNodeValueAsInt("@DataTransferOrigin");
            linkList.FileVersion = linkListNode.GetXmlNodeValue("@FileVersion") ?? string.Empty;

            XmlNodeList lgpNodes = linkListNode.SelectNodes("LGP");

            if (lgpNodes != null)
            {
                linkList.LinkGroups.AddRange(ISOLinkGroup.ReadXML(lgpNodes));
            }

            return(linkList);
        }
        public static ISO11783_TaskData ReadXML(XmlNode taskDataNode, string baseFolder)
        {
            ISO11783_TaskData taskData = new ISO11783_TaskData();

            //Attributes
            taskData.VersionMajor = taskDataNode.GetXmlNodeValueAsInt("@VersionMajor");
            taskData.VersionMinor = taskDataNode.GetXmlNodeValueAsInt("@VersionMinor");
            taskData.ManagementSoftwareManufacturer = taskDataNode.GetXmlNodeValue("@ManagementSoftwareManufacturer");
            taskData.ManagementSoftwareVersion      = taskDataNode.GetXmlNodeValue("@ManagementSoftwareVersion");
            taskData.TaskControllerManufacturer     = taskDataNode.GetXmlNodeValue("@TaskControllerManufacturer");
            taskData.TaskControllerVersion          = taskDataNode.GetXmlNodeValue("@TaskControllerVersion");
            taskData.DataTransferOriginInt          = taskDataNode.GetXmlNodeValueAsInt("@DataTransferOrigin");
            taskData.DataTransferLanguage           = taskDataNode.GetXmlNodeValue("@DataTransferLanguage");

            //--------------
            //Child Elements
            //--------------
            //Attached Files
            XmlNodeList afeNodes = taskDataNode.SelectNodes("AFE");

            if (afeNodes != null)
            {
                taskData.ChildElements.AddRange(ISOAttachedFile.ReadXML(afeNodes));
            }
            ProcessExternalNodes(taskDataNode, "AFE", baseFolder, taskData, ISOAttachedFile.ReadXML);

            //Coded Comments
            XmlNodeList cctNodes = taskDataNode.SelectNodes("CCT");

            if (cctNodes != null)
            {
                taskData.ChildElements.AddRange(ISOCodedComment.ReadXML(cctNodes));
            }
            ProcessExternalNodes(taskDataNode, "CCT", baseFolder, taskData, ISOCodedComment.ReadXML);

            //Crop Types
            XmlNodeList ctpNodes = taskDataNode.SelectNodes("CTP");

            if (ctpNodes != null)
            {
                taskData.ChildElements.AddRange(ISOCropType.ReadXML(ctpNodes));
            }
            ProcessExternalNodes(taskDataNode, "CTP", baseFolder, taskData, ISOCropType.ReadXML);

            //Cultural Practices
            XmlNodeList cpcNodes = taskDataNode.SelectNodes("CPC");

            if (cpcNodes != null)
            {
                taskData.ChildElements.AddRange(ISOCulturalPractice.ReadXML(cpcNodes));
            }
            ProcessExternalNodes(taskDataNode, "CPC", baseFolder, taskData, ISOCulturalPractice.ReadXML);

            //Customers
            XmlNodeList ctrNodes = taskDataNode.SelectNodes("CTR");

            if (ctrNodes != null)
            {
                taskData.ChildElements.AddRange(ISOCustomer.ReadXML(ctrNodes));
            }
            ProcessExternalNodes(taskDataNode, "CTR", baseFolder, taskData, ISOCustomer.ReadXML);

            //Devices
            XmlNodeList dvcNodes = taskDataNode.SelectNodes("DVC");

            if (dvcNodes != null)
            {
                taskData.ChildElements.AddRange(ISODevice.ReadXML(dvcNodes));
            }
            ProcessExternalNodes(taskDataNode, "DVC", baseFolder, taskData, ISODevice.ReadXML);

            //Farms
            XmlNodeList frmNodes = taskDataNode.SelectNodes("FRM");

            if (frmNodes != null)
            {
                taskData.ChildElements.AddRange(ISOFarm.ReadXML(frmNodes));
            }
            ProcessExternalNodes(taskDataNode, "FRM", baseFolder, taskData, ISOFarm.ReadXML);

            //Operation Techniques
            XmlNodeList otqNodes = taskDataNode.SelectNodes("OTQ");

            if (otqNodes != null)
            {
                taskData.ChildElements.AddRange(ISOOperationTechnique.ReadXML(otqNodes));
            }
            ProcessExternalNodes(taskDataNode, "OTQ", baseFolder, taskData, ISOOperationTechnique.ReadXML);

            //Partfields
            XmlNodeList pfdNodes = taskDataNode.SelectNodes("PFD");

            if (pfdNodes != null)
            {
                taskData.ChildElements.AddRange(ISOPartfield.ReadXML(pfdNodes));
            }
            ProcessExternalNodes(taskDataNode, "PFD", baseFolder, taskData, ISOPartfield.ReadXML);

            //Products
            XmlNodeList pdtNodes = taskDataNode.SelectNodes("PDT");

            if (pdtNodes != null)
            {
                taskData.ChildElements.AddRange(ISOProduct.ReadXML(pdtNodes));
            }
            ProcessExternalNodes(taskDataNode, "PDT", baseFolder, taskData, ISOProduct.ReadXML);

            //Product Groups
            XmlNodeList pgpNodes = taskDataNode.SelectNodes("PGP");

            if (pgpNodes != null)
            {
                taskData.ChildElements.AddRange(ISOProductGroup.ReadXML(pgpNodes));
            }
            ProcessExternalNodes(taskDataNode, "PGP", baseFolder, taskData, ISOProductGroup.ReadXML);

            //Task Controller Capabilities
            XmlNodeList tccNodes = taskDataNode.SelectNodes("TCC");

            if (tccNodes != null)
            {
                taskData.ChildElements.AddRange(ISOTaskControllerCapabilities.ReadXML(tccNodes));
            }
            ProcessExternalNodes(taskDataNode, "TCC", baseFolder, taskData, ISOTaskControllerCapabilities.ReadXML);

            //Tasks
            XmlNodeList tskNodes = taskDataNode.SelectNodes("TSK");

            if (tskNodes != null)
            {
                taskData.ChildElements.AddRange(ISOTask.ReadXML(tskNodes));
            }
            ProcessExternalNodes(taskDataNode, "TSK", baseFolder, taskData, ISOTask.ReadXML);

            //Value Presentations
            XmlNodeList vpnNodes = taskDataNode.SelectNodes("VPN");

            if (vpnNodes != null)
            {
                taskData.ChildElements.AddRange(ISOValuePresentation.ReadXML(vpnNodes));
            }
            ProcessExternalNodes(taskDataNode, "VPN", baseFolder, taskData, ISOValuePresentation.ReadXML);

            //Workers
            XmlNodeList wkrNodes = taskDataNode.SelectNodes("WKR");

            if (wkrNodes != null)
            {
                taskData.ChildElements.AddRange(ISOWorker.ReadXML(wkrNodes));
            }
            ProcessExternalNodes(taskDataNode, "WKR", baseFolder, taskData, ISOWorker.ReadXML);

            //LinkList
            ISOAttachedFile linkListFile = taskData.ChildElements.OfType <ISOAttachedFile>().SingleOrDefault(afe => afe.FileType == 1);

            if (linkListFile != null)
            {
                XmlDocument linkDocument = new XmlDocument();
                string      linkPath     = Path.Combine(baseFolder, linkListFile.FilenamewithExtension);
                if (File.Exists(linkPath))
                {
                    linkDocument.Load(linkPath);
                    XmlNode linkRoot = linkDocument.SelectSingleNode("ISO11783LinkList");
                    taskData.LinkList = ISO11783_LinkList.ReadXML(linkRoot, baseFolder);
                }
            }

            return(taskData);
        }