コード例 #1
0
ファイル: HPNController.cs プロジェクト: x55756016/kmproject
        public ActionResult getHistory(string userId, string templateName)
        {
            try
            {
                if (string.IsNullOrEmpty(templateName) || string.IsNullOrEmpty(userId))
                {
                    return(Json(new { Status = -1, Data = string.Empty, Msg = "参数错误1" }, JsonRequestBehavior.AllowGet));
                }

                HR_CNR_USER user = _db.Set <HR_CNR_USER>().Where(p => p.USERID == userId).FirstOrDefault();
                if (user == null)
                {
                    return(Json(new { Status = -2, Data = string.Empty, Msg = "参数错误2" }, JsonRequestBehavior.AllowGet));
                }

                /*if (string.IsNullOrEmpty(user.IDCARD))
                 *  return Json(new { Status = -3, Data = string.Empty, Msg = "参数错误3" }, JsonRequestBehavior.AllowGet);
                 *
                 * HPN_Users hpn_user = (from x in _db.Set<HPN_Users>() where x.IDCard == user.IDCARD select x).FirstOrDefault();
                 * if(hpn_user == null)
                 *  return Json(new { Status = -4, Data = string.Empty, Msg = "参数错误4" }, JsonRequestBehavior.AllowGet);*/

                HPN_TEMPLATE temp = templateService.getTemplateByName(templateName);
                if (temp == null)
                {
                    return(Json(new { Status = -5, Data = string.Empty, Msg = "参数错误5" }, JsonRequestBehavior.AllowGet));
                }

                List <HPN_TESTRESULT> testResultList = (from x in _db.Set <HPN_TESTRESULT>()
                                                        where x.TEMPLATENAME == templateName && x.USERID.Equals(user.USERID)
                                                        select x).OrderBy(p => p.INPUTTIME).ToList();

                Chart chart = new Chart();
                chart.title = temp.TITLE;

                ChartData chartData = new ChartData();
                chartData.label                = temp.TITLE;
                chartData.fillColor            = "rgba(151,187,205,0.2)";
                chartData.strokeColor          = "rgba(151,187,205,1)";
                chartData.pointColor           = "rgba(151,187,205,1)";
                chartData.pointStrokeColor     = "#fff";
                chartData.pointHighlightFill   = "#fff";
                chartData.pointHighlightStroke = "rgba(151,187,205,1)";

                foreach (HPN_TESTRESULT item in testResultList)
                {
                    chart.labels.Add(item.INPUTTIME.ToString());
                    chartData.data.Add(item.RESULT.ToDouble(0));
                }
                chart.datasets.Add(chartData);

                return(Json(new { Status = 1, Data = chart, Msg = "操作成功" }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(new { Status = -99, Data = string.Empty, Msg = ex.Message }, JsonRequestBehavior.AllowGet));
            }
        }
コード例 #2
0
ファイル: HPNController.cs プロジェクト: x55756016/kmproject
        public ActionResult getTemplate(string templateName, string userId = null)
        {
            if (string.IsNullOrEmpty(templateName))
            {
                return(null);
            }

            HPN_TEMPLATE template = templateService.getTemplateByName(templateName);

            if (template == null)
            {
                return(null);
            }

            return(Json(template, JsonRequestBehavior.AllowGet));
        }
コード例 #3
0
ファイル: HPNController.cs プロジェクト: x55756016/kmproject
        public ActionResult getResult(string testno)
        {
            HPN_TESTRESULT   testResult = (from x in _db.Set <HPN_TESTRESULT>() where x.TESTNO == testno select x).FirstOrDefault();
            List <subresult> list       = new List <subresult>();
            HPN_TEMPLATE     t          = (from x in _db.Set <HPN_TEMPLATE>() where x.NAME == testResult.TEMPLATENAME select x).FirstOrDefault();
            int templateType            = 1;

            if (t != null)
            {
                templateType = (int)t.TYPE;
            }
            if (!string.IsNullOrEmpty(testResult.RESULT))
            {
                list = testResult.RESULT.JsonDeserialize() as List <subresult>;
            }
            else
            {
                List <HPN_RESULTDESC> resultList = templateService.getResultDescByScore(testResult.TEMPLATENAME, testResult.RESULT.ToDouble(0));
                if (resultList.Count <= 0)
                {
                    subresult sr = new subresult();
                    sr.Score  = testResult.RESULT.ToDouble(0);
                    sr.RESULT = string.Empty;
                    sr.Remark = string.Empty;
                    list.Add(sr);
                }
                else
                {
                    foreach (HPN_RESULTDESC result in resultList)
                    {
                        subresult sr = new subresult();
                        sr.Score  = testResult.RESULT.ToDouble(0);
                        sr.RESULT = result.RESULT;
                        sr.Remark = result.RESULTDETAIL;
                        list.Add(sr);
                    }
                }
            }
            return(Json(new { Score = testResult.RESULT, Result = list, IsFinish = testResult.USERID == "0" ? true : false, TemplateType = templateType, UserId = testResult.USERID }, JsonRequestBehavior.AllowGet));
        }