Thursday, October 9, 2008

Imagine

Imagine you create a incremental deployment job that runs every 15min. Imagine after a while something is going wrong...you look and the sql server and it has 0 bytes free :o

You start browsing the files and the wss_content_log has 10Gb... wtf?!?

change the recovery model to simple and then use this sql to trunk the db

BACKUP LOG wss_content WITH TRUNCATE_ONLY
DBCC SHRINKFILE(wss_content_log,2)


this worked out for me hope it helps, tks ricardo :D

Sunday, October 5, 2008

Fábrica Braço de Prata

I was browsing http://www.bracodeprata.org/, a nice library with good concerts here in Lisbon, when i got this nice page on my browser, bad bad practice..you can see the VB (uhhhh) code...custom errors going public? ...someone should be fired :P

Thursday, September 18, 2008

Dates and FullTextSqlQuery

When comparing dates in a FullTextSqlQuery remember the date literal must be surrounded by single quotes and formatted in YYYY-MM-DD format.

Example: 

SELECT Title,FileExtension,ContentType,Path FROM SCOPE() WHERE  owsStartDate > '2003-12-01'

Trying to use an SPWeb object that has been closed or disposed and is no longer valid

This is one is an olddie but it's never too much, when using SPWeb and SPSite, you should remember the Context, so when doing

using (SPWeb web = SPContext.Current.Web)
{
...
}

You will get a nice "Trying to use an SPWeb object that has been closed or disposed and is no longer valid" because you are disposing an object you really didnt create.

Best practices here.

An unexpected error has occurred

I was tired of looking into my mail for this, so i guess that putting in my blog was a easy way to get this info... How to show debug messagens in MOSS. Basically if have to change the web.config of the Web Application in question:

1.     Change CallStack="false" to   CallStack="true"

2.     Change customerrors mode="On"  to   customerrors mode="Off" 

3.     Change compilation batch="false" debug="false"  to   compilation batch="false" debug="true"

Full Articles here, and here.

Tuesday, September 2, 2008

Setting Current Navigation programatically

In the MOSS UI you can set Current Navigation to any of these options:

  • Display the same navigation items as the parent site
  • Display the current site, the navigation items below the current site, and the current site's siblings
  • Display only the navigation items below the current site
But if you wantto do it programatically how can you?

The default is "Display the current site, the navigation items below the current site, and the current site's siblings" so you dont need to care, when adding a web.

Hope this helps for other options, and you dont need to loose time looking and testing.

//Sets Current Navigation to Display the same navigation items as the parent site
pubWeb.InheritCurrentNavigation = true;
pubWeb.NavigationShowSiblings = false;
pubWeb.Update();

//Sets Current Navigation to Display only the navigation items below the current site
pubWeb.NavigationShowSiblings = false;
pubWeb.Update();
}

Monday, June 23, 2008

Event Handlers

If you are working with event handlers in sharepoint and having troubles updating, changing properties and roles plz remember:

in short: IF you're trying to impersonate using RunWithElevatedPrivileges, ALWAYS follow the practice of creating a NEW SPSite inside the RunWith... block. You can grab the current site ID from the event properties object, and then instantiate a new SPSite by e.g.:

using (SPSite theSite = new SPSite(properties.OpenWeb().Site.ID)) {...}


o after some research, here is my solution: item[fieldnamehere] = fieldvaluehere; this.DisableEventFiriing(); item.SystemUpdate(false); this.EnableEventFiring();

This piece of code updates the item without firing the current event handler events, and doing the update using the SystemUpdate(false) method ensures that version number doesnt increase and the update is considered as if it was part of the user's update.


found one thing about this code. You don't need to do the Item.Update() command when you change Roles atribute of the item.
This Prevents unexpected errors or strange behaviours when you attach this event handler to an Publishing pages Library or some list with version control and Check-in Check-out control to allow item changes.
It worked well to me this way.


these sentences saved my afternoon, read them in their respective blogs

EventHandler Impersonation

Preventing Event Handler Recursion

Uploading a file eventhandler

event handler to set permissions

great great resources