Esempio n. 1
0
            public string Render()
            {
                var m  = string.Format(Template, Id, Interno, LabelStyle, Icono, Completed, Tipo);
                var st = string.Concat("[", string.Join(",", Detalles.Select(d => d.Render()).ToArray()), "]");

                return(string.Format("addMimico('{0}', {1}, {2});", Id, m, st));
            }
Esempio n. 2
0
            private int GetCompleted()
            {
                var firstDetalle = Detalles.First();
                var lastDetalle  = Detalles.Last();

                if (lastDetalle.Automatico.HasValue)
                {
                    return(100);
                }

                var totalTime = lastDetalle.Programado.Subtract(firstDetalle.Programado).TotalMinutes;

                lastDetalle = null;

                foreach (var detalle in Detalles)
                {
                    if (lastDetalle != null)
                    {
                        var duracion = detalle.Programado.Subtract(lastDetalle.Programado).TotalMinutes;
                        var parcial  = !detalle.Automatico.HasValue && lastDetalle.Automatico.HasValue
                                          ? (DateTime.UtcNow.Subtract(lastDetalle.Automatico.Value).TotalMinutes * 100) / duracion
                                          : 0;
                        if (parcial > 100)
                        {
                            parcial = 100;
                        }
                        detalle.Duracion           = Convert.ToInt32(duracion);
                        detalle.PorcentajeDelTotal = totalTime == 0 ? 0 : Convert.ToInt32((duracion / totalTime) * 100);
                        detalle.Completado         = detalle.Automatico.HasValue;
                        detalle.PorcentajeParcial  = detalle.Automatico.HasValue
                                                        ? 100
                                                        : Math.Min(90, Convert.ToInt32(parcial));
                    }
                    lastDetalle = detalle;
                }

                return(Convert.ToInt32(Detalles.Select(d => (d.PorcentajeParcial / 100) * d.PorcentajeDelTotal).Sum()));
            }