Пример #1
0
        private void Btn_TrcukOD_Click(object sender, EventArgs e)
        {
            if (PublicVariable.SplitedFilePath.Count > 0)
            {
                Dgv_StatisticSetting_CellLeave(this, null);

                //添加要生成的文件的标题行信息
                MatrixStruce = new PublicVariable.StatisticResultStruce();
                string title = "";
                foreach (PublicVariable.StatisticSetting v in PublicVariable.statisticSettings)
                {
                    title += v.FieldName + PublicVariable.StrConnector;
                }
                MatrixStruce.Title  = title + "计数";
                MatrixStruce.Matrix = new Dictionary <string, List <double> >();

                for (int i = 0; i < PublicVariable.SplitedFilePath.Count; i++)
                {
                    Tssl_ProgressInfo.Text = i + 1 + "/" + PublicVariable.SplitedFilePath.Count;
                    FileOperate.StatisticODData(PublicVariable.SplitedFilePath[i], MatrixStruce, tssl_Progress, Tssl_FileSize);
                }

                Frm_DataView frm_DataView = new Frm_DataView();
                frm_DataView.Show();
                SendContentsEvent += frm_DataView.FillDataGridview;
                SendContentsEvent?.Invoke(MatrixStruce);
                SendContentsEvent -= frm_DataView.FillDataGridview;
            }
            else
            {
                MessageBox.Show("请在右侧列表框中选中要统计的文件!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
        private void Btn_TrcukOD_Click(object sender, EventArgs e)
        {
            Btn_TrcukOD.Enabled = false;
            if (PublicVariable.SplitedFilePath.Count > 0)
            {
                Dgv_StatisticSetting_CellLeave(this, null);

                //添加要生成的文件的标题行信息
                MatrixStruce = new PublicVariable.StatisticResultStruce();
                string title = "";
                foreach (PublicVariable.StatisticSetting v in PublicVariable.statisticSettings)
                {
                    title += v.FieldName + PublicVariable.StrConnector;
                }
                MatrixStruce.Title  = title + "计数";
                MatrixStruce.Matrix = new Dictionary <string, List <double> >();

                for (int i = 0; i < PublicVariable.SplitedFilePath.Count; i++)
                {
                    Tssl_ProgressInfo.Text = i + 1 + "/" + PublicVariable.SplitedFilePath.Count;
                    FileOperate.StatisticODData(PublicVariable.SplitedFilePath[i], MatrixStruce, tssl_Progress, Tssl_FileSize);
                }

                Frm_DataView frm_DataView = new Frm_DataView();
                frm_DataView.Show();
                SendContentsEvent += frm_DataView.FillDataGridview;

                if (MatrixStruce.Matrix.Count >= 10000)
                {
                    string message      = string.Format("共有{0}行数据,数据导入较慢,是否继续导入!\r\n 是\t继续导入 \r\n否\t直接导出为文件", MatrixStruce.Matrix.Count);
                    string dialogResult = MessageBox.Show(message, "导入提示", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question).ToString();
                    if (dialogResult == "Yes")
                    {
                        SendContentsEvent?.Invoke(MatrixStruce);
                    }
                }
                else
                {
                    SendContentsEvent?.Invoke(MatrixStruce);
                }

                SendContentsEvent -= frm_DataView.FillDataGridview;
            }
            else
            {
                MessageBox.Show("请在右侧列表框中选中要统计的文件!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            Btn_TrcukOD.Enabled = true;
        }
Пример #3
0
        private void Btn_temp_Click(object sender, EventArgs e)
        {
            if (PublicVariable.SplitedFilePath.Count == 0)
            {
                MessageBox.Show("请在右侧列表框中选中要统计的文件!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            //添加要生成的文件的标题行信息
            MatrixStruce = new PublicVariable.StatisticResultStruce
            {
                Title  = "日期,时间,车型,总里程,计数",
                Matrix = new Dictionary <string, List <double> >()
            };

            for (int i = 0; i < PublicVariable.SplitedFilePath.Count; i++)
            {
                Tssl_ProgressInfo.Text = i + 1 + "/" + PublicVariable.SplitedFilePath.Count;
                StreamReader sr   = new StreamReader(PublicVariable.SplitedFilePath[i], Encoding.Default);
                string       line = "";
                double       n    = 0;
                while ((line = sr.ReadLine()) != null)
                {
                    n += 1;
                    try
                    {
                        string[] splited_line = line.Split(new char[] { '\t', ' ' });
                        double   miles        = Convert.ToDouble(splited_line[8]);
                        int      veh          = Convert.ToInt32(splited_line[6]);
                        if (miles <= 0 | veh <= 4)
                        {
                            continue;
                        }
                        string key = splited_line[4] + "," + splited_line[5].Substring(0, 2) + "," + splited_line[14];
                        if (MatrixStruce.Matrix.ContainsKey(key))
                        {
                            MatrixStruce.Matrix[key][0] += miles;
                            MatrixStruce.Matrix[key][1] += 1;
                        }
                        else
                        {
                            MatrixStruce.Matrix.Add(key, new List <double>()
                            {
                                miles, 1
                            });
                        }
                    }
                    catch (Exception)
                    {
                        continue;
                    }
                    if (n % 10000 == 0)
                    {
                        tssl_Progress.Text = n.ToString();
                        Application.DoEvents();
                    }
                }
                sr.Close();
            }

            Frm_DataView frm_DataView = new Frm_DataView();

            frm_DataView.Show();
            SendContentsEvent += frm_DataView.FillDataGridview;
            SendContentsEvent?.Invoke(MatrixStruce);
            SendContentsEvent -= frm_DataView.FillDataGridview;
        }