Thursday, October 8, 2009

Creating recursive folders in the Sharepoint Document Library

Microsoft has a sample on how to create folder to place the file. But when I wish to create the recursive sub folders it is not exactly working. Thus I ended up recoding a little to get this task done.

Dim SubFolders As String = "/" + Format(runDate, "yyyy") + "/" + Format(runDate, "MMM").ToUpper()

Dim Site As SPWeb = New SPSite(SPSite).OpenWeb

For Each Folder In SubFolders.Split("/"c)
If Folder <> "" Then
SPFolder += "/" & Folder
EnsureParentFolder(Site, SPSite + SPFolder + "/")
End If
Next Folder
Public Sub EnsureParentFolder(ByVal ParentSite As SPWeb, ByVal Destination As String)
Destination = ParentSite.GetFile(Destination).Url
Dim index As Integer = Destination.LastIndexOf("/")
Try
If index > -1 Then
Dim currentFolder As SPFolder = ParentSite.RootFolder
currentFolder = currentFolder.SubFolders.Add(Destination)
End If
Catch e As Exception
Console.WriteLine(e.Message.ToString)
End Try
End Sub

Wednesday, April 1, 2009

Mystery of Sharepoint Designer Edit Problem, Workflow is not working properly, cannot edit Excel Web Parts

In the past few months I've been encountering a slew of problems after we have migrated our sharepoint server on the VMWare server. Cannot edit the Sharepoint Page in Sharepoint Designer, the user cannot edit the numbers and figures in Excel Web Part and save it although she has all the rights for the web part and some users are complaining their workflow are not working correctly.

After hours of investigation and fraustrations I observed a few common symptoms in Sharepoint Logs. Everytime the search crawling service is running I will encounter all these issues. And I will keep seeing "Permission Mask Check Failed" in sharepoint log and some occasional event log error which says .NET encounter out of memory issues.

The source of the problem is because the VMWare has not enough memory to run the MOSS Search Services. We confirm the issue by trying to turn off all the crawling schedule on Sharepoint for a few days and all the mystery problems go away. And later we try to turn on the crawling schedules again to see if the same problems come back and it really did come back.

It is the Sharepoint Crawling and Search Services that causes out of memory issue on .NET and the issue introduce a lot of permission related problems and workflow delay etc on Sharepoint. Finally we decided to dedicate another server just for sharepoint server search and crawling.

What I wish to share is, if you normally keep seeing 'Permission Mask Check Failed' in Sharepoint Logs and having frequent out of memory problems, you might want to consider isolating the Search Services on somewhere else to pin point if it is one of the issue. Shared Services and Search Services on sharepoint is something that could consume quite a lot of memory on server unless you have very big memory (4-6 GB RAM ? )allocated for sharepoint server.

Thursday, February 5, 2009

How to call external program to execute from SQL

I was having requirement from user which I need to execute a program everytime a certain record is inserted into SQL with parameter from SQL. After doing some research I found out how to call external program from SQL in this article.

http://msdn.microsoft.com/en-us/library/ms175046(SQL.90).aspx

What I need to achieve will be something similar to this example. I found this very useful.

Writing variable contents to a file
The following example writes the contents of the @var variable to a file named var_out.txt in the current server directory.

Copy Code
DECLARE @cmd sysname, @var sysname
SET @var = 'Hello world'
SET @cmd = 'echo ' + @var + ' > var_out.txt'
EXEC master..xp_cmdshell @cmd

Monday, January 5, 2009

Excel Services Refresh Problem

When opening the workbook and refresh dataconnection sometimes excel can encounter problem playing the data again after refresh. Normal cases involves not setting Trusted Data Connection in excel services etc. But at 1 instance all the normal solution doesn't work for me and I found out this on the internet which seems to solve the problem

http://msdn.microsoft.com/en-us/library/cc514223.aspx


Windows Authentication Option
In Windows authentication mode, Excel Services attempts to use the Windows identity of the user who is logged on when authenticating with the external data source. Be aware of the following when choosing this mode:

Ensure Excel Services is configured to use the Delegation access model rather than the Trusted Subsystem model. You must set this configuration even if Excel Services and the back-end data source are running on the same server. To configure Excel Services to use the Delegation access model, use the Stsadm command-line tool. Type the following commands at a command prompt on the server, replacing sspname with the name of your Shared Services Provider (SSP):

stsadm -o set-ecssecurity -accessmodel delegation -ssp sspname

stsadm -o execsvcadmjobs

iisreset

If the external data source and Excel Services are running on separate servers, set up Kerberos delegation. You must do this to enable Excel Services to delegate the identity of the user who is viewing the workbook through the server tiers. For information about how to do this, see the Configuring Excel Services to Work with Kerberos later in this article.