File Extension Find Media Formats in eDirectory

Details

This is file extension report that displays the fullpath, filename, size, owner, scan_target, and file_extension from the srs.current_fs_scandata_eir database view, and is limited to current scan data in eDirectory.

Code
 SELECT
    sd.fullpath AS fullpath1,
    sd.name,
    srs.byte_string(sd.size),
    sd.size,
    sd.owner_display_name,
    sd.scan_target,
    sd.filename_extension,
    Sum(sd.size) OVER (PARTITION BY sd.filename_extension, sd.scan_target) AS extension_size_by_target,
    srs.byte_string(CAST(Sum(sd.size) OVER (PARTITION BY sd.filename_extension, sd.scan_target) AS BIGINT)) AS extension_size_by_target_string,
    Sum(sd.size) OVER (PARTITION BY sd.filename_extension) AS extension_total_size,
    srs.byte_string(CAST(Sum(sd.size) OVER (PARTITION BY sd.filename_extension) AS BIGINT)) AS extension_total_size_string
FROM
    srs.current_fs_scandata_edir AS sd
WHERE
    sd.filename_extension IN ('3gp','3g2','asf','avi','drc','flv','mkv','mng','mp4','m2v','m4p','m4v','mov','mpg','mp2','mpeg','mpe','mpv','mv4','mxf','ogg','ogv','qt','rm', 'rmvb', 'roq', 'svi', 'webm', 'wmv', 'yuv','act','aiff','aac','amr','au','awb','dct','dss','dvf','flac','gsm','iklax','ivs','m4a','m4p','mmf','mp3','mpc','msv','opus','raw','wav','wma','wv')
 
 const long OneKB = 1024;           // KiloBytes
const long OneMB = OneKB * 1024;   // Megabytes
const long OneGB = OneMB * 1024;   // Gigabytes
const long OneTB = OneGB * 1024;   // Terabytes
const long OnePB = OneTB * 1024;   // Petabytes
const long OneEB = OnePB * 1024;   // Exabytes

private static string GetByteSizeString(long size)
{
    double dbl = 0;
    string str = string.Empty;
    string precisionStr = "#.##";
    var _size = Math.Abs(size);
    
    if (size < 0)
        str = "-";

    if (_size < OneKB)
    {
        str += _size + " bytes";
    }
    else if (_size < OneMB)
    {
        dbl = (double)_size / OneKB;
        str += dbl.ToString(precisionStr) + " KB";
    }

    else if (_size < OneGB)
    {
        dbl = (double)_size / OneMB;
        str += dbl.ToString(precisionStr) + " MB";
    }
    else if (_size < OneTB)
    {
        dbl = (double)_size / OneGB;
        str += dbl.ToString(precisionStr) + " GB";
    }

    else if (_size < OnePB)
    {
        dbl = (double)_size / OneTB;
        str += dbl.ToString(precisionStr) + " TB";
    }

    else if (_size < OneEB)
    {
        dbl = (double)_size / OnePB;
        str += dbl.ToString(precisionStr) + " PB";
    }

    else
    {
        dbl = (double)_size / OneEB;
        str += dbl.ToString(precisionStr) + " EB";
    }

    return str;
}

private void chart1_CustomDrawAxisLabel(object sender, DevExpress.XtraCharts.CustomDrawAxisLabelEventArgs e) {
    RenderCustomAxisLabel(sender, e);
}

private void chart1_CustomDrawSeriesPoint(object sender, DevExpress.XtraCharts.CustomDrawSeriesPointEventArgs e) {
    RenderCustomSeriesPoint(sender, e);
}

private void RenderCustomAxisLabel(object sender, DevExpress.XtraCharts.CustomDrawAxisLabelEventArgs e)
{
    var chart = sender as DevExpress.XtraReports.UI.XRChart;
    if (chart == null)
        return;

    XYDiagram xyd = chart.Diagram as XYDiagram;
    if (xyd == null)
        return;

    if (e.Item.Axis == xyd.AxisY)
    {
        long value = (long)(double)e.Item.AxisValue;
        e.Item.Text = GetByteSizeString(value);
    }
}

private void RenderCustomSeriesPoint(object sender, DevExpress.XtraCharts.CustomDrawSeriesPointEventArgs e)
{
    long value = (long)e.SeriesPoint[0];
    e.LabelText = GetByteSizeString(value);
} 
Author
richlagger
Last modified
Friday, April 10, 2015 - 14:41
Properties
Minimum Version
Report Category
Includes a Report Layout
Yes
Databases
Tags
Rating
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
Downloads
Sample Report
Preview Images