예제 #1
0
        public List <MeterGroupModel> MeterGroups(string otherCode)
        {
            var result = new List <MeterGroupModel>();

            using (var connection = new NpgsqlConnection(_connectionString)) {
                var command = new NpgsqlCommand(
                    @"select clave_acometida, log_sexadecimal, lat_sexadecimal, matricula_salidabt
                    from coordenadas_acometida where matricula_ct = @OtherCode", connection);

                command.Parameters.Add("OtherCode", NpgsqlDbType.Varchar).Value = otherCode;

                connection.Open();

                var reader = command.ExecuteReader();
                while (reader.Read())
                {
                    var model = new MeterGroupModel {
                        Code = ((double)reader["clave_acometida"]).ToString(),
                        Lng  = (double)reader["log_sexadecimal"],
                        Lat  = (double)reader["lat_sexadecimal"],
                        Exit = reader.IsDBNull(3) ? "" : reader["matricula_salidabt"] as string
                    };
                    if (result.All(o => o.Code != model.Code))
                    {
                        result.Add(model);
                    }
                }

                reader.Close();
            }

            return(result);
        }
예제 #2
0
        public void create_meter_group()
        {
            LogManager      manager = new LogManager();
            MeterGroupModel groups  = manager.Default.Metrics.Create <MeterGroupModel>("group", MetricUnitModel.Bytes);

            // Espera al siguiente minuto
            WaitNextMinute();
            // Añade los contadores
            groups.Meters["first"].Mark();
            groups.Meters["first"].Mark();
            groups.Meters["second"].Mark();
            groups.Meters["second"].Mark();
            groups.Meters["second"].Mark();
            // Obtiene los valores
            groups.Meters.Count.Should().Be(2);
            groups.Meters["first"].LastMinute.Should().Be(2);
            groups.Meters["first"].LastFiveMinutes.Should().Be(2);
            groups.Meters["first"].LastFifteenMinutes.Should().Be(2);
            groups.Meters["second"].LastMinute.Should().Be(3);
        }
        public ActionResult Edit(MeterGroupModel model)
        {
            var meterGroup = _meterGroupRepository.GetById(model.Id);

            if (ModelState.IsValid)
            {
                meterGroup = model.ToEntity(meterGroup);

                //always set IsNew to false when saving
                meterGroup.IsNew = false;
                _meterGroupRepository.Update(meterGroup);

                //commit all changes
                this._dbContext.SaveChanges();

                //notification
                SuccessNotification(_localizationService.GetResource("Record.Saved"));
                return(new NullJsonResult());
            }
            else
            {
                return(Json(new { Errors = ModelState.SerializeErrors() }));
            }
        }
예제 #4
0
 public static MeterGroup ToEntity(this MeterGroupModel model, MeterGroup destination)
 {
     return(model.MapTo(destination));
 }
예제 #5
0
 public static MeterGroup ToEntity(this MeterGroupModel model)
 {
     return(model.MapTo <MeterGroupModel, MeterGroup>());
 }