public static List <ISOTask> ReadXML(XmlNodeList taskNodes) { List <ISOTask> tasks = new List <ISOTask>(); foreach (XmlNode taskNode in taskNodes) { tasks.Add(ISOTask.ReadXML(taskNode)); } return(tasks); }
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); }
public static ISOTask ReadXML(XmlNode taskNode) { ISOTask task = new ISOTask(); task.TaskID = taskNode.GetXmlNodeValue("@A"); task.TaskDesignator = taskNode.GetXmlNodeValue("@B"); task.CustomerIdRef = taskNode.GetXmlNodeValue("@C"); task.FarmIdRef = taskNode.GetXmlNodeValue("@D"); task.PartFieldIdRef = taskNode.GetXmlNodeValue("@E"); task.ResponsibleWorkerIdRef = taskNode.GetXmlNodeValue("@F"); task.TaskStatusInt = taskNode.GetXmlNodeValueAsInt("@G"); task.DefaultTreatmentZoneCode = taskNode.GetXmlNodeValueAsNullableInt("@H"); task.PositionLostTreatmentZoneCode = taskNode.GetXmlNodeValueAsNullableInt("@I"); task.OutOfFieldTreatmentZoneCode = taskNode.GetXmlNodeValueAsNullableInt("@J"); //Treatment Zones XmlNodeList tznNodes = taskNode.SelectNodes("TZN"); if (tznNodes != null) { task.TreatmentZones.AddRange(ISOTreatmentZone.ReadXML(tznNodes)); } //Times XmlNodeList timNodes = taskNode.SelectNodes("TIM"); if (timNodes != null) { task.Times.AddRange(ISOTime.ReadXML(timNodes)); } //Worker Allocations XmlNodeList wanNodes = taskNode.SelectNodes("WAN"); if (wanNodes != null) { task.WorkerAllocations.AddRange(ISOWorkerAllocation.ReadXML(wanNodes)); } //Device Allocations XmlNodeList danNodes = taskNode.SelectNodes("DAN"); if (danNodes != null) { task.DeviceAllocations.AddRange(ISODeviceAllocation.ReadXML(danNodes)); } //Connections XmlNodeList cnnNodes = taskNode.SelectNodes("CNN"); if (cnnNodes != null) { task.Connections.AddRange(ISOConnection.ReadXML(cnnNodes)); } //Product Allocations XmlNodeList panNodes = taskNode.SelectNodes("PAN"); if (panNodes != null) { task.ProductAllocations.AddRange(ISOProductAllocation.ReadXML(panNodes)); } //Data Log Triggers XmlNodeList dltNodes = taskNode.SelectNodes("DLT"); if (dltNodes != null) { task.DataLogTriggers.AddRange(ISODataLogTrigger.ReadXML(dltNodes)); } //Comment Allocations XmlNodeList canNodes = taskNode.SelectNodes("CAN"); if (canNodes != null) { task.CommentAllocations.AddRange(ISOCommentAllocation.ReadXML(canNodes)); } //Grid XmlNode grdNode = taskNode.SelectSingleNode("GRD"); if (grdNode != null) { task.Grid = ISOGrid.ReadXML(grdNode); } //TimeLogs XmlNodeList tlgNodes = taskNode.SelectNodes("TLG"); if (tlgNodes != null) { task.TimeLogs.AddRange(ISOTimeLog.ReadXML(tlgNodes)); } //Guidance Allocations XmlNodeList ganNodes = taskNode.SelectNodes("GAN"); if (ganNodes != null) { task.GuidanceAllocations.AddRange(ISOGuidanceAllocation.ReadXML(ganNodes)); } //OperTechPractice XmlNode otpNode = taskNode.SelectSingleNode("OTP"); if (otpNode != null) { task.OperationTechPractice = ISOOperTechPractice.ReadXML(otpNode); } return(task); }