public ActionResult Test(string primaryKey, TestParamViewModel model) { list = new List <InGroupResultViewModel>(); var result = GroupRuleTest(model, primaryKey); if (result.Item1) { _procLogService.Insert(new PDP_PROC_LOG { SD_ID = ProjectProvider.Instance.Current.SD_ID, PROC_CAT_CODE = _procLogService.InGroupCatCode(), PROC_CONTENT_ID = primaryKey, START_TIME = model.startTime, END_TIME = model.endTime, PATIENT_ID = model.patientId, PROC_URL = model.url }); return(Success(result.Item2)); } else { _iErrorLogService.Insert(new PDP_ERROR_LOG { SD_ID = ProjectProvider.Instance.Current.SD_ID, PROC_TYPE = ConvertExeFlag("test"), //PROC_URL = //DLL_NAME = //CLASS_NAME = //FUNC_NAME = ERR_CONTENT = result.Item2, }); list = new List <InGroupResultViewModel>(); return(Error(result.Item2)); } }
[HttpPost]//, AsyncTimeout(60000) //public ActionResult Execute(string url, string primaryKey)//, string ProGuid //{ // int id = int.Parse(primaryKey); // var result = GroupRuleExecute(url.Trim(), id);//, ProGuid // if (result.Item1) // { // _inGroupStateService.InGroupDoExecute(ProjectProvider.Instance.Current.SD_ID, primaryKey); // var prolog = _procLogService.GetManay(log => log.SD_ID == ProjectProvider.Instance.Current.SD_ID && log.PROC_CAT_CODE == "1" && log.PROC_CONTENT_ID == primaryKey).OrderByDescending(r => r.UPD_DATE).FirstOrDefault() ?? new PDP_PROC_LOG(); // _procLogService.Insert(new PDP_PROC_LOG // { // SD_ID = ProjectProvider.Instance.Current.SD_ID, // PROC_CAT_CODE = _procLogService.InGroupCatCode(), // PROC_CONTENT_ID = primaryKey, // START_TIME = prolog.START_TIME, // END_TIME = prolog.END_TIME, // PATIENT_ID = prolog.PATIENT_ID, // PROC_URL = url // }); // return Success("入组执行成功", new { UserName = OperatorProvider.Instance.Current.RealName, UpdateDate = DateTime.Now }); // } // else // { // _iErrorLogService.Insert(new PDP_ERROR_LOG // { // SD_ID = ProjectProvider.Instance.Current.SD_ID, // PROC_TYPE = ConvertExeFlag("execute"), // //PROC_URL = // //DLL_NAME = // //CLASS_NAME = // //FUNC_NAME = // ERR_CONTENT = result.Item2, // }); // return Error(result.Item2); // } //} private Tuple <bool, string> GroupRuleTest(TestParamViewModel model, string primaryKey) { try { DateTime minTime = model.startTime == DateTime.MinValue ? _ingroupService.GetMinAndMaxTime().Item1 : model.startTime; DateTime maxTime = model.endTime == DateTime.MinValue ? _ingroupService.GetMinAndMaxTime().Item2.AddDays(1) : Convert.ToDateTime(model.endTime.ToDateString() + " 23:59:59"); for (DateTime dt = minTime; dt <= maxTime; dt = dt.AddDays(60)) { var starTime = dt; var endTime = dt.AddDays(60) < maxTime?dt.AddDays(60) : maxTime; var tuple = ExecuteUrl(model.url.Trim(), starTime, endTime, model.patientId.IsNullOrEmpty() ? model.patientId : model.patientId.Trim()); if (tuple == null || tuple.Item1.Count == 0 || tuple.Item2.Count == 0 || tuple.Item3.Count == 0) { continue; } if (tuple?.Item2.Select(r => r.SD_CODE).FirstOrDefault() == ProjectProvider.Instance.Current.SD_CODE) { list.AddRange(_inGroupResultService.GetList(tuple.Item3, primaryKey)); } else { list = new List <InGroupResultViewModel>(); return(new Tuple <bool, string>(false, "调用的webapi与该病种不匹配")); } } return(new Tuple <bool, string>(true, "测试成功")); } catch (Exception ex) { return(new Tuple <bool, string>(false, ex.ToString())); } }
public IActionResult BuildQuestion([FromForm] TestParamViewModel testModel) { if (testModel.Test == null) { return(NotFound()); } testModel.CountQuestions = 1; return(View(testModel)); }
public IActionResult CreateParamTest([FromForm] TestParamViewModel testModel) { if (testModel.Test != null) { return(View(testModel)); } else { return(NotFound()); } }
public void CheckValue(TestParamViewModel testModel) { for (int i = 0; i < testModel.Test.Question.Count; i++) { if (testModel.CountAnswerViewModel[i].CountAnswers == 1) { testModel.Test.Question[i].IsOpenType = true; } } testModel.Test.Category = null; }
public ActionResult Test(TestParamViewModel model, bool state) { if (state)//测试 { try { var id = int.Parse(model.primaryKey); var testResult = _ingroupService.GroupRuleTest(model); if (testResult.Item1) { var filterInfo = _ingroupService.Get(r => r.SD_ID == ProjectProvider.Instance.Current.SD_ID && r.SD_FILTER_ID == id); _procLogService.Insert(new PDP_PROC_LOG { SD_ID = ProjectProvider.Instance.Current.SD_ID, PROC_CAT_CODE = _procLogService.InGroupCatCode(), PROC_CONTENT_ID = model.primaryKey, START_TIME = model.startTime == DateTime.MinValue ? (DateTime?)null : model.startTime,//Convert.ToDateTime("1753 年 1 月 1 日") END_TIME = model.endTime == DateTime.MinValue ? (DateTime?)null : model.endTime, PATIENT_ID = model.patientId, PROC_URL = model.url }); return(Success(testResult.Item2, testResult.Item3)); //, testResult.Item3 } else if (!testResult.Item2.Contains("api接口调用失败")) //api接口调用失败的日志已在调用的时候写入日志 { _errorLogService.Insert(new PDP_ERROR_LOG { SD_ID = ProjectProvider.Instance.Current.SD_ID, ERROR_CAT_CODE = "1", SD_CPAT_NO = model.patientId, PROC_TYPE = ConvertExeFlag("test"), PROC_URL = model.url, ERR_CONTENT = testResult.Item2, }); return(Error(testResult.Item2)); } else { return(Error(testResult.Item2)); } } catch (Exception ex) { return(Error(ex.Message)); } } else//取消 { //_ingroupService.CancelTasks(model.clientKey); return(Error("该功能暂时无法使用")); } }
public IActionResult BuildAnswers([FromForm] TestParamViewModel testModel) { if (testModel.Test == null) { return(NotFound()); } if (ModelState.IsValid) { return(View(testModel)); } else { return(View(nameof(BuildQuestions), testModel)); } }
[HttpPost]//, AsyncTimeout(60000) public ActionResult Execute(TestParamViewModel model, bool state) { try { if (state) { int id = int.Parse(model.primaryKey); _ingroupService.GroupRuleExecute(model); //执行成功,插入项目日志 _procLogService.Insert(new PDP_PROC_LOG { SD_ID = ProjectProvider.Instance.Current.SD_ID, PROC_CAT_CODE = _procLogService.InGroupCatCode(), PROC_CONTENT_ID = model.primaryKey, START_TIME = model.startTime == DateTime.MinValue ? (DateTime?)null : model.startTime, //prolog.START_TIME, END_TIME = model.endTime == DateTime.MinValue ? (DateTime?)null : model.endTime, //prolog.END_TIME, PATIENT_ID = model.patientId == null ? null : model.patientId.Trim(), //prolog.PATIENT_ID, PROC_URL = model.url, //url PROC_STAT_CODE = 2, }); return(Success("正在执行入组!"));//入组执行中,可以关闭该窗口,若查看进度,可再次打开该窗口 } else { _ingroupService.CancelTasks(model.clientKey); return(null); } } catch (Exception ex) { _errorLogService.Insert(new PDP_ERROR_LOG { SD_ID = ProjectProvider.Instance.Current.SD_ID, ERROR_CAT_CODE = "1", SD_CPAT_NO = model.patientId, PROC_TYPE = ConvertExeFlag("execute"), PROC_URL = model.url, ERR_CONTENT = ex.ToString(), }); return(Error(ex.InnerException.Message)); } }
public IActionResult CreateQuestion(TestParamViewModel testModel) { List <Question> questions = testModel.Test.Question; if (questions.FirstOrDefault().Answer.Where(p => p.IsCorrect).Count() != 1) { ModelState.AddModelError("", $"Правильным должен быть 1 вариант ответа"); } if (ModelState.IsValid) { handler.CheckValue(testModel); questionService.AddQuestion(testModel.Test.Question.FirstOrDefault()); TempData["message"] = "Отлично!!! Вопрос успешно добавлен"; return(RedirectToAction(nameof(ChooseActionQuestions), new { id = testModel.Test.Id })); } else { return(View(nameof(BuildAnswers), testModel)); } }
public IActionResult CreateTest(TestParamViewModel testModel) { List <Question> questions = testModel.Test.Question; for (int i = 0; i < questions.Count; i++) { if (questions[i].Answer.Where(p => p.IsCorrect).Count() != 1) { ModelState.AddModelError("", $"Правильным должен быть 1 вариант ответа (Вопрос №{i + 1})"); } } if (ModelState.IsValid) { handler.CheckValue(testModel); testService.AddTest(testModel.Test); TempData["message"] = "Отлично!!! Тест успешно создан"; return(RedirectToAction(nameof(GetListTests), new { id = testModel.Test.CategoryId })); } else { return(View(nameof(BuildAnswers), testModel)); } }