/// <summary> /// 双击List处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void record_listView_DoubleClick(object sender, EventArgs e) { try { ListViewItem item = record_listView.SelectedItems[0]; int id = int.Parse(item.SubItems[0].Text); string strReview = item.SubItems[8].Text; ReviewRecord reviewObj = ReviewRecord.GetObjectFormString(strReview); reviewObj.m_strTFSId = item.SubItems[1].Text; if (reviewObj == null) { MainForm.ErrorMessage(string.Format("内容格式错误: {0}", strReview)); return; } if (reviewObj.m_QuestionList.Count == 0) { MainForm.WarningMessage("没有要处理的走查问题!"); return; } // 显示对应问题窗口 ModifyHelperForm form = new ModifyHelperForm(id, reviewObj); form.ShowDialog(); } catch (System.Exception ex) { this.Cursor = System.Windows.Forms.Cursors.Arrow; MainForm.ErrorMessage(ex.ToString()); } }
// 通过字符串构造对象 public static TFSRecord GetObjectFormString(string strTFS) { // 【需求:AAAA】BALABALABALABALA // 【走查者】赵利平 // 【走查时间】2018年2月28日 // 【走查行数】100 // 【1】[类型]实现逻辑[级别]严重[状态]Open[模块]硬件配置[位置]AutoThink.cpp Line:21[问题说明]内存泄露[修改说明]请补充 // 【走查者】赵利平 // 【走查时间】2018年2月28日 // 【走查行数】100 // 【走查结果】通过 // strTFS = @"【需求:AAAA】BALABALABALABALA // 【走查者】赵利平 // 【走查时间】2018年2月28日 // 【走查行数】100 // 【1】[类型]实现逻辑[级别]严重[状态]Open[模块]硬件配置[位置]AutoThink.cpp Line:21[问题说明]内存泄露[修改说明]请补充 // 【走查者】赵利平 // 【走查时间】2018年2月28日 // 【走查行数】100 // 【走查结果】通过"; TFSRecord obj = new TFSRecord(); string[] sArray = Regex.Split(strTFS, @"【走查者】", RegexOptions.IgnoreCase); // 解析签入信息 string strCheckin = sArray[0].Trim(); CheckinRecord checkinObj = CheckinRecord.GetObjectFormString(strCheckin); if (checkinObj == null) { // 格式出错 return(null); } obj.checkinObj = checkinObj; if (sArray.Count() > 1) { // 有Review信息 int iCount = TFSRecord.GetSReviewCount(strTFS); for (int iIdx = 0; iIdx < iCount; ++iIdx) { string strReview = TFSRecord.GetReviewStringAt(strTFS, iIdx); ReviewRecord reviewObj = ReviewRecord.GetObjectFormString(strReview); if (reviewObj == null) { // 格式出错 return(null); } obj.reviewObjList.Add(reviewObj); } } return(obj); }
/// <summary> /// 导出Excel信息 /// </summary> /// <param name="strExcelFile"></param> /// <returns></returns> private int ExportExcel(string strExcelFile) { int iRecordCount = 0; OleDbConnection connectObj = null; OleDbCommand commandObj = null; try { // 打开连接 string strConnect = "Provider=Microsoft.Ace.OleDb.12.0;" + "data source=" + strExcelFile + ";Extended Properties='Excel 12.0; HDR=Yes; IMEX=0'"; connectObj = new OleDbConnection(strConnect); connectObj.Open(); // 导出到第一个Sheet DataTable sheetsName = connectObj.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[] { null, null, null, "Table" }); string strSheet = sheetsName.Rows[0][2].ToString(); commandObj = connectObj.CreateCommand(); int iItemCount = this.record_listView.Items.Count; for (int iIdx = 0; iIdx < iItemCount; ++iIdx) { string strReview = this.record_listView.Items[iIdx].SubItems[8].Text.Trim(); ReviewRecord reviewObj = ReviewRecord.GetObjectFormString(strReview); if (reviewObj == null) { continue; } int iReviewLine = reviewObj.m_iReviewLine; reviewObj.m_strTFSId = this.record_listView.Items[iIdx].SubItems[1].Text.Trim(); reviewObj.m_strCoder = this.record_listView.Items[iIdx].SubItems[3].Text.Trim(); String strGroup = this.record_listView.Items[iIdx].SubItems[2].Text.Trim(); for (int jIdx = 0; jIdx < reviewObj.m_QuestionList.Count; ++jIdx) { QuestionRecord questionObj = reviewObj.m_QuestionList[jIdx]; // 对问题描述中的单引号进行转义,因为这个在随后执行ExecuteNonQuery会导致异常 string[] newStrs = Regex.Split(questionObj.m_strQDes, "'"); questionObj.m_strQDes = string.Join("''", newStrs); string strSQL = string.Format("INSERT INTO [{0}] VALUES('{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}', '{10}', '{11}', '{12}', '{12}')", strSheet, reviewObj.m_strReviewDate, // 走查日期 questionObj.m_strModuleName, // 模块名称 reviewObj.m_strTFSId, // 变更集 iReviewLine, // 代码行数 strGroup, // 资源组 reviewObj.m_strReviewer, // 走查者 reviewObj.m_strCoder, // 作者 questionObj.m_strQDes, // 问题描述 questionObj.m_strLocation, // 位置 questionObj.m_strType, // 问题类型 questionObj.m_strLevel, // 问题级别 questionObj.m_strADes, // 修改说明 questionObj.m_strStatus); // 状态 commandObj.CommandText = strSQL; commandObj.ExecuteNonQuery(); iRecordCount += 1; // 一个变更集的代码行数只在一个问题中体现,其他问题都填0,避免重复计算 iReviewLine = 0; } } return(iRecordCount); } catch (System.Exception ex) { throw ex; } finally { if (commandObj != null) { commandObj.Dispose(); commandObj = null; } if (connectObj != null) { connectObj.Close(); connectObj.Dispose(); connectObj = null; } } }
/// <summary> /// 填充List数据 /// </summary> /// <param name="reader"></param> private void FillList(MySqlDataReader reader) { try { // 清空List this.record_listView.Items.Clear(); UpdateStatuesBar(0, 0, 0, 0); // 统计检索到的数据 int iRecord = 0; int iCode = 0; int iQuestion = 0; int iNoQuestion = 0; // 填充Reader数据 ListViewItem item = null; string strDate = ""; while (reader.Read()) { item = new ListViewItem(); item.SubItems[0].Text = reader["id"].ToString(); item.SubItems.Add(reader["tfs_id"].ToString()); item.SubItems.Add(reader["group_name"].ToString()); item.SubItems.Add(reader["coder"].ToString()); strDate = reader["code_date"].ToString(); item.SubItems.Add(DateTime.Parse(strDate).Date.ToShortDateString()); item.SubItems.Add(reader["reviewer"].ToString()); strDate = reader["review_date"].ToString(); item.SubItems.Add(DateTime.Parse(strDate).Date.ToShortDateString()); item.SubItems.Add(reader["code_line"].ToString()); string strContent = reader["content"].ToString(); item.SubItems.Add(strContent); // 统计总代码行数 iCode += int.Parse(reader["code_line"].ToString()); // 有没有关闭的问题,背景色设置为黄色 ReviewRecord reviewObj = ReviewRecord.GetObjectFormString(strContent); if (reviewObj != null) { // 统计总问题数 iQuestion += reviewObj.m_QuestionList.Count; for (int iIdx = 0; iIdx < reviewObj.m_QuestionList.Count; ++iIdx) { if (QuestionRecord.QuestionIsClose(reviewObj.m_QuestionList[iIdx]) == false) { item.BackColor = Color.Yellow; // 统计未解决的问题数 iNoQuestion += 1; } } } this.record_listView.Items.Add(item); } // 总记录数 iRecord = this.record_listView.Items.Count; // 更新状态栏显示 UpdateStatuesBar(iRecord, iCode, iQuestion, iNoQuestion); } catch (System.Exception ex) { throw ex; } }