New version of the WSP Listener

by Bas Hammendorp 17. May 2010 09:12

Finally after lots of coding, testing and feedback; I have the new WSP listener ready. You can download it from codeplex.

In short, the improvements:

  • All assemblies and required assets in one WSP
  • Seperated code in library assembly
  • Activate the WSP Listener with one simple feature
  • Clear overview of (previous) installations in one document library
  • Several bugfix and code improvements

Hope you like it as much as I do.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , ,

Sharepoint | Tools

Upload a file in central admin document library

by Bas Hammendorp 16. May 2010 09:15

I was making a simple console application to upload a zip file (with a WSP Listener solution) in the document library. This document library was located in the central admin, so I also wanted to find the central admin web application dynamic. I came up with the next solution:

// Set the path to the zip file and the name of the document library
string path = "c:\temp\testfile.zip";
string documentLibraryName = "WSPListener document library";

// Get the central administration web application and the upload folder
SPWeb centralAdminWeb = SPAdministrationWebApplication.Local.Sites[0].OpenWeb();
SPFolder uploadFolder = centralAdminWeb.Folders[documentLibraryName];
bool replaceExistingFiles = true;

SPFolder myLibrary = centralAdminWeb.Folders[documentLibraryName];

// Open a file stream to add the file in the document library
using (FileStream fileStream = File.OpenRead(path))
{
   SPFile spFile = myLibrary.Files.Add(fi.Name, fileStream, replaceExistingFiles);
   myLibrary.Update(); // save the file

   // Get the corresponding SPItem to update some properties and start the installation
   SPListItem item = spFile.Item;
   item["InstallationStartTime"] = null;
   item["InstallationEndTime"] = null;
   item["InstallationStatus"] = "Install";
   item["InstallationResult"] = "";
   item.Update();
}

As you can see, it's very easy :)

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,

C# | Sharepoint

Save a file to disk from a document library

by Bas Hammendorp 13. March 2010 07:17

In my new update for the WSP Listener I need to save a file from a document library to disk. This can be done by the following code:

// item is an SPListItem
SPFile myFile = item.File;
DestinationFile = Path.Combine(@"c:\temp", myFile.Name);
if (File.Exists(DestinationFile))
{
   // Remove the old file
   File.Delete(DestinationFile);
}

// Open the binary data
byte[] data = myFile.OpenBinary();
using (FileStream stream = new FileStream(DestinationFile, FileMode.CreateNew))
{
   // Save the file
   BinaryWriter writer = new BinaryWriter(stream);
   writer.Write(data, 0, (int)myFile.Length);
   writer.Close();
   stream.Close();
}

Have fun!

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , ,

C# | Sharepoint

My first codeplex: WSP Listener

by Bas Hammendorp 8. March 2010 06:53

Finally my first codeplex project is finished: http://wsplistener.codeplex.com/

Super easy copy paste installation of WSP files on different servers in your OTAP environments.

The WSP listener is a windows service application which waits for new config and WSP files in a specific folder. If a new config and WSP file are added, the WSP Listener will install the new SharePoint solution on the server based on values in de config file. The config file is a configuration file (for example MySharePointSolution.wsp.config) which defines the settings for the installation of the WSP solution file.

All feedback is welcome, hope this tool helps improvethe efficiency of your deployment

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , ,

Sharepoint | Tools

UserControl error could not load type in SharePoint

by Bas Hammendorp 18. February 2010 04:59

So I was building my user control in SharePoint, no rocket sience I thought. When I opened my default.aspx page with the user control, the error 'could not load type ...' is shown. After some struggling and experimenting, I found out that my dll which was deployed in the GAC needed to be moved into the BIN folder.

Maybe there is a good explanation for this, but I have no clue ;) So my conclusion is to deploy the ASCX / ASPX code behind assemblies in the BIN folder of the web application.

Have fun!

Update 4 March 2010: Also when you get the error 'Could not load type ...' from a code behind file in for example a masterpage, try to move the assembly to the BIN folder

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,

asp.net | Sharepoint

Draft Item Security in the list schema file

by Bas Hammendorp 6. January 2010 05:21

I was looking for an option to add the 'Draft Item Security' in the list schema file. This can be changed in the UI when you click the document library settings -> versioning settings. The possible options of 'Who should see draft items in this document library?' are:

  • Any user who can read items (DEFAULT)
  • Only users who can edit items
  • Only users who can approve items (and the author of the item)

If you want this setting automatically in you document library, you must add the DraftVersionVisibility attribute to your List node in the schema.xml. The value must be an integer which has the next options:

  • 1 = Only users who can edit items
  • 2 = Only users who can approve items (and the author of the item)
  • All other values = Any user who can read items (DEFAULT)

So for example :

<List Title="My new document list" DraftVersionVisibility="1">

Have fun!

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , ,

Sharepoint

Narrow search results to one type

by Bas Hammendorp 21. December 2009 11:22

Lat's say you want to show the results of your own document content type, but when you search all possible options show up. What you can do then is to add a rule to your search scope.

Go to site settings > Scopes > Click on your custom scope

The click on the 'add rule' option and in the next screen choose the 'Property Query' option. Then choose the 'contentclass' option in the 'Property Query' section. As a value for this property you must fill out the value STS_ListItem_<your list template ID>. For example if you used the template ID 10150 in your list feature, the contenclass must be equal to STS_ListItem_10150. The behaviour option must be set to Require.

After recrawling, the search result is narrowed to only your list items.

Currently rated 3.0 by 5 people

  • Currently 3/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , ,

Sharepoint

In my ONET.XML module I wat two views on one list

by Bas Hammendorp 21. December 2009 07:56

In a recent project I wanted to show two views of one list. The problem is that by default the title of the List node is copied into title[1] and title[2]. To solve this, you must include the <webpart> in the view element. So I opened the ONET.xml of the site definition. In the Configuration/Lists section I added my list feature:

<Lists>
 <List FeatureId="&lt;myGuid>" Title="My List" Type="12345" Url="Lists/MyList" />
</Lists>

Then in the Modules/Module/File section in the ONET.xml we need to add the View element:

<View List="Lists/My List" BaseViewID="1" WebPartZoneID="Header" WebPartOrder="1" Type="HTML">
 <![CDATA[
  <WebPart xmlns="http://schemas.microsoft.com/WebPart/v2">
   <Title>My first custom title</Title>
   <Assembly>Microsoft.SharePoint, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>
   <TypeName>Microsoft.SharePoint.WebPartPages.ListViewWebPart</TypeName>
  </WebPart>
 ]]>
</View>


<View List="Lists/My List" BaseViewID="2" WebPartZoneID="Header" WebPartOrder="2" Type="HTML">
 <![CDATA[
  <WebPart xmlns="http://schemas.microsoft.com/WebPart/v2">
   <Title>My second custom title</Title>
   <Assembly>Microsoft.SharePoint, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>
   <TypeName>Microsoft.SharePoint.WebPartPages.ListViewWebPart</TypeName>
  </WebPart>
 ]]>
</View>

As you can see, in the CDATA you can find an element Title which you can use for your own custom title!

Have fun!

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , ,

Sharepoint

Enable list versioning in the schema.xml

by Bas Hammendorp 15. October 2009 05:01

If you want to enable versioning for your Sharepoint list, you can do this is the schema.xml of your list. You must add the next attributes in the List node:

VersioningEnabled="TRUE" MajorVersionLimit="0" MajorWithMinorVersionsLimit="0"

It's as easy as that, but always be carefull not to enable this for all lists!

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,

Sharepoint

Show all items of the Sharepoint list item in itemstyle.xsl

by Bas Hammendorp 28. September 2009 09:03

If you want to know which attributes and value are available in a sharepoint list (item), you can add the following code in the itemstyle.xsl:

<xsl:for-each select="@*">
Item: <xsl:value-of select="name()"/>
Value: <xsl:value-of select="."/><br/>
</xsl:for-each>

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,

Sharepoint | XSL

Powered by BlogEngine.NET 1.4.5.0
Theme by Mads Kristensen

About the author

My name is Bas Hammendorp, I work as an Enterprise Engineer at PGGM. My specialties are ASP.NET, C#, SQL and Sharepoint 2007.

Google ads