private void lab_MouseClick(object sender, MouseEventArgs e) { MyLable lab = sender as MyLable; //得到配置文件信息 List <string> cfg = AnalyzerCfg.toolDict[lab.Text.Trim()]; // 所需分析的文件列表 List <string> fileNameList = new List <string>(); string dictName = Environment.CurrentDirectory + "\\" + userid + "_" + date + ".dict"; if (!File.Exists(dictName)) { MessageBox.Show("This trial didn't have the .dict file!", "error"); return; } FileStream fs = new FileStream(dictName, FileMode.Open); StreamReader sr = new StreamReader(fs); string line = null; while ((line = sr.ReadLine()) != null && !line.Equals("")) { fileNameList.Add(line); } sr.Close(); fs.Close(); string[] filekeywords = (cfg[2] + ",").Split(','); List <string> findFileIds = new List <string>(); // foreach (string str in filekeywords) { //分割keywords[] 去find文件 findAnalyzeFileId(str.Split(':').ToList(), fileNameList, findFileIds); } if (findFileIds.Count == 0) { MessageBox.Show("Didn't find any file for tfc analyze!", "operator error"); return; } if (findFileIds.Count > 0) { foreach (string id in findFileIds) { MyLogger.WriteLine("find id:" + id); } //GetCsvSock 获取要下载的文件 ImpAnalyzeCsvDnlded callback = new ImpAnalyzeCsvDnlded(); callback.AnalyzeName = lab.Text.Trim(); callback.Parent = parent; GetCsvSock.dnldFiles(userid, date, null, findFileIds, false, callback); } }
// 下载按钮,点击后遍历listview 中的选中项,然后下载 private void picboxDnld_Click(object sender, EventArgs e) { MyLogger.WriteLine("download list:"); List <string> dnldFileIdList = new List <string>(); foreach (ListViewItem item in listView1.CheckedItems) { dnldFileIdList.Add(item.SubItems[0].Text); // subitems[0]:fileid [1]:filename MyLogger.WriteLine(item.SubItems[0].Text + " +++ " + item.SubItems[1].Text); } //先判断txtDnldFolder是否有目录 if (!txtDnldFolder.Text.Trim().Equals("")) { if (dnldFileIdList.Count >= 1) { //开始下载 GetCsvSock.dnldFiles(userid, date, dnldFolder, dnldFileIdList, true, null); } else { MessageBox.Show("Please at least 1 file to download!", "operator error!"); } //重置list选中状态 for (int i = 0; i < listView1.Items.Count; i++) { listView1.Items[i].Checked = false; } labSelectNum.Text = listView1.CheckedItems.Count + ""; } else { MessageBox.Show("Please choose a download folder!", "download deny"); } }