private IEnumerable <Summary> ReadSummaries(IBaseSerializer baseSerializer, string documentsPath)
        {
            var summaryFiles = Directory.EnumerateFiles(documentsPath, ConvertToSearchPattern(DatacardConstants.SummaryFile));

            foreach (var summaryFile in summaryFiles)
            {
                yield return(baseSerializer.Deserialize <Summary>(summaryFile));
            }
        }
        private IEnumerable <Recommendation> ReadRecommendations(IBaseSerializer baseSerializer, string documentsPath)
        {
            var recommendationFiles = Directory.EnumerateFiles(documentsPath, ConvertToSearchPattern(DatacardConstants.RecommendationFile));

            foreach (var recommendationFile in recommendationFiles)
            {
                yield return(baseSerializer.Deserialize <Recommendation>(recommendationFile));
            }
        }
    private void ImportSections(IBaseSerializer baseSerializer, string documentsPath, OperationData operationData)
    {
      var sectionsFileName = string.Format(DatacardConstants.SectionFile, operationData.Id.ReferenceId);
      var sectionsFilePath = Path.Combine(documentsPath, sectionsFileName);
      var sections = baseSerializer.Deserialize<Dictionary<int, IEnumerable<DeviceElementUse>>>(sectionsFilePath);

      if (sections != null && sections.Any())
        operationData.GetDeviceElementUses = x => sections[x] ?? new List<DeviceElementUse>();
    }
        private IEnumerable <Plan> ReadPlans(IBaseSerializer baseSerializer, string documentsPath)
        {
            var planFiles = Directory.EnumerateFiles(documentsPath, ConvertToSearchPattern(DatacardConstants.PlanFile));

            foreach (var planFile in planFiles)
            {
                yield return(baseSerializer.Deserialize <Plan>(planFile));
            }
        }
        private IEnumerable <GuidanceAllocation> ReadGuidanceAllocations(IBaseSerializer baseSerializer, string documentsPath)
        {
            var guidanceAllocationFiles = Directory.EnumerateFiles(documentsPath, ConvertToSearchPattern(DatacardConstants.GuidanceAllocationFile));

            foreach (var guidanceAllocationFile in guidanceAllocationFiles)
            {
                yield return(baseSerializer.Deserialize <GuidanceAllocation>(guidanceAllocationFile));
            }
        }
        private IEnumerable <Load> ReadLoads(IBaseSerializer baseSerializer, string documentsPath)
        {
            var loadFiles = Directory.EnumerateFiles(documentsPath, ConvertToSearchPattern(DatacardConstants.LoadFile));

            foreach (var loadFile in loadFiles)
            {
                yield return(baseSerializer.Deserialize <Load>(loadFile));
            }
        }
        private IEnumerable <WorkItemOperation> ReadWorkItemOperations(IBaseSerializer baseSerializer, string documentsPath)
        {
            var workItemOperationFiles = Directory.EnumerateFiles(documentsPath, ConvertToSearchPattern(DatacardConstants.WorkItemOperationFile));

            foreach (var workItemOperationFile in workItemOperationFiles)
            {
                yield return(baseSerializer.Deserialize <WorkItemOperation>(workItemOperationFile));
            }
        }
        private IEnumerable <WorkItem> ReadWorkItems(IBaseSerializer baseSerializer, string documentsPath)
        {
            var loggedDataFiles = Directory.EnumerateFiles(documentsPath, ConvertToSearchPattern(DatacardConstants.WorkItemFileOnly));

            foreach (var loggedDataFile in loggedDataFiles)
            {
                yield return(baseSerializer.Deserialize <WorkItem>(loggedDataFile));
            }
        }
Beispiel #9
0
    public T Deserialize(IBaseSerializer baseSerializer, string dataPath)
    {
      var filePath = Path.Combine(dataPath, _fileName);

      if (!File.Exists(filePath))
      {
        return new T();
      }

      return baseSerializer.Deserialize<T>(filePath);
    }
        public IEnumerable <ReferenceLayer> Deserialize(IBaseSerializer baseSerializer, string path)
        {
            var filePath = Path.Combine(path, DatacardConstants.ReferenceLayersFile);

            if (!File.Exists(filePath))
            {
                return(new List <ReferenceLayer>());
            }

            var serializableReferenceLayers = baseSerializer.Deserialize <List <SerializableReferenceLayer> >(filePath);

            return(serializableReferenceLayers.Select(x => _protobufReferenceLayerConverter.ConvertToReferenceLayer(x)));
        }
        private LoggedData MapLoggedData(IBaseSerializer baseSerializer, string documentsPath, string loggedDataFile)
        {
            var loggedData = baseSerializer.Deserialize <LoggedData>(loggedDataFile);

            foreach (var operationData in loggedData.OperationData)
            {
                ImportSpatialRecords(baseSerializer, documentsPath, operationData);
                ImportSections(baseSerializer, documentsPath, operationData);
                ImportMeters(baseSerializer, documentsPath, operationData);
            }

            return(loggedData);
        }
        private void ImportMeters(IBaseSerializer baseSerializer, string documentsPath, OperationData operationData)
        {
            var deviceElementUses = GetAllDeviceElementUses(operationData).Where(x => x.Value != null).SelectMany(x => x.Value);

            var workingDataFileName = string.Format(DatacardConstants.WorkingDataFile, operationData.Id.ReferenceId);
            var workingDataFilePath = Path.Combine(documentsPath, workingDataFileName);
            var allWorkingData      = baseSerializer.Deserialize <IEnumerable <WorkingData> >(workingDataFilePath);

            foreach (var deviceElementUse in deviceElementUses)
            {
                var deviceElementUseWorkingData = allWorkingData.Where(x => x.DeviceElementUseId == deviceElementUse.Id.ReferenceId);
                deviceElementUse.GetWorkingDatas = () => deviceElementUseWorkingData;
            }
        }
Beispiel #13
0
    private IEnumerable<LoggedData> ReadLoggedData(IBaseSerializer baseSerializer, string documentsPath)
    {
      var loggedDataCol = new List<LoggedData>();

      var loggedDataFiles = Directory.EnumerateFiles(documentsPath, ConvertToSearchPattern(DatacardConstants.LoggedDataFile));
      foreach (var loggedDataFile in loggedDataFiles)
      {
        var loggedData = baseSerializer.Deserialize<LoggedData>(loggedDataFile);
        foreach (var operationData in loggedData.OperationData)
        {
          ImportSpatialRecords(baseSerializer, documentsPath, operationData);
          ImportSections(baseSerializer, documentsPath, operationData);
          ImportMeters(baseSerializer, documentsPath, operationData);
        }

        loggedDataCol.Add(loggedData);
      }

      return loggedDataCol;
    }
Beispiel #14
0
        private void ButtonLoad_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialogLoad = new OpenFileDialog();

            if (openFileDialogLoad.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }
            string fileName      = openFileDialogLoad.FileName;
            string fileExtention = fileName.Split('.')[fileName.Split('.').Length - 1];

            if (fileName.Split('.').Length == 3)
            {
                IPlugin plugin = data.plugins.First(p => p.GetExt() == fileExtention);
                using (Stream inputStream = plugin.Dearchive(fileName))
                {
                    fileName      = fileName.Remove(fileName.LastIndexOf('.')).Substring(fileName.LastIndexOf('\\') + 1);
                    fileExtention = fileName.Split('.')[fileName.Split('.').Length - 1];
                    data.objects.Clear();
                    IBaseSerializer serializer = data.serializers.First(s => s.GetExtention() == fileExtention);
                    data.objects = (List <IBaseObject>)serializer.Deserialize(inputStream);
                }
            }
            else if (fileName.Split('.').Length == 2)
            {
                IBaseSerializer serializer = data.serializers.First(s => s.GetExtention() == fileExtention);
                if (serializer == null)
                {
                    MessageBox.Show("Unknown extention");
                    return;
                }
                data.objects.Clear();
                using (Stream inputStream = new FileStream(fileName, FileMode.Open))
                {
                    data.objects = (List <IBaseObject>)serializer.Deserialize(inputStream);
                }
            }
            data.FillListView(listviewObject);
            MessageBox.Show("Data has successfully loaded!");
        }
Beispiel #15
0
 private IEnumerable<WorkOrder> ReadWorkOrders(IBaseSerializer baseSerializer, string documentsPath)
 {
   var loggedDataFiles = Directory.EnumerateFiles(documentsPath, ConvertToSearchPattern(DatacardConstants.WorkOrderFile));
   return loggedDataFiles.Select(loggedDataFile => baseSerializer.Deserialize<WorkOrder>(loggedDataFile));
 }
Beispiel #16
0
 private IEnumerable<GuidanceAllocation> ReadGuidanceAllocations(IBaseSerializer baseSerializer, string documentsPath)
 {
   var loggedDataFiles = Directory.EnumerateFiles(documentsPath, ConvertToSearchPattern(DatacardConstants.GuidanceAllocationFile));
   return loggedDataFiles.Select(loggedDataFile => baseSerializer.Deserialize<GuidanceAllocation>(loggedDataFile));
 }
Beispiel #17
0
 private IEnumerable<Load> ReadLoads(IBaseSerializer baseSerializer, string documentsPath)
 {
   var loadFiles = Directory.EnumerateFiles(documentsPath, ConvertToSearchPattern(DatacardConstants.LoadFile));
   return loadFiles.Select(loadFile => baseSerializer.Deserialize<Load>(loadFile));
 }