private void WriteMessageToTxt(string message) { TxtResult.Invoke(new Action(() => { TxtResult.AppendText(message + Environment.NewLine); })); }
private void dialog_outBuffer_Loaded(object sender, RoutedEventArgs e) { foreach (string s in resultText) { TxtResult.AppendText(s + "\r\n"); } }
/// <summary> /// 预处理程序 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtnPreProcess_Click(object sender, RoutedEventArgs e) { string filePath = this._preProcessFilePath; string strCon = "Provider=Microsoft.Ace.OLEDB.12.0;" + "Data Source=" + filePath + ";" + "Extended Properties=Excel 12.0;"; TxtResult.AppendText("开始预处理,请稍后" + Environment.NewLine); StringBuilder result = PreProcess(strCon); SaveFileDialog save = new SaveFileDialog { DefaultExt = ".txt", Filter = "文本文件 (.txt)|*.txt" }; if (save.ShowDialog() == true) { FileStream output = new FileStream(save.FileName, FileMode.Create); StreamWriter writer = new StreamWriter(output, Encoding.UTF8); writer.Write(result); writer.Close(); output.Close(); } TxtResult.AppendText("预处理完成,结果为:" + save.FileName + Environment.NewLine); }
private void BuscarDatos(ContactoModel filter) { TxtResult.Clear(); List <ContactoModel> lista = clientSoap.GetContacts(filter); foreach (ContactoModel contacto in lista) { TxtResult.AppendText(contacto.Id.ToString()); TxtResult.AppendText("\t\t"); TxtResult.AppendText(contacto.Nombre); TxtResult.AppendText("\r\n"); } if (string.Empty.Equals(TxtResult.Text)) { TxtResult.AppendText("Sin Resultados encontrados"); TxtResult.AppendText("\r\n"); } }
/// <summary> /// 显示记录 /// </summary> /// <param name="pIndex"></param> private void ShowRecord(int pIndex) { TxtResult.Clear(); TxtRecordHtml.Clear(); if (pIndex >= 0) { if (mRecordHtmls != null && mRecordHtmls.Length > pIndex) { TxtCurrent.Text = pIndex.ToString(); TxtRecordHtml.Text = mRecordHtmls[pIndex]; RegScriptTransactor sSe = new RegScriptTransactor(TxtRecordHtml.Text); if (mDrillRule.Feilds != null) { for (int i = 0; i < mDrillRule.Feilds.Count; i++) { RegularMetaFeild sFeild = mDrillRule.Feilds[i]; if (sFeild.Rule != null) { try { TxtResult.AppendText(sFeild.Name); TxtResult.AppendText(" : "); TxtResult.AppendText(sSe.Exe(sFeild.Rule)); TxtResult.AppendText("\n"); } catch (Exception E) { MessageBox.Show(E.Message); } } } } } } else { TxtCurrent.Text = "0"; } }
//TODO: 逆序、合并、去重、输出 /// <summary> /// 再处理程序 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtnReProcess_Click(object sender, RoutedEventArgs e) { TxtResult.AppendText("开始再处理,请稍后" + Environment.NewLine); //去除 FP-Growth 所得结果中的出现次数 List <List <string> > reverse = RemovePrefix(); //使用删减版流通记录制作图书名称字典 OpenFileDialog open = new OpenFileDialog(); open.DefaultExt = ".xlsx"; open.Filter = "Excel 工作簿 (.xlsx)|*.xlsx"; string filePath = open.FileName; string strCon = ""; Nullable <bool> openedFile = open.ShowDialog(); if (openedFile == true) { //this._preProcessFilePath = open.FileName; //this.TxtPreProcess.Text = open.FileName; this.TxtResult.AppendText("已选择图书集文件:" + open.FileName + Environment.NewLine); strCon = "Provider=Microsoft.Ace.OLEDB.12.0;" + "Data Source=" + open.FileName + ";" + "Extended Properties=Excel 12.0;"; } OleDbConnection connection = new OleDbConnection(strCon); connection.Open(); string strExcel = ""; OleDbDataAdapter adapter = null; DataSet ds = null; strExcel = "select * from [Sheet1$]"; adapter = new OleDbDataAdapter(strExcel, strCon); ds = new DataSet(); adapter.Fill(ds, "table1"); DataTable table = ds.Tables[0]; //HashSet<string> bookName = new HashSet<string>(); Dictionary <string, string> bookName = new Dictionary <string, string>(); for (int i = 0; i < table.Rows.Count; i++) { try { bookName.Add(table.Rows[i][0].ToString(), table.Rows[i][1].ToString()); } catch (Exception exception) { } } //逆序 for (int i = 0; i < reverse.Count; i++) { reverse[i].Reverse(); } //合并与去重 //每一行 List <string> row = new List <string>(); List <List <string> > result = new List <List <string> >(); //List<HashSet<string>> hashList = new List<HashSet<string>>(); HashSet <string> hashSet = new HashSet <string>(); /* * for (int i = 0; i < reverse.Count; i++) * { * for (int j = i; j < reverse.Count; j++) * { * if (reverse[i][0] == reverse[j][0]) * { * row.AddRange(reverse[j]); * } * else * { * i = j; * hashSet = new HashSet<string>(row); * result.Add(hashSet.ToList()); * row.Clear(); * hashSet.Clear(); * break; * } * } * } */ for (int i = 0; i < reverse.Count; i++) { row.AddRange(reverse[i]); for (int j = i + 1; j < reverse.Count; j++) { if (reverse[i][0] == reverse[j][0]) { row.AddRange(reverse[j]); } else { i = j - 1; hashSet = new HashSet <string>(row); result.Add(hashSet.ToList()); row.Clear(); hashSet.Clear(); break; } } } //替换结果中的图书种类号 for (int i = 0; i < result.Count; i++) { for (int j = 0; j < result[i].Count; j++) { result[i][j] = bookName[result[i][j]]; } //result[i].Add(Environment.NewLine); } /* * for (int i = 0; i < result.Count; i++) * { * result[i].Add(Environment.NewLine); * } */ //图书名称保存本次分析结果 SaveFileDialog save = new SaveFileDialog { DefaultExt = ".txt", Filter = "文本文件 (.txt)|*.txt" }; if (save.ShowDialog() == true) { FileStream output = new FileStream(save.FileName, FileMode.Create); StreamWriter writer = new StreamWriter(output, Encoding.UTF8); for (int i = 0; i < result.Count; i++) { for (int j = 0; j < result[i].Count; j++) { writer.Write(result[i][j] + ","); } writer.Write(Environment.NewLine + Environment.NewLine); } //writer.Write(result); writer.Close(); output.Close(); } TxtResult.AppendText("再处理完成,结果为:" + save.FileName + Environment.NewLine); }