Esempio n. 1
0
        private void btnCombine_Click(object sender, EventArgs e)
        {
            if (txtInFolder.Text == String.Empty)
            {
                return;
            }
            if (!Directory.Exists(txtOutFolder.Text))
            {
                Directory.CreateDirectory(txtOutFolder.Text);
            }
            List <string> fileLists = new List <string>();

            for (int i = dataGridView1.SelectedRows.Count - 1; i > -1; i--)
            {
                fileLists.Add(txtInFolder.Text + dataGridView1.SelectedRows[i].Cells[2].Value);

                dataGridView1.SelectedRows[i].Cells[0].Style.BackColor = Color.Green;
                dataGridView1.SelectedRows[i].Cells[0].Value           = "已合并" + (dataGridView1.SelectedRows.Count - i);
            }
            string path = txtOutFolder.Text + "合并数据" +
                          dataGridView1.SelectedRows[dataGridView1.SelectedRows.Count - 1].Cells[2].Value
                          + "-" + dataGridView1.SelectedRows[0].Cells[2].Value +
                          "(" + lblSelectedCount.Text + ")" + ".mca";

            Mca.CombineMCA(fileLists, path);
            MessageBox.Show("     合并完成!\n\n成功合并文件数:" + dataGridView1.SelectedRows.Count +
                            "\n数据条数:" + lblSelectedCount.Text, "完成提示框", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Esempio n. 2
0
        private void combineThread(object obj)
        {
            //拆箱
            listpath      p    = (listpath)obj;
            List <string> list = p.list;
            string        path = p.path;

            this.Invoke(myProgressInit, list.Count);
            this.Invoke(myShowStatus, "合并中...");
            //建立合并文件夹,存在则删除重建
            string saveFolder = Path.Combine(path, "合并文件");

            if (Directory.Exists(saveFolder))
            {
                Directory.Delete(saveFolder, true);
            }
            Directory.CreateDirectory(saveFolder);
            //开始合并
            List <string> files      = new List <string>();
            int           combineNum = 0; //文件名计数
            int           counts     = 0; //总行数,最后比对

            for (int i = 0; i < list.Count; i++)
            {
                if (list[i] != "")
                {
                    string filePath = Path.Combine(path, list[i]);
                    files.Add(filePath);
                }
                if (list[i] == "" && files.Count > 0)
                {
                    combineNum++;
                    string outPath = Path.Combine(saveFolder, combineNum.ToString() + ".mca");
                    int    count   = Mca.CombineMCA(files, outPath);
                    counts += count;
                    files.Clear();
                }
                this.Invoke(myPerformStep);
            }
            this.Invoke(myShowStatus, "合并完成");
            MessageBox.Show("合并完成!\n文件数:" + combineNum + "\n数据:" + counts, "成功提示", MessageBoxButtons.OK, MessageBoxIcon.Information);


            //catch
            //{
            //    MessageBox.Show("诶呀!出问题了");
            //}
        }
Esempio n. 3
0
        string combineMcaPath = "";//全局变量保存临时合并mca的路径,所有线程执行完毕之后删除。
        private void btnCereate_Click(object sender, EventArgs e)
        {
            if (txtFindData.Text == "")
            {
                return;
            }
            if (txtSourceData.Text == "")
            {
                return;
            }

            //保存路径
            //string combineMca = "Combine" + Path.GetFileNameWithoutExtension(txtSourceData.Text) + ".tmp";
            //string filePath = Path.GetDirectoryName(txtSourceData.Text);
            combineMcaPath = Path.Combine(txtSourceData.Text, "Combine.tmp");
            //获取mca文件列表
            List <string> sourceFiles = Mca.GetMcaList(txtSourceData.Text);

            Mca.CombineMCA(sourceFiles, combineMcaPath);

            //获取补卡卡号文件列表
            FileHandle    fileHandle = new FileHandle(txtFindData.Text);
            List <string> findFiles  = fileHandle.GetFileList("*.*");

            Threadcounts = findFiles.Count;//补卡文件总和
            //同时开启多线程工作
            foreach (string files in findFiles)
            {
                myPath mypath = new myPath();
                mypath.pathone = combineMcaPath; //txtSourceData.Text;
                mypath.pathtwo = files;          //txtFindData.Text;

                Thread t = new Thread(FindDataAll);
                t.Start(mypath);
            }
            //string path=TrimMca(txtFindData.Text);
            //MessageBox.Show(path);
        }