コード例 #1
0
        internal static object ToJsonModel(Site site, string path)
        {
            var section = GetDirectoryBrowseSection(site, path);

            DirectoryBrowsingId dirbId = new DirectoryBrowsingId(site?.Id, path, section.IsLocallyStored);

            DirectoryBrowseShowFlags showFlags = section.ShowFlags;

            Dictionary <string, bool> showDictionary = new Dictionary <string, bool>();

            showDictionary.Add("date", showFlags.HasFlag(DirectoryBrowseShowFlags.Date));
            showDictionary.Add("time", showFlags.HasFlag(DirectoryBrowseShowFlags.Time));
            showDictionary.Add("size", showFlags.HasFlag(DirectoryBrowseShowFlags.Size));
            showDictionary.Add("extension", showFlags.HasFlag(DirectoryBrowseShowFlags.Extension));
            showDictionary.Add("long_date", showFlags.HasFlag(DirectoryBrowseShowFlags.LongDate));

            var obj = new {
                id                 = dirbId.Uuid,
                scope              = site == null ? string.Empty : site.Name + path,
                metadata           = ConfigurationUtility.MetadataToJson(section.IsLocallyStored, section.IsLocked, section.OverrideMode, section.OverrideModeEffective),
                enabled            = section.Enabled,
                allowed_attributes = showDictionary,
                website            = SiteHelper.ToJsonModelRef(site),
            };

            return(Environment.Hal.Apply(Defines.Resource.Guid, obj));
        }
コード例 #2
0
        public object Get(string id)
        {
            DirectoryBrowsingId dirbId = new DirectoryBrowsingId(id);

            Site site = dirbId.SiteId == null ? null : SiteHelper.GetSite(dirbId.SiteId.Value);

            return(DirectoryBrowsingHelper.ToJsonModel(site, dirbId.Path));
        }
コード例 #3
0
        public object Patch(string id, [FromBody] dynamic model)
        {
            DirectoryBrowsingId dirbId = new DirectoryBrowsingId(id);

            Site site = dirbId.SiteId == null ? null : SiteHelper.GetSite(dirbId.SiteId.Value);

            if (dirbId.SiteId != null && site == null)
            {
                return(NotFound());
            }

            string configPath = model == null ? null : ManagementUnit.ResolveConfigScope(model);

            DirectoryBrowsingHelper.UpdateSettings(model, site, dirbId.Path, configPath);

            ManagementUnit.Current.Commit();

            return(DirectoryBrowsingHelper.ToJsonModel(site, dirbId.Path));
        }
        public void Delete(string id)
        {
            DirectoryBrowsingId dirbId = new DirectoryBrowsingId(id);

            Context.Response.StatusCode = (int)HttpStatusCode.NoContent;

            Site site = (dirbId.SiteId != null) ? SiteHelper.GetSite(dirbId.SiteId.Value) : null;

            if (site == null)
            {
                return;
            }

            var section = DirectoryBrowsingHelper.GetDirectoryBrowseSection(site, dirbId.Path, ManagementUnit.ResolveConfigScope());

            section.RevertToParent();

            ManagementUnit.Current.Commit();
        }
コード例 #5
0
        public async Task Delete(string id)
        {
            DirectoryBrowsingId dirbId = new DirectoryBrowsingId(id);

            Context.Response.StatusCode = (int)HttpStatusCode.NoContent;

            Site site = (dirbId.SiteId != null) ? SiteHelper.GetSite(dirbId.SiteId.Value) : null;

            if (site != null)
            {
                var section = DirectoryBrowsingHelper.GetDirectoryBrowseSection(site, dirbId.Path, ManagementUnit.ResolveConfigScope());
                section.RevertToParent();
                ManagementUnit.Current.Commit();
            }

            if (dirbId.SiteId == null && DirectoryBrowsingHelper.IsFeatureEnabled())
            {
                await DirectoryBrowsingHelper.SetFeatureEnabled(false);
            }
        }