/// <summary> /// 不是问题按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void no_button_Click(object sender, EventArgs e) { // 信息检查 string strTemp = mod_answer_textBox.Text.Trim(); if (strTemp == "") { MainForm.WarningMessage("确认说明不能为空!"); mod_answer_textBox.Focus(); return; } // 获取对应的问题对象 int iQuestionIdx = mod_question_listBox.SelectedIndex; QuestionRecord questionObj = m_reviewObj.m_QuestionList[iQuestionIdx]; // 更改的问题信息 questionObj.m_strStatus = "不是问题"; questionObj.m_strADes = mod_answer_textBox.Text.Trim(); // 更新List显示 strTemp = QuestionRecord.GetStringFormObject(questionObj); mod_question_listBox.Items.RemoveAt(iQuestionIdx); mod_question_listBox.Items.Insert(iQuestionIdx, strTemp); mod_question_listBox.SelectedIndex = iQuestionIdx; }
/// <summary> /// 初始化界面数据 /// </summary> private void InitData() { int iCount = m_reviewObj.m_QuestionList.Count(); for (int iIdx = 0; iIdx < iCount; ++iIdx) { QuestionRecord questionObj = m_reviewObj.m_QuestionList[iIdx]; string strQuestion = QuestionRecord.GetStringFormObject(questionObj); mod_question_listBox.Items.Add(strQuestion); } // 默认选择第一个 if (mod_question_listBox.Items.Count > 0) { mod_question_listBox.SelectedIndex = 0; } }
public static ReviewRecord GetObjectFormString(string strReview) { // 有问题记录的Review信息字符串格式: // 【走查者】赵利平 // 【走查时间】2018年2月28日 // 【走查行数】100 // 【1】[类型]实现逻辑[级别]严重[状态]Open[模块]硬件配置[位置]AutoThink.cpp Line:21[问题说明]内存泄露[修改说明]请补充 // // 无问题记录的Review信息字符串格式: // 【走查者】赵利平 // 【走查时间】2018年2月28日 // 【走查行数】100 // 【走查结果】通过 ReviewRecord obj = new ReviewRecord(); string[] sArray = Regex.Split(strReview, @"【.*?】", RegexOptions.IgnoreCase); if (sArray.Count() < 5) { return(null); } obj.m_strReviewer = sArray[1].Trim(); obj.m_strReviewDate = sArray[2].Trim(); obj.m_iReviewLine = int.Parse(sArray[3]); if (sArray[4].Trim().Replace("\r\n", "") == "通过") { // Review通过的记录 obj.m_bResultFlag = true; obj.m_QuestionList.Clear(); return(obj); } // 问题列表 for (int iIdx = 4; iIdx < sArray.Count(); ++iIdx) { QuestionRecord questionObj = QuestionRecord.GetObjectFormString(sArray[iIdx].Trim()); if (questionObj == null) { return(null); } obj.m_QuestionList.Add(questionObj); } return(obj); }
public static string GetStringFormObject(QuestionRecord obj) { // [类型]实现逻辑[级别]严重[状态]Open[模块]硬件配置[位置]AutoThink.cpp Line:21[问题说明]内存泄露[修改说明]请补充 if (obj == null) { MessageBox.Show("null"); return(""); } string strQuestion = "[类型]" + obj.m_strType + "[级别]" + obj.m_strLevel + "[状态]" + obj.m_strStatus + "[模块]" + obj.m_strModuleName + "[位置]" + obj.m_strLocation + "[问题说明]" + obj.m_strQDes + "[修改说明]" + obj.m_strADes; return(strQuestion); }
/// <summary> /// 生成Review的字符串信息 /// </summary> /// <returns></returns> private string GeneralReviewInfo() { // 注释信息可以往后面追加,不过存到数据库就不用存已有信息,只用显示处理Review的字符串信息 string strRet = ""; string strReviewer = review_name_textBox.Text.Trim(); bool bFlag = review_no_checkBox.CheckState == CheckState.Checked; if (strReviewer == "") { return(strRet); } ReviewRecord obj = new ReviewRecord(); obj.m_strReviewer = review_name_textBox.Text.Trim(); obj.m_strReviewDate = DateTime.Now.ToLongDateString().ToString(); if (review_line_textBox.Text.Trim() == "") { obj.m_iReviewLine = 0; } else { obj.m_iReviewLine = int.Parse(review_line_textBox.Text); } obj.m_bResultFlag = bFlag; if (obj.m_bResultFlag == false) { // 有问题的场合记录问题 for (int iIdx = 0; iIdx < review_listBox.Items.Count; ++iIdx) { string strQuestion = review_listBox.Items[iIdx].ToString(); QuestionRecord objQuestion = QuestionRecord.GetObjectFormString(strQuestion); obj.m_QuestionList.Add(objQuestion); } } if (strRet != "") { strRet += "\r\n"; } strRet += ReviewRecord.GetStringFormObject(obj); return(strRet); }
/// <summary> /// 添加问题按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void revier_add_button_Click(object sender, EventArgs e) { // 检查输入信息 if (review_module_textBox.Text == "") { review_module_textBox.Focus(); MainForm.WarningMessage("问题模块内容不能为空!"); return; } if (review_position_textBox.Text == "") { review_position_textBox.Focus(); MainForm.WarningMessage("问题位置内容不能为空!"); return; } if (review_textBox.Text == "") { review_textBox.Focus(); MainForm.WarningMessage("问题说明内容不能为空!"); return; } QuestionRecord obj = new QuestionRecord(); obj.m_strType = review_type_comboBox.Text.Trim(); obj.m_strLevel = review_level_comboBox.Text.Trim(); obj.m_strStatus = "打开"; obj.m_strModuleName = review_module_textBox.Text.Trim(); obj.m_strLocation = review_position_textBox.Text.Trim(); obj.m_strQDes = review_textBox.Text.Trim(); obj.m_strADes = "请补充"; string strQuestion = QuestionRecord.GetStringFormObject(obj); // 增加列表信息 int iIdx = review_listBox.Items.Add(strQuestion); review_listBox.SelectedIndex = iIdx; // 更新TFS注释 review_tfs_textBox.Text = GeneralReviewInfo(); }
/// <summary> /// Review问题记录选择改变时更新处理问题状态 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void mod_question_listBox_SelectedIndexChanged(object sender, EventArgs e) { if (mod_question_listBox.SelectedItems.Count == 0) { // 无选择项目 return; } string strQuestion = mod_question_listBox.SelectedItem.ToString(); QuestionRecord questionObj = QuestionRecord.GetObjectFormString(strQuestion); bool bFlag = questionObj.m_strStatus == "打开"; mod_type_comboBox.Text = questionObj.m_strType; mod_level_comboBox.Text = questionObj.m_strLevel; mod_module_textBox.Text = questionObj.m_strModuleName; mod_position_textBox.Text = questionObj.m_strLocation; mod_question_textBox.Text = questionObj.m_strQDes; mod_answer_textBox.Text = questionObj.m_strADes; mod_answer_textBox.Enabled = bFlag; mod_button.Enabled = bFlag; no_button.Enabled = bFlag; }
public static string GetStringFormObject(ReviewRecord obj) { // 有问题记录的Review信息字符串格式: // 【走查者】赵利平 // 【走查时间】2018年2月28日 // 【走查行数】100 // 【1】[类型]实现逻辑[级别]严重[状态]Open[模块]硬件配置[位置]AutoThink.cpp Line:21[问题说明]内存泄露[修改说明]请补充 // // 无问题记录的Review信息字符串格式: // 【走查者】赵利平 // 【走查时间】2018年2月28日 // 【走查行数】100 // 【走查结果】通过 string strReview = "【走查者】" + obj.m_strReviewer + "\r\n" + "【走查时间】" + obj.m_strReviewDate + "\r\n" + "【走查行数】" + obj.m_iReviewLine.ToString() + "\r\n"; if (obj.m_bResultFlag) { strReview += "【走查结果】通过"; } else { // 遍历所有问题 for (int iIdx = 0; iIdx < obj.m_QuestionList.Count; ++iIdx) { string strQuestion = QuestionRecord.GetStringFormObject(obj.m_QuestionList[iIdx]); strReview += "【" + (iIdx + 1).ToString() + "】" + strQuestion; if (iIdx != obj.m_QuestionList.Count - 1) { strReview += "\r\n"; } } } return(strReview); }
public static QuestionRecord GetObjectFormString(string strQuestion) { // [类型]实现逻辑[级别]严重[状态]Open[模块]硬件配置[位置]AutoThink.cpp Line:21[问题说明]内存泄露[修改说明]请补充 // strQuestion = "[类型]实现逻辑[级别]严重[状态]Open[模块]硬件配置[位置]AutoThink.cpp Line:21[问题说明]内存泄露[修改说明]请补充"; QuestionRecord obj = new QuestionRecord(); string[] sArray = Regex.Split(strQuestion, @"\[.*?\]", RegexOptions.IgnoreCase); if (sArray.Count() != 8) { return(null); } // 第一个是空串,从第二个开始处理 obj.m_strType = sArray[1].Trim(); obj.m_strLevel = sArray[2].Trim(); obj.m_strStatus = sArray[3].Trim(); obj.m_strModuleName = sArray[4].Trim(); obj.m_strLocation = sArray[5].Trim(); obj.m_strQDes = sArray[6].Trim(); obj.m_strADes = sArray[7].Trim(); 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; } }
/// <summary> /// 判断问题是否关闭 /// </summary> /// <param name="obj"></param> /// <returns></returns> public static bool QuestionIsClose(QuestionRecord obj) { return(obj.m_strStatus == "关闭" || obj.m_strStatus == "不是问题"); }