All posts by rogue lj

VB.NET Iteration Time

I recently had reason to perform an operation on a bunch of files in a directory. I wanted to view a running average iteration time. It would have been easy to use a collection / generic / array, sum the contents and divide by the collection / generic / array length, but I knew there was a simpler way, having done it before. Linq to the rescue! Here the function :

 

    Public Function IterateFiles(path As String) As Double

        Dim iterationDurations As New List(Of Double)

        For Each fileName As String In IO.Directory.GetFiles(path, "*.*", IO.SearchOption.AllDirectories)

            Dim iterationStartTime As Date = Now

            ' ... Your operation here...

            Dim iterationEndTime As Date = Now

            iterationDurations.Add((iterationEndTime - iterationStartTime).TotalMilliseconds)

            Console.Write("{0} Avg Iteration Time {1}", vbCr, System.Linq.Enumerable.Average(iterationDurations).ToString("F2"))

        Next

        Return System.Linq.Enumerable.Average(iterationDurations)

    End Function

Sharepoint 2010 & Google Analytics

Discovered that you can set a custom variable in Google Analytics to the ID of the Sharepoint user (that’s ID, not Name) :

This is the tracking code I used. The important part here is the _gaq.push([‘_setCustomVar’ line. We can use the Sharepoint JS variable _spUserId:


Don’t forget to change the UA string from

UA-xxxxxxxx-x

to the value for your site!

 Lovely!

Sharepoint Error, Part 2

Sharepoint Error

“The list cannot be imported because a Microsoft SharePoint Foundation-compatible spreadsheet application is not installed or is not compatible with your browser.”

 I resolved the above error by running the Office Setup routine from the installation disk. Incidentally, you’ll need to use 32 bit Internet Explorer when importing your spreadsheet as a list.

However, I still had an issue, where once i’d clicked ‘Import’, the following error occurred:

“An unexpected error has occurred.”
 
Handy. Not.

However, the following Microsoft Support Article helped resolved the issue:

http://support.microsoft.com/kb/2492798

It would appear that you have to append ‘&ListBaseType=0&DisplayName=Spreadsheet+Import‘ to the URL of the import page.

Thanks to the following websites for help with this:

http://kbalertz.com/833714/requires-Windows-SharePoint-error-message-Office-document-document-library.aspx

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

http://lichao.net/eblog/how-to-resolve-edit-document-requires-a-windows-sharepoint-services-compatible-application-and-microsoft-internet-explorer-60-or-greater-error-200901215.html