Esempio n. 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.valid       = sdr.GetValue(5).ToString();
                    segmentRmsItemCls.channelName = tableName;

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

            return(srCls);
        }
Esempio n. 2
0
        private List <SegmentRmsItemClass> GetList(string rmsIdfFile, int peakValue1, int peakValue2, string importFile)
        {
            List <SegmentRmsItemClass> tmp = new List <SegmentRmsItemClass>();

            List <String> tableNames = null;

            String condition = null;
            String strYes    = "是";
            String strNo     = "否";

            try
            {
                String[] tmpStr = rmsIdfFile.Split('.');

                tableNames = GetTableNames(rmsIdfFile);

                GetLineName(rmsIdfFile, tableNames[0]);

                tableNames.RemoveAt(0);

                this.daoChaMileRange = new DaoChaMileRange(importFile, this.lineName);

                foreach (String str in tableNames)
                {
                    //condition = String.Format(" where (valid = 1)", peakValue1.ToString());
                    condition = String.Format(" where (valid = \"1\")", peakValue1.ToString());
                    SegmentRmsClass srCls = GetTableValue(rmsIdfFile, str, condition);

                    for (int i = 0; i < srCls.segmentRmsItemClsList.Count; i++)
                    {
                        bool isDaoCha = false;
                        if (null != this.daoChaMileRange)
                        {// liyang: 加入是否道岔的判断,并置上。
                            isDaoCha = this.daoChaMileRange.IsDaoChao(srCls.segmentRmsItemClsList[i].kiloMeter);
                            srCls.segmentRmsItemClsList[i].isDaoCha = isDaoCha ? strYes : strNo;
                        }
                        else
                        {
                            srCls.segmentRmsItemClsList[i].isDaoCha = "未加载道岔位置表";
                        }

                        // liyang: 加入针对于道岔的峰值的判断。
                        //liyang:是道岔就按照道岔的超限值判断
                        if (isDaoCha)
                        {
                            if (srCls.segmentRmsItemClsList[i].segmentRmsPeak >= float.Parse(peakValue2.ToString()))
                            {
                                tmp.Add(srCls.segmentRmsItemClsList[i]);
                            }
                        }
                        else //liyang:不是道岔就按照直线曲线的超限值判断
                        {
                            if (srCls.segmentRmsItemClsList[i].segmentRmsPeak >= float.Parse(peakValue1.ToString()))
                            {
                                tmp.Add(srCls.segmentRmsItemClsList[i]);
                            }
                        }
                    }
                }
            }
            catch (System.Exception ex)
            {
                throw new Exception(ex.ToString());
            }

            return(tmp);
        }