eddyblanco on January 22nd, 2010

Yesterday, I was working on a SharePoint Workflow. I needed to copy the final InfoPath (xml) to a different library. My first thought was to use the spfile.copyto but that gave me the “Value does not fall within the expected range.” or COM errors.
Instead of wasting my time trying to figure out how to make the copyto  method copy across site collections, I did the following.
   

SPFile file = workflowProperties.Item.File;
string xmlFileContent = System.Text.Encoding.Default.GetString(file.OpenBinary());
int index = xmlFileContent.IndexOf(”<?xml”);
if (index != 0)
    xmlFileContent = xmlFileContent.Remove(0, index);
XmlDocument doc = new XmlDocument();
doc.LoadXml(xmlFileContent);
XmlNamespaceManager mgr = new XmlNamespaceManager(doc.NameTable);
mgr.AddNamespace(”my”, @”http://schemas.microsoft.com/office/infopath/2003/myXSD/2007-10-05T17:30:02”

 I needed to set the status before I move to the new location.

XmlNode nodeStatus = doc.DocumentElement.SelectSingleNode(”/my:myFields/my:FormStatus”, mgr);
nodeStatus.InnerText = status;
char[] newFile = doc.InnerXml.ToCharArray();
file.SaveBinary(System.Text.Encoding.Default.GetBytes(newFile));
Stream s = file2.OpenBinaryStream();
SPFolder target = curweb.GetFolder(”Contract”);
SPFile ofile = curweb.GetFile(”Contract/” + _requestName + “.xml”);
if (ofile.Exists)
    ofile.Delete();
target.Files.Add(_requestName + “.xml”, s);
fileURLWorkSpace = thedestinationlocation-URL + _requestName + “.xml”;
target.Update(

 Hope this helps someone.

Tags:

eddyblanco on October 21st, 2009

The process to install an instance of Project Server 2007 and the PWA site required a several steps. Please follow the instructions below.

First we have to make sure that the “Project Application Services” is running.

Open the SharePoint Central Administration website and select the “Operations” tab under Topology and services select “Services on Server”. Select “Project Application” and start the “Project Application Service” if is stop.

In order to install the PWA site do the following

Open the SharePoint Central Administration website. Select SharedServices1 or the name of your SSP link in the left menu. Then select

admin-01

Then Click on the “Project Web Access Site” under Project Server heading.

admin-03

Under the “Manage Project Web Access Site” Click the Create Project Web Acess Site button.

admin-04

On the Create Project Web Access Site page, enter the following information, then click the OK

 

SharePoint Web Application to host Project Web Access: <The Name of the website>

Project Web Access path: PWA

Administrator account: <Account>

Primary Database:

Primary database server: <Server Name>

Published database name: Default is <ProjectServer_Published>

Draft database name: Default is <ProjectServer_Draft>

Archive database name: Default is <ProjectServer_Archive>

Reporting Database:

Use the primary database server: Yes

Reporting database name: Default is  <ProjectServer_Reporting>

At the end is going to take a few minutes to create the PWA site and DB’s. Click on refresh tilt you see “Provisioned” Once is completed the PWA site is ready.

eddyblanco on October 19th, 2009

This is a series of White Papers that have been published by Microsoft before the reveal of Sharepoint 2010 at Sharepoint Coference 2009.   

Microsoft SharePoint Server 2010 Upgrade Planning
Microsoft SharePoint Server 2010 — Test Your Upgrade Process
Microsoft SharePoint Server 2010 — Services Upgrade

eddyblanco on May 11th, 2009

Microsoft just announced the Sharepoint 2010 preliminary system requirements. From this point on only 64bit of Sharepoint and SQL are supported.

 

Link

eddyblanco on April 29th, 2009

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

eddyblanco on March 5th, 2009

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
                {
                 
                }
            }
        }
    }
}

eddyblanco on February 28th, 2009

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

eddyblanco on February 10th, 2009

Article by Michael Gannotti on the announcement of ESP for SharePoint.

Link

eddyblanco on January 31st, 2009

PDisposeCheck for SharePoint Developers has been released. SPDisposeCheck inspect your SharePoint assemblies to make sure you are code is disposing correctly

Link

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.

eddyblanco on January 18th, 2009

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
eddyblanco on January 1st, 2009

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.

eddyblanco on December 28th, 2008

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″

  1. stsadm -o setproperty -propertyname alerts-enabled -propertyvalue false -url
  2. stsadm -o setproperty -propertyname alerts-enabled -propertyvalue true -url
  3. stsadm -o setproperty -propertyname job-immediate-alerts -propertyvalue “every 5 minutes”  -url
eddyblanco on November 10th, 2008

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;

eddyblanco on October 24th, 2008

Click to read

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();
                            }
 
                        }
                    }
                }
            }
 
        }
       
 
    }

eddyblanco on September 27th, 2008

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…

eddyblanco on September 7th, 2008

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.

eddyblanco on August 30th, 2008

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
eddyblanco on August 30th, 2008

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;