Tuesday, April 23, 2013

Fast Search in SharePoint 2010


Advantages of using Fast Search in SharePoint 2010
1. Crawl BDC content with FAST.
2. Previewers – Display inline previews of Word, PowerPoint, and Excel files.
3. Indexing more documents
4. FAST can be configured for Enterprise edition only
5. Search enhancements based on user context Scopes Best Bets, visual Best Bets, and document promotions and demotions to a sub-group of employees.
6. Rich Web indexing support Indexing of wide variety of Web content, including Flash.

Using LINQ to SharePoint


The LINQ to SharePoint provider is a new feature in SharePoint 2010 that allows you to use a strongly-typed entity model and the language integrated query (LINQ) query syntax to query list data. Essentially, LINQ to SharePoint hides the complexity of developing CAML queries from developers, which can reduce development time and make code more readable. The LINQ to SharePoint provider converts the LINQ expressions into CAML queries at run time.

Using LINQ to SharePoint in your own solutions consists of three main steps:
  • Generate the entity classes. Before you can start writing LINQ queries against your SharePoint lists, you must create or generate the strongly-typed entity classes that represent your list data and lookup column relationships.
  • Develop the solution. After you add the entity classes to your Visual Studio 2010 project, you can write LINQ queries against the strongly-typed entities that represent your data model.
  • Run the solution. At run time, the LINQ to SharePoint provider dynamically converts your LINQ expressions into CAML queries, executes the CAML, and then maps the returned items to your strongly-typed data entities.
Although you can manually develop your entity classes, in most cases, you will want to use the SPMetal command line tool. This is included in SharePoint Foundation 2010 and can be found in the BIN folder in the SharePoint root. The SPMetal tool targets an individual SharePoint site and, by default, generates the following code resources:
  • A data context class that derives from DataContext. This is the top-level entity class. It represents the content of your site and provides methods that allow you to retrieve list entities. The data context class uses the EntityList<TEntity> class to represent the lists in your site, where TEntity is a class that represents a content type.
  • Classes that represent content types. These are marked with the ContentTypeAttribute. Content type classes are generated for implicit content types as well as content types that are explicitly defined on the site. For example, if a user adds a column to an existing list, the user is creating an implicit content type and a representative class will be generated.
  • Classes and properties that represent relationships between listsSPMetal can detect relationships based on lookup columns. Within the entity class that represents a content type, SPMetaluses the EntityRef<TEntity> class to represent the singleton side of a one-to-many relationship and the EntitySet<TEntity> class to represent the “many” side of one-to-many or many-to-many relationships (known as a reverse lookup). Properties that are mapped to a field in a related list are decorated with the AssociationAttribute.
Reference: 

Error: The type or namespace name ‘SharePoint’ does not exist in the namespace ‘Microsoft’(are you missing reference?)


Issue: I’ve got the above error when trying to run a simple code in the console application. Though added the Microsoft.SharePoint .dll from the following path C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI\Microsoft.SharePoint.dll, was getting the error during debugging.
Resolution: Right click the Solution Explorer and click properties, In Application tab, .Net Frameworkf 4.0 Client Profile was selected by default, change it to .Net Framework 3.5 and debug again. Also change the Platform target in the Build tab to x64.

When to use ‘using’ and ‘dispose’ and when not to use in SharePoint


If you create your own SPSite object, you can use the Dispose method to close the object. However, if you have a reference to a shared resource, such as when the object is provided by the GetContextSite method in a Web Part, do not use either method to close the object. Using either method on a shared resource causes an Access Violation error to occur
Likewise, If you obtain an SPWeb object using OpenWeb or RootWeb, the best practice is to implement the using statement or the Dispose method to dispose of the object.
However, if you have a reference to a shared resource, such as when you obtain the Web site object from the SPContext object in a Web Part by using SPContext.Current.Web, do not use either method to close the object.

SharePoint 2010 Development Platform Stack

Wednesday, March 20, 2013

SharePoint Licensing - Client Access License (CALs)


Types of CALs:


·         User CAL
·         Device CAL 

User CAL:

     
      With the User CAL, you purchase a CAL for every user who accesses the server to use services such as file storage or printing, regardless of the number of devices they use for that access. Purchasing a User CAL might make more sense if your company employees need to have roaming access to the corporate network using multiple devices, or from unknown devices, or simply have more devices than users in your organization. You can go for User CAL if number of User is less than number of devices.

 Client Access License based on user

Device CAL:


     With a Device CAL, you purchase a CAL for every device that accesses your server, regardless of the number of users who use that device to access the server. Device CALs may make more economic and administrative sense if your company has workers who share devices, for example, on different work shifts. 


A SharePoint Server device CAL authorizes one computer to access SharePoint Server, regardless of the number of users (for example, a shared workstation).

SharePoint Server User CALs are also available. A user CAL authorizes a user to access SharePoint Server from any device (for example, when an employee accesses the server from a computer at work and another at home). 

Client Access License based on device

External Connectors

If you want external users—such as business partners, external contractors, or customers—to be able to access your network, you have two licensing options:
·         Acquire CALs for each of your external users.
·         Acquire External Connector (EC) licenses for each server that will be accessed by your external users.
For SharePoint, Acquire External Connector (EC) licenses would be the right choice.

External Connector licensing

Specialty Server Licensing

Specialty Server licensing is a commonly used model. Specialty Servers are server-only licenses that also do not require CALs. Specialty Servers require a server license for each instance of the server software running on a server. An example of this is Microsoft Office SharePoint Server for Internet Sites. You can run the instance in a physical or virtual operating system environment. By exception, some products provide more specific use rights.
 Specialty Server licensing

Thursday, February 28, 2013

Sync list with user group using jquery

Requirement: To get all the user names from the SharePoint group "Deliverable Owners" and sync with a custom list called "Team Members" in a button click.

Solution: This is done using jquery and SharePoint web services.

Code:

<script type="text/javascript" src="https://siteurl/Documents/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="https://siteurl/Documents/jquery.SPServices-0.7.2.min.js"></script>
<script  type="text/javascript">
    $(document).ready(function() {
 
     $("#syncUsers").click(function()  //'syncUsers' is the ID of button control added in the CEWP
{
var errorOccured  = DeleteUsersFromTeamMembersList();
if(!errorOccured)
{
AddUsersToTeamMembersList();
}
 });
});

      // to delete the existing users from the custom list
function DeleteUsersFromTeamMembersList()
{

var errorOccured = false;

$().SPServices({
            operation: "GetListItems",
            async: false,
            debug: true,
            listName: "Team Members",
            CAMLViewFields: "<ViewFields></ViewFields>",
            completefunc: function (xData, Status) {
                $(xData.responseXML).SPFilterNode("z:row").each(function() {
                    $().SPServices({
                        operation: "UpdateListItems",
                        async: false,
                        debug: true,
                        batchCmd: "Delete",
                        listName: "Team Members",
                        ID: $(this).attr("ows_ID"),
                        completefunc: function (xData, Status) {
                        msgData = xData.responseText;
isError = msgData.indexOf("ErrorText");
           if (isError > 0) {
               // Error creating fields!
               alert("Error deleted user names from Team Member list!");
               errorOccured = true;
           }
                        }
                    });
                });
            }
        });
         return errorOccured;
}
//add all the users from the sharepoint group to custom list.
function AddUsersToTeamMembersList()
{

var alreadyProcessed = false;
var userName ;
var iD;
var userID;
var errorOccured = false;

$().SPServices({
operation: "GetUserCollectionFromGroup",
groupName: "Deliverable Owners",
completefunc: function (xData, Status) {
$("#results").text(xData.responseXML.xml);
$(xData.responseXML).find("User").each(function () {
  userName = $(this).attr("LoginName");
  iD = $(this).attr("ID");
  userID = iD +";#"+userName;
  $().SPServices({
operation: "UpdateListItems",
async: false,
batchCmd: "New",
listName: "Team Members",
valuepairs: [["User",userID  ]],
completefunc: function(xData, Status)
{
msgData = xData.responseText;
isError = msgData.indexOf("ErrorText");
if (isError > 0) {
// Error creating fields!
alert("Error synchronizing user names!");
errorOccured = true;
}
}
});
});

if( errorOccured == false)
{
alert("User name synchronized successfully.");
$(window.location).attr('href', 'currentpagename.aspx');
}                    
}
});
}
</script>


P.S:
- The performance of this code will get affected based on the size of the user group.
- The Team Members custom list must have "User" field with people and group type.