Sign In
dwinter's [MSFT] WebLog
SharePoint Program Manager
Translate This Page
Translate this page
Powered by
Microsoft® Translator
Options
Blog Home
About
Email Blog Author
Share this
RSS for posts
Atom
RSS for comments
Search
Advanced search options...
Search In:
Everything
Blogs
Forums
People
Groups
Places
Pages
Date range:
All Time
Last Year
Last 6 Months
Last 3 Months
Last Month
Last Week
Last Two Days
Tags
Active Directory
DST2007
Exchange Server
General OM
Introducing...
Pages
Patching
PowerShell
Product Support
SharePoint 2010
Site Definitions
SPAT
SPC2008
SPModule
Tool Release
ULSViewer
Web Services
WikiMigrator
Archive
Archives
December 2009
(1)
August 2009
(1)
May 2009
(1)
December 2008
(1)
November 2008
(1)
September 2008
(2)
August 2008
(1)
July 2008
(4)
June 2008
(10)
March 2008
(2)
December 2007
(1)
June 2007
(2)
March 2007
(1)
December 2006
(2)
July 2006
(1)
June 2006
(1)
January 2006
(1)
May 2005
(1)
March 2005
(5)
February 2005
(10)
July 2004
(1)
Setting Max and Warning Quotas globally on existing WSS sites
MSDN Blogs
>
dwinter's [MSFT] WebLog
>
Setting Max and Warning Quotas globally on existing WSS sites
Setting Max and Warning Quotas globally on existing WSS sites
Dan Winter - MSFT
18 Feb 2005 4:02 PM
Comments
0
Refer to
http://blogs.msdn.com/dwinter/archive/2005/02/15/373076.aspx
for setup if you are not familiar with creating a SharePoint OM application.
This is a simple example of changing Max and Warning Storage quotas on all sites. This can be necessary if you wish to change the quotas on existing sites and not just new ones. I am showing a few new concepts over previous blog entries which will likely continue to be used in later blog entires.
First I want to point out that I am using a perhaps non-standard technique to allow for quick design and easy interface. This app requires:
a combobox named vsCombo
a listbox named vsList
a listbox named errorBox (which I'm logging errors/etc to)
two textboxes for input newMax and newWarn
a button called setNewValues.
You can pretty up the interface however you want beyond this and you should be able to drop this code in place. You'll want to register the combobox dropdown event and also the button click to match these functions.
I am doing something unique here by putting the URL of the virtualservers in a listbox and then putting the actual virtualserver objects in a listbox that is hidden (vsList.Visible=false). I then ensure that selectedindexchanged on the combobox also moves the index number in the listbox so we can access the right item later.
You may be saying.. I could have also accessed
SPSite.Quota.StorageMaximumLevel
and warninglevel from a simple SPSite object as in the DeleteSite example. However, the methods are only read only there. Set is allowed in intellisense but not in reality. So by getting an SPSite object off of a SPVirtualServer object, we are going through a different codepath that is allowing us to have both get and set. This may change in the future, but at the time I wrote this code--thats the way it was. It also allows me to show some enumeration code and some tricks, so why not.
private
void
vsCombo_DropDown(
object
sender, System.EventArgs e)
{
//SPGlobalAdmin and SPVirtualServerCollection are under
Microsoft.SharePoint.Administration
//add:
using
Microsoft.SharePoint.Administration;
to the top top allow these to be easily accessible
//
SPGlobalAdmin myGlobalAdmin =
new
SPGlobalAdmin();
SPVirtualServerCollection SPVirtCol = myGlobalAdmin.VirtualServers;
this
.vsList.Items.Clear();
this
.vsCombo.Items.Clear();
foreach
(Microsoft.SharePoint.Administration.SPVirtualServer SPVirt
in
SPVirtCol)
{
try
{
//Add the virtual server URLs to the visible listbox vsCombo.
//Add the virtualserver objects to vsList.
this
.vsList.Items.Add(SPVirt);
this
.vsCombo.Items.Add(SPVirt.Url);
}
catch
(Exception ex)
{
errorBox.Items.Add(ex.Message);
}
}
}
private
void
vsCombo_SelectedIndexChanged(
object
sender, System.EventArgs e)
{
//When you click the virutal server in the combo box, change the selected item in the hidden list.
vsList.SelectedIndex = vsCombo.SelectedIndex;
}
private
void
setNewValues_Click(
object
sender, System.EventArgs e)
{
//I'm accessing the VirtualServer objects in the listbox by casting them as you see below.
SPSiteCollection SPSiteCol = ((SPVirtualServer)(vsList.SelectedItem)).Sites;
foreach
(SPSite mySPSite
in
SPSiteCol)
{
if
(mySPSite.Url == mySiteUrl)
{
//I am getting tempOldMax and tempOldWarn before changing them because...
//How else will I know its value when I go to log the success/failure?
//set max storage level
long
tempOldMax = mySPSite.Quota.StorageMaximumLevel;
mySPSite.Quota.StorageMaximumLevel=Convert.ToInt64(newMax.Text);
errorBox.Items.Add(mySPSite.Url+" Old Max: "+tempOldMax+" New Max: "+newMax.Text);
//set warning storage level
long
tempOldWarn = mySPSite.Quota.StorageWarningLevel;
mySPSite.Quota.StorageWarningLevel=Convert.ToInt64(newWarn.Text);
errorBox.Items.Add(mySPSite.Url+" Old Warn: "+tempOldWarn" New Warn: "+newWarn.Text);
}
}
}
Hope this is useful to someone... More entries to come next week. I'll be posting some SPList object code to show how to change metadata, and also some doclib code.
0 Comments
General OM
Blog - Comment List MSDN TechNet
Comments
Loading...
Leave a Comment
Name
Comment
Please add 8 and 7 and type the answer here:
Post