示例#1
0
        public static void Write(TaskDocumentWriter taskWriter)
        {
            if (taskWriter.DataModel.Catalog.Products == null)
                return;

            var writer = new ProductWriter(taskWriter);
            writer.WriteProducts(taskWriter.RootWriter);
        }
示例#2
0
        public static void Write(TaskDocumentWriter taskWriter)
        {
            if (taskWriter.DataModel.Catalog.Growers == null ||
                taskWriter.DataModel.Catalog.Growers.Count == 0)
                return;

            var writer = new CustomerWriter(taskWriter);
            writer.WriteCustomers(taskWriter.RootWriter);
        }
示例#3
0
        public static void Write(TaskDocumentWriter taskWriter)
        {
            if (taskWriter.DataModel.Documents ==null ||
                taskWriter.DataModel.Documents.WorkOrders ==null)
                return;

            var writer = new CommentWriter(taskWriter);
            writer.WriteComments(taskWriter.RootWriter);
        }
示例#4
0
        public static void Write(TaskDocumentWriter taskWriter)
        {
            if (taskWriter.DataModel.Catalog.Prescriptions == null ||
                !taskWriter.DataModel.Catalog.Prescriptions.Any())
                return;

            var writer = new PrescriptionWriter(taskWriter);
            writer.WritePrescriptions();
        }
示例#5
0
        public static void Write(TaskDocumentWriter taskWriter)
        {
            if (taskWriter.DataModel.Catalog.Persons == null ||
                taskWriter.DataModel.Catalog.Persons.Count == 0)
                return;

            var writer = new WorkerWriter(taskWriter);
            writer.WriteWorkers(taskWriter.RootWriter);
        }
示例#6
0
        public static void Write(TaskDocumentWriter taskWriter)
        {
            if (taskWriter.DataModel.Catalog.Fields == null ||
                taskWriter.DataModel.Catalog.Fields.Count == 0)
                return;

            var writer = new FieldWriter(taskWriter);
            writer.WriteFields(taskWriter.RootWriter);
        }
示例#7
0
 private static int GetNumberOfExistingTasks(XmlWriter data, TaskDocumentWriter isoTaskData)
 {
     data.Flush();
     var xml = Encoding.UTF8.GetString(isoTaskData.XmlStream.ToArray());
     if(!xml.EndsWith(">"))
         xml += ">";
     xml += "</ISO11783_TaskData>";
     var xDocument = XDocument.Parse(xml);
     return xDocument.Root.Descendants("TSK").Count();
 }
示例#8
0
 public static void WriteSingle(TaskDocumentWriter taskWriter, Prescription prescription)
 {
     if (prescription == null)
         return;
     var rasterPrescription = prescription as RasterGridPrescription;
     if (rasterPrescription != null)
     {
         var writer = new PrescriptionWriter(taskWriter);
         writer.WritePrescription(rasterPrescription);
     }
 }
        public void ShouldWriteAllTypesOfPatterns()
        {
            // Setup
            var taskWriter = new TaskDocumentWriter();
            var adaptDocument = TestHelpers.LoadFromJson<ApplicationDataModel>(TestData.TestData.AllPatterns);

            // Act
            using (taskWriter)
            {
                var actual = TestHelpers.Export(taskWriter, adaptDocument, _exportPath);

                Assert.AreEqual(TestData.TestData.AllPatternsOutput, actual);
            }
        }
示例#10
0
        public void Export(ApplicationDataModel.ADM.ApplicationDataModel dataModel, string exportPath, Properties properties = null)
        {
            using (var taskWriter = new TaskDocumentWriter())
            {
                var taskDataPath = Path.Combine(exportPath, "TASKDATA");
                var iso11783TaskData = _exporter.Export(dataModel, taskDataPath, taskWriter);

                var filePath = Path.Combine(taskDataPath, FileName);
                if (iso11783TaskData != null)
                {
                    var xml = Encoding.UTF8.GetString(taskWriter.XmlStream.ToArray());
                    File.WriteAllText(filePath, xml);
                    LinkListWriter.Write(taskDataPath, taskWriter.Ids);
                }
            }
        }
示例#11
0
 public static void Write(TaskDocumentWriter writer)
 {
     writer.RootWriter.WriteStartElement("ISO11783_TaskData");
     writer.RootWriter.WriteAttributeString("VersionMajor", "4");
     writer.RootWriter.WriteAttributeString("VersionMinor", "0");
     writer.RootWriter.WriteAttributeString("ManagementSoftwareManufacturer", "AgGateway");
     writer.RootWriter.WriteAttributeString("ManagementSoftwareVersion", "1.0");
     writer.RootWriter.WriteAttributeString("DataTransferOrigin", ((int)ISO11783_TaskDataDataTransferOrigin.Item1).ToString(CultureInfo.InvariantCulture));
     writer.RootWriter.WriteAttributeString("TaskControllerManufacturer", "");
     writer.RootWriter.WriteAttributeString("TaskControllerVersion", "");
     if (writer.DataModel != null)
     {
         if (writer.DataModel.Catalog != null)
         {
             WriteMetaItems(writer);
         }
     }
 }
示例#12
0
        private TLG Map(OperationData operationData, string taskDataPath, TaskDocumentWriter taskDocumentWriter)
        {
            var tlgId = operationData.Id.FindIsoId() ?? "TLG" + operationData.Id.ReferenceId;
            taskDocumentWriter.Ids.Add(tlgId, operationData.Id);

            var tlg = new TLG { A = tlgId};
            var sections = operationData.GetAllSections();
            var meters = sections.SelectMany(x => x.GetWorkingDatas()).ToList();
            var spatialRecords = operationData.GetSpatialRecords != null ? operationData.GetSpatialRecords() : null;

            var timHeader = _timHeaderMapper.Map(meters);
            _xmlReader.WriteTlgXmlData(taskDataPath, tlg.A + ".xml", timHeader);

            var binFilePath = Path.Combine(taskDataPath, tlg.A + ".bin");
            _binaryWriter.Write(binFilePath, meters, spatialRecords);

            return tlg;
        }
        public void ShouldWritePrescription()
        {
            // Setup
            var taskWriter = new TaskDocumentWriter();
            var adaptDocument = TestHelpers.LoadFromJson<ApplicationDataModel>(TestData.TestData.SingleProduct);
            var fertilizerProduct = new FertilizerProduct{ Description = "product"};
            fertilizerProduct.Id.ReferenceId = -1;
            adaptDocument.Catalog.Products.Add(fertilizerProduct);

            // Act
            using (taskWriter)
            {
                var actualXml = TestHelpers.Export(taskWriter, adaptDocument, _exportPath);
                Assert.AreEqual(TestData.TestData.SingleProductOutputXml, actualXml);
            }

            // Verify
            var expectedPath = Path.Combine(_exportPath, "TASKDATA", "GRD00000.BIN");
            Assert.AreEqual(TestData.TestData.SingleProductOutputTxt, TestHelpers.LoadFromFileAsHexString(expectedPath));
        }
示例#14
0
        public XmlWriter Export(ApplicationDataModel.ADM.ApplicationDataModel applicationDataModel, string taskDataPath, TaskDocumentWriter writer)
        {
            var isoTaskData = writer.Write(taskDataPath, applicationDataModel);

            if (applicationDataModel != null)
            {

                var numberOfExistingTasks = GetNumberOfExistingTasks(isoTaskData, writer);
                var tasks = applicationDataModel.Documents == null
                    ? null
                    : _taskMapper.Map(applicationDataModel.Documents.LoggedData, applicationDataModel.Catalog,
                        taskDataPath, numberOfExistingTasks, writer, false);
                if (tasks != null)
                {
                    var taskList = tasks.ToList();
                    taskList.ForEach(t => t.WriteXML(isoTaskData));
                }
            }

            //Close the root element with </ISO11783_TaskData>
            isoTaskData.WriteEndElement();
            isoTaskData.Close();
            return isoTaskData;
        }
示例#15
0
 private FieldWriter(TaskDocumentWriter taskWriter)
     : base(taskWriter, "PFD")
 {
     _guidanceWriter = new GuidanceGroupWriter(taskWriter);
 }
示例#16
0
 private CustomerWriter(TaskDocumentWriter taskWriter)
     : base(taskWriter, "CTR")
 {
 }
示例#17
0
        public void Setup()
        {
            _operationData = new OperationData();
            _operationDatas = new List<OperationData> { _operationData };

            _binaryWriterMock = new Mock<IBinaryWriter>();
            _xmlReaderMock = new Mock<IXmlReader>();
            _timHeaderMock = new Mock<ITimHeaderMapper>();
            _datacardPath = "";
            _taskDocumentWriter = new TaskDocumentWriter();

            _tlgMapper = new TlgMapper(_xmlReaderMock.Object, _timHeaderMock.Object, _binaryWriterMock.Object);
        }
示例#18
0
 public GuidancePatternWriter(TaskDocumentWriter taskWriter)
     : base(taskWriter, "GPN")
 {
 }
示例#19
0
 public GridWriter(TaskDocumentWriter taskWriter)
     : base(taskWriter, "GRD", 0)
 {
     _unitConverter = new ADAPT.Representation.UnitSystem.UnitOfMeasureConverter();
 }
示例#20
0
 private FarmWriter(TaskDocumentWriter taskWriter)
     : base(taskWriter, "FRM")
 {
 }
示例#21
0
 private ProductWriter(TaskDocumentWriter taskWriter)
     : base(taskWriter, "PDT")
 {
 }
示例#22
0
        public void Setup()
        {
            _loggedData = new LoggedData();
            _loggedDatas = new List<LoggedData>{ _loggedData };
            _catalog = new Catalog();
            _datacardPath = "";
            _taskDocumentWriter = new TaskDocumentWriter();

            _timeMapperMock = new Mock<ITimeMapper>();
            _tlgMapperMock = new Mock<ITlgMapper>();

            _taskMapper = new TaskMapper(_timeMapperMock.Object, _tlgMapperMock.Object);
        }
示例#23
0
 private WorkerWriter(TaskDocumentWriter taskWriter)
     : base(taskWriter, "WKR")
 {
 }
示例#24
0
 private CropWriter(TaskDocumentWriter taskWriter)
     : base(taskWriter, "CTP")
 {
     _cropVarietyWriter = new CropVarietyWriter(taskWriter);
 }
示例#25
0
 public GuidancePatternWriter(TaskDocumentWriter taskWriter)
     : base(taskWriter, "GPN")
 {
 }
示例#26
0
 private FarmWriter(TaskDocumentWriter taskWriter)
     : base(taskWriter, "FRM")
 {
 }
示例#27
0
 public CropVarietyWriter(TaskDocumentWriter taskWriter)
     : base(taskWriter, "CVT")
 {
 }
示例#28
0
 private FieldWriter(TaskDocumentWriter taskWriter)
     : base(taskWriter, "PFD")
 {
     _guidanceWriter = new GuidanceGroupWriter(taskWriter);
 }
示例#29
0
 protected AttachedFileWriter(TaskDocumentWriter taskWriter)
     : base(taskWriter, "AFE")
 {
 }
示例#30
0
 private WorkerWriter(TaskDocumentWriter taskWriter)
     : base(taskWriter, "WKR")
 {
 }
示例#31
0
 private CommentWriter(TaskDocumentWriter taskWriter)
     : base(taskWriter, "CCT")
 {
     _listWriter = new CommentListWriter();
 }
示例#32
0
 public IEnumerable<TLG> Map(IEnumerable<OperationData> operationDatas, string taskDataPath, TaskDocumentWriter taskDocumentWriter)
 {
     if (operationDatas == null)
         return Enumerable.Empty<TLG>();
     return operationDatas.Select(x => Map(x, taskDataPath, taskDocumentWriter));
 }
示例#33
0
 private ProductWriter(TaskDocumentWriter taskWriter)
     : base(taskWriter, "PDT")
 {
 }
示例#34
0
 private string Export()
 {
     using (var taskDocumentWriter = new TaskDocumentWriter())
     {
         var xmlWriter = _exporter.Export(_applicationDataModel, _datacardPath, taskDocumentWriter);
         xmlWriter.Flush();
         return Encoding.UTF8.GetString(taskDocumentWriter.XmlStream.ToArray());
     }
 }
示例#35
0
 private PrescriptionWriter(TaskDocumentWriter taskWriter)
     : base(taskWriter, "TSK")
 {
     _unitConverter = new ADAPT.Representation.UnitSystem.UnitOfMeasureConverter();
     _gridWriter    = new GridWriter(taskWriter);
 }
示例#36
0
 protected BaseWriter(TaskDocumentWriter taskWriter, string xmlPrefix, int startId = 1)
 {
     TaskWriter = taskWriter;
     XmlPrefix  = xmlPrefix;
     _itemId    = startId;
 }
示例#37
0
 public GridWriter(TaskDocumentWriter taskWriter)
     : base(taskWriter, "GRD", 0)
 {
     _unitConverter = new ADAPT.Representation.UnitSystem.UnitOfMeasureConverter();
 }
示例#38
0
 private CustomerWriter(TaskDocumentWriter taskWriter)
     : base(taskWriter, "CTR")
 {
 }
示例#39
0
 private PrescriptionWriter(TaskDocumentWriter taskWriter)
     : base(taskWriter, "TSK")
 {
     _unitConverter = new ADAPT.Representation.UnitSystem.UnitOfMeasureConverter();
     _gridWriter = new GridWriter(taskWriter);
 }
示例#40
0
 protected BaseWriter(TaskDocumentWriter taskWriter, string xmlPrefix, int startId = 1)
 {
     TaskWriter = taskWriter;
     XmlPrefix = xmlPrefix;
     _itemId = startId;
 }
示例#41
0
 private CropWriter(TaskDocumentWriter taskWriter)
     : base(taskWriter, "CTP")
 {
     _cropVarietyWriter = new CropVarietyWriter(taskWriter);
 }
示例#42
0
        public static void Write(TaskDocumentWriter taskWriter)
        {
            var writer = new AttachedFileWriter(taskWriter);

            writer.WriteAttachedFile(taskWriter.RootWriter);
        }
示例#43
0
 public void Setup()
 {
     _taskWriter = new TaskDocumentWriter();
     _directory = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
     Directory.CreateDirectory(_directory);
 }
示例#44
0
 public CropVarietyWriter(TaskDocumentWriter taskWriter)
     : base(taskWriter, "CVT")
 {
 }
示例#45
0
 public GuidanceGroupWriter(TaskDocumentWriter taskWriter)
     : base(taskWriter, "GGP")
 {
     _guidancePatternWriter = new GuidancePatternWriter(taskWriter);
 }
示例#46
0
 private CommentWriter(TaskDocumentWriter taskWriter)
     : base(taskWriter, "CCT")
 {
     _listWriter = new CommentListWriter();
 }