Exemple #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)));
     }
 }
        public ActionResult AddToSet(string id)
        {
            var configSet = reader.GetConfigSet(id);

            ViewBag.Id = id;
            return(View(new AdministratorsModel {
                CurrentAdministrators = configSet.Administrators.ToList(), AvaliableUsers = ConfigReaderFactory.GetUserFacade().GetUsers().ToList(), PostedUserIds = new string[] {}
            }));
        }
Exemple #3
0
        public ActionResult Create(string id)
        {
            var configSet = reader.GetConfigSet(id);

            if (!configSet.UserHasAccessTo())
            {
                throw new UnauthorizedAccessException("Access denied to configset");
            }
            ViewBag.Id     = configSet.Id;
            ViewBag.Name   = configSet.Name;
            ViewBag.System = configSet.System;
            return(View((object)null));
        }
        public ActionResult Create(string id, string command)
        {
            var cs = reader.GetConfigSet(command);

            if (!cs.UserHasAccessTo())
            {
                throw new UnauthorizedAccessException("Access denied to configset");
            }
            ViewBag.Trail  = cs.GetTrail();
            ViewBag.Name   = cs.Name;
            ViewBag.System = cs.System;
            return(View());
        }
        public ActionResult Create(string id, string item)
        {
            var cs = configSetTasks.GetConfigSet(item);

            ViewBag.Trail = cs.GetTrail();
            if (!cs.UserHasAccessTo())
            {
                throw new UnauthorizedAccessException("Access denied to configset");
            }
            ViewBag.Name   = cs.Name;
            ViewBag.System = cs.System;
            return(View((object)null));
        }
Exemple #6
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)));
            }
        }
Exemple #7
0
 public bool TryUpdateCache(string configSet, string environment)
 {
     using (TracerFactory.StartTracer(this, "TryUpdateCache"))
     {
         var  config = configSetTask.GetConfigSet(configSet);
         bool doSave;
         var  raw = config.GetRawConfigData(environment, out doSave);
         var  environmentSettings = GetEnvironmentSettings(config, environment);
         if (doSave)
         {
             environmentTask.UpdateEnvironment(environmentSettings);
         }
         if (realtimeNotificationService != null)
         {
             realtimeNotificationService(configSet, environment);
         }
         var wrapper = Runtime.CreateRuntimeTask <ICacheManagementWrapper>(environmentSettings.CacheType.CacheType);
         return(wrapper.UpdateCache(environmentSettings, raw));
     }
 }
        public ActionResult Details(string name, string system)
        {
            var cs = reader.GetConfigSet(name, system);

            if (!cs.UserHasAccessTo())
            {
                throw new UnauthorizedAccessException("Access denied to configset");
            }
            ViewBag.Id = cs.Id;
            return(View(cs));
        }