示例#1
0
        public JsonResult AddorEidt(MonitoringconfigViewModel model)
        {
            object retJson = new { success = 0, msg = "操作失败" };

            if (model.Id > 0)//如果是修改 删除已存在的数据
            {
                var boo = bll.DeleteByType(model.TypeId, model.TargetId, model.RelatedId);
            }
            else//如果是修改判断是否已存在
            {
                var isextist = bll.Exists(model.TypeId, model.TargetId, model.RelatedId);
                if (isextist)
                {
                    retJson = new { success = 1, msg = "此数据已存在" };
                    return(Json(retJson));
                }
            }
            foreach (var op in model.WhichHourLists)
            {
                JMP.MDL.jmp_channel_filter_config mo = new JMP.MDL.jmp_channel_filter_config();
                if (op.Threshold == 0)
                {
                    continue;
                }
                else
                {
                    mo.TypeId            = model.TypeId;
                    mo.RelatedId         = model.RelatedId;
                    mo.TargetId          = model.TargetId;
                    mo.WhichHour         = op.WhichHour;
                    mo.IntervalOfRecover = model.IntervalOfRecover;
                    mo.Threshold         = op.Threshold;
                    mo.CreatedByUserId   = UserInfo.UserId;
                    mo.CreatedByUserName = UserInfo.UserName;
                    mo.CreatedOn         = DateTime.Now;
                    int cg = bll.Add(mo);
                    if (cg > 0)
                    {
                        Logger.CreateLog("操作监控配置", mo);

                        retJson = new { success = 1, msg = "操作成功" };
                    }
                    else
                    {
                        retJson = new { success = 0, msg = "操作失败" };
                    }
                }
            }
            return(Json(retJson));
        }
示例#2
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public ActionResult AddMonitoringconfig()
        {
            int TypeId    = string.IsNullOrEmpty(Request["TypeId"]) ? -1 : int.Parse(Request["TypeId"]);
            int TargetId  = string.IsNullOrEmpty(Request["TargetId"]) ? -1 : int.Parse(Request["TargetId"]);
            int RelatedId = string.IsNullOrEmpty(Request["RelatedId"]) ? -1 : int.Parse(Request["RelatedId"]);
            var list      = new List <JMP.MDL.jmp_channel_filter_config>();
            var model     = new MonitoringconfigViewModel();

            if (TypeId >= 0 && TargetId >= 0 && RelatedId >= 0)
            {
                JMP.BLL.jmp_channel_filter_config yybll = new JMP.BLL.jmp_channel_filter_config();
                string where = " TypeId=" + TypeId + " and  TargetId=" + TargetId + " and RelatedId=" + RelatedId + "";
                DataTable yydt = yybll.GetList(where).Tables[0];//获取应用类型在用信息
                List <JMP.MDL.jmp_channel_filter_config> yylist = JMP.TOOL.MdlList.ToList <JMP.MDL.jmp_channel_filter_config>(yydt);
                list = yylist;

                model.RelatedId         = list[0].RelatedId;
                model.IntervalOfRecover = list[0].IntervalOfRecover;
                model.TypeId            = list[0].TypeId;
                model.TargetId          = list[0].TargetId;
                model.Id = list[0].Id;
            }
            for (int i = 0; i < 24; i++)
            {
                var hourConfig = new WhichHourList
                {
                    Threshold = 0,
                    WhichHour = i,
                };
                var filter = list.FirstOrDefault(x => x.WhichHour == i);
                if (filter != null)
                {
                    hourConfig.Threshold = filter.Threshold;
                }
                model.WhichHourLists.Add(hourConfig);
            }
            ViewBag.mo = model;
            return(View());
        }