public void createMeasurement(MeasurementModel measurement)
 {
     try
     {
         mrepo.Add(measurement);
         mrepo.Save();
         log.Info("Measurement von RestService wurde gespeichert.");
     }
     catch (BLException exp)
     {
         log.Error("Measurement von RestService konnte nicht gespeichert werden.");
         throw new BLException("Measurement von RestService konnte nicht gespeichert werden.", exp);
     }
 }
 public static MeasurementModel ConvertfromEntity(Measurement inmeasurement)
 {
     MeasurementModel measurement = null;
     try
     {
         measurement = new MeasurementModel();
         measurement.measid = inmeasurement.measid;
         measurement.timestamp = DateTime.Parse(inmeasurement.timestamp.ToString());
         measurement.typeid = inmeasurement.typeid;
         measurement.installationid = inmeasurement.installationid;
         measurement.measurevalue = inmeasurement.measurevalue;
         log.Info("Measurement wurde konvertiert.");
     }
     catch (Exception exp)
     {
         log.Error("Measurement konnte nicht konvertiert werden.");
         throw new DalException("Measurement konnte nicht konvertiert werden.", exp);
     }
     return measurement;
 }
 public static Measurement ConverttoEntity(MeasurementModel inmeasurement)
 {
     Measurement measurement;
     try
     {
         MeasurementTypeRepository mtrepo = new MeasurementTypeRepository();
         //InstallationRepository irepo = new InstallationRepository();
         measurement = new Measurement();
         measurement.measid = inmeasurement.measid;
         measurement.timestamp = inmeasurement.timestamp;
         measurement.typeid = inmeasurement.typeid;
         measurement.installationid = inmeasurement.installationid;
         measurement.measurevalue = inmeasurement.measurevalue;
         //measurement.Measurement_Type = ConvertMeasurementType.ConverttoEntity(mtrepo.GetById(measurement.typeid));
         //measurement.Installation = ConvertInstallation.ConverttoEntity(irepo.GetById(measurement.installationid));
         log.Info("MeasurementModel wurde konvertiert.");
     }
     catch (Exception exp)
     {
         log.Info("MeasurementModel konnte nicht konvertiert werden.");
         throw new DalException("MeasurementModel konnte nicht konvertiert werden.", exp);
     }
     return measurement;
 }
Пример #4
0
        public void CreateMeasurement(string installationid, MeasuredValue measvalue)
        {
            try
            {
                log4net.Config.XmlConfigurator.Configure();
                MeasurementModel measurement = new MeasurementModel();
                measurement.installationid =  Int32.Parse(installationid);
                measurement.measurevalue = Decimal.Parse(measvalue.value.ToString());
                measurement.timestamp = measvalue.timestamp;
                measurement.typeid = measvalue.type;
                IUnityContainer container = new UnityContainer();
                UnityConfigurationSection section = (UnityConfigurationSection)ConfigurationManager.GetSection("unity");
                section.Configure(container);
                IRestServiceBL rservicebl = container.Resolve<IRestServiceBL>();

                rservicebl.createMeasurement(measurement);
            }

            catch (Exception exp)
            {
                log.Error("Measurement via Rest konnte nicht gespeichert werden.");
                throw new Exception("Measurement via Rest konnte nicht gespeichert werden.", exp);
            }
        }