public static void Write(TaskDocumentWriter taskWriter) { if (taskWriter.DataModel.Catalog.Products == null) return; var writer = new ProductWriter(taskWriter); writer.WriteProducts(taskWriter.RootWriter); }
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); }
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); }
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(); }
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); }
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); }
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(); }
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); } }
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); } } }
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); } } }
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)); }
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; }
private FieldWriter(TaskDocumentWriter taskWriter) : base(taskWriter, "PFD") { _guidanceWriter = new GuidanceGroupWriter(taskWriter); }
private CustomerWriter(TaskDocumentWriter taskWriter) : base(taskWriter, "CTR") { }
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); }
public GuidancePatternWriter(TaskDocumentWriter taskWriter) : base(taskWriter, "GPN") { }
public GridWriter(TaskDocumentWriter taskWriter) : base(taskWriter, "GRD", 0) { _unitConverter = new ADAPT.Representation.UnitSystem.UnitOfMeasureConverter(); }
private FarmWriter(TaskDocumentWriter taskWriter) : base(taskWriter, "FRM") { }
private ProductWriter(TaskDocumentWriter taskWriter) : base(taskWriter, "PDT") { }
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); }
private WorkerWriter(TaskDocumentWriter taskWriter) : base(taskWriter, "WKR") { }
private CropWriter(TaskDocumentWriter taskWriter) : base(taskWriter, "CTP") { _cropVarietyWriter = new CropVarietyWriter(taskWriter); }
public CropVarietyWriter(TaskDocumentWriter taskWriter) : base(taskWriter, "CVT") { }
protected AttachedFileWriter(TaskDocumentWriter taskWriter) : base(taskWriter, "AFE") { }
private CommentWriter(TaskDocumentWriter taskWriter) : base(taskWriter, "CCT") { _listWriter = new CommentListWriter(); }
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)); }
private string Export() { using (var taskDocumentWriter = new TaskDocumentWriter()) { var xmlWriter = _exporter.Export(_applicationDataModel, _datacardPath, taskDocumentWriter); xmlWriter.Flush(); return Encoding.UTF8.GetString(taskDocumentWriter.XmlStream.ToArray()); } }
private PrescriptionWriter(TaskDocumentWriter taskWriter) : base(taskWriter, "TSK") { _unitConverter = new ADAPT.Representation.UnitSystem.UnitOfMeasureConverter(); _gridWriter = new GridWriter(taskWriter); }
protected BaseWriter(TaskDocumentWriter taskWriter, string xmlPrefix, int startId = 1) { TaskWriter = taskWriter; XmlPrefix = xmlPrefix; _itemId = startId; }
public static void Write(TaskDocumentWriter taskWriter) { var writer = new AttachedFileWriter(taskWriter); writer.WriteAttachedFile(taskWriter.RootWriter); }
public void Setup() { _taskWriter = new TaskDocumentWriter(); _directory = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()); Directory.CreateDirectory(_directory); }
public GuidanceGroupWriter(TaskDocumentWriter taskWriter) : base(taskWriter, "GGP") { _guidancePatternWriter = new GuidancePatternWriter(taskWriter); }