Example #1
0
        public void SetPrograma(int index, Programa programa)
        {
            if (_programas.Count > index)
            {
                _programas.RemoveAt(index);
            }

            _programas.Insert(index, programa);
        }
Example #2
0
        public bool ParseFile(string[] lines, string latupdateprogram, string lastupdateconfig)
        {
            bool     result    = true;
            LineType linetype  = LineType.Desconocido;
            int      progIndex = 0;

            foreach (string line in lines)
            {
                switch (line)
                {
                case "+C:":
                {
                    linetype = LineType.Config;
                }
                break;

                case "+P:":
                {
                    linetype = LineType.Programa;
                }
                break;

                case "+S:":
                {
                    linetype = LineType.Salida;
                }
                break;

                case "+L:":
                {
                    linetype = LineType.Log;
                }
                break;

                default:
                {
                    switch (linetype)
                    {
                    case LineType.Config:
                    {
                        if (IsUpdateConfig(lastupdateconfig))
                        {
                            ParseDevice(line);
                        }
                    }
                    break;

                    case LineType.Salida:
                    {
                        AddSalida(Salida.ParseSalida(line));
                    }
                    break;

                    case LineType.Programa:
                    {
                        if (IsUpdateProgram(latupdateprogram))
                        {
                            SetPrograma(progIndex, Programa.ParsePrograma(line));
                            progIndex++;
                        }
                    }
                    break;

                    case LineType.Log:
                    {
                        AddLog(line);
                    }
                    break;

                    case LineType.Desconocido:
                    {
                        result = false;
                    }
                    break;
                    }
                }
                break;
                }
            }

            return(result);
        }