/// <summary>
 /// 处理测试截面查询条件
 /// </summary>
 /// <param name="req"></param>
 /// <param name="ps"></param>
 void DealWithEqualTypeId(AbnormalThresholdValueSettingRequest req, IList <Func <Abnormal_ThresholdValueTable, bool> > ps)
 {
     if (req.TypeId > 0)
     {
         ps.Add(m => m.Id == req.TypeId);
     }
 }
        /// <summary>
        /// 通过测点编号Id修改阈值
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        public Abnormal_ThresholdValueTable ModifyAbnormalThresholdValueByTypeId(AbnormalThresholdValueSettingRequest req)
        {
            IList <Func <Abnormal_ThresholdValueTable, bool> > ps = new List <Func <Abnormal_ThresholdValueTable, bool> >();

            DealWithEqualTypeId(req, ps);
            return(_abnormalThresholdValueSettingDAL.FindBy(ps).SingleOrDefault());
        }
        public ActionResult AbnormalSaveThresholdValue(AbnormalThresholdValueView model)
        {
            var color   = string.Empty;
            var message = string.Empty;

            if (ModelState.IsValid)
            {
                var req = new AbnormalThresholdValueSettingRequest
                {
                    TypeId = model.TypeId,
                    MaxLevelThresholdValue = model.AbnormalThresholdValues[0],
                    MinLevelThresholdValue = model.AbnormalThresholdValues[1]
                };
                var abnomalthresholdValueSettingService = new AbnormalThresholdValueSettingService();
                var resp = abnomalthresholdValueSettingService.ModifyAbnormalThresholdValue(req);
                message = resp.Message;
                color   = resp.Succeed ? StyleConstants.GreenColor : StyleConstants.RedColor;
            }
            else
            {
                message = "阈值设置错误!";
                color   = StyleConstants.RedColor;
            }
            return(Json(new { color, message }, JsonRequestBehavior.AllowGet));
        }
        public AbnormalThresholdValueResponse ModifyAbnormalThresholdValue(AbnormalThresholdValueSettingRequest req)
        {
            var resp = new AbnormalThresholdValueResponse();

            try
            {
                var abnormalThresholdValues = ModifyAbnormalThresholdValueByTypeId(req);
                abnormalThresholdValues.MaxLevelThresholdValue = req.MaxLevelThresholdValue;
                abnormalThresholdValues.MinLevelThresholdValue = req.MinLevelThresholdValue;
                SaveThresholdValueByPointsNumberId(abnormalThresholdValues);
                resp.Message = "保存成功!";
                resp.Succeed = true;
            }
            catch (Exception ex)
            {
                resp.Message = "阈值保存失败!";
                Log(ex);
            }
            return(resp);
        }