Пример #1
0
        public virtual async Task <IActionResult> Put(string key, [FromBody] EdmPluginDescriptor entity)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                string systemName       = key.Replace('-', '.');
                var    pluginDescriptor = pluginFinder.GetPluginDescriptorBySystemName(systemName, LoadPluginsMode.All);

                if (pluginDescriptor == null)
                {
                    return(NotFound());
                }

                pluginDescriptor.FriendlyName = entity.FriendlyName;
                pluginDescriptor.DisplayOrder = entity.DisplayOrder;
                pluginDescriptor.LimitedToTenants.Clear();

                if (!entity.LimitedToTenants.IsNullOrEmpty())
                {
                    pluginDescriptor.LimitedToTenants = entity.LimitedToTenants.ToList();
                }

                PluginManager.SavePluginDescriptor(pluginDescriptor);
            }
            catch (Exception x)
            {
                //Logger.LogError(new EventId(), x, x.GetBaseException().Message);
            }

            return(Ok(entity));
        }
Пример #2
0
        public virtual async Task <IActionResult> Get(string key)
        {
            string systemName          = key.Replace('-', '.');
            var    pluginDescriptor    = pluginFinder.GetPluginDescriptorBySystemName(systemName, LoadPluginsMode.All);
            EdmPluginDescriptor entity = pluginDescriptor;

            return(Json(JObject.FromObject(entity)));
        }
Пример #3
0
        public virtual SingleResult <EdmPluginDescriptor> Get([FromODataUri] string key)
        {
            if (!CheckPermission(StandardPermissions.FullAccess))
            {
                return(SingleResult.Create(Enumerable.Empty <EdmPluginDescriptor>().AsQueryable()));
            }

            string systemName          = key.Replace('-', '.');
            var    pluginDescriptor    = pluginFinder.GetPluginDescriptorBySystemName(systemName, false);
            EdmPluginDescriptor entity = pluginDescriptor;

            return(SingleResult.Create(new[] { entity }.AsQueryable()));
        }
Пример #4
0
        public virtual IHttpActionResult Put([FromODataUri] string key, EdmPluginDescriptor entity)
        {
            if (!CheckPermission(StandardPermissions.FullAccess))
            {
                return(Unauthorized());
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                string systemName       = key.Replace('-', '.');
                var    pluginDescriptor = pluginFinder.GetPluginDescriptorBySystemName(systemName, false);

                if (pluginDescriptor == null)
                {
                    return(NotFound());
                }

                pluginDescriptor.FriendlyName = entity.FriendlyName;
                pluginDescriptor.DisplayOrder = entity.DisplayOrder;
                pluginDescriptor.LimitedToTenants.Clear();
                if (!entity.LimitedToTenants.IsNullOrEmpty())
                {
                    pluginDescriptor.LimitedToTenants = entity.LimitedToTenants.ToList();
                }
                PluginFileParser.SavePluginDescriptionFile(pluginDescriptor);
            }
            catch (Exception x)
            {
                logger.Value.Error(x.Message, x);
            }

            return(Updated(entity));
        }