Example #1
0
        private void WriteCropZone(XmlWriter writer, CompoundIdentifier fieldId)
        {
            if (TaskWriter.DataModel.Catalog.CropZones == null ||
                TaskWriter.DataModel.Catalog.CropZones.Count == 0)
                return;

            foreach (var cropZone in TaskWriter.DataModel.Catalog.CropZones)
            {
                if (cropZone.FieldId == fieldId.ReferenceId)
                {
                    var cropId = TaskWriter.Crops.FindById(cropZone.CropId.Value);
                    writer.WriteXmlAttribute("G", cropId);
                    break;
                }
            }
        }
Example #2
0
        public void GivenPathAndIdsWhenWriteThenLgp1Added()
        {
            var uniqueId = new UniqueId
            {
                Id = Guid.NewGuid().ToString(),
                CiTypeEnum = CompoundIdentifierTypeEnum.UUID,
                Source = "urn:epc:id:sgln:0000000.00000.1",
            };
            var id = new CompoundIdentifier(0) { UniqueIds = new List<UniqueId> { uniqueId } };
            _ids.Add("TSK5", id);

            var linkListFilename = Path.Combine(_taskdataPath, "LINKLIST.XML");

            LinkListWriter.Write(_taskdataPath, _ids);

            var linkListDocument = new XmlDocument();
            linkListDocument.Load(linkListFilename);

            var lgps = linkListDocument.DocumentElement.SelectNodes("LGP");

            Assert.AreEqual("LGP1", lgps[0].Attributes["A"].Value);
            Assert.AreEqual("1", lgps[0].Attributes["B"].Value);
        }
Example #3
0
        public void LoadLinkedIds(string elementId, CompoundIdentifier id)
        {
            var linkedIds = LinkedIds.FindById(elementId);
            if (linkedIds == null || linkedIds.Count == 0)
                return;

            id.UniqueIds.AddRange(linkedIds);
        }
Example #4
0
 public ValuePresentation()
 {
     Id = new CompoundIdentifier(0);
 }
Example #5
0
        public void GivenPathAndIdWithTypeUuidAndStringWhenWriteThenLstAddedToCorrectGroup()
        {
            var uniqueId1 = new UniqueId
            {
                Id = Guid.NewGuid().ToString(),
                CiTypeEnum = CompoundIdentifierTypeEnum.UUID,
                Source = "urn:epc:id:sgln:0000000.00000.1",
            };
            var uniqueId2 = new UniqueId
            {
                Id = "456",
                CiTypeEnum = CompoundIdentifierTypeEnum.LongInt,
                Source = "urn:epc:id:sgln:0000000.00000.1",
            };
            var id = new CompoundIdentifier(0) { UniqueIds = new List<UniqueId> { uniqueId1, uniqueId2 } };
            _ids.Add("TSK5", id);

            var linkListFilename = Path.Combine(_taskdataPath, "LINKLIST.XML");

            LinkListWriter.Write(_taskdataPath, _ids);

            var linkListDocument = new XmlDocument();
            linkListDocument.Load(linkListFilename);
            var group1Links = linkListDocument.DocumentElement.SelectNodes("LGP")[0].ChildNodes;
            var group2Links = linkListDocument.DocumentElement.SelectNodes("LGP")[1].ChildNodes;

            Assert.AreEqual("TSK5", group1Links[0].Attributes["A"].Value);
            Assert.AreEqual(uniqueId1.Id, group1Links[0].Attributes["B"].Value);
            Assert.AreEqual(uniqueId1.Source, group1Links[0].Attributes["C"].Value);
            Assert.AreEqual("TSK5", group2Links[0].Attributes["A"].Value);
            Assert.AreEqual(uniqueId2.Id, group2Links[0].Attributes["B"].Value);
            Assert.AreEqual(uniqueId2.Source, group2Links[0].Attributes["C"].Value);
        }
Example #6
0
        public void GivenPathAndIdWithTypeStringWhenWriteThenLstAddedToLGP2()
        {
            var uniqueId = new UniqueId
            {
                Id = "bob",
                CiTypeEnum = CompoundIdentifierTypeEnum.String,
                Source = "urn:epc:id:sgln:0000000.00000.1",
            };
            var id = new CompoundIdentifier(0) { UniqueIds = new List<UniqueId>{ uniqueId } };
            _ids.Add("TSK5", id);

            var linkListFilename = Path.Combine(_taskdataPath, "LINKLIST.XML");

            LinkListWriter.Write(_taskdataPath, _ids);

            var linkListDocument = new XmlDocument();
            linkListDocument.Load(linkListFilename);
            var lsts = linkListDocument.DocumentElement.SelectNodes("LGP")[1].ChildNodes;

            Assert.AreEqual("TSK5", lsts[0].Attributes["A"].Value);
            Assert.AreEqual(uniqueId.Id, lsts[0].Attributes["B"].Value);
            Assert.AreEqual(uniqueId.Source, lsts[0].Attributes["C"].Value);
        }
Example #7
0
        public void GivenPathAndIdWithMultipleIdsWhenWriteThenLstsAdded()
        {
            var uniqueId1 = new UniqueId
            {
                Id = Guid.NewGuid().ToString(),
                Source = "urn:epc:id:sgln:0000000.00000.1",
            };
            var id1 = new CompoundIdentifier(0) { UniqueIds = new List<UniqueId>{ uniqueId1 } };
            _ids.Add("TSK5", id1);

            var uniqueId2 = new UniqueId
            {
                Id = Guid.NewGuid().ToString(),
                Source = "urn:epc:id:sgln:0000000.00000.1",
            };
            var id2 = new CompoundIdentifier(0) { UniqueIds = new List<UniqueId>{ uniqueId2 } };
            _ids.Add("TSK6", id2);

            var linkListFilename = Path.Combine(_taskdataPath, "LINKLIST.XML");

            LinkListWriter.Write(Path.GetDirectoryName(linkListFilename), _ids);

            var linkListDocument = new XmlDocument();
            linkListDocument.Load(linkListFilename);
            var lsts = linkListDocument.DocumentElement.ChildNodes[0].ChildNodes;

            Assert.AreEqual("TSK5", lsts[0].Attributes["A"].Value);
            Assert.AreEqual(uniqueId1.Id, lsts[0].Attributes["B"].Value);
            Assert.AreEqual(uniqueId1.Source, lsts[0].Attributes["C"].Value);

            Assert.AreEqual("TSK6", lsts[1].Attributes["A"].Value);
            Assert.AreEqual(uniqueId2.Id, lsts[1].Attributes["B"].Value);
            Assert.AreEqual(uniqueId2.Source, lsts[1].Attributes["C"].Value);
        }
Example #8
0
        public void GivenPathAndIdsWithMultipleUniqueIdsAndMultipleSourcesWhenWriteThenLstAdded()
        {
            var uniqueId1 = new UniqueId
            {
                Id = Guid.NewGuid().ToString(),
                Source = "urn:epc:id:sgln:0000000.00000.1",
            };
            var uniqueId2 = new UniqueId
            {
                Id = Guid.NewGuid().ToString(),
                Source = "urn:epc:id:sgln:0000000.00000.2",
            };
            var id = new CompoundIdentifier(0) { UniqueIds = new List<UniqueId> { uniqueId1, uniqueId2 } };
            _ids.Add("TSK5", id);

            var linkListFilename = Path.Combine(_taskdataPath, "LINKLIST.XML");

            LinkListWriter.Write(_taskdataPath, _ids);

            var linkListDocument = new XmlDocument();
            linkListDocument.Load(linkListFilename);
            var linkGroup1Lists = linkListDocument.DocumentElement.SelectNodes("LGP")[0].ChildNodes;
            var linkGroup3Lists = linkListDocument.DocumentElement.SelectNodes("LGP")[2].ChildNodes;

            Assert.AreEqual("TSK5", linkGroup1Lists[0].Attributes["A"].Value);
            Assert.AreEqual(uniqueId1.Id, linkGroup1Lists[0].Attributes["B"].Value);
            Assert.AreEqual(uniqueId1.Source, linkGroup1Lists[0].Attributes["C"].Value);
            Assert.AreEqual("TSK5", linkGroup3Lists[0].Attributes["A"].Value);
            Assert.AreEqual(uniqueId2.Id, linkGroup3Lists[0].Attributes["B"].Value);
            Assert.AreEqual(uniqueId2.Source, linkGroup3Lists[0].Attributes["C"].Value);
        }