public override ThresholdValueResponse ModifyThresholdValue(ThresholdValueSettingRequest req)
        {
            var resp = new ThresholdValueResponse();

            try
            {
                var source = ModifyThresholdValueByPointsNumberId(req);
                foreach (var item in source)
                {
                    item.PositiveFirstLevelThresholdValue  = req.PositiveFirstLevelThresholdValue;
                    item.PositiveSecondLevelThresholdValue = req.PositiveSecondLevelThresholdValue;
                    item.NegativeFirstLevelThresholdValue  = req.NegativeFirstLevelThresholdValue;
                    item.NegativeSecondLevelThresholdValue = req.NegativeSecondLevelThresholdValue;
                }
                var thresholdValue = source.First();
                SaveThresholdValueByPointsNumberId(thresholdValue);

                resp.Message = "保存成功!";
                resp.Succeed = true;
            }
            catch (Exception ex)
            {
                resp.Message = "阈值保存失败!";
                Log(ex);
            }
            return(resp);
        }
Example #2
0
 /// <summary>
 /// 处理测点编号包含字符查询条件
 /// </summary>
 /// <param name="req"></param>
 /// <param name="ps"></param>
 void DealWithContainsPointsNumber(ThresholdValueSettingRequest req, IList <Func <T, bool> > ps)
 {
     if (!string.IsNullOrEmpty(req.PointsNumber))
     {
         ps.Add(m => m.PointsNumber.Name.Contains(req.PointsNumber));
     }
 }
Example #3
0
        /// <summary>
        /// 通过测点编号Id修改阈值
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        public T ModifyThresholdValueByPointsNumberId(ThresholdValueSettingRequest req)
        {
            IList <Func <T, bool> > ps = new List <Func <T, bool> >();

            DealWithContainsPointsNumber(req, ps);
            return(_thresholdValueSettingDAL.FindBy(ps, PointsNumber_NavigationProperty).SingleOrDefault());
        }
        public ActionResult SaveThresholdValue(ThresholdValueView model)
        {
            var color   = string.Empty;
            var message = string.Empty;

            if (ModelState.IsValid)
            {
                var req = new ThresholdValueSettingRequest
                {
                    PointsNumber   = model.PointsNumber,
                    PointsNumberId = model.PointsNumberId
                };
                SaveThresholdValuesFromViewToRequest(req, model);
                var thresholdValueSettingService = ThresholdValueSettingServiceFactory.GetThresholdValueServiceFrom(model.TestTypeId);
                var resp = thresholdValueSettingService.ModifyThresholdValue(req);
                message = resp.Message;
                color   = resp.Succeed ? StyleConstants.GreenColor : StyleConstants.RedColor;
            }
            else
            {
                message = "阈值设置错误!";
                color   = StyleConstants.RedColor;
            }
            return(Json(new { color, message }, JsonRequestBehavior.AllowGet));
        }
        void SaveThresholdValuesFromViewToRequest(ThresholdValueSettingRequest req, ThresholdValueView model)
        {
            var tg = ThresholdValuesConvert.ConvertForm(model.ThresholdValues);

            req.PositiveFirstLevelThresholdValue  = tg.PositiveStandardValueGroup.FirstLevelThresholdValue;
            req.PositiveSecondLevelThresholdValue = tg.PositiveStandardValueGroup.SecondLevelThresholdValue;
            req.NegativeFirstLevelThresholdValue  = tg.NegativeStandardValueGroup.FirstLevelThresholdValue;
            req.NegativeSecondLevelThresholdValue = tg.NegativeStandardValueGroup.SecondLevelThresholdValue;
        }
Example #6
0
        public ThresholdValueWithoutNegativeResponse ModifyThresholdValue(ThresholdValueSettingRequest req)
        {
            var resp = new ThresholdValueWithoutNegativeResponse();

            try
            {
                var thresholdValues = ModifyThresholdValueByPointsNumberId(req);
                thresholdValues.PositiveFirstLevelThresholdValue  = req.PositiveFirstLevelThresholdValue;
                thresholdValues.PositiveSecondLevelThresholdValue = req.PositiveSecondLevelThresholdValue;
                SaveThresholdValueByPointsNumberId(thresholdValues);
                resp.Message = "保存成功!";
                resp.Succeed = true;
            }
            catch (Exception ex)
            {
                resp.Message = "阈值保存失败!";
                Log(ex);
            }
            return(resp);
        }