示例#1
0
        public static void EliminarFueraDeIntervalo(ResumenLecturaMedidor resumen, ResultadoLectura res, ParametrosLectura parametros)
        {
            MC_IntervaloMaestro intervaloMaestro = MC_IntervaloMaestroMgr.Instancia.GetIntervaloPorFecha(DateTime.Now.Date);
            DataTable           tabla            = MC_IntervaloDetalleMgr.Instancia.GetPorPkCodMaestro(intervaloMaestro.PkCodIntervaloMaestro);
            List <string>       horasIntervalos  = new List <string>();

            foreach (DataRow r in tabla.Rows)
            {
                horasIntervalos.Add((string)r[MC_IntervaloDetalle.C_HORA_INTERVALO]);
            }

            for (int i = 0; i < res.Registros.Count; i++)
            {
                RegistroLectura registro = res.Registros[i];
                if (!horasIntervalos.Contains(registro.Hora))
                {
                    res.Registros.RemoveAt(i);
                    foreach (DataRow r in registro.RowsItems)
                    {
                        res.Tabla.Rows.Remove(r);
                    }
                    i--;
                }
            }
        }
示例#2
0
        public bool Validar(ResumenLecturaMedidor resumen, ResultadoLectura res, ParametrosLectura parametros)
        {
            bool resultado = true;
            MC_IntervaloMaestro       intervaloMaestro = MC_IntervaloMaestroMgr.Instancia.GetIntervaloPorFecha(DateTime.Now.Date);
            DataTable                 tabla            = MC_IntervaloDetalleMgr.Instancia.GetPorPkCodMaestro(intervaloMaestro.PkCodIntervaloMaestro);
            Dictionary <string, long> horasIntervalos  = new Dictionary <string, long>();

            foreach (DataRow r in tabla.Rows)
            {
                horasIntervalos.Add((string)r[MC_IntervaloDetalle.C_HORA_INTERVALO], (long)r[MC_IntervaloDetalle.C_PK_COD_INTERVALO]);
            }

            int contadorFueraIntervalo = 0;

            foreach (RegistroLectura registro in res.Registros)
            {
                if (horasIntervalos.ContainsKey(registro.Hora))
                {
                    foreach (DataRow row in registro.RowsItems)
                    {
                        row["CodIntervalo"] = horasIntervalos[registro.Hora];
                    }
                }
                else
                {
                    contadorFueraIntervalo++;
                }
            }

            resumen[Nombre] = contadorFueraIntervalo;
            return(resultado);
        }
示例#3
0
        public bool Validar(ResumenLecturaMedidor resumen, ResultadoLectura res, ParametrosLectura parametros)
        {
            bool resultado = true;
            MC_IntervaloMaestro intervaloMaestro = MC_IntervaloMaestroMgr.Instancia.GetIntervaloPorFecha(DateTime.Now.Date);
            DataTable           tabla            = MC_IntervaloDetalleMgr.Instancia.GetPorPkCodMaestro(intervaloMaestro.PkCodIntervaloMaestro);
            List <string>       horasIntervalos  = new List <string>();
            Dictionary <DateTime, List <string> > dicVerifDatosInterv = new Dictionary <DateTime, List <string> >();

            foreach (DataRow r in tabla.Rows)
            {
                horasIntervalos.Add((string)r[MC_IntervaloDetalle.C_HORA_INTERVALO]);
            }

            int contadorFaltantes = 0;

            foreach (RegistroLectura registro in res.Registros)
            {
                if (!dicVerifDatosInterv.ContainsKey(registro.Fecha.Date))
                {
                    dicVerifDatosInterv[registro.Fecha.Date] = new List <string>();
                    foreach (string h in horasIntervalos)
                    {
                        dicVerifDatosInterv[registro.Fecha.Date].Add(h);
                    }
                }

                dicVerifDatosInterv[registro.Fecha.Date].Remove(registro.Hora);
            }

            int idx = 0;

            foreach (List <string> lista in dicVerifDatosInterv.Values)
            {
                if (idx > 0 && idx < dicVerifDatosInterv.Values.Count - 1)
                {
                    contadorFaltantes += lista.Count;
                }
                idx++;
            }

            resumen[Nombre] = contadorFaltantes;
            return(resultado);
        }
示例#4
0
        public MC_IntervaloMaestro GetIntervaloPorFecha(DateTime fecha)
        {
            MC_IntervaloMaestro resultado = null;
            string sql = @"SELECT *
            FROM p_mc_intervalo_maestro 
            WHERE :fecha between fecha_desde AND NVL(fecha_hasta,sysdate)";

            OracleCommand cmd = CrearCommand();

            cmd.CommandText = sql;
            cmd.BindByName  = true;
            cmd.Parameters.Add("fecha", OracleDbType.Date, fecha, ParameterDirection.Input);
            DataTable tabla = EjecutarCmd(cmd);

            if (tabla.Rows.Count > 0)
            {
                resultado = new MC_IntervaloMaestro(tabla.Rows[0]);
            }
            return(resultado);
        }
示例#5
0
        public bool Validar(ResumenLecturaMedidor resumen, ResultadoLectura res, ParametrosLectura parametros)
        {
            bool                resultado          = true;
            RegistroLectura     ultimoEnBD         = MC_LecturaMgr.Instancia.GetUltimoRegistroBD(resumen.PkCodPuntoMedicion);
            MC_IntervaloMaestro defIntervaloActual = MC_IntervaloMaestroMgr.Instancia.GetIntervaloPorFecha(DateTime.Now.Date);

            if (ultimoEnBD == null || ultimoEnBD.Fecha.AddMinutes(defIntervaloActual.PeriodoTiempo) == res.Registros[0].Fecha)
            {
                resumen[Nombre] = "OK";
            }
            else if (ultimoEnBD.Fecha.AddMinutes(defIntervaloActual.PeriodoTiempo) < res.Registros[0].Fecha)
            {//hay hueco
                resumen[Nombre] = "Faltan Registros";
                resultado       = false;
            }
            else
            {
                List <RegistroLectura> registrosAnteriores = MC_LecturaMgr.Instancia.GetRegistrosDesdeFecha(resumen.PkCodPuntoMedicion, res.Registros[0].Fecha.Date);
                MC_LecturaDetalle.EliminarDuplicados(resumen, res, parametros);
                MC_LecturaDetalle.EliminarFueraDeIntervalo(resumen, res, parametros);
                int i = 0, j = 0;
                for (; i < registrosAnteriores.Count && j < res.Registros.Count; i++)
                {
                    if (registrosAnteriores[i].Igual(res.Registros[j]))
                    {
                        res.Registros[j].MarcadoParaBorrar = true;
                    }
                    else
                    {
                        resumen[Nombre] = "Datos Inconsistentes";
                        resultado       = false;
                    }
                    j++;
                }
                if (resultado)
                {
                    resumen[Nombre] = "OK";
                }
            }
            return(resultado);
        }
示例#6
0
        public bool Guardar(MC_IntervaloMaestro obj)
        {
            bool          resultado = true;
            OracleCommand cmd       = null;
            string        sql       = string.Empty;

            if (obj.EsNuevo)
            {
                Pista p = PistaMgr.Instance.Info("DALSisFalla", obj.GetEstadoString());
                obj.SecLog = (long)p.PK_SecLog;
                sql        = "INSERT INTO {0} ({1},{2},{3},{4},{5},{6},{7})" +
                             "VALUES(:{1},:{2},:{3},:{4},:{5},:{6},:{7})";
                obj.PkCodIntervaloMaestro = GetIdAutoNum("SEC_PK_COD_INTERVALO_M");
            }
            else
            {
                sql = "UPDATE {0} SET " +
                      "{2}=:{2} ," +
                      "{3}=:{3} ," +
                      "{4}=:{4} ," +
                      "{5}=:{5} ," +
                      "{6}=:{6}, {7}=:{7}  WHERE {1}=:{1}";
            }

            sql = string.Format(sql, MC_IntervaloMaestro.NOMBRE_TABLA, MC_IntervaloMaestro.C_PK_COD_INTERVALO_MAESTRO,
                                MC_IntervaloMaestro.C_NOMBRE,
                                MC_IntervaloMaestro.C_PERIODO_TIEMPO,
                                MC_IntervaloMaestro.C_FECHA_DESDE,
                                MC_IntervaloMaestro.C_FECHA_HASTA,
                                MC_IntervaloMaestro.C_D_COD_ESTADO,
                                MC_IntervaloMaestro.C_SEC_LOG);
            cmd             = CrearCommand();
            cmd.CommandText = sql;
            cmd.BindByName  = true;
            cmd.Parameters.Add(MC_IntervaloMaestro.C_PK_COD_INTERVALO_MAESTRO, OracleDbType.Int64, obj.PkCodIntervaloMaestro, ParameterDirection.Input);
            cmd.Parameters.Add(MC_IntervaloMaestro.C_NOMBRE, OracleDbType.Varchar2, obj.Nombre, ParameterDirection.Input);
            cmd.Parameters.Add(MC_IntervaloMaestro.C_PERIODO_TIEMPO, OracleDbType.Int32, obj.PeriodoTiempo, ParameterDirection.Input);
            cmd.Parameters.Add(MC_IntervaloMaestro.C_FECHA_DESDE, OracleDbType.Date, obj.FechaDesde, ParameterDirection.Input);
            cmd.Parameters.Add(MC_IntervaloMaestro.C_FECHA_HASTA, OracleDbType.Date, obj.FechaHasta, ParameterDirection.Input);
            cmd.Parameters.Add(MC_IntervaloMaestro.C_D_COD_ESTADO, OracleDbType.Int16, obj.DCodEstado, ParameterDirection.Input);
            cmd.Parameters.Add(MC_IntervaloMaestro.C_SEC_LOG, OracleDbType.Int64, obj.SecLog, ParameterDirection.Input);

            try
            {
                cmd.ExecuteNonQuery();
                if (obj.EsNuevo)
                {
                    obj.EsNuevo = false;
                    int totalPeriodosDia = MINUTOS_POR_DIA / obj.PeriodoTiempo;
                    int minutos          = 0;
                    for (int i = 1; i <= totalPeriodosDia; i++)
                    {
                        minutos += obj.PeriodoTiempo;
                        MC_IntervaloDetalle detalle = new MC_IntervaloDetalle();
                        detalle.FkCodIntervaloMaestro = obj.PkCodIntervaloMaestro;
                        detalle.EsNuevo         = true;
                        detalle.HoraIntervalo   = GetHora(minutos);
                        detalle.NumeroIntervalo = i;
                        MC_IntervaloDetalleMgr.Instancia.Guardar(detalle);
                    }
                }
            }
            catch (Exception exception)
            {
                PistaMgr.Instance.Error("DALSisFalla", exception);
                resultado = false;
            }
            finally
            {
                DisposeCommand(cmd);
            }

            return(resultado);
        }