#region 得到测试用例编号
        private string GetTestCaseCode(int projectID)
        {
            //用例编号编码规则:系统编号+版本_功能点编号_U+两位流水号
            string testCaseCode = "";
            DALService.DALServiceClient dal = new TMS.WinUI.DALService.DALServiceClient();
            Model.ProjectModel projectModel = new TMS.Model.ProjectModel();
            projectModel = dal.ProjectGetModel(projectID);
            string functionIDCode = projectModel.ProjectCode;

            testCaseCode = projectModel.ItemCode + projectModel.Version + "_" + functionIDCode + "_U";
            int testCaseCodeCount = dal.GetTestCaseCode(testCaseCode);
            string strSplice = "";
            string testCaseResult = "";
            if (testCaseCodeCount != -1)
            {
                if (testCaseCodeCount == 0)
                {
                    testCaseResult = testCaseCode + "01";
                    dal.Close();
                    return testCaseResult;
                }
                else
                {
                    if (testCaseCodeCount + 1 < 10)
                    {
                        strSplice = "0" + (testCaseCodeCount + 1).ToString();
                        testCaseResult = testCaseCode + strSplice;
                    }
                    else
                    {
                        testCaseResult = testCaseCode + (testCaseCodeCount + 1).ToString();
                    }
                }
            }
            dal.Close();
            return VerifyGetTestCaseCode(testCaseResult);
        }

        private string VerifyGetTestCaseCode(string testCaseResult)
        {
            DALService.DALServiceClient dal = new TMS.WinUI.DALService.DALServiceClient();
            int count = dal.VerifyTestCaseCode(testCaseResult);//是否有相同的用例编号在数据库中大于0说明存在
            string verifyTestCaseResult = "";
            if (count != -1)
            {
                if (count == 0)
                {
                    verifyTestCaseResult = testCaseResult;
                    dal.Close();
                    return verifyTestCaseResult;
                }
                else
                {
                    //取两位流水号
                    string strSpliceTestCase = testCaseResult.Substring(testCaseResult.Length - 2, 2);
                    //如果有重复在原来两位流水号个位加1
                    int newTestCase = Convert.ToInt32(strSpliceTestCase.Substring(1, 1)) + 1;
                    //用例编号固定的组成部分(用例编号编码规则:系统编号+版本_功能点编号_U)
                    string itemCodeVersionInfo = testCaseResult.Substring(0, testCaseResult.Length - 2);
                    //判断新的流水号个位是否小于10,小于10前面加0
                    if (newTestCase < 10)
                    {
                        verifyTestCaseResult = itemCodeVersionInfo + "0" + newTestCase.ToString();
                        dal.Close();
                        return VerifyGetTestCaseCode(verifyTestCaseResult);
                    }
                    else
                    {
                        verifyTestCaseResult = itemCodeVersionInfo + newTestCase.ToString();
                        dal.Close();
                        return VerifyGetTestCaseCode(verifyTestCaseResult);
                    }
                }
            }
            else
            {
                dal.Close();
                return verifyTestCaseResult;
            }
            dal.Close();

        }
        #endregion

 

来源:(http://www.szemba.cn/  深圳MBA

posted on 2012-06-08 13:50  小角色  阅读(194)  评论(0)    收藏  举报