Esempio n. 1
0
 private void tagChooseText_clicked(DataTable tb)
 {
     textBox.Text += "File loaded! ";
     try
     {
         single = tb.Clone();                                //复制输入tb的结构
         DataTable sortTable = SortAccordingToLength(tb, 1); //根据指定列的长度进行排序
         Dictionary <string, string> indexMap = SingleExtraction(sortTable, single);
         //CommonTools.SaveDataTable2Excel(single);
         idxMap = CommonTools.DictToDataTable <string>(indexMap);
         //CommonTools.SaveDataTable2Excel(map);
     }
     catch (Exception err)
     {
         MessageBox.Show(err.Message);
     }
     textBox.Text += "input row lines:" + tb.Rows.Count.ToString() + "\n";
     originCount   = tb.Rows.Count;
 }
        /*
         * private void LoadIndexFile(object sender, RoutedEventArgs e)
         * {
         *  var filePath = CommonTools.OpenOneFile(excelSuffix);
         *  if (filePath != null)
         *  {
         *      string[] tableTags = { "Src", "Target" };
         *      TagChoose tagChoose = new TagChoose(tableTags);
         *      tagChoose.sendTable += new TagChoose.Tabledelegate(tagChooseIndex_clicked);
         *      textBox.Text += "Loading " + filePath + "...\n";
         *      tagChoose.SetData(filePath);
         *      tagChoose.Show();
         *  }
         * }
         *
         * private void LoadOrgFile(object sender, RoutedEventArgs e)
         * {
         *  var filePath = CommonTools.OpenOneFile(excelSuffix);
         *  if (filePath != null)
         *  {
         *      string[] tableTags = { "UniqueId", "Src","Target" };
         *      TagChoose tagChoose = new TagChoose(tableTags);
         *      tagChoose.sendTable += new TagChoose.Tabledelegate(tagChooseOrg_clicked);
         *      textBox.Text += "Loading " + filePath + "...\n";
         *      tagChoose.SetData(filePath);
         *      tagChoose.Show();
         *  }
         * }
         * private void LoadSingleFile(object sender, RoutedEventArgs e)
         * {
         *  var filePath = CommonTools.OpenOneFile(excelSuffix);
         *  if (filePath != null)
         *  {
         *      string[] tableTags = { "UniqueId", "Target" };
         *      TagChoose tagChoose = new TagChoose(tableTags);
         *      tagChoose.sendTable += new TagChoose.Tabledelegate(tagChooseSingle_clicked);
         *      textBox.Text += "Loading "+ filePath + "...\n";
         *      tagChoose.SetData(filePath);
         *      tagChoose.Show();
         *  }
         * }
         */
        private void DoMerge(object sender, RoutedEventArgs e)
        {
            if (simALL == null)
            {
                MessageBox.Show("please load origin file!");
                return;
            }
            if (labelMap == null)
            {
                MessageBox.Show("please load index file!");
                return;
            }
            if (singleDict == null)
            {
                MessageBox.Show("please load simple file!");
                return;
            }

            textBox.Text += "Processing... \n";
            for (int i = 0; i < simALL.Rows.Count; i++)
            {
                string id = simALL.Rows[i][0].ToString();
                if (labelMap.ContainsKey(id))
                {
                    id = labelMap[id];
                }
                if (singleDict.ContainsKey(id))
                {
                    if (simALL.Rows[i][2] == DBNull.Value)
                    {
                        simALL.Rows[i][2] = singleDict[id];
                    }
                }
            }
            CommonTools.SaveDataTable2Excel(simALL, "保存输出表");
            textBox.Text += "Finished!! \n";
            //Thread.Sleep(5000);
            Close();
        }
 private void tagChooseIndex_clicked(DataTable dt)
 {
     textBox.Text += "File loaded\n";
     labelMap      = CommonTools.DataTableToDict(dt);
 }