public HttpResponseMessage TryAddService([FromBody] ServiceRegistrationServer.ServiceRegistrationMessage data) { try { var cs = configSetTasks.GetConfigSet(data.ConfigSetId); var service = (from s in cs.Services where s.Name == data.ServiceName select s).SingleOrDefault(); if (service.IsNull()) { service = configSetTasks.CreateService(cs, data.ServiceName); configSetTasks.CreateEndpoint(service, data.DefaultBinding, data.Properties); var env = (from e in cs.Environments where e.Name == data.Environment select e).SingleOrDefault(); if (env.IsNull()) { env = environmentTasks.CreatEnvironment(cs, data.Environment); } var serviceRoot = (from sp in env.SubstitutionParameters where sp.Name == string.Format("{0}_Address", data.ServiceName) select sp).SingleOrDefault(); if (serviceRoot.IsNull() && data.DefaultEnvirionmentUrlPath.ContainsCharacters()) { serviceRoot.ItemValue = data.DefaultEnvirionmentUrlPath; } ConnectToHost(data, cs, service); } return(Request.CreateResponse(HttpStatusCode.OK, "OK")); } catch (Exception exception) { Logging.Exception(exception); return(Request.CreateResponse(HttpStatusCode.InternalServerError, string.Format("Error: {0}", exception.Message))); } }
public ActionResult Create(string id, string command, ServiceDescription model) { var cs = reader.GetConfigSet(command); if (!cs.UserHasAccessTo()) { throw new UnauthorizedAccessException("Access denied to configset"); } ViewBag.Name = cs.Name; ViewBag.System = cs.System; reader.CreateService(cs, model.Name); return(RedirectToAction("Details", "ConfigSet", new { name = cs.Name, system = cs.System })); }
public ActionResult TryAddService(string serviceMetadata) { try { if (serviceMetadata.IsNullOrWhiteSpace()) { using (var tr = new StreamReader(Request.InputStream)) { serviceMetadata = tr.ReadToEnd(); } } var data = Deserializer <ServiceRegistrationServer.ServiceRegistrationMessage> .Deserialize(serviceMetadata); var cs = configSetTasks.GetConfigSet(data.ConfigSetId); var service = (from s in cs.Services where s.Name == data.ServiceName select s).SingleOrDefault(); if (service.IsNull()) { service = configSetTasks.CreateService(cs, data.ServiceName); configSetTasks.CreateEndpoint(service, data.DefaultBinding, data.Properties); var env = (from e in cs.Environments where e.Name == data.Environment select e).SingleOrDefault(); if (env.IsNull()) { env = environmentTasks.CreatEnvironment(cs, data.Environment); } var serviceRoot = (from sp in env.SubstitutionParameters where sp.Name == string.Format("{0}_Address", data.ServiceName) select sp).SingleOrDefault(); if (serviceRoot.IsNull() && data.DefaultEnvirionmentUrlPath.ContainsCharacters()) { serviceRoot.ItemValue = data.DefaultEnvirionmentUrlPath; } ConnectToHost(data, cs, service); } return(Json("OK")); } catch (Exception exception) { Logging.Exception(exception); return(Json(string.Format("Error: {0}", exception.Message))); } }