Exemple #1
0
        private SegmentRmsClass GetTableValue(String idfFilePath, String tableName, String condition)
        {
            SegmentRmsClass srCls = new SegmentRmsClass();

            srCls.tableName = tableName;

            using (OleDbConnection sqlconn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + idfFilePath + ";Persist Security Info=True"))
            {
                String       sSQL   = "select Id,KiloMeter,Speed,Segment_RMS,Segment_RMS_Peak,valid from " + tableName + condition;
                OleDbCommand sqlcom = new OleDbCommand(sSQL, sqlconn);

                sqlconn.Open();
                OleDbDataReader sdr = sqlcom.ExecuteReader();

                while (sdr.Read())
                {
                    SegmentRmsItemClass segmentRmsItemCls = new SegmentRmsItemClass();

                    segmentRmsItemCls.id             = (int.Parse(sdr.GetValue(0).ToString()));
                    segmentRmsItemCls.kiloMeter      = (float.Parse(sdr.GetValue(1).ToString()));
                    segmentRmsItemCls.speed          = (float.Parse(sdr.GetValue(2).ToString()));
                    segmentRmsItemCls.segmentRms     = (float.Parse(sdr.GetValue(3).ToString()));
                    segmentRmsItemCls.segmentRmsPeak = (float.Parse(sdr.GetValue(4).ToString()));
                    segmentRmsItemCls.valid          = (int.Parse(sdr.GetValue(5).ToString()));
                    segmentRmsItemCls.channelName    = tableName;

                    srCls.segmentRmsItemClsList.Add(segmentRmsItemCls);
                }
                sdr.Close();
                sqlconn.Close();
            }

            return(srCls);
        }
Exemple #2
0
        /// <summary>
        /// 从大到小排序
        /// </summary>
        /// <param name="segment1">第一个</param>
        /// <param name="segment2">第二个</param>
        /// <returns></returns>
        public int CompareByKiloMeter(SegmentRmsItemClass segment1, SegmentRmsItemClass segment2)
        {
            if (segment1 == null)
            {
                if (segment2 == null)
                {
                    return(0);
                }

                return(1);
            }

            if (segment2 == null)
            {
                return(-1);
            }

            int retval = segment1.kiloMeter.CompareTo(segment2.kiloMeter);

            return(retval);
        }