/// <summary> /// 窗体加载事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void InvalidDataAddForm_Load(object sender, EventArgs e) { comboBox1.Items.Clear(); DataTable dt = invalidManager.GetValidDataType(); for (int i = 0; i < dt.Rows.Count; i++) { comboBox1.Items.Add(dt.Rows[i][1].ToString()); } }
/// <summary> /// 统计按钮事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonStatistics_Click(object sender, EventArgs e) { if (dataGridView1.Rows.Count == 0) { return; } int totalCount = dataGridView1.Rows.Count; int totalGongli = 0; int startMile = 0; int endMile = 0; if (bIndex) { startMile = (int)(waveformMaker.WaveformDataList[0].MileageFix.FixData[0].MarkedStartPoint.UserSetMileage * 1000); endMile = (int)(waveformMaker.WaveformDataList[0].MileageFix.FixData[waveformMaker.WaveformDataList[0].MileageFix.FixData.Count - 1].MarkedEndPoint.UserSetMileage) * 1000; } else { Milestone milestone = citHelper.GetStartMilestone(citFilePath); startMile = Convert.ToInt32(milestone.mKm * 1000 + milestone.mMeter); milestone = citHelper.GetEndMilestone(citFilePath); endMile = Convert.ToInt32(milestone.mKm * 1000 + milestone.mMeter); } totalGongli = Math.Abs(startMile - endMile); List <StatisticsData> dataList = new List <StatisticsData>(); try { int typeNum = 0; //无效区段类型的个数 Dictionary <int, String> dicInvalidType = new Dictionary <int, String>(); //无效区段类型 DataTable dt = invalidManager.GetValidDataType(); for (int i = 0; i < dt.Rows.Count; i++) { dicInvalidType.Add(Convert.ToInt32(dt.Rows[i][0].ToString()), dt.Rows[i][1].ToString()); } typeNum = dicInvalidType.Count; List <InvalidData> list = invalidManager.InvalidDataList(idfFilePath); for (int i = 0; i < typeNum; i++) { List <InvalidData> listNew = list.Where(s => s.iType == i).ToList(); StatisticsData statisticsDataCls = null; for (int j = 0; j < listNew.Count; j++) { if (statisticsDataCls == null) { statisticsDataCls = new StatisticsData(totalCount, totalGongli); } statisticsDataCls.reasonType = dicInvalidType[listNew[j].iType];//类型 statisticsDataCls.sumcount++; startMile = (int)(float.Parse(listNew[j].sStartMile) * 1000); endMile = (int)(float.Parse(listNew[j].sEndMile) * 1000); statisticsDataCls.sumGongli = statisticsDataCls.sumGongli + Math.Abs(endMile - startMile); } if (statisticsDataCls != null) { dataList.Add(statisticsDataCls); } } } catch (System.Exception ex) { MyLogger.LogError("统计无效数据时失败", ex); MessageBox.Show(ex.Message); } //无效区段统计窗体 InvalidDataStatisticsForm statisticsForm = new InvalidDataStatisticsForm(dataList); //statisticsForm.TopLevel = true; statisticsForm.Show(); }