Dev Team Assemble

Evil beware!
Add to Technorati Favorites

Archive

Tag: moss 2007

I often find in my sharepoint development environments that I have issues with transaction logs filling up. This gives me the "Error" page with no indication of what the problem is...yes I can go and change the <customErrors> tag to set the customer errors mode to off and add the callstack to the page but it still doesn't address the problem. I whipped this script up because the dev sql server we are using has well over a hundred db's on it and I didn't fell like manually typing the ALTER DATABASE [xxx] SET RECOVERY SIMPLE for each one or doing the clickity click thing either. Now the solution below probably breaks lots of best practices and such but it works for what I wanted it to do....which is modify all existing db's recovery mode. To modify new db's recovery mode, just set the model db's option to simple and voila..you are ready to go.

Quick note: YOU PROBABLY DO NOT WANT TO EVER...I MEAN EVER...USE THIS ON A PRODUCTION SYSTEM.


*/

Modify th recovery model for all databases on your server

*/

DECLARE @lasterror int

DECLARE @sql nvarchar(max)

DECLARE @dbname nvarchar(100)

DECLARE @dbid int

DECLARE @recModel int

-- cycle the log

exec sp_cycle_errorlog

CREATE Table #dbInfo

(

database_id int NOT NULL,

dbName nvarchar(100) NOT NULL,

recoveryModel int

)

--SELECT database_id, [name], recovery_model FROM sys.databases order by database_id

SELECT TOP 1 @dbid = database_id FROM sys.databases where database_id > 4 ORDER BY database_id asc;

SELECT @dbname = [name] FROM sys.databases where database_id = @dbid;

SELECT @recModel = recovery_model FROM sys.databases where database_id = @dbid;

-- begin backup process

WHILE @dbid > 0

BEGIN

INSERT INTO #dbInfo (database_id, dbName, recoveryModel) VALUES (@dbid, @dbname, @recModel);

IF @recModel = 1

BEGIN

SELECT @sql = 'ALTER DATABASE [' + @dbname + '] SET RECOVERY SIMPLE'

EXEC sp_executesql @sql

SELECT @lasterror = @@ERROR

IF @lasterror <> 0

-- log the error to the message console

PRINT 'ERROR: Changing the recovery mode for database : ' + @dbname + ' with error number ' + CAST(@lasterror as nvarchar(25))

ELSE

PRINT 'Recovery mode changed to simple (3) for database : ' + @dbname

END

-- get a new record

SELECT @dbid = 0;

SELECT TOP 1 @dbid = database_id FROM sys.databases where database_id > 4 and

database_id NOT IN (SELECT DISTINCT x.database_id FROM #dbInfo x);

SELECT @dbname = [name] FROM sys.databases where database_id = @dbid;

SELECT @recModel = recovery_model FROM sys.databases where database_id = @dbid;

END

DROP Table #dbInfo

SELECT database_id, [name], recovery_model FROM sys.databases order by database_id

GO

Technorati Tags: , , , ,

Scenario: Forms Based Authentication on an external facing portal. Users are having trouble (as in not able too) uploading multiple documents at once.

This was a pretty easy fix....Enable Client Integration for the given website zone in Central Administration.

Technorati Tags: , , ,

One of the things I was working on today was trying to get an actual image from the library was that initially I was expecting to get a PublishingImage.  All the samples on MSDN and the ones strewn about the web refer to using the ImageFieldValue and getting it from a field in the SPListItem.  Like outlined on MSDN :

  // Retrieve the current value from an SPListItem with a
  // column of the ImageField type with the name imageFieldName
  ImageFieldValue currentFieldValue =
        listItemWithImageField[imageFieldName] as ImageFieldValue;

The problem is this only works for images that are in a list, like the PublishingRollupImage of a page that links to an image in the Site Collection Images library.  The actual images in the library are stored as documents (Referenced using SPFile) so in order utilize them I need to extract the information out and create an image tag for it...like so:

 
     ImageFieldValue imageValue = new ImageFieldValue(
          string.Format("<img src=\"{0}\" alt=\"{1}\" />",
          file.Url, file.Title == null ? string.Empty : file.Title));
 

Now that I had the ImageFieldValue it was easy to work with. I could manipulate many aspects of the image using this object and then save it for rendering using ToString(). Funny thing is for my purposes (ImageGallery xml generation) I didn't even end up needing this code after all...frustrating but a good learning experience.

Props to Phanat Chan as he did the initial development on this.

Technorati Tags: , ,

So I got this error the other day when putting together a dev site collection usign varations:

An error was encountered performing this operation. You may re-try the operation, and you may need to clean up the half-created data first before re-trying. If the problem persists, please contact your system administrator

This was actually a fairly easy fix for me.  I simply had to enable the publishing features in my site.  Which is funny...because they should have been on but I must have overlooked that.  :)

Technorati Tags: , , , ,