예제 #1
0
        public JsonResult Add(MonitorItemDBModel model)
        {
            try
            {
                MonitorItemType type = (MonitorItemType)Enum.Parse(typeof(MonitorItemType), Request.Form["typeSelect"].ToString().Trim());

                model               = new MonitorItemDBModel();
                model.Name          = Request.Form["Name"].ToString().Trim();
                model.Note          = Request.Form["Note"].ToString().Trim();
                model.Host          = Request.Form["MHost"].ToString().Trim();
                model.CollectorHost = Request.Form["CollectorHost"].ToString().Trim();
                model.ItemType      = type;
                model.Paramter      = GetParamterStr(Request, model.ItemType);

                bool b = _business.Add(model);
                return(Json(new { State = b }));
            }
            catch (AppException ex)
            {
                return(Json(new { State = false, Message = ex.Message }));
            }
            catch (Exception)
            {
                return(Json(new { State = false, Message = "未知错误,请联系管理人员" }));
            }
        }
예제 #2
0
 public MonitorItemDBModel Get(int id)
 {
     using (var context = new db_cmaEntities())
     {
         var tbItem = context.tb_monitoritem.Where(n => n.Id == id).FirstOrDefault();
         MonitorItemDBModel itemList = GetDBMonitorItemModel(tbItem);
         return(itemList);
     }
 }
예제 #3
0
 public bool Add(MonitorItemDBModel model)
 {
     try
     {
         string       url    = UrlHelper.GetInstance().GetDBUrl($"MonitorItemManage/Add/");
         WebApiClient client = new WebApiClient();
         return(client.Post <bool, MonitorItemDBModel>(url, model));
     }
     catch (WebApiClientException ex)
     {
         throw new Exception(ex.Message);
     }
 }
예제 #4
0
 public bool Edit(MonitorItemDBModel model)
 {
     try
     {
         string       url    = UrlHelper.GetInstance().GetDBUrl($"MonitorItem/Edit");
         WebApiClient client = new WebApiClient();
         var          temp   = client.Post <bool, MonitorItemDBModel>(url, model);
         return(true);
     }
     catch (WebApiClientException ex)
     {
         throw new Exception(ex.Message);
     }
 }
예제 #5
0
 public bool Edit(MonitorItemDBModel model)
 {
     try
     {
         return(_business.Edit(model));
     }
     catch (Exception ex)
     {
         throw new HttpResponseException(new HttpResponseMessage()
         {
             StatusCode = HttpStatusCode.InternalServerError,
             Content    = new StringContent(ex.Message)
         });
     }
 }
예제 #6
0
 public bool Add(MonitorItemDBModel model)
 {
     if (_dbCleint.Add(model))
     {
         if (_coreClient.Add(model))
         {
             return(true);
         }
         else
         {
             throw new AppException("更新采集器失败");
         }
     }
     else
     {
         throw new AppException("添加数据库失败");
     }
 }
예제 #7
0
        public bool Edit(MonitorItemDBModel model)
        {
            bool result = false;

            using (var context = new db_cmaEntities())
            {
                var tbItem = context.tb_monitoritem.Where(n => n.Id == model.Id).FirstOrDefault();

                tbItem.Host = model.Host;
                //tbItem.ItemType = (int)model.ItemType;
                tbItem.Name          = model.Name;
                tbItem.Note          = model.Note;
                tbItem.Paramter      = model.Paramter;
                tbItem.CollectorHost = model.CollectorHost;

                context.SaveChanges();
                result = true;
            }
            return(result);
        }
예제 #8
0
        public bool Add(MonitorItemDBModel model)
        {
            bool result = false;

            using (var context = new db_cmaEntities())
            {
                context.tb_monitoritem.Add(new tb_monitoritem()
                {
                    Host          = model.Host,
                    ItemType      = (int)model.ItemType,
                    Name          = model.Name,
                    Note          = model.Note,
                    CollectorHost = model.CollectorHost,
                    Paramter      = model.Paramter
                });

                context.SaveChanges();
                result = true;
            }
            return(result);
        }
예제 #9
0
 public ActionResult Edit(BaseParamter Model)
 {
     try
     {
         MonitorItemDBModel model = new MonitorItemDBModel();
         model.Id            = Convert.ToInt32(Request.Form["Id"]);
         model.Name          = Request.Form["Name"].ToString().Trim();
         model.Note          = Request.Form["Note"].ToString().Trim();
         model.Host          = Request.Form["MHost"].ToString().Trim();
         model.CollectorHost = Request.Form["CollectorHost"].ToString().Trim();
         model.ItemType      = (MonitorItemType)int.Parse(Request.Form["ItemType"]);
         model.Paramter      = GetParamterStr(Request, model.ItemType);
         bool b = _business.Edit(model);
         return(Json(new { State = b }));
     }
     catch (AppException ex)
     {
         return(Json(new { State = false, Message = ex.Message }));
     }
     catch (Exception)
     {
         return(Json(new { State = false, Message = "未知错误,请联系管理人员" }));
     }
 }
예제 #10
0
 public bool AddMonitorItem(MonitorItemDBModel model)
 {
     return(_collectorClient.AddMonitorItem(model.CollectorHost, null));
 }
예제 #11
0
 public bool DeleteMonitorItem(MonitorItemDBModel model)
 {
     return(_collectorClient.RemoveMonitorItem(model.CollectorHost, model.Id));
 }