Wiggy Thoughts

Monday, August 24, 2009

Software (and Sharepoint) Development

Nowadays it’s really important to do a proper google search before embracing a new development task. This gains a bigger importance when we’re talking about sharepoint development.

Why?

Simple, sharepoint development is done on virtual machine in a single server environment, but production scenarios are normally populated by several servers in a Sharepoint Farm.

Just to give you all an example: I was starting a simple task - “Just add a simple WSP Feature to allow application content deployment, much like calling STSADM –o copyappbincontent”.

My first thought was, “Ok, that’s a simple one”… than as usually i googled a little about it, just to get myself into context and figure out if someone had any problem in a similar approach. The truth is that it has token me only a few minutes, to figure out that my task was not going to be that simple, because i found this and this one to. After that, I've started implementing a different solution for that not so simple task.

Bottom line: Allays (even for the simpler tasks) have someone in your team to “loose” a few minutes investigating for problems and solutions… it will save you (or your team) a lot.

Labels:

Wednesday, August 19, 2009

Content Management and Sharepoint

The use of Sharepoint as a content management product is growing fast. Microsoft Sharepoint is a average product that has several advantages, been one of them it’s ease of use. Standard users can by itself deploy content management solutions with low effort.

Ease of use sometimes means that important issues are left aside. Despite what the majority believes, content management is not all about content types and template layouts. One of the major and probably the most important issue to solve in a content management solution is content categorization.

If you don’t provide your solution with the means to properly categorize the information, soon it will be left down. Sharepoint somehow provide means to categorize contents but they are poorly implemented. Basically, you can use sub-sites, lists, folders, navigation and that’s it. If one wants to provide extended cross-site categorization capabilities it is left alone with the need to implement custom tools.

I find it very important to discuss proper content categorization, as it is a key for success in a content management solution. Therefore i will be writing more about this issues here.

Labels: ,

Sunday, June 21, 2009

Provision lookup field using only the list schema

Defining a lookup field on a list schema seems to be a simple task… but as almost everything that looks simple, it turns out not so simple.

My first approach was to simply include this in my list schema:

<Field ID="{52C2BFC2-268B-4bc8-9D6D-A7BEDEFDFA8C}" Type="Lookup" Name="QuestionCategory"
DisplayName="Category" List="{a8c71795-34a4-41e2-b15e-72a3620a1887}" ShowField="CategoryName" />


And it didn’t worked. First thought was to create a feature receiver that would handle the lookup field provision. But after a few minutes googling about the problem i found that apparently de List attribute should be set to the lookup list relative path. So, this one just works:



<Field ID="{52C2BFC2-268B-4bc8-9D6D-A7BEDEFDFA8C}" Type="Lookup" Name="QuestionCategory"
DisplayName="Categoria" List="$Resources:core,lists_Folder;/Categories" ShowField="CategoryName" />

Labels:

Saturday, June 20, 2009

Removing the “Title” column from a sharepoint list

Recently I’ve needed to provide a list without using the default “Title” column. Removing the title was quite easy.

The problem is that if you remove the “Title” column you lose the item menu… or not! yes, it’s true, it took me a while googling the internet, but i found this. It’s a nice, and simple post that explains how to add the link and the menu to a custom column.

Labels:

Friday, June 12, 2009

Linked Files and WSPBuilder

I’m a WSPBuilder fan. I like the way it works, and i really like the Visual Studio extensions.

As everything else WSPBuilder is not perfect, it has at least one major drawback. It can’t handle visual studio linked files. This is a major problem for me, because i like to have my pages and user controls on a Web application and use a different project for the WSP.

To solve this problem I've created a simple command line application that reads the WSP project, and copies the linked files to the expected location. Now i use this tool as a PreBuild step for my WSP project, and that’s it… Linked files now work like a charm.

You can download the tool from here and check it’s source code (very simple) :

   1:  #region Revision history
   2:  // 6/12/2009 7:14:58 AM, Pedro M.V.Gomes -
   3:  //      Initial version.
   4:  #endregion
   5:   
   6:  #region Using directives
   7:  using System;
   8:  using System.IO;
   9:  using System.Xml;
  10:  #endregion
  11:   
  12:  namespace PedroMVGomes.CopyVsLinkedFiles {
  13:      /// <summary>
  14:      /// </summary>
  15:      public class Program {
  16:          public static int Main(string[] args) {
  17:              // check arguments
  18:              if (args.Length != 1) {
  19:                  Console.Out.WriteLine("syntax error");
  20:                  Console.Out.WriteLine("usage: CopyVsLinkedFiles.exe VSProject");
  21:                  return -1;
  22:              }
  23:   
  24:              // output welcome message
  25:              Console.Out.WriteLine("Visual Studio Linked Files Copy Tool");
  26:              Console.Out.WriteLine("Version: 0.1.0.0");
  27:              Console.Out.WriteLine("Created by Pedro M.V.Gomes, All rights reserved");
  28:              Console.Out.WriteLine("http://wiggythoughts.blogspot.com/");
  29:              Console.Out.WriteLine();
  30:   
  31:              // file must exist
  32:              string file = args[0];
  33:              if (!File.Exists(file)) {
  34:                  Console.Out.WriteLine("project file not found");
  35:                  return -2;
  36:              }
  37:   
  38:              // get folder name, will use later to combine with linked relative path
  39:              string projectFolder = Path.GetDirectoryName(file);
  40:   
  41:              // load project XML
  42:              XmlDocument projectFile = new XmlDocument();
  43:              projectFile.Load(file);
  44:   
  45:              // add msbuild namespace
  46:              XmlNamespaceManager nsManager = new XmlNamespaceManager(projectFile.NameTable);
  47:              nsManager.AddNamespace("mns", "http://schemas.microsoft.com/developer/msbuild/2003");
  48:   
  49:              // search linked nodes
  50:              XmlNodeList nodes = projectFile.DocumentElement.SelectNodes(@"//mns:Content/mns:Link", nsManager);
  51:              foreach (XmlNode node in nodes) {
  52:   
  53:                  // compute source and target path
  54:                  string linkFile = node.FirstChild.Value;
  55:                  string linkedFile = node.ParentNode.Attributes["Include"].Value;
  56:                  string source = Path.Combine(projectFolder, linkedFile);
  57:                  string target = Path.Combine(projectFolder, linkFile);
  58:   
  59:                  if (File.Exists(target)) {
  60:                      // compare file modified dates and decide if we need to copy the files
  61:                      FileInfo sourceFileInfo = new FileInfo(source);
  62:                      FileInfo targetFileInfo = new FileInfo(target);
  63:                      if (targetFileInfo.LastWriteTimeUtc == sourceFileInfo.LastWriteTimeUtc) {
  64:                          continue;
  65:                      }
  66:                  }
  67:   
  68:                  // copy files
  69:                  Console.Out.WriteLine("Copying file {0} to {1}", source, target);
  70:                  File.Copy(source, target, true);
  71:              }
  72:   
  73:              // done
  74:              return 0;
  75:          }
  76:      }
  77:  }

Labels: ,

Tuesday, May 12, 2009

Now that’s a smart thing…

Just imagine this… you have a development server that goes out of hard disk space. No problem you delete some unused and temporary files, and you can say problem solved.

Well, that's not quite... if you have Excel Services for SharePoint running... you're may be in trouble. If the Excel Services workbook cache is in the disk that got out of space, then Excel Services will cease working, and just getting the disk free space up won’t solve it. To so that, you will have to restart excel services, by running these commands:

stsadm -o provisionservice -action stop -servicetype "Microsoft.Office.Excel.Server.ExcelServerSharedWebService, Microsoft.Office.Excel.Server, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"

stsadm -o provisionservice -action start -servicetype "Microsoft.Office.Excel.Server.ExcelServerSharedWebService, Microsoft.Office.Excel.Server, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"

After each stsadm command you better issue a IISRESET.

Ok, now you can say problem solved.... but it has token me 2 hours to get it done.

Labels:

Thursday, January 15, 2009

This one is for your Boss

I was doing my mourning readings when I found this post on Joel Spolsky's Blog (Fog Creek, Joel's company, recently changed to a new office, were every one gets its own private space).

For the ones that work on an Open-plan and don't like to, follow this article to your boss.

What does it says?

It talks about some scientific study from the Queensland University of Technology's Institute of Health and Biomedical Innovation (what a large name!) from Australia. They concluded that switching to the modern open-plan offices led to lower productivity and higher worker stress.

Take a look on what they said (I think this is no novelty for the ones that work on open-plan offices, but now there's a scientific study to use as support)

"The high level of noise causes employees to lose concentration, leading to low productivity, there are privacy issues because everyone can see what you are doing on the computer or hear what you are saying on the phone, and there is a feeling of insecurity.''

"The problem is that employers are always looking for ways to cut costs, and using open-plan designs can save 20 per cent on construction.''

Labels: