示例#1
0
        public static void AreEqual(ApplicationDataModel applicationDataModel, ISO11783_TaskData isoTaskData, string cardPath)
        {
            var loggedData = applicationDataModel.Documents.LoggedData.ToList();
            var tasks = isoTaskData.Items.Where(x => x.GetType() == typeof (TSK)).Cast<TSK>().ToList();

            TskAssert.AreEqual(loggedData, tasks, applicationDataModel.Catalog, cardPath);
        }
示例#2
0
        public void GivenDataPathAndAdmWhenExportThenAdmIsExported()
        {
            var adm = new ApplicationDataModel();

            _plugin.Export(adm, _dataPath);
            _exporterMock.Verify(x => x.Export(adm, Path.Combine(_dataPath, "TASKDATA"), It.IsAny<TaskDocumentWriter>()), Times.Once);
        }
示例#3
0
        public Documents Map(List<TSK> tsks, string dataPath, ApplicationDataModel.ADM.ApplicationDataModel dataModel, Dictionary<string, List<UniqueId>> linkedIds)
        {
            var tasksWithLoggedData = tsks.Where(task => task.Items != null && task.Items.OfType<TLG>().Any()).ToList();
            _loggedDataMapper.Map(tasksWithLoggedData, dataPath, dataModel, linkedIds);

            var tasksWithoutLogData = tsks.Where(task => task.Items == null || !task.Items.OfType<TLG>().Any()).ToList();
            var workOrders = _workOrderMapper.Map(tasksWithoutLogData, dataModel);
            dataModel.Documents.WorkOrders = workOrders;

            return dataModel.Documents;
        }
示例#4
0
        public void Setup()
        {
            _tsks = new List<TSK>();
            _dataPath = Path.GetTempPath();
            _documents = new Documents();
            _dataModel = new ApplicationDataModel { Documents = _documents };

            _loggedDataMapperMock = new Mock<ILoggedDataMapper>();
            _workOrderMapperMock = new Mock<IWorkOrderMapper>();

            _documentMapper = new DocumentMapper(_loggedDataMapperMock.Object, _workOrderMapperMock.Object);
            _linkedIds = new Dictionary<string, List<UniqueId>>();
        }
示例#5
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);
                }
            }
        }
示例#6
0
        public ApplicationDataModel.ADM.ApplicationDataModel Import(ISO11783_TaskData iso11783TaskData, string dataPath, ApplicationDataModel.ADM.ApplicationDataModel dataModel, Dictionary<string, List<UniqueId>> linkedIds)
        {
            if (dataModel.Catalog == null)
                dataModel.Catalog = CreateCatalog();
            if (dataModel.Documents == null)
                dataModel.Documents = CreateDocuments();

            if(dataModel.Documents.LoggedData == null)
                dataModel.Documents.LoggedData = new List<LoggedData>();

            var isoObjects = iso11783TaskData.Items;
            if (isoObjects == null || isoObjects.Length == 0)
                return dataModel;

            var tasks = isoObjects.GetItemsOfType<TSK>();

            _documentMapper.Map(tasks, dataPath, dataModel, linkedIds);
            return dataModel;
        }
示例#7
0
        public void Setup()
        {
            _linkIds = new Dictionary<string, List<UniqueId>>();
            _taskData = new ISO11783_TaskData();
            _dataPath = Path.GetTempPath();
            _applicationDataModel = new ApplicationDataModel();
            _documentMapperMock = new Mock<IDocumentMapper>();

            _importer = new Importer(_documentMapperMock.Object);
        }
示例#8
0
        private static TaskDataDocument ConvertTaskDataFileToModel(string taskDataFile, ApplicationDataModel.ADM.ApplicationDataModel dataModel)
        {
            var taskDocument = new TaskDataDocument();
            if (taskDocument.LoadFromFile(taskDataFile) == false)
                return taskDocument;

            var catalog = new Catalog();
            catalog.Growers = taskDocument.Customers.Values.ToList();
            catalog.Farms = taskDocument.Farms.Values.ToList();
            catalog.Fields = taskDocument.Fields.Values.ToList();
            catalog.GuidanceGroups = taskDocument.GuidanceGroups.Values.Select(x => x.Group).ToList();
            catalog.GuidancePatterns = taskDocument.GuidanceGroups.Values.SelectMany(x => x.Patterns.Values).ToList();
            catalog.Crops = taskDocument.Crops.Values.ToList();
            catalog.CropZones = taskDocument.CropZones.Values.ToList();
            catalog.DeviceElements = taskDocument.Machines.Values.ToList();
            catalog.FieldBoundaries = taskDocument.FieldBoundaries;
            catalog.Ingredients = taskDocument.Ingredients;
            catalog.Prescriptions = taskDocument.RasterPrescriptions.Cast<Prescription>().ToList();
            catalog.ContactInfo = taskDocument.Contacts;
            catalog.Products = AddAllProducts(taskDocument);

            dataModel.Catalog = catalog;

            var documents = new Documents();
            documents.GuidanceAllocations = taskDocument.GuidanceAllocations;
            documents.LoggedData = taskDocument.Tasks;

            dataModel.Documents = documents;

            return taskDocument;
        }
示例#9
0
文件: TestPlugin.cs 项目: ranec/ADAPT
 public void Export(ApplicationDataModel.ADM.ApplicationDataModel dataModel, string exportPath, Properties properties = null)
 {
 }
 public static void AreEqual(XmlNode taskData, ApplicationDataModel applicationDataModel, string currentPath, Dictionary<string, List<UniqueId>> linkList)
 {
     CatalogAssert.AreEqual(taskData, applicationDataModel.Catalog, linkList);
     DocumentsAssert.AreEqual(taskData, applicationDataModel.Documents, applicationDataModel.Catalog, currentPath);
 }
示例#11
0
        public void Setup()
        {
            _tsk = new TSK();
            _tsks = new List<TSK>{ _tsk };
            _dataPath = Path.GetTempPath();
            _documents = new Documents();
            _catalog = new Catalog();
            _linkIds = new Dictionary<string, List<UniqueId>>();

            _dataModel = new ApplicationDataModel();
            _dataModel.Documents = _documents;
            _dataModel.Catalog = _catalog;

            _operationDataMapper = new Mock<IOperationDataMapper>();

            _loggedDataMapper = new LoggedDataMapper(_operationDataMapper.Object);
        }
示例#12
0
        public void Setup()
        {
            _task = new TSK();
            _taskList = new List<TSK> {_task};
            _dataPath = Path.GetTempPath();
            _dataModel = new ApplicationDataModel {Catalog = new Catalog(), Documents = new Documents()};
            _linkedIds = new Dictionary<string, List<UniqueId>>();

            _statusUpdateMapperMock = new Mock<IStatusUpdateMapper>();

            _mapper = new WorkOrderMapper(_statusUpdateMapperMock.Object);
        }
示例#13
0
        public static void Export(IPlugin plugin, ApplicationDataModel.ADM.ApplicationDataModel applicationDataModel, string initializeString, string exportPath)
        {
            InitializePlugin(plugin, initializeString);

            plugin.Export(applicationDataModel, exportPath);
        }
示例#14
0
        public void Setup()
        {
            _applicationDataModel = new ApplicationDataModel
            {
                Catalog = new Catalog(),
                Documents = new Documents()
            };
            _datacardPath = Path.GetTempPath();

            _growerFarmFieldMapperMock = new Mock<IGrowerFarmFieldMapper>();
            _cropZoneMapperMock = new Mock<ICropZoneMapper>();
            _cropTypeMapperMock = new Mock<ICropTypeMapper>();
            _taskMapperMock = new Mock<ITaskMapper>();

            _exporter = new Exporter(_taskMapperMock.Object);
        }