设为首页 收藏本站
查看: 933|回复: 0

[经验分享] 查看SharePoint 2007中站点的存储空间和配额

[复制链接]

尚未签到

发表于 2015-9-29 10:48:28 | 显示全部楼层 |阅读模式
  今天一个朋友问起我, 如何查看它的站点的空间使用情况.
  
  首先, 你需要在管理中心中给站点指定一个配额(Quota).
  
  1. 在管理中心中先建立一个quota template.
  2. 点击Site collection quotas and locks. 选中一个site collection.
  3. 给这个站点集指定一个quota template.
  4. 然后在站点集的网站设置页面中, 就可以看到如下的链接: Storage space allocation出现了.
DSC0000.png
  5. 点击这个链接, 你就可以进入下面的页面, 查看站点集内的任何文档库, 列表, 和文档的大小了.
DSC0001.png
  通过代码, 你也可以得到相同的结果, 代码如下:
    SPSite oSite = new SPSite("http://blr3r7-19c:13774/sites/testwp");
DataTable oDtRawData = null;
// this line of code will return the stroage information of all the document lirbaries in this site
oDtRawData = oSite.StorageManagementInformation(
SPSite.StorageManagementInformationType.DocumentLibrary,
SPSite.StorageManagementSortOrder.Increasing,
SPSite.StorageManagementSortedOn.Size, 100);
// this line of code will return the stroage information of all the lists in this site
oDtRawData = oSite.StorageManagementInformation(
SPSite.StorageManagementInformationType.List,
SPSite.StorageManagementSortOrder.Increasing,
SPSite.StorageManagementSortedOn.Size, 100);
// this line of code will return the stroage information of all the Documents in this site
oDtRawData = oSite.StorageManagementInformation(
SPSite.StorageManagementInformationType.Document,
SPSite.StorageManagementSortOrder.Increasing,
SPSite.StorageManagementSortedOn.Size, 100);
// if you wan to see column names, loop through all the columns and find out the names and grab the needed one.
foreach (DataColumn oColumn in oDtRawData.Columns)
{
Console.WriteLine(oColumn.ColumnName);
}
Console.ReadLine();
// loop through all the rows and find out the values. Here the size will be return in bytes (size/1024 = size in KBs)
foreach (DataRow oRow in oDtRawData.Rows)
{
Console.WriteLine(oRow["Title"].ToString() + " : " + oRow["Size"].ToString() + " : " + oRow["LeafName"].ToString());
}
Console.ReadLine();
}  
  第二种方法, 使用stsadm命令: stsadm -o enumsites -url http://testserver/
  输出结果举例:
<Sites Count="1">
<Site Url="http://testserver" Owner="domain\mossadmin" ContentDatabase="WSS_
Content_80" StorageUsedMB="8.9" StorageWarningMB="150" StorageMaxMB="200" /
>
</Sites>  
  第三种方法, 使用Object Model.
string siteCollectionURL = "http://testserver/"; // Site Collection URL
SPSiteAdministration st = new SPSiteAdministration(siteCollectionURL);
float scDiskUsage = st.DiskUsed;
float a = (scDiskUsage / (1024 * 1024));  
  注意: 这里得到的全部都是站点集的大小.
  
  如何得到子站点的大小呢?
  ======================
  方法是使用Object Model, 代码如下:
public void GetSubSiteSize()
{
string siteCollectionURL = ""; // Site Collection URL
SPSite oSPSite = new SPSite(siteCollectionURL);
SPWeb oSPWeb = oSPSite.RootWeb;
float totalSiteDiskUsage = GetWebSize(oSPWeb);
string filePath = @"C:\MyFile.txt"; // File Path
FileStream sb = new FileStream(filePath, FileMode.Create);
StreamWriter sw = new StreamWriter(sb);
sw.Write(str);
sw.Close();
}
private float GetWebSize(SPWeb web)
{
float total = 0;
foreach (SPFolder folder in web.Folders)
{
total += GetFolderSize(folder);
}
foreach (SPWeb subweb in web.Webs)
{
total += GetWebSize(subweb);
subweb.Dispose();
}
if (!web.IsRootWeb)
{
str += "Site url : " + web.Url + "\r\n";
str += "Size : " + (total / (1024 * 1024)) + " MB" + "\r\n";
str += "\r\n";
}
return total;
}
private float GetFolderSize(SPFolder folder)
{
float folderSize = 0;
foreach (SPFile file in folder.Files)
{
folderSize += file.Length;
}
foreach (SPFolder subfolder in folder.SubFolders)
{
folderSize += GetFolderSize(subfolder);
}
return folderSize;
}  
  参考资料:
  Check quota data for a site
  http://office.microsoft.com/en-us/sharepointtechnology/HA101577661033.aspx
  SharePoint Quota Management
  http://nextconnect.blogspot.com/2009/06/sharepoint-quota-management.html
  STSADM EnumSites Operation Reports Actual Site Storage space as ZERO for an actively used site
  http://www.sharepointdev.net/sharepoint--setup-upgrade-administration-operation/stsadm-enumsites-operation-reports-actual-site-storage-space-as-zero-for-an-actively-used-site-2280.shtml
  SharePoint Site Size?
  http://social.technet.microsoft.com/Forums/en/sharepointadmin/thread/8fd798ac-e60f-471c-ae5f-523393360cf8
  WSS - How to get site size? Site collection site? Workspace site? - WSS
  http://social.technet.microsoft.com/Forums/en-US/sharepointgeneral/thread/a2e84703-2be2-488d-84f5-d6f287de621d
  How to find out the storage space allocation details a site through code.
  http://blogs.msdn.com/sowmyancs/archive/2008/11/15/how-to-find-out-the-storage-space-allocation-details-a-site-through-code.aspx

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-120357-1-1.html 上篇帖子: Microsoft Office SharePoint Server 2007的文件目录结构 下篇帖子: How to Manually Remove SharePoint Portal Server
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表