Exemplo n.º 1
0
        /// <summary>
        /// analyze text in the doc and Bulk insert Vcr Test.
        /// </summary>
        /// <param name="filepath"></param>
        /// <param name="vcrid"></param>
        /// <returns></returns>
        public List <VcrTest> BulkInsert(string filepath, string vcrid)
        {
            Result <List <SplitWord> > result = WordHelper.FindInAll(filepath);
            List <VcrTest>             list   = new List <VcrTest>();

            if (result.Code == 0)
            {
                try
                {
                    string  answer = string.Empty;
                    string  option = string.Empty;
                    string  ans    = string.Empty;
                    VcrTest vcrTestModel;

                    foreach (var item in result.Data)
                    {
                        vcrTestModel = new VcrTest();
                        answer       = Utility.DropHTML(item.Answer).Replace(":", ":");

                        if (!string.IsNullOrEmpty(answer))
                        {
                            var dalist = answer.Split(':');
                            if (dalist.Length == 2)
                            {
                                option = string.Join(",", Utility.GetLetters(Convert.ToInt32(dalist[0])).ToArray());
                                ans    = dalist[1].Replace("\\", ",");//将英文反斜杠替换成逗号
                            }
                            else
                            {
                                option = string.Join(",", Utility.GetLetters());
                                ans    = dalist[0].Replace("\\", ",");//将英文反斜杠替换成逗号
                            }


                            vcrTestModel.Analyze      = item.Analytic;
                            vcrTestModel.Answer       = ans;
                            vcrTestModel.AnswerLetter = option;
                            vcrTestModel.Id           = Guid.NewGuid().ToString("n");
                            vcrTestModel.IsCorrect    = false;
                            vcrTestModel.IsEnabled    = true;
                            vcrTestModel.Qustion      = item.Question;
                            vcrTestModel.VcrId        = vcrid;
                        }

                        list.Add(vcrTestModel);
                    }

                    return(list);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }


            return(null);
        }
Exemplo n.º 2
0
        public ActionResult Add(VcrTest mdl)
        {
            int i = dbData.Add(mdl);

            return(Json(new { i }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 3
0
 public int Update(VcrTest mdl)
 {
     return(vcrTestDal.Update(mdl));
 }
Exemplo n.º 4
0
 public int Add(VcrTest mdl)
 {
     return(vcrTestDal.Add(mdl));
 }