Example #1
0
 public DbDataModifier(PlantsAreas plantsAreas, SensorsCollection sensorsCollection,
     IMeasurableParameterMappingRepository measurableParameterMappingRepository,
     IPlantMappingRepository plantMappingRepository, ISensorMappingRepository sensorMappingRepository,
     IPlantsAreaMappingRepository plantsAreaMappingRepository, 
     IServiceScheduleMappingRepository serviceScheduleMappingRepository)
 {
     _plantsAreas = plantsAreas;
     _sensorsCollection = sensorsCollection;
     _measurableParameterMappingRepository = measurableParameterMappingRepository;
     _plantMappingRepository = plantMappingRepository;
     _sensorMappingRepository = sensorMappingRepository;
     _plantsAreaMappingRepository = plantsAreaMappingRepository;
     _serviceScheduleMappingRepository = serviceScheduleMappingRepository;
     _dbMapper = new DbMapper(_plantMappingRepository,
         _measurableParameterMappingRepository, _serviceScheduleMappingRepository);
 }
Example #2
0
 public MySqlDbDataModifier(MySqlMeasurableParameterMappingRepository sqlMeasurableParameterMappingRepository,
     MySqlPlantMappingRepository sqlPlantMappingRepository,
     MySqlPlantsAreaMappingRepository sqlPlantsAreaMappingRepository,
     MySqlSensorMappingRepository sqlSensorMappingRepository,
     MySqlServiceScheduleMappingRepository sqlServiceScheduleMappingRepository,
     MySqlMeasuringMessageMappingRepository sqlMeasuringMessageMappingRepository,
     SensorsCollection sensorsCollection, PlantsAreas plantsAreas)
 {
     _sqlMeasurableParameterMappingRepository = sqlMeasurableParameterMappingRepository;
     _sqlPlantMappingRepository = sqlPlantMappingRepository;
     _sqlPlantsAreaMappingRepository = sqlPlantsAreaMappingRepository;
     _sqlServiceScheduleMappingRepository = sqlServiceScheduleMappingRepository;
     _sqlMeasuringMessageMappingRepository = sqlMeasuringMessageMappingRepository;
     _sensorsCollection = sensorsCollection;
     _plantsAreas = plantsAreas;
     _sqlSensorMappingRepository = sqlSensorMappingRepository;
     _dbMapper = new DbMapper(_sqlPlantMappingRepository,
         _sqlMeasurableParameterMappingRepository, _sqlServiceScheduleMappingRepository);
 }
Example #3
0
        public void Initialize()
        {
            //IPlantMappingRepository plantRepository = new PlantMappingRepository();
            //IPlantsAreaMappingRepository plantsAreaRepository = new PlantsAreaMappingRepository();
            //IMeasurableParameterMappingRepository measurableParameterRepository =
            //    new MeasurableParameterMappingRepository();
            //ISensorMappingRepository sensorRepository = new SensorMappingRepository();
            //IServiceScheduleMappingRepository serviceScheduleMappingRepository = new ServiceScheduleMappingRepository();

            MySqlMeasurableParameterMappingRepository sqlMeasurableParameterMappingRepository = new MySqlMeasurableParameterMappingRepository();
            MySqlPlantMappingRepository sqlPlantMappingRepository = new MySqlPlantMappingRepository();
            MySqlPlantsAreaMappingRepository sqlPlantsAreaMappingRepository = new MySqlPlantsAreaMappingRepository();
            MySqlSensorMappingRepository sqlSensorMappingRepository = new MySqlSensorMappingRepository();
            MySqlServiceScheduleMappingRepository sqlServiceScheduleMappingRepository = new MySqlServiceScheduleMappingRepository();

            _dbMapper = new DbMapper(sqlPlantMappingRepository,
                sqlMeasurableParameterMappingRepository, sqlServiceScheduleMappingRepository);

            _mongoDbAccessor = new MongoDbAccessor();

            List<PlantsAreaMapping> plantsAreaMappings = new List<PlantsAreaMapping>();

            if (_user != null)
            {
                plantsAreaMappings = sqlPlantsAreaMappingRepository.GetAll(mapping => mapping.UserId == new Guid(_user.Id));
            }

            _plantsAreas = new PlantsAreas();
                
            plantsAreaMappings.ForEach(p => _plantsAreas.AddPlantsArea(_dbMapper.RestorePlantArea(p)));

            _sensorsCollection = new SensorsCollection();

            foreach (PlantsArea area in _plantsAreas.Areas)
            {
                foreach (SensorMapping sensorMapping in sqlSensorMappingRepository.GetAll(sm => sm.PlantsAreaId == area.Id))
                {
                    Sensor sensor = _dbMapper.RestoreSensor(sensorMapping, area);
                    if (sensor != null)
                    {
                        _sensorsCollection.AddSensor(sensor);
                        sensor.IsOn = true;
                    }
                }
            }

            foreach (PlantsArea area in _plantsAreas.Areas)
            {
                //if custom sensor
                foreach (Sensor source in area.Sensors.Where(s => s.IsCustom))
                {
                    ServiceState serviceState = new ServiceState(source.MeasurableType, true);
                    area.PlantServicesStates.AddServiceState(serviceState);
                }
            }

            _sensorsMeasuringsProvider = new SensorsMeasuringsProvider(_sensorsCollection);

            _observer = new Observer(_sensorsMeasuringsProvider, _plantsAreas);

            _mongoMessagesListener = new MongoMessagesListener(_observer);

            _serviceProvider = new ServiceProvider(_observer, _plantsAreas);

            //_dbDataModifier = new DbDataModifier(_plantsAreas, _sensorsCollection, measurableParameterRepository,
            //    plantRepository, sensorRepository, plantsAreaRepository, serviceScheduleMappingRepository);

            _mySqlDbDataModifier = new MySqlDbDataModifier(sqlMeasurableParameterMappingRepository,
                sqlPlantMappingRepository, sqlPlantsAreaMappingRepository, sqlSensorMappingRepository,
                sqlServiceScheduleMappingRepository, new MySqlMeasuringMessageMappingRepository(), _sensorsCollection,
                _plantsAreas);
            //new MySqlMeasurableParameterMappingRepository(),
            //               new MySqlPlantMappingRepository(), new MySqlPlantsAreaMappingRepository(),
            //               new MySqlSensorMappingRepository(), new MySqlServiceScheduleMappingRepository(), new MySqlMeasuringMessageMappingRepository(), new SensorsCollection(), new PlantsAreas());
        }