/// <summary>
        ///
        /// </summary>
        /// <param name="IndiceProceso"></param>
        /// <returns></returns>
        public DateTime?ObtenerIndicadorTiempo(long IndiceProceso)
        {
            DateTime?Fecha = null;

            var IndicadorTiempoV2BD = db.IndicadorTiempo_V2
                                      .Where(columna => columna.IndiceProceso == IndiceProceso)
                                      .OrderByDescending(columna => columna.Fecha)
                                      .FirstOrDefault();

            if (IndicadorTiempoV2BD == null)
            {
                Indicador_Tiempo IndicadorTiempoV1BD = db.Indicador_Tiempo
                                                       .Where(columna => columna.id_proceso == IndiceProceso)
                                                       .OrderByDescending(columna => columna.fecha_hora)
                                                       .FirstOrDefault();

                if (IndicadorTiempoV1BD != null)
                {
                    Fecha = IndicadorTiempoV1BD.fecha_hora ?? null;
                }
            }
            else
            {
                Fecha = IndicadorTiempoV2BD.Fecha ?? null;
            }

            return(Fecha);
        }
        public void ActualizarIndicadorTiempo(long IndiceProceso, DateTime Fecha, int Ciclo)
        {
            DateTime FechaActualizada = Fecha.AddMinutes(Ciclo);

            IndicadorTiempo_V2 IndicadorTiempo = db.IndicadorTiempo_V2
                                                 .Where(c => c.IndiceProceso == IndiceProceso)
                                                 .FirstOrDefault();

            if (IndicadorTiempo == null)
            {
                Indicador_Tiempo IndicadorTiempoV1 = db.Indicador_Tiempo.Where(c => c.id_proceso == IndiceProceso).FirstOrDefault();

                if (IndicadorTiempoV1 != null)
                {
                    // Si el indicador sólo existe en V1, se convierte a objeto V2
                    DateTime?FechaActualIndicadorTiempo = IndicadorTiempoV1.fecha_hora;
                    if (FechaActualIndicadorTiempo == null)
                    {
                        FechaActualIndicadorTiempo = FechaActualizada;
                    }
                    else if (FechaActualIndicadorTiempo.GetValueOrDefault() < FechaActualizada)
                    {
                        FechaActualIndicadorTiempo = FechaActualizada;
                    }

                    IndicadorTiempo = new IndicadorTiempo_V2()
                    {
                        IndiceProceso = IndiceProceso,
                        Fecha         = FechaActualIndicadorTiempo.GetValueOrDefault()
                    };

                    db.IndicadorTiempo_V2.Add(IndicadorTiempo);
                    db.SaveChanges();
                }
                else
                {
                    // No existe ni en V1 y V2 un indicador de tiempo, por lo que se crea
                    IndicadorTiempo = new IndicadorTiempo_V2()
                    {
                        IndiceProceso = IndiceProceso,
                        Fecha         = FechaActualizada
                    };

                    db.IndicadorTiempo_V2.Add(IndicadorTiempo);
                    db.SaveChanges();
                }
            }
            else
            {
                if (IndicadorTiempo.Fecha.GetValueOrDefault() < FechaActualizada)
                {
                    IndicadorTiempo.Fecha = FechaActualizada;
                    db.SaveChanges();
                }
            }
        }