Пример #1
0
 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)));
     }
 }
Пример #2
0
        public ActionResult Create(string id, string command, Endpoint model)
        {
            var service = reader.GetService(command);

            if (!service.UserHasAccessTo())
            {
                throw new UnauthorizedAccessException("Access denied to configset");
            }
            ViewBag.Name      = service.ConfigSet.Name;
            ViewBag.System    = service.ConfigSet.System;
            ViewBag.ServiceId = service.Id;
            var endpoint = reader.CreateEndpoint(service, model.Name);

            return(RedirectToAction("Details", new { id = "edit", item = endpoint.Id }));
        }
Пример #3
0
        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)));
            }
        }