Sunday, 10 February 2013

Triggers in WPF

What are triggers?


Triggers have a collection of Setters which  performs its work based on one or more conditions.

Example: Setting up style of elements.

Three types of Triggers:


Property triggers—Get invoked when the value of a dependency property changes
Data triggers—Get invoked when the value of a plain .NET property changes
Event triggers—Get invoked when a routed event is raised

Property Trigger:


In following trigger, data binding is used to provide an appropriate message inside the
ToolTip when validation error occurs.



<Style x:Key=”MyTextBoxStyle” TargetType=”{x:Type TextBox}”>
<Style.Triggers>
<Trigger Property=”Validation.HasError” Value=”True”>
<Setter Property=”Background” Value=”Red”/>
<Setter Property=”ToolTip”
Value=”{Binding RelativeSource={RelativeSource Self},
Path=(Validation.Errors)[0].ErrorContent}”/>
</Trigger>
</Style.Triggers>
</Style>
<TextBox Style=”{StaticResource MyTextBoxStyle}”>

Data Trigger



Wednesday, 30 January 2013

Service Application Architecture

Service Application Architecture

•       SharePoint 2007

–   SSP [shared service provider)

–   Each instance of The SSP has all services enabled

–   Each site collection was locked into a single SSP

–   The SSP was a single point of failure

–   Lacked scalability

–   Lacked flexibility



Service Application Architecture

•       Sharepoint 2010

–   SA (service application) architecture

–   Provide background services to SharePoint sites

–   More flexibility thon the SSP

–   Each SA can serve one or multiple sites

–   SAs can be placed in groups for simpler deployment to Web applications

–   Load balancing

SA Terminology

•       Service

–   Binary file[s) installed on The server form To execute a function

–   A program running in The server form That does something for SharePoint

•     Excel services do Excel data processing

•       Service Application

–   Implementation of the service

–   Reference to the service in the form









SA Terminology

•       Service application proxy

–   Target for calls to the SAs

–   Multiple instances of The service on the back end

–   Load balance between instances

•       Service instance

–   Single implementation of an SA



SAs in SharePoint Foundation

•       Business Data Connectivity service

–   Connect to external data sources

•       Usage and Health Data Collection

–   SharePoint Health Analyzer

•       Microsoft SharePoint Foundation Subscription Settings service

–   Multi-tenancy

•     More than one user consuming the services on one form.

Standard Edition SAs

•       Managed Metadata service

–   Centralized Taxonomy for social Tagging keywords

•       Search service application

–   Full-fledged search for Sharepoint sites

–   Search entire form and remote servers

•       Secure Store service

–   Claims-based authentication

•       State service

–   Track user state

•       User Profile service application

–   Full-featured My Sites

•       Web Analytics service application

–   Statistical tracking

•       Word Automation services

–   Workflows for Word documents

–   View Word documents within Web browser

Enterprise Edition SAs (BI)

•       Access services

–   Consume Access databases into a SharePoint site

•       Excel services

–   Work with Excel workbooks embedded into The site

–   Provide forms to modify cells

–   Use Excel workbooks lo create programatic application

•       PerformancePoint service application

•       Business Intelligence, dashboard and key performance indicators

•       Visio Graphics services

•       Render graphical visio diagrams based on data

•       Diagrams are created within the visio application

SA Security

•       Improves on SSP security from 2007

–   Claims-based authorization

–   Based on identities and properties of identities

–   Can be utilized for authentication with external networks outside of Active Directory

–   Support for SSL

•     Use encryption between WFE’s and application servers

–   Applications are isolated

–   A separate database is used for each application

–   A separate application pool may be used

–   Multiple service applications may be deployed with different accounts and different databases



SA Benefits

•       Granular deployment

–   Install on the server end then disable all features except the one needed

•       Configuration flexibility

–   SA proxy can take care of network load balancing by using round-robin Techniques

•       Administration delegation

•       Sharing of services across Web applications and even server forms

SharePoint Tab Web Part with JQuery

I found very easy way to implement Tab Control in Sharepoint using jQuery,

Steps:


- The first thing that you will need to do is identify the document/page library to house the tabpage.
This page can be added to any document library and so it gives you much flexibility as to where you deploy this.
- Download the tabpage file from here: http://www.bitsofsharepoint.com/ExamplePoint/Download/TabPage.zip
- Extract the contents of the zip file and then upload to a document or page library
- In this step you will want to open the page.
- Then go to Site Actions and select Edit Page
- Now look for the section called "Tab"
- Click "Add a Web Part"
- Select a Content Editor Web Part and click Add
- Now edit the Content Editor Web Part (CEWP)
- At this point you will then want to open up the Source Editor and past in the code below
- Now you will need to decide the number of tabs you want.
- To have less then 8 tabs I recommend that you do the following, add <!--  & --> to the start of this code <li> and the end of this code </li>
- This will allow you to easily add a tab back if you need it in the future with out having to remember the code to add
- Example: <!--<li><a href="#tab-8" ><span>TAB 8</span></a></li>-->
- Next you will want to the change the title of the tabs.
- The title is found between the code <span>  </span>
- Last do you want the  Tab Page Help to show or NOT show
- Add the <script> code to HIDE the help button
- Below is the code to add to the CEWP

<!-- Code to hide Tab Page Help Link -->
<script type="text/javascript">
   $(document).ready(function() {
        $('#TabPageHelp').hide();
   });
</script>

<!-- Code to add Tabs -->

<div id="tabs">
     <ul class="tabNavigation ms-WPBody">
         <li><a href="#tab-1" class="selected ms-topnavselected"><span>TAB 1</span></a></li>
          <li><a href="#tab-2" ><span>TAB 2</span></a></li>
          <li><a href="#tab-3" ><span>TAB 3</span></a></li>
          <li><a href="#tab-4" ><span>TAB 4</span></a></li>
          <li><a href="#tab-5" ><span>TAB 5</span></a></li>
          <li><a href="#tab-6" ><span>TAB 6</span></a></li>
          <li><a href="#tab-7" ><span>TAB 7</span></a></li>
          <li><a href="#tab-8" ><span>TAB 8</span></a></li>
     </ul>
        <div style="clear: both"></div>
</div>
- When you add a webpart to Tab 2 - 8 you will notice that each time the page refreshes it takes you back to Tab 1. 
- This will happen each time, but it does not affect what webpart you are working on. 
- So just because you clicked Modify Shared Webpart on tab 3 and it refreshes to Tab 1 does NOT mean you are editing the webpart in Tab 1.  
- You will notice that you can click on tab 3 and see that the webpart has the dotted lines indicating that it is being edited.

Tuesday, 29 January 2013


Service Application Architecture

Atal

Service Application Architecture

       SharePoint 2007

   SSP [shared service provider)

   Each instance of The SSP has all services enabled

   Each site collection was locked into a single SSP

   The SSP was a single point of failure

   Lacked scalability

   Lacked flexibility

 

Service Application Architecture

       Sharepoint 2010

   SA (service application) architecture

   Provide background services to SharePoint sites

   More flexibility thon the SSP

   Each SA can serve one or multiple sites

   SAs can be placed in groups for simpler deployment to Web applications

   Load balancing

SA Terminology

       Service

   Binary file[s) installed on The server form To execute a function

   A program running in The server form That does something for SharePoint

     Excel services do Excel data processing

       Service Application

   Implementation of the service

   Reference to the service in the form

 

 

 

 

SA Terminology

       Service application proxy

   Target for calls to the SAs

   Multiple instances of The service on the back end

   Load balance between instances

       Service instance

   Single implementation of an SA

 

SAs in SharePoint Foundation

       Business Data Connectivity service

   Connect to external data sources

       Usage and Health Data Collection

   SharePoint Health Analyzer

       Microsoft SharePoint Foundation Subscription Settings service

   Multi-tenancy

     More than one user consuming the services on one form.

Standard Edition SAs

       Managed Metadata service

   Centralized Taxonomy for social Tagging keywords

       Search service application

   Full-fledged search for Sharepoint sites

   Search entire form and remote servers

       Secure Store service

   Claims-based authentication

       State service

   Track user state

       User Profile service application

   Full-featured My Sites

       Web Analytics service application

   Statistical tracking

       Word Automation services

   Workflows for Word documents

   View Word documents within Web browser

Enterprise Edition Sas (BI)

       Access services

   Consume Access databases into a SharePoint site

       Excel services

   Work with Excel workbooks embedded into The site

   Provide forms to modify cells

   Use Excel workbooks lo create programatic application

       PerformancePoint service application

       Business Intelligence, dashboard and key performance indicators

       Visio Graphics services

       Render graphical visio diagrams based on data

       Diagrams are created within the visio application

SA Security

       Improves on SSP security from 2007

   Claims-based authorization

   Based on identities and properties of identities

   Can be utilized for authentication with external networks outside of Active Directory

   Support for SSL

     Use encryption between WFE’s and application servers

   Applications are isolated

   A separate database is used for each application

   A separate application pool may be used

   Multiple service applications may be deployed with different accounts and different databases

 

SA Benefits

       Granular deployment

   Install on the server end then disable all features except the one needed

       Configuration flexibility

   SA proxy can take care of network load balancing by using round-robin Techniques

       Administration delegation

       Sharing of services across Web applications and even server forms

SA Communication Process

Monday, 5 November 2012


Accessing Data in a SharePoint 2010 Web Part by using LINQ
Task yo complete: Ojective for this exercise is to query and displays it in a DataGrid control. To complete this task, you must do the following:
·         Create a Visual Web Part Project
·         Generate LINQ to SharePoint Proxy Code
·         Add Code to Read Data from a SharePoint List
·         Deploy and Add the Web Part to a Web Part Page
Create a Visual Web Part Project
In this task, you create a Visual Web Part project in Microsoft Visual Studio 2010.
To create the Visual Web Part
1.     Start Visual Studio 2010, click File, point to New, and then click Project.
2.     Navigate to the Visual C# node in the Installed Templates section, click SharePoint, and then click 2010.
3.     Select the Visual Web Part project template, provide a name (such as AccessSPDatawithLINQ) and a location for your project, and then click OK.
4.     In the What local site do you want to use for debugging drop-down list, select the site to use (such as http://localhost/sites/MySampleWebSite). Also select theDeploy as a farm solution option and then click Finish.
Note that after the project is created, Solution Explorer contains the visual Web Part named VisualWebPart1 

Generate LINQ to SharePoint Proxy Code
In this task, you use the spmetal.exe code-generation utility to generate the LINQ to SharePoint proxy code. The tool generates entity class code that Visual Studio 2010 uses as an interface to obtain IntelliSense and enable LINQ-based queries to be performed on SharePoint Server 2010 lists.
To generate the LINQ proxy code
1.     In Solution Explorer, right-click AccessSPDatawithLINQ and then click Open Folder in Windows Explorer.
2.     Press and hold the SHIFT key, right-click the Explorer window, and then click Open command window here to open the command window in the current project directory.
3.     In the command window, type the following command and press the ENTER key to set the path of the SharePoint Server 2010 folder.
set path=%path%;c:\program files\common files\microsoft shared\web server extensions\14\bin
4.     In the command window, type the following command and press the ENTER key to generate the LINQ to SharePoint proxy code. Replace the SharePoint site URL with your own site's URL.
spmetal.exe /web:http://localhost/sites/MySampleWebSite /namespace:AccessSPDatawithLINQ.VisualWebPart1 /code:SPLinq.cs
This command creates the SPLinq.cs file in the AccessSPDatawithLINQ project folder.
5.     Close the command window.
6.     Now add the file to the project. Switch back to the Visual Studio project screen.
7.     In Solution Explorer, right-click AccessSPDatawithLINQ, point to Add, and then click Existing Item.
8.     Select SPLinq.cs from the Add Existing Item dialog window and then click Add.
9.     In Solution Explorer, right-click References and then click Add Reference.
10. Click the Browse tab and type C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI in the File Name box.
11. Select Microsoft.SharePoint.Linq.dll and then click OK.
Add Code to Read Data from a SharePoint List
In this task, you add code to your solution that enables the visual Web Part to retrieve data from the SharePoint Server 2010 lists.
To add code to the project
1.     In Solution Explorer, expand VisualWebPart1 and then double-click VisualWebPart1UserControl.ascx. Visual Studio displays the HTML for the visual Web Part user control.
2.     Add the following code at the bottom of the existing code to construct the grid view.
HTML
<%@ Import Namespace="Microsoft.SharePoint.WebControls" %>
<SharePoint:SPGridView id="spGridView" runat="server" AutoGenerateColumns="false">
  <HeaderStyle HorizontalAlign="Left" ForeColor="Navy" Font-Bold="true" />
  <Columns>
    <SharePoint:SPBoundField  DataField="Title" HeaderText="Title"></SharePoint:SPBoundField>
    <SharePoint:SPBoundField DataField="JobTitle" HeaderText="JobTitle"></SharePoint:SPBoundField>
    <SharePoint:SPBoundField DataField="ProjectTitle" HeaderText="ProjectTitle"></SharePoint:SPBoundField>
    <SharePoint:SPBoundField DataField="DueDate" HeaderText="DueDate"></SharePoint:SPBoundField>
  </Columns>
</SharePoint:SPGridView>

The HTML for the visual Web Part user control should resemble Figure 2 after you add the code.

3.     In Solution Explorer, right-click VisualWebPart1UserControl.ascx and then click View Code.
4.     Add the following statements to the code at the top of the code screen.

using Microsoft.SharePoint.Linq;
using Microsoft.SharePoint;
using System.Linq;
5.     Insert the following code inside the Page_Load method.

SPLinqDataContext dc = new SPLinqDataContext(SPContext.Current.Web.Url); 
EntityList<EmployeesItem> Employees = dc.GetList<EmployeesItem>("Employees"); 
var empQuery = from emp in Employees
               where emp.Project.DueDate < DateTime.Now.AddMonths(6)
               select new
               {
                   emp.Title,
                   emp.JobTitle,
                   ProjectTitle = emp.Project.Title,
                   DueDate = emp.Project.DueDate.Value.ToShortDateString()
               }; 
spGridView.DataSource = empQuery;
spGridView.DataBind();
Deploy and Add the Web Part to a Web Part Page
In this task, you deploy the Web Part and add it to the Home page on the SharePoint Server 2010 website.
To deploy and test the visual Web Part
1.     In Solution Explorer, right-click AccessSPDatawithLINQ and then click Deploy. This builds and deploys the visual Web Part to the SharePoint site that you specified earlier.
2.     Open Internet Explorer and browse to the SharePoint site.
3.     Click the Edit icon at the top of the Home page to start to edit the page.
4.     On the ribbon, on the Editing Tools tab, click Insert, and then click Web Part.
5.     In the Categories section, click Custom, and in the Web Parts section, click SPLinqDemoTitle, and then click Add as shown in Figure 3.
On the ribbon, click Stop Editing to save the page and stop editing.
6.     Close Internet Explorer.