Table of Contents

Class ListWidgetBase

Namespace
Dynamicweb.Dashboard.Widgets
Assembly
Dynamicweb.Core.dll

The class DashboardWidget provides base list dashboard widget

[AddInIcon(KnownIcon.List)]
public abstract class ListWidgetBase : DashboardWidget, IParameterOptions
Inheritance
ListWidgetBase
Implements
Derived
Inherited Members

Examples

using Dynamicweb.Core;
using Dynamicweb.Dashboard.Data;
using Dynamicweb.Dashboard.Widgets;
using Dynamicweb.Extensibility.AddIns;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Dynamicweb.Dashboard.Examples;

[AddInName("Top files folders size")]
[AddInDescription("Show files folders sizes")]
[AddInIcon(Core.UI.Icons.KnownIcon.Healing)]
public class FilesFolderSizes : ListWidgetBase
{
    const string Folder = "/Files";

    public FilesFolderSizes()
    {
        Title = "Top space-hogging files folders";
    }

    public override IEnumerable<ListViewItem> GetItems(IDashboard dashboard, string path)
    {
        var filesPath = SystemInformation.MapPath(Folder);

        var items = from dirPath in Directory.GetDirectories(filesPath)
                    let dirInfo = new DirectoryInfo(dirPath)
                    let dirSize = Helper.DirSize(dirInfo)
                    orderby dirSize descending
                    select new
                    {
                        Name = dirInfo.Name,
                        Size = dirSize
                    };

        double count;
        string subtitle;
        foreach (var item in items.Take(4))
        {
            Helper.HumanizeByteSize(item.Size, out count, out subtitle);
            yield return new ListViewItem()
            {
                Icon = Core.UI.Icons.KnownIcon.Folder,
                Title = item.Name,
                Hint = string.Format("The folder size {0:0.##} {1}", count, subtitle)
            };
        }
    }
}

Constructors

ListWidgetBase()

The list widget default constructor

public ListWidgetBase()

Methods

GetItems(IDashboard, string)

Gets list items

public abstract IEnumerable<ListViewItem> GetItems(IDashboard dashboard, string path)

Parameters

dashboard IDashboard

The dashboard

path string

The request path

Returns

IEnumerable<ListViewItem>
To top