ATMLDataAccessLibrary.db.daos.InstrumentDAO.FindCapableEquipment C# (CSharp) Method

FindCapableEquipment() public method

public FindCapableEquipment ( ICollection attributes, string uuid = null ) : ICollection
attributes ICollection
uuid string
return ICollection
        public ICollection<object> FindCapableEquipment(ICollection<Tuple<string, object, string>> attributes, string uuid = null)
        {
            List<object> instrumentIds = new List<object>();
            List<string> names = new List<string>();
            List<object> values = new List<object>();
            List<string> qualifiers = new List<string>();
            foreach (Tuple<string, object, string> attribute in attributes)
            {
                names.Add( attribute.Item1 );
                values.Add( attribute.Item2 );
                qualifiers.Add(attribute.Item3);
            }
            string sql = BuildCapabilityQuery( names.ToArray() );
            if (uuid != null)
                sql += " AND instrument_uuid=? ";

            List<OleDbParameter> dbParams = new List<OleDbParameter>();
            foreach (Tuple<string, object, string> attribute in attributes)
            {
                names.Add(attribute.Item1);
                values.Add(attribute.Item2);
                string name = attribute.Item1;
                object value = attribute.Item2;
                object valueHi;
                object valueLo;
                string qualifier = attribute.Item3;
                DetermineHoLoValues( qualifier, value, out valueHi, out valueLo );
                dbParams.Add(CreateParameter(string.Format("{0}_low", name), valueLo));
                dbParams.Add(CreateParameter(string.Format("{0}_high", name), valueHi));
            }

            if (uuid != null)
                dbParams.Add(CreateParameter("instrument_uuid", uuid));

            using (OleDbDataReader rs = ExecuteSqlQuery( sql, dbParams.ToArray() ))
            {
                if (rs != null)
                {
                    try
                    {
                        while (rs.Read())
                        {
                            instrumentIds.Add( rs[InstrumentCapabilitiesBean._INSTRUMENT_UUID] );
                        }
                    }
                    finally
                    {
                        rs.Close();
                        rs.Dispose();
                    }
                }
            }
            return instrumentIds;
        }

Usage Example

コード例 #1
0
        public void ProcessSignal(SignalRequirementsSignalRequirement signalRequirement)
        {
            var dao = new InstrumentDAO();
            var attributes = ( from attribute
                                 in signalRequirement.TsfClassAttribute
                                let name = attribute.Name
                              where attribute.Value != null
                              where attribute.Value.Item is DatumType
                                let value = Datum.GetNominalDatumValue( (DatumType) attribute.Value.Item )
                               let qualifier = ((DatumType)attribute.Value.Item).unitQualifier
                              where value != null
                             select new Tuple<string, object, string>( name.Value, value, qualifier ) ).ToList();

            lvTestStations.BeginUpdate();
            try
            {
                foreach (ListViewItem lvi in lvTestStations.Items)
                    lvi.BackColor = Color.White;

                ICollection<object> ids = dao.FindCapableEquipment(attributes);
                foreach (ListViewItem lvi in lvTestStations.Items)
                {
                    var instrument = lvi.Tag as TestStationDescription11;
                    if (instrument != null)
                    {
                        foreach (var id in ids)
                        {
                            if (id.Equals(instrument.uuid))
                                lvi.BackColor = Color.PaleGreen;
                        }
                    }
                }
            }
            catch (Exception e2)
            {
                LogManager.Debug("Error In TSF Class: {0}", signalRequirement.TsfClass.tsfClassName);
                foreach (Tuple<string, object, string> tuple in attributes)
                {
                    LogManager.Debug("     {0} = {1} {2}", tuple.Item1, tuple.Item2, tuple.Item3);
                }

            }
            lvTestStations.EndUpdate();
        }
All Usage Examples Of ATMLDataAccessLibrary.db.daos.InstrumentDAO::FindCapableEquipment