Exemplo n.º 1
0
        private DataTable GetFileTable(string path)
        {
            List <string> fileList = new List <string>();

            fileList.Clear();
            fileList = Mca.GetMcaList(path);
            DataTable dataTable = new DataTable();

            dataTable.Columns.Add("状态", Type.GetType("System.String"));

            dataTable.Columns.Add("数量", Type.GetType("System.String"));
            dataTable.Columns.Add("文件名", Type.GetType("System.String"));

            foreach (string file in fileList)
            {
                //int index = this.dataGridView1.Rows.Add();
                //this.dataGridView1.Rows[index].Cells[0].Value = "未合并";
                //this.dataGridView1.Rows[index].Cells[0].Style.BackColor = Color.Yellow;
                //this.dataGridView1.Rows[index].Cells[1].Value = mca.GetFileLinesCount(file) - 2;
                //this.dataGridView1.Rows[index].Cells[2].Value = mca.GetFileName(file);
                DataRow row = dataTable.NewRow();
                row[0] = "未合并";
                row[1] = Mca.GetFileLineCount(file) - 2;
                row[2] = Mca.GetFileName(file);
                dataTable.Rows.Add(row);
            }
            return(dataTable);
        }
Exemplo n.º 2
0
        private void AddListViewItems(string path)
        {
            lvList.Items.Clear();
            if (path.Trim() == "")
            {
                return;
            }

            List <string> fileLists = Mca.GetMcaList(path);
            int           count     = 0;

            //数据更新,UI暂时挂起,直到EndUpdate绘制控件,可以有效避免闪烁并大大提高加载速度
            this.lvList.BeginUpdate();
            foreach (string file in fileLists)
            {
                count++;
                ListViewItem lvi = new ListViewItem();
                lvi.Text = count.ToString();
                lvi.SubItems.Add(Mca.GetFileName(file));
                lvi.SubItems.Add((Mca.GetFileLineCount(file) - 2).ToString());
                lvList.Items.Add(lvi);
            }
            this.lvList.EndUpdate();//结束数据处理,UI界面一次性绘制。
        }
Exemplo n.º 3
0
        private void AddListViewItems(object obj)
        {
            //拆箱
            parameters p        = (parameters)obj;
            string     path     = p.one;
            string     filePath = p.two;

            if (filePath.Trim() == "")
            {
                return;
            }
            if (path.Trim() == "")
            {
                return;
            }
            //开始加载数据
            this.Invoke(myShowStatus, "数据加载中");
            string[] files = File.ReadAllLines(filePath, Encoding.Default);
            this.Invoke(myProgressInit, files.Length * 2);

            //显示数据列表
            int                    fileCount = 0;
            int                    lineCount = 0;
            int                    listNum   = 0;//文件列表序号
            List <string>          existList = new List <string>();
            List <ThreeParameters> list      = new List <ThreeParameters>();

            //加载数据列表,显示
            foreach (string file in files)
            {
                string fullName = Path.Combine(path, file);

                listNum++;
                ThreeParameters threePara = new ThreeParameters();
                threePara.one = listNum.ToString();
                if (File.Exists(fullName)) //文件存在检查
                {
                    fileCount++;           //文件计数
                    existList.Add(fullName);
                    threePara.two = Mca.GetFileName(fullName);
                    int lines = Mca.GetFileLineCount(fullName) - 2;
                    lineCount      += lines;
                    threePara.three = lines.ToString();
                }
                else
                {
                    threePara.two   = "";
                    threePara.three = "";
                }
                list.Add(threePara);
                this.Invoke(myPerformStep);
            }
            //校验数据
            this.Invoke(myShowStatus, "数据校验中");
            int counts = Mca.checkMca(existList);

            if (counts == -1)//校验出错
            {
                this.Invoke(myProgressInit, 0);
                this.Invoke(myShowStatus, "数据校验出错");
            }
            else
            {
                for (int i = 0; i < files.Length; i++)
                {
                    this.Invoke(myPerformStep);
                }
                parameters pLbl = new parameters();
                pLbl.one = fileCount.ToString();
                pLbl.two = lineCount.ToString();
                this.Invoke(myShowCount, pLbl);

                //             显示数据列表
                this.Invoke(myAddListView, list);
                this.Invoke(myShowStatus, "数据加载完成");
            }
        }