/// <summary>
        /// 创建场景
        /// </summary>
        public static void creatScene(Stream MS, int DemandID, string name)
        {
            QCTESTEntities QC_DB = new QCTESTEntities();

            M_runScene mrs = new M_runScene();

            mrs.DemandID  = DemandID;
            mrs.name      = name;
            mrs.creatDate = DateTime.Now;
            QC_DB.M_runScene.Add(mrs);



            HSSFWorkbook hssfworkbook = new HSSFWorkbook(MS);


            HSSFFormulaEvaluator eva = new HSSFFormulaEvaluator(hssfworkbook);

            //eva.EvaluateInCell(cell);//取结果不取公式
            eva.EvaluateAll();//取结果不取公式

            ISheet sheet = hssfworkbook.GetSheetAt(0);

            System.Collections.IEnumerator rows = sheet.GetRowEnumerator();
            rows.MoveNext();



            while (rows.MoveNext())
            {
                IRow   row       = (IRow)rows.Current;
                string sheetName = row.GetCell(1).ToString();
                if (sheetName == null || sheetName.Trim() == "")
                {
                    break;
                }

                ISheet caseSheet = hssfworkbook.GetSheet(sheetName);

                //找不到相关案例的话直接下一条
                int        ID  = Convert.ToInt32(caseSheet.SheetName);
                M_testCase mtc = QC_DB.M_testCase.Where(t => t.ID == ID).FirstOrDefault();
                if (mtc == null)
                {
                    continue;
                }

                var rts = getRunScript <M_runTestCase>(mtc, caseSheet, mrs.ID);
                QC_DB.M_runTestCase.AddRange(rts);
            }

            QC_DB.SaveChanges();
        }
Beispiel #2
0
        public static void creatScene(Stream MS, int DemandID, string name)
        {
            QCTESTEntities QC_DB = new QCTESTEntities();

            M_runScene mrs = new M_runScene();

            mrs.DemandID  = DemandID;
            mrs.name      = name;
            mrs.creatDate = DateTime.Now;
            QC_DB.M_runScene.Add(mrs);



            HSSFWorkbook hssfworkbook = new HSSFWorkbook(MS);


            HSSFFormulaEvaluator eva = new HSSFFormulaEvaluator(hssfworkbook);

            //eva.EvaluateInCell(cell);//取结果不取公式
            eva.EvaluateAll();//取结果不取公式

            ISheet sheet = hssfworkbook.GetSheetAt(0);

            System.Collections.IEnumerator rows = sheet.GetRowEnumerator();
            rows.MoveNext();



            while (rows.MoveNext())
            {
                IRow   row       = (IRow)rows.Current;
                string sheetName = row.GetCell(1).ToString();
                if (sheetName == null || sheetName.Trim() == "")
                {
                    break;
                }

                ISheet caseSheet = hssfworkbook.GetSheet(sheetName);

                insertRunCase(QC_DB, caseSheet, mrs.ID);
            }

            QC_DB.SaveChanges();
        }