MOSS Developement: Storage Space Allocation Report
MOSS Developement: Storage Space Allocation Report
"Storage Space Allocation" report will be available out-of-the box in Site Settings --> Site Collection Administration --> Storage space allocation . The same will be available for site collection administrators as in below screen:
But what if my all site collection users needs to see this report, to be aware of thier site remaining space VS allocated space?
I created a custom web part which displays the pie chart about the same, and this includes below components:
- Custom web application which generates bmp image on-fly. This web application has "DrawChart.ashx" http handler which implements IhttpHandler.
My DrawChart.ashx draws charts based on query string property. (Please refer http://www.codeproject.com/KB/web-image/MyGraphsAndChartsSite.aspx for more information on this web application with source code).
For e.g. DrawChart.ashx?width=250&height=150&background=white&piechart=3.27,100&titles=Space%20Used%20(3.27%20MB),Space%20Remaining%20(96.73%20MB)
Here I passed various parameters like chart widht, height, background color, chart type, parameters and parameters title.
Now I have to get parameters and parameter title values dinamically to generate "Storage Space Allocation" chart. - Custom Web Part which generates above URL property dynamically and renders the chart.
I used SPSite.Usage.Storage to get space used by and SPSite.Quota.StorageMaximumLevel to get maximum allocated space.
Note that the value returned by these two property are in bytes, so I converted it to MB by dividing it with (1024 X 1024).
Now my Dynamic URL will be:
DrawChart.ashx?width=250&height=150&background=white&piechart=SPSite.Usage.Storage/(1024 * 1024),SPSite.Quota.StorageMaximumLevel/(1024 * 1024)&titles=Space%20Used,Space%20Remaining
OH yes you have to impersonate by the account who is site collection admin, to get these two property .
Done!! Result is:
For more flexibility to end users you can provide custom web application base URL property, image width, image height, background color property in "custom tool part".