Tuesday, July 12, 2011

Clicking "Lock and Edit" throws Item archive error has occured

Recently i have been baffled to figure out why clicking "lock and edit" throws an "Item Archive error has occured: Object reference not set to an instance of an object"

The problem is because of the Security setup. Now the Sitecore Tree setup which we inherit from another company is quite messy. Here is the structure


Sitecore
--> Content
--> Home (aka main website)
--> Page 1
--> Mini Website
--> Page 1
--> Another Mini Website

We have a requirement whereby a user let's called him user1 is allowed only to look at "Mini Website". Of course the approach is to use default Sitecore Security feature. Ideally when user1 is logged in the Sitecore tree should look like below

Sitecore
--> Content
--> Mini Website
--> Page 1

That's the cause of the error. Basically Sitecore->Content->Home need to be available.

So the Tree setup turn out to be


Sitecore
--> Content
--> Home
--> Mini Website
--> Page 1

Friday, July 8, 2011

Script to Deploy Files to Delivery

@ECHO OFF
SETLOCAL

::******************************************* Constants / ROBOCOPY Settings ***********************************************************

SET _what=/COPYALL /E
:: /COPYALL :: COPY ALL file info
:: /B :: copy files in Backup mode.
:: /SEC :: copy files with SECurity
:: /MIR :: MIRror a directory tree
:: /E :: Copy Subfolders, including Empty Subfolders.

SET _options=/R:0 /W:0 /TS /FP /IS
:: /R:n :: number of Retries
:: /W:n :: Wait time between retries
:: /LOG :: Output log file
:: /NFL :: No file logging
:: /NDL :: No dir logging
:: /IS :: Include Same, overwrite files even if they are already the same. Use this options if you want to overwrite
:: /XO :: eXclude Older - if destination file exists and is the same date or newer than the source - don't bother to overwrite it.

SET _timestamp=%DATE:~10,4%%DATE:~4,2%%DATE:~7,2%%TIME:~0,2%%TIME:~3,2%
:: This will create a timestamp like yyyymmyyhhmm.

SET _source="X:\source\Deployment\Deploy Me"
:: Source of the files to copy from

::*************************************** End of Constants / ROBOCOPY Settings ********************************************************

:: Delivery 1
SET _dev1="\\delivery1\c$\inetpub\dev.website.com\Website"
SEt _dev1log="X:\delivery1\Deployment\Deployment Logs\APP01"\%_timestamp%.txt

Echo Synchronising Delivery Server 1 with CMS Server
ROBOCOPY %_source% %_dev1% %_what% %_options% /LOG:%_dev1log%
Echo Synchronising to Delivery Server 1 has been completed!
:: End of Delivery 1

Echo.

:: Delivery 2
SET _dev2="\\delivery2\c$\inetpub\dev.website.com\Website"
SEt _dev2log="X:\delivery2\Deployment\Deployment Logs\APP02"\%_timestamp%.txt

Echo Synchronising Delivery Server 2 with CMS Server
ROBOCOPY %_source% %_dev2% %_what% %_options% /LOG:%_dev2log%
Echo Synchronising to Delivery Server 2 has been completed!
:: End of Delivery 2

::***************************************** Archive Settings **************************************************************************
SET _archiveDest="X:\Some Folder\Deployment\Archive"\%_timestamp%
SEt _archivelog="X:\Some Folder\Deployment\Archive\Logs"\%_timestamp%.txt

SET _ArchiveWhat=/MOVE /E /COPYALL
:: /COPYALL :: COPY ALL file info
:: /B :: copy files in Backup mode.
:: /SEC :: copy files with SECurity
:: /MIR :: MIRror a directory tree
:: /E :: Copy Subfolders, including Empty Subfolders.

SET _ArchiveOptions=/R:0 /W:0 /XO /LOG:%_archivelog%
:: /R:n :: number of Retries
:: /W:n :: Wait time between retries
:: /LOG :: Output log file
:: /NFL :: No file logging
:: /NDL :: No dir logging
:: /IS :: Include Same, overwrite files even if they are already the same. Use this options if you want to overwrite
:: /XO :: eXclude Older - if destination file exists and is the same date or newer than the source - don't bother to overwrite it.
::************************************** End of Archive Settings **********************************************************************
Echo.
Echo Archiving "Deploy Me" folder

ROBOCOPY %_source% %_archiveDest% %_ArchiveWhat% %_ArchiveOptions%
md "X:\Some Folder\Deployment\Deploy Me"

Echo Archive complete!
pause

Script to Synchronise Author with Delivery

@ECHO OFF
SETLOCAL

::******************************************* Constants / ROBOCOPY Settings ***********************************************************

SET _what=/COPYALL /E
:: /COPYALL :: COPY ALL file info
:: /B :: copy files in Backup mode.
:: /SEC :: copy files with SECurity
:: /MIR :: MIRror a directory tree
:: /E :: Copy Subfolders, including Empty Subfolders.

SET _options=/R:0 /W:0 /TS /FP /XO
:: /R:n :: number of Retries
:: /W:n :: Wait time between retries
:: /LOG :: Output log file
:: /NFL :: No file logging
:: /NDL :: No dir logging
:: /IS :: Include Same, overwrite files even if they are already the same. Use this options if you want to overwrite
:: /XO :: eXclude Older - if destination file exists and is the same date or newer than the source - don't bother to overwrite it.

SET _timestamp=%DATE:~10,4%%DATE:~4,2%%DATE:~7,2%%TIME:~0,2%%TIME:~3,2%
:: This will create a timestamp like yyyymmyyhhmm.

SET _source="C:\inetpub\source\Website"
:: Source of the files to copy from

SET _ExcludeDir= /XD App_Browsers App_Data data temp upload
SET _ExcludeFile= /XF *.specific.config ConnectionStrings.config web.config

::*************************************** End of Constants / ROBOCOPY Settings ********************************************************

:: Delivery 1
SET _dev1="\\delivery1\c$\inetpub\dev.website.com\Website"
SEt _dev1log="X:\delivery1\Deployment\Deployment Logs\APP01"\%_timestamp%.txt

Echo Synchronising Delivery Server 1 with CMS Server
ROBOCOPY %_source% %_dev1% %_what% %_options% %_ExcludeDir% %_ExcludeFile% /LOG:%_dev1log%
Echo Synchronising to Delivery Server 1 has been completed!
:: End of Delivery 1

Echo.

:: Delivery 2
SET _dev2="\\delivery2\c$\inetpub\dev.website.com\Website"
SEt _dev2log="X:\delivery2\Deployment\Deployment Logs\APP02"\%_timestamp%.txt

Echo Synchronising Delivery Server 2 with CMS Server
ROBOCOPY %_source% %_dev2% %_what% %_options% %_ExcludeDir% %_ExcludeFile% /LOG:%_dev2log%
Echo Synchronising to Delivery Server 2 has been completed!
:: End of Delivery 2

pause

Thursday, July 7, 2011

Sitecore Encrypting Connection String and etc

Recently, I was asked to encrypt connection strings. Here are the codes

Encrypting
----------
@ECHO OFF
ECHO Encrypting web.config connectionStrings ...

SET target="C:\inetpub\folder\Website"

C:\Windows\Microsoft.NET\Framework64\v2.0.50727\aspnet_regiis -pef "system.web/membership" %target%
C:\Windows\Microsoft.NET\Framework64\v2.0.50727\aspnet_regiis -pef "system.web/roleManager" %target%
C:\Windows\Microsoft.NET\Framework64\v2.0.50727\aspnet_regiis -pef "system.web/profile" %target%
C:\Windows\Microsoft.NET\Framework64\v2.0.50727\aspnet_regiis -pef "system.web/machineKey" %target%
C:\Windows\Microsoft.NET\Framework64\v2.0.50727\aspnet_regiis -pef "connectionStrings" %target%

ECHO Finished Encrypting web.config connectionStrings...
pause

Decrypting
----------

@ECHO OFF
ECHO Decrypting web.config connectionStrings ...

SET target="C:\inetpub\folder\Website"

C:\Windows\Microsoft.NET\Framework64\v2.0.50727\aspnet_regiis -pdf "system.web/membership" %target%
C:\Windows\Microsoft.NET\Framework64\v2.0.50727\aspnet_regiis -pdf "system.web/roleManager" %target%
C:\Windows\Microsoft.NET\Framework64\v2.0.50727\aspnet_regiis -pdf "system.web/profile" %target%
C:\Windows\Microsoft.NET\Framework64\v2.0.50727\aspnet_regiis -pdf "system.web/machineKey" %target%
C:\Windows\Microsoft.NET\Framework64\v2.0.50727\aspnet_regiis -pdf "connectionStrings" %target%

ECHO Finished Decrypting web.config connectionStrings...
pause