public bool TryCreateApplication(string name, string hostid) { using (var context = _contextCreator()) { try { var service = new ZabbixApi.Services.ApplicationService(context); var applications = service.Get(new { name = name, hostid = hostid }); var application = applications == null || applications.Count() == 0 ? null : applications.First(); if (application == null) { application = new Application(); application.hostid = hostid; application.name = name; application.Id = service.Create(application); } if (application.Id != null) { _ApplicationCache = application; return(true); } else { return(false); } } catch (Exception ex) { MetricsErrorHandler.Handle(ex, string.Format("Error on configuring zabbix application, zabbix api {0}", _url)); return(false); } }; }
public bool TryCreateApplication(string name, string hostid) { using (var context = _contextCreator()) { try { var service = new ZabbixApi.Services.ApplicationService(context); var applications = service.Get(new { name = name, hostid = hostid }); var application = applications == null || applications.Count() == 0 ? null : applications.First(); if (application == null) { application = new Application(); application.hostid = hostid; application.name = name; application.Id = service.Create(application); } if (application.Id != null) { _ApplicationCache = application; return true; } else { return false; } } catch (Exception ex) { MetricsErrorHandler.Handle(ex, string.Format("Error on configuring zabbix application, zabbix api {0}", _url)); return false; } }; }