test
SharePoint 2010 requirements
Microsoft just announced the Sharepoint 2010 preliminary system requirements. From this point on only 64bit of Sharepoint and SQL are supported.
WSS 3 /MOSS SP2 errors encounter
After installing WSS 3 SP2 I encounter the following error.
Server error: http://go.microsoft.com/fwlink?LinkID=96177
I try the following and nothing happened, after started changing the version number in the SQL DB and that broke the entire solution.
USE master;
GO
EXEC sp_configure ’show advanced option’, ‘1′;
RECONFIGURE WITH OVERRIDE;
EXEC sp_configure;
psconfig -cmd upgrade
stsadm -o upgrade –forceupgrade -inplace
stsadm -o upgrade -url http://laptopdev -inplace –forceupgrade
At this point I try the “Sharepoint products and technologies configuration” and created a new Config DB , reinstall the entire and then restore the old DB
stsadm.exe -o addcontentdb -url http://laptopdev:80 -databasename WSS_Content -databaseserver laptopdev
Sending mail using c#
The simple program will send emails at the end of the month.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Mail;
namespace SendEmailLastDayofMonth
{
class Program
{
static void Main(string[] args)
{
DateTime lastDayofMonth = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.DaysInMonth(DateTime.Today.Year,DateTime.Today.Month));
if(DateTime.Today == lastDayofMonth)
{
try
{
MailMessage mM = new MailMessage();
mM.From = new MailAddress(”eddyblanco@gmail.com“);
mM.To.Add(”eddyblanco@gmail.com“);
mM.Subject = “Text Subject”;
mM.Body = “The body of the email”;
mM.IsBodyHtml = true;
mM.Priority = MailPriority.High;
SmtpClient sC = new SmtpClient(”smtp.mail.eddyblanco.com”);
sC.Send(mM);
}
catch
{
}
}
}
}
}
Warning: Importing Group “Group Name”
Today in the process of a SharePoint migration I encounter several Warnings in the logs. Warning: User or group xxxx cannot be resolved.
The problem is every security group that has the ID’s with the warning above do not come over on the import, which shows up as a warning in the import log as.
Warning: Importing Group <Group Name>
The SQL query below when run on the content DB will return all groups that have the owner ID’s specified in the warning.
select * from groups with (nolock) where owner = XXXX
ESP For SharePoint Announced!
Article by Michael Gannotti on the announcement of ESP for SharePoint.
SPDisposeCheck Released
PDisposeCheck for SharePoint Developers has been released. SPDisposeCheck inspect your SharePoint assemblies to make sure you are code is disposing correctly
stsadm restore Results “No content databases are available for this operation”
The reason for the problem is that the GUID is the same as an existing site. You could either delete the old site or create a new web application and restore in that new one.
Visual Studio 2008 extensions for SharePoint 1.3
The Community Technology Preview release for Visual Studio 2008 extensions for SharePoint 1.3 is now publicly available on Microsoft Connect.
The CTP is available at: https://connect.microsoft.com/site/sitehome.aspx?SiteID=428
New Features in VSeWSS 1.3
- The extensions now install on x64 bit OS. Visual Studio 2008 and SharePoint must be already installed.
- Command Line Build option for TFS and MSBuild integration
- Separate WSP Package and Retract commands. You can now build the WSP without deploying it
- SPSolGen to Support Exporting from Content Management Publishing Sites
- New Item Template for RootFiles Deployment
- Automatically Remove conflicting existing features on development SharePoint server
- WSP View New Feature Dialog Improvements: scope, receiver checkbox, element checkbox
- WSP View can now be used to merge features and it blocks site features being merged into web features
- Allow adding separate binary files such as Workflow assemblies
- Some refactoring allowing for Web Part renaming and removing lines from feature.xml Item Removed
- Allow selection of GAC or BIN deployment for Web Part Project not including CAS generation
- Increase visibility of hidden features that VSeWSS creates
- Add fast update deploy for DLL only or file only changes to solutions
- Numerous Bug Fixes and improvements to error messages
Happy New Year
I spent most of this year doing SharePoint development and Architecture. My role at my company will probably continue along that path and perhaps even more so.
Resolutions for 2009
Spend more time outside and SharePoint of course.
Alerts are not working
If your alerts stop working below you will find the solution that works for me. Also I have created a custom handler to take care of the 70 character
stsadm -o updatealerttemplates -url -f “c:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\XML\alerttemplates.xml” -LCID 2057″
- stsadm -o setproperty -propertyname alerts-enabled -propertyvalue false -url
- stsadm -o setproperty -propertyname alerts-enabled -propertyvalue true -url
- stsadm -o setproperty -propertyname job-immediate-alerts -propertyvalue “every 5 minutes” -url
Sub site to use navigation from parent site
In order to use the navigation from the parent site. The following code would help with that.
SPSite SiteCollection = new SPSite(http://laptopdev/eddy);
SPWeb Webopenme = SiteCollection.OpenWeb();
Webopenme.allowunsafeupdates = true;
Webopenme.Navigation.UseShared = true;
Office 14 rumors
Adding a New Group and users to group just created (All Site collections and sub webs)
I needed to add a group and several users to all site collections in a farm that consisted of 4000+ site collections and 20+ terabytes. This users would be a part of an administration group that could view and manage the collections. In order to add the users I use the spfarm class.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;
namespace AddUser
{
class Program
{
static void Main(string[] args)
{
//Add all the users that will be included on the group
string[] username =
{
“laptopdev/jim”,
“laptopdev/administrator”
};
// Get a reference to the local farm
SPFarm oFarm = SPFarm.Local;
// Loop through the services in the farm
foreach (SPService oService in oFarm.Services)
{
// See if this service is a SPWebService
if (oService is SPWebService)
{
// Cast into a SPWebService
SPWebService oWebService = (SPWebService)oService;
// Loop through the web applications in the web service
foreach (SPWebApplication oWebApplication in oWebService.WebApplications)
{
foreach (SPSite oSite in oWebApplication.Sites)
{
// Get the root web object
SPWeb oWebRoot = oSite.RootWeb;
SPRoleDefinition readDef = oWebRoot.RoleDefinitions[”Read”];
SPRoleDefinition contributeDef = oWebRoot.RoleDefinitions[”Contribute”];
SPRoleDefinition admins2 = oWebRoot.RoleDefinitions[”Full Control”];
SPRole admins = oWebRoot.Roles[”Full Control”];
string FBARoleProviderPrefix = “CustomRoleProvider”;
string newGroupName = “Test”;
foreach (SPGroup spGroup in oWebRoot.Groups)
{
//if the group we want to add does not already exist, create it at the top level and make
//the owner the top level owners group.
if (!oWebRoot.SiteGroups.Xml.Contains(string.Format(”Name=\”{0}\”", newGroupName)))
oWebRoot.SiteGroups.Add(newGroupName, oWebRoot.SiteAdministrators[0], null, “This is for administrator for all sites” + newGroupName);
}
try
{
SPGroup newGroup = oWebRoot.SiteGroups[newGroupName];
newGroup.AllowMembersEditMembership = true;
SPRoleAssignment spRoleAssignment = new SPRoleAssignment(newGroup);
SPRoleDefinition role = oWebRoot.RoleDefinitions[”Full Control”];
spRoleAssignment.RoleDefinitionBindings.Add(role);
oWebRoot.RoleAssignments.Add(spRoleAssignment);
oWebRoot.Update();
foreach (string UserName in username)
{
SPUser oUser = oWebRoot.AllUsers[UserName];
newGroup.AddUser(oUser);
newGroup.Update();
}
// Be sure to dispose the SPSite and SPWeb objects for memory cleanup
oWebRoot.Dispose();
oSite.Dispose();
}
catch { }
//Do the same for all the subsites under a site collection.
//Add Full Control to the group
foreach (SPWeb subWeb in oWebRoot.Webs)
{
SPGroup newGroupSubWeb = oWebRoot.SiteGroups[newGroupName];
SPRoleAssignment spRoleAssignmentSubWeb = new SPRoleAssignment(newGroupSubWeb);
SPRoleDefinition roleSubWeb = oWebRoot.RoleDefinitions[”Full Control”];
spRoleAssignmentSubWeb.RoleDefinitionBindings.Add(roleSubWeb);
subWeb.RoleAssignments.Add(spRoleAssignmentSubWeb);
subWeb.Update();
}
}
}
}
}
}
}
MOSS: Goodbye 2000 limit, Hello 3000?
The rule of thumb for SharePoint lists has always been “no more than 2000 items in a given container”.
Now in the recently released White Paper “SharePoint Performance Optimization - How Microsoft IT Increases Availability and Decreases Rendering Time of SharePoint Sites”, the following is stated in the Best Practices section:
“Manage large lists for performance
Having large lists by itself is not necessarily a performance issue. When SharePoint Server renders the many items in those lists, that can cause spikes in render times and database blocking. One way to mitigate large lists is to use subfolders and create a hierarchical structure where each folder or subfolder has no more than 3,000 items.”
The 2000 items was always a soft limit, of course, but interesting to see MS now saying 3000…
The Passing of Patrick Tisseghem
I just read that Patrick Tisseghem, one of the most remarkable persons in the SharePoint community, has passed away. Patrick leaves a huge global footprint in the community, and he will be remembered. I’d like to express my deepest condolences to his family, friends and the entire U2U team.
Patrick, you will be missed.
Windows Server 2008 improvements
Some of the improvements in the Windows 2008 operating system are:
- RPC Asynchronous Pipe vs. Multiple RPC Calls in Windows Server 2003 R2
- Asynchronous I/Os vs. Synchronous I/Os in Windows Server 2003 R2
- Unbuffered I/Os vs. Buffered I/Os in Windows Server 2003 R2
- Low Priority I/Os vs. Normal Priority I/Os in Windows Serve 2003 R2
- 16 Concurrent File Downloads vs. 4 Concurrent File Downloads in Windows Server 2003 R2
Code For Uploading File to Document Library
If you need to upload files to a SharePoint document library programmatically the following code accomplishes that need.
SPSite site = new SPSite(URL);
SPWeb web = site.OpenWeb();
web.AllowUnsafeUpdates=true;
string path =”";
string []fileName =filePath.PostedFile.FileName.Split(’\\’);
int length = fileName.Length;
string file=fileName[length-1];
SPFolder folder = web.GetFolder(LibraryName);
SPFileCollection files=folder.Files;
Stream fStream = filePath.PostedFile.InputStream;
byte[] MyData= new byte[fStream.Length];
fStream.Read(MyData, 0, (int)fStream.Length);
fStream.Close();
SPFile fff= files.Add(file,MyData);
web.AllowUnsafeUpdates=false;
Surfing back home
InfoPath Insert value to Sharepoint List
I’ve working on infopath recently. I had to insert a value via code to a sharepoint list and here in how I did it.
XPathNavigator xnDoc = this.MainDataSource.CreateNavigator();
//Create a Navigator object for the field that you want to set.
XPathNavigator TitleDescription = xnDoc.SelectSingleNode(”/my:Baseline_Change_Request/my:TitleDescription”, this.NamespaceManager);
XPathNavigator XMLFileName = xnDoc.SelectSingleNode(”/my:Baseline_Change_Request/my:CR_File_Name”, this.NamespaceManager);
//Remove the “nil” attribute.
if (TitleDescription.MoveToAttribute(”nil”, “http://www.w3.org/2001/XMLSchema-instance“))
TitleDescription.DeleteSelf();
//Set the value of the TitleDescriptionField field.
TitleDescription.InnerXml.ToString();
XMLFileName.InnerXml.ToString();
string TitleDescriptionSet = TitleDescription.InnerXml.ToString();
string XMLFileNameSet = XMLFileName.InnerXml.ToString();
SPSListWeb.Lists listService = new SPSListWeb.Lists();
DataSet ds = new DataSet();
/*Authenticate the current user by passing their default
credentials to the Web service from the system credential cache.*/
listService.Credentials = System.Net.CredentialCache.DefaultCredentials;
listService.PreAuthenticate = true;
/*Set the Url property of the service for the path to a subsite.*/
listService.Url = “http://xxxxxx/_vti_bin/lists.asmx“;
listService.PreAuthenticate = true;
/*Get Name attribute values (GUIDs) for list and view. */
System.Xml.XmlNode ndListView = listService.GetListAndView(”One Title”, “”);
string strListID = ndListView.ChildNodes[0].Attributes[”Name”].Value;
string strViewID = ndListView.ChildNodes[1].Attributes[”Name”].Value;
/*Create an XmlDocument object and construct a Batch element and its attributes. Note that an empty ViewName parameter causes the method to use the default view. */
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
System.Xml.XmlElement batchElement = doc.CreateElement(”Batch”);
batchElement.SetAttribute(”OnError”, “Continue”);
batchElement.SetAttribute(”ListVersion”, “1″);
batchElement.SetAttribute(”ViewName”, strViewID);
XmlDocument documentQuery = new XmlDocument();
XmlElement query = documentQuery.CreateElement(”Query”);
System.Xml.XmlElement viewFields = documentQuery.CreateElement(”ViewFields”);
// The CAML query to return what I’m looking for.
query.InnerXml = ” <Where>” +
“<Eq>” +
“<FieldRef Name=\”Title\” />” +
“<Value Type=\”Text\”>” + TitleDescriptionSet + “</Value>” +
“</Eq>” +
“</Where>”;
string ListName = “BCR Title”;
XmlNode ndResult = listService.GetListItems(ListName, null, query, viewFields, “10″, null, null);
XmlTextReader rdr = new XmlTextReader(ndResult.OuterXml, XmlNodeType.Document, null);
ds.ReadXml(rdr);
ArrayList array = new ArrayList();
if (XMLFileNameSet == “CR_New”)
{
XMLFileNameSet = “No file”;
batchElement.InnerXml = “<Method ID=’1′ Cmd=’New’>” +
“<Field Name=’Title’>” + XMLFileNameSet + “</Field>” +
“<Field Name=’Description’>” + TitleDescriptionSet + “</Field></Method>”;
/*Update list items. This example uses the list GUID, which is recommended, but the list display name will also work.*/
listService.UpdateListItems(strListID, batchElement);
}
if (ds.Tables.Count > 1)
{
DataTable dt = ds.Tables[1];
foreach (DataRow dr in dt.Rows)
{
string UpdateID = dr[”ows_ID”].ToString();
batchElement.InnerXml = “<Method ID=’1′ Cmd=’Update’>” +
“<Field Name=’ID’>” + UpdateID + “</Field>” +
“<Field Name=’Title’>” + XMLFileNameSet + “</Field>” +
“<Field Name=’Description’>” + TitleDescriptionSet + “</Field></Method>”;
/*Update list items. This example uses the list GUID, which is recommended, but the list display name will also work.*/
listService.UpdateListItems(strListID, batchElement);
}
}
//Clean up.
xnDoc = null;
TitleDescription = null;
