상속: IDisposable
예제 #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
파일: Plugin.cs 프로젝트: ADAPT/ISOv4Plugin
        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;
        }
예제 #13
0
        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();
 }