Пример #1
0
        /// <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());
            }
        }
Пример #2
0
        /// <summary>
        /// 确定按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ok_button_Click(object sender, EventArgs e)
        {
            try
            {
                this.Cursor = System.Windows.Forms.Cursors.WaitCursor;

                // 更新数据库信息
                string strReview = ReviewRecord.GetStringFormObject(m_reviewObj);
                DatabaseInterface.ModRecord(m_id, strReview);

                // 给走查者发送邮件
                if (mod_mail_checkBox.CheckState == CheckState.Checked)
                {
                    SendMail();
                }

                this.Cursor       = System.Windows.Forms.Cursors.Arrow;
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            catch (System.Exception ex)
            {
                this.Cursor = System.Windows.Forms.Cursors.Arrow;
                MainForm.ErrorMessage(ex.ToString());
            }
        }
Пример #3
0
        /// <summary>
        /// 给走查者发送邮件
        /// </summary>
        private void SendMail()
        {
            try
            {
                Microsoft.Office.Interop.Outlook.Application outlookApp = new Outlook.Application();
                Outlook.MailItem mailItem = (Outlook.MailItem)outlookApp.CreateItem(Outlook.OlItemType.olMailItem);

                string strTo    = m_reviewObj.m_strReviewer + "@hollysys.net";
                string strTFSID = m_reviewObj.m_strTFSId.ToString();
                mailItem.To         = strTo;
                mailItem.Subject    = "变更集: " + strTFSID + " 走查问题处理通知邮件";
                mailItem.BodyFormat = Outlook.OlBodyFormat.olFormatHTML;

                string strContent = ReviewRecord.GetStringFormObject(m_reviewObj);
                strContent        = strContent.Replace("\r\n", "<br/>");
                strContent        = "您好:<br/><br/>" + strContent + "<br/><br/>此邮件为走查问题处理结果自动邮件通知,不用回复!";
                mailItem.HTMLBody = strContent;

                ((Outlook._MailItem)mailItem).Send();

                mailItem   = null;
                outlookApp = null;
            }
            catch (System.Exception ex)
            {
                throw ex;
            }
        }
Пример #4
0
        // 通过字符串构造对象
        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);
        }
Пример #5
0
        /// <summary>
        /// 构造函数
        /// </summary>
        public ModifyHelperForm(int id, ReviewRecord reviewObj)
        {
            InitializeComponent();

            InitControl();

            this.m_id        = id;
            this.m_reviewObj = reviewObj;
            if (this.m_reviewObj != null)
            {
                InitData();
            }
        }
Пример #6
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);
        }
Пример #7
0
        /// <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);
        }
Пример #8
0
        // 通过对象生成格式化字符串
        public static string GetStringFormObject(TFSRecord obj)
        {
            string strRet = "";

            if (obj == null)
            {
                return(strRet);
            }

            strRet += CheckinRecord.GetStringFormObject(obj.checkinObj);
            for (int iIdx = 0; iIdx < obj.reviewObjList.Count(); ++iIdx)
            {
                ReviewRecord reviewObj = obj.reviewObjList[iIdx];
                strRet += "\r\n";

                strRet += ReviewRecord.GetStringFormObject(reviewObj);
            }

            return(strRet);
        }
Пример #9
0
        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);
        }
Пример #10
0
        /// <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;
                }
            }
        }
Пример #11
0
        /// <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;
            }
        }