Example #1
0
        private ListadoInstrumentos ObtenerInstrumentos(List <IGrouping <int?, SenalElectronica> > SenalesAgrupadas, List <Instrumento> Instrumentos, ListadoSenales SenalesActuales)
        {
            foreach (var item in Instrumentos)
            {
                if (SenalesAgrupadas.Find(x => x.Key == item.Oid) != null)
                {
                    var SenalesXInstrumento = SenalesAgrupadas.FirstOrDefault(o => o.Key.Equals(item.Oid)).Select(x => x.Id).ToArray();

                    var           NombreInstrumento = item.NombreInstrumento;
                    var           IdInstrumento     = item.Oid;
                    var           Tipo_Instrumento  = item.TipoSeƱal.Value;
                    Mod_Senales[] Senales           = new Mod_Senales[SenalesXInstrumento.Length];
                    for (int i = 0; i < SenalesXInstrumento.Length; i++)
                    {
                        if (SenalesXInstrumento[i].Equals(SenalesActuales.FirstOrDefault(o => o.IDProtocolo.Equals(SenalesXInstrumento[i])).IDProtocolo))
                        {
                            Senales[i] = SenalesActuales.FirstOrDefault(o => o.IDProtocolo.Equals(SenalesXInstrumento[i]));
                        }
                    }
                    Mod_Instrumento InstrumentoDummy = new Mod_Instrumento(IdInstrumento, NombreInstrumento, Senales, Tipo_Instrumento, "0");
                    InstrumentosActuales.Add(InstrumentoDummy);
                }
                else
                {
                    var             NombreInstrumento = item.NombreInstrumento;
                    var             IdInstrumento     = item.Oid;
                    var             Tipo_Instrumento  = item.TipoSeƱal.Value;
                    Mod_Senales[]   Senales           = new Mod_Senales[0];
                    Mod_Instrumento InstrumentoDummy  = new Mod_Instrumento(IdInstrumento, NombreInstrumento, Senales, Tipo_Instrumento, "0");
                    InstrumentosActuales.Add(InstrumentoDummy);
                }
            }
            return(InstrumentosActuales);
        }