March 23, 2011

UserControl in SharePoint 2007

http://blogs.msdn.com/b/pranab/archive/2007/11/30/adding-user-control-to-sharepoint-2007-moss-wss-web-part-and-handling-events-in-there.aspx

Important! - Fully Qualified Name

When Copying the ASCX File from UI Project to WebPart Project, need to change the Inherit attribute as below along with the reference of UI Project in WebPart Project.

<%@ Control Language="C#" AutoEventWireup="true" Inherits="UINameSpace.ClassName, UINameSpace, Version=1.0.0.0, Culture=neutral, PublicKeyToken=Key" Debug="true" %>

It searches for the classname in the given namespace and executes our logic.
Code-Behind also works!!!

WSPBuilder Project - SharePoint 2007

1. File --> New Project --> WspBuilder Project
2. Add existing item [ Shared Signin Key if you have one, otherwise create one]
3. Delete default signin key.
4. Add any other existing items, like GlobalInfo.cs
5. Create Deployment Folder
6. Add existing Install and Remove Scripts and modify as per the current features and wsp.
7. Add READMe.txt of what the solution does.
8. Add WSPBuilder.exe which has the settings for the build.
9. Add wspbuilder.ExcludedFiles.txt to exclude dll's which are already in the GAC or BIN.
Note: Change the Application Target Framework as per your need, 3.5 is good.
10. Now add whatever you need like Features, Workflows, EventHandler etc.

Files:

1. GlobalInfo.cs

[assembly: System.Security.AllowPartiallyTrustedCallers()]

2. WSPBuilder.exe
Note: DLLReferencePath : 80\BIN means it gets the dlls from the solution 80\bin folder
          Deployment Target: GAC (or) BIN (or) Auto

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings>
    <add key="BuildDDF" value="true" />
    <add key="TraceLevel" value="3" />
    <add key="Cleanup" value="false" />
    <add key="BuildWSP" value="true" />
    <add key="BuildMode" value="Release"/>
    <add key="Outputpath" value="DeploymentFolder" />
    <add key="BuildSafeControls" value="true"/>
    <add key="IncludeAssemblies" value="true" />
    <add key="BuildCAS" value="false" />
    <add key="DLLReferencePath" value="80\BIN" />
    <add key="Excludefiletypes" value="ignore,spsource" />
    <add key="DeploymentTarget" value="GAC" />
    <!-- don't add dlls that are already in the portal. -->
    <add key="ExcludeFiles" value="wspbuilder.ExcludedFiles.txt" />
    <!--
    Optional settings
    You can set the arguments in this file or use them directly in the console.
    All arguments has a defualt value. See wspbuilder -help
   
    <add key="BuildCAS" value="true" />
    <add key="CustomCAS" value="CASPolicy.txt" />
    <add key="DLLReferencePath" value="80\BIN" />
    <add key="CustomCAS" value="CASPolicy.txt" />
    <add key="12Path" value="" />
    <add key="80Path" value="" />
    <add key="BinPath" value="" />
    <add key="BuildCAS" value="" />
    <add key="PermissionSetLevel" value="" />
    <add key="BuildSafeControls" value="" />
    <add key="Createfolders" value="" />
    <add key="DeploymentTarget" value="" />
    <add key="Destination" value="" />
    <add key="DLLReferencePath" value="" />
    <add key="Excludefiletypes" value="" />
    <add key="ExpandTypes" value="" />
    <add key="Help" value="" />
    <add key="IncludeAssemblies" value="" />
    <add key="IncludeFeatures" value="" />
    <add key="Includefiletypes" value="" />
    <add key="ManifestEncoding" value="" />
    <add key="ResetWebServer" value="" />
    <add key="Silence" value="" />
    <add key="SolutionId" value="" />
    <add key="SolutionPath" value="DeploymentFolder" />
    <add key="WSPName" value="" />

    TraveLevel switch controls the general messages. In order to
         receive general trace messages change the value to the
         appropriate level.
         Possible values :
         "0" gives no messages
         "1" gives error messages
         "2" gives errors and warnings
         "3" gives information
         "4" gives verbose information
      
     The default value in WSPBuilder is Information (3).
    -->
  </appSettings>
</configuration>

3. Install Script:

echo off
@SET STSADM="c:\program files\common files\microsoft shared\web server extensions\12\bin\stsadm.exe"
@SET SOLUTION=SolutionName.wsp
@SET FEATURE=SolutionName
@SET URL=http://server:port
cls
ECHO OFF
ECHO -------------------------------------------------------------------------------
ECHO Deactivate Feature if it exists
ECHO -------------------------------------------------------------------------------
%STSADM% -o deactivatefeature -name %FEATURE% -url %URL% -force
%STSADM% -o execadmsvcjobs
ECHO -------------------------------------------------------------------------------
ECHO Retract the solution if it exists
ECHO -------------------------------------------------------------------------------
%STSADM% -o retractsolution -name %SOLUTION% -immediate -url %URL%
%STSADM% -o execadmsvcjobs
ECHO -------------------------------------------------------------------------------
ECHO Deleting the solution...
ECHO -------------------------------------------------------------------------------
%STSADM% -o deletesolution -name %SOLUTION% -override
%STSADM% -o execadmsvcjobs
rem pause
ECHO -------------------------------------------------------------------------------
ECHO Adding the solution...
ECHO -------------------------------------------------------------------------------
%STSADM% -o addsolution -filename %SOLUTION%
IF %ERRORLEVEL% NEQ 0 goto removeError
%STSADM% -o execadmsvcjobs
ECHO -------------------------------------------------------------------------------
ECHO Deploying the solution.
ECHO -------------------------------------------------------------------------------
%STSADM% -o deploysolution -name %SOLUTION% -immediate -allowgacdeployment -url %URL% -force -allowCASPolicies
IF %ERRORLEVEL% NEQ 0 goto removeError
%STSADM% -o execadmsvcjobs
ECHO -------------------------------------------------------------------------------
ECHO Activate Feature
ECHO -------------------------------------------------------------------------------
%STSADM% -o activatefeature -name %FEATURE% -url %URL% -force
IF %ERRORLEVEL% NEQ 0 goto removeError
%STSADM% -o execadmsvcjobs
goto removeSuccess

:removeError
ECHO *** FAILURE ***
ECHO --------------------------------------------------
pause > nul
goto :deployDone
:removeSuccess
ECHO *** SUCCESS ***
:deployDone

4. RemoveScript

echo off
@SET STSADM="c:\program files\common files\microsoft shared\web server extensions\12\bin\stsadm.exe"
@SET SOLUTION=SolutionName.wsp
@SET FEATURE=SolutionName
@SET URL=http://server:port
cls
ECHO OFF
ECHO -------------------------------------------------------------------------------
ECHO Deactivate Feature if it exists
ECHO -------------------------------------------------------------------------------
%STSADM% -o deactivatefeature -name %FEATURE% -url %URL% -force
%STSADM% -o execadmsvcjobs
ECHO -------------------------------------------------------------------------------
ECHO Retract the solution if it exists
ECHO -------------------------------------------------------------------------------
%STSADM% -o retractsolution -name %SOLUTION% -immediate -url %URL%
%STSADM% -o execadmsvcjobs
ECHO -------------------------------------------------------------------------------
ECHO Deleting the solution...
ECHO -------------------------------------------------------------------------------
%STSADM% -o deletesolution -name %SOLUTION% -override
%STSADM% -o execadmsvcjobs
rem pause

5.  Note: SPContext in feature activation doesn't work while running the script.
 For that you have to use, workflowproperties.feature as Site(or)Web depending on the feature scope.

Disable MySite and MyLinks in Sharepoint (MOSS) 2007

Go to the Central Administration Web Page
Click on the link for Shared Services Administration
     If you have more than one SSP, select the one that is running the MySites functionality
Under "User Profiles and My Sites" click Personalization Services PermissionsSelect the group you want to limit the functionality for. 
NTAuthority\Authenticated Users.
In the next screen you will see a list of checkboxes,
     To disable MySites uncheck "Create Personal Site"
     To disable MyLinks uncheck "Use Personal Features"

March 21, 2011

Custom BreadCrumb - SharePoint

http://aspnetcoe.wordpress.com/2006/09/28/moss-2007-wcm-development-part-1/

private void TraverseUp(SiteMapNode currentNode, Stack linkStack)
    {
      if (currentNode != null)
      {
        HyperLink currentLink = new HyperLink();
        currentLink.Text = currentNode.Title;
        currentLink.NavigateUrl = currentNode.Url;
        currentLink.Attributes.Add("alt", currentNode.Description);
        linkStack.Push(currentLink);
        if (currentNode.ParentNode != null)
        {
          TraverseUp(currentNode.ParentNode, linkStack);
        }
      }
    }

March 07, 2011

XSLT for each @*


<xsl:template name="ShowXML" match="Row[@Style='ShowXML']" mode="itemstyle">
    <xsl:for-each select="@*">
        </br>
        Name: <xsl:value-of select="name()" /> Value:<xsl:value-of select="." />
    </xsl:for-each>
</xsl:template>

March 03, 2011

Debugging in SharePoint



Change
<SafeMode MaxControls=“200“ CallStack=“false“…
to…
<SafeMode MaxControls=“200“ CallStack=“true“…
You will also need to set custom errors to 'Off' .
<customErrors mode=“Off“/>

SharePoint CSS

http://www.heathersolomon.com/blog/articles/AlterSPCSS.aspx

HTML:

1. Head {Style, Scripts}
2. Body

CSS:

1. Background, Position
2. Margin, Padding
3. Display, Border, Width, Cursor
4. Text-Decoration, Background-Color

Scripts:

1. $("X").click(function () {}); //onclick
2. "X" --> class --> tag --> subtag etc
3. $("X").keydown(function (e) {}); //onkeydown(40)/up(38) -- (13--Enter)

CabLib Compress ERROR: Could not flush cabinet:

Right Click Solution folder -> Properties --> Uncheck "Read only" -> Build WSP again.

SonarQube with Jenkins Setup using Docker Images

https://funnelgarden.com/sonarqube-jenkins-docker/  https://medium.com/@hakdogan/an-end-to-end-tutorial-to-continuous-integration-and-con...