/// <summary> /// 添加 /// </summary> /// <param name="host"></param> public bool AddHost(CollectorDBModel model) { bool result = false; lock (_listlock) { try { var item = _collectorList.Find(n => n == model.Host); if (item == null) { //同时修改数据库 if (!new CollectorDBClient().Add(model)) { throw new Exception("同步添加采集器成功,但同步添加数据库失败,请重新检查!"); } else { _collectorList.Add(model.Host); } } else { throw new Exception("采集器已存在,请重新检查!"); } } catch (Exception ex) { throw ex; } } result = true; return(result); }
public void Add(CollectorDBModel model) { var result = _dbCleint.Add(model); if (result == false) { throw new AppException("添加用户失败!"); } }
public bool Add(CollectorDBModel model) { try { string url = UrlHelper.GetInstance().GetDBUrl($"Collector/Add/"); WebApiClient client = new WebApiClient(); return(client.Post <bool, CollectorDBModel>(url, model)); } catch (WebApiClientException ex) { throw new Exception(ex.Message); } }
public bool Add(CollectorDBModel model) { bool result = false; using (var context = new db_cmaEntities()) { context.tb_collector.Add(new tb_collector() { Host = model.Host, Note = model.Note }); result = context.SaveChanges() > 0 ? true : false; } return(result); }
public bool Add(CollectorDBModel model) { try { return(_business.Add(model)); } catch (Exception ex) { throw new HttpResponseException(new HttpResponseMessage() { StatusCode = HttpStatusCode.InternalServerError, Content = new StringContent(ex.Message) }); } }
public ActionResult Add(CollectorDBModel model) { try { _business.Add(model); return(Json(new { State = true, Message = "已经成功添加了一个采集器" })); } catch (AppException ex) { return(Json(new { State = false, Message = ex.Message })); } catch (Exception) { return(Json(new { State = false, Message = "未知错误,请联系管理人员" })); } }