Thursday, October 1, 2015

Exposing WCF REST Service over BasicAuthentication

<system.serviceModel>
  <behaviors>
      <serviceBehaviors>
        <behavior name="MyServiceServiceBehavior">
          <serviceMetadata httpGetEnabled="false" httpsGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        
        </behavior>
     
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="jsonBehaviour">
          <webHttp automaticFormatSelectionEnabled="true"/>
        </behavior>
      </endpointBehaviors>
    </behaviors>
<bindings>
    <webHttpBinding>
        <binding name="BasicAuthentication">
            <security mode="TransportCredentialOnly">
                <transport clientCredentialType="Basic" />
            </security>
        </binding>
    </webHttpBinding>
</bindings>
    <services>
      <service name="Cadence.SP.COS.Services.QueryService" behaviorConfiguration="MyServiceServiceBehavior">
       <endpoint address="" bindingConfiguration="BasicAuthentication" binding="webHttpBinding" behaviorConfiguration="jsonBehaviour" contract="Cadence.SP.COS.Services.IQueryService">
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange">
        </endpoint>
      </service>
      </services>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />

  </system.serviceModel>


Thursday, July 30, 2015

Federating Search


Federating Search
Sometimes you may have too much content outside of SharePoint or maybe you have a system that already has a capable search engine (i.e.: an ERP or another document management system).  This calls for federated search. As another example, you might use a federated search to display results from your public facing web site or from a public search engine like Bing.  You don’t want to completely index their data, but you would still like to see results from those external systems when searching from SharePoint.  The Federated Search feature allows you to display results from any search engine supporting the OpenSearch 1.1 protocol alongside your local search results.  If you are not familiar with OpenSearch, the results come back as an RSS feed.  Even if your external system doesn’t support OpenSearch, you can write some code to refactor the results as RSS and integrate them easily into SharePoint.  Here is an example, where the federated results come from DotNetMafia.com on the right side of the screen.
Exposing SharePoint Search to other applications



Search Reports
The search reports capture the user behavior information related to the queries on the site.
Trend Reports
1.     Number of Queries: Total number of queries each day.
Rank Reports
1.     Top Queries: Most issued queries per day.
2.     Failed Queries: Most issued queries for which either there were no results or the user did not click on any results.
3.     No Result Queries: Most issued queries for which no results were returned.
Other Reports
1.     Best Bet Suggestion Report: Recommends URLs as most likely results for particular search queries based on analysis of usage patterns. The site administrators can accept or reject these suggestions. If they accept, the corresponding query-URL pair is added to the search keywords list.
2.     Best Bet Usage: Shows how Best Bet suggestions are doing over time. For every Best Bet query issued, the report shows the percentage of clicks on the Best Bet URL compared to other URLs.
3.     Best Bet Action History Report: Tracks the actions performed by the site administrator on the ‘Best Bet Suggestion’ Report.
Report Scope
Site
Site Collection
Web Application
Search Service Application
Number of Queries

check[51]
check[53]
check[55]
Top Queries

check[59]

check[57]
Failed Queries

check[61]


No Result Queries



check[63]
Best Bet Usage

check[65]


Best Bet Suggestions

check[67]


Best Bet Suggestion Action History

check[69]



Table 2:  Summary of the search reports availability at different SharePoint component hierarchy levels

Get Search Analytics Reports programmatically in SharePoint 2013

How to get Search Analytics Reports programmatically in SharePoint 2013

Console application

using System;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;
using Microsoft.Office.Server.Search.Administration;
using Microsoft.Office.Server.Search.Analytics;


namespace SharePointConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            SPSite site = new SPSite("http://YourseverName/sites/Ptrends/");
            SPUserToken userToken = site.UserToken;

            SPSecurity.RunWithElevatedPrivileges(delegate
            {
                using (SPSite site1 = new SPSite(site.ID, userToken))
                {
                    SPServiceContext context = SPServiceContext.GetContext(site1);
                    SearchServiceApplicationProxy searchProxy = context.GetDefaultProxy(typeof(SearchServiceApplicationProxy)) as SearchServiceApplicationProxy;
                    AnalyticsItemData usageData = searchProxy.GetRollupAnalyticsItemData((int)SearchReportTypeId.TopQuery, Guid.Empty, Guid.Empty, Guid.Empty);

                    int dailyHits = usageData.GetHitCountForDay(DateTime.Today);
                    int monthlyHits = usageData.GetHitCountForMonth(DateTime.Today);
                    Console.WriteLine(String.Format("Report Daily Hits={0}; Monthly Hits={1}", dailyHits, monthlyHits));

                    uint maxRows = 1000;
                    DateTime startDate = new DateTime(2015, 7, 1);
                    var searchResults = searchProxy.GetSearchReport((int)SearchReportTypeId.TopQuery, Guid.Empty, Guid.Empty, startDate.Date, true, maxRows);
                    if (searchResults.Count > 0)
                    {
                        foreach (QueryReportData rptData in searchResults)
                        {
                            int hitsCnt = rptData.Count;
                            string qry = rptData.Query;
                            Guid scope = rptData.Scope;
                            Console.WriteLine(String.Format("Report Count={0}; Query={1}; Scope={2}", hitsCnt, qry, scope.ToString()));
                        }
                    }
                }
            });

        }
    }
}

Friday, July 24, 2015

Configure Outgoing emails in Sharepoint server

To install the SMTP service
  1. Verify that the user account that is performing this procedure is a member of the Administrators group on the front-end web server.
  2. Click Start, point to Administrative Tools, and then click Server Manager.
  3. In Server Manager, click Features.
  4. In Features Summary, click Add Features to open the Add Features Wizard.
  5. On the Select Features page, select SMTP Server.
  6. In the Add Features Wizard dialog box, click Add Required Roll Services, and then click Next.
  7. On the Confirm Installation Selections page, click Install.
  8. On the Installation Results page, ensure that the installation is complete, and then click Close.
To Configure SMTP Server:
1.      Click Start, point to Administrative Tools, and then click Internet Information Services (IIS) 6.0 Manager.
2.      In IIS Manager, expand the server name that contains the SMTP server that you want to configure.
3.      Right-click the SMTP virtual server that you want to configure, and then click Start.
4.      Right-click the SMTP virtual server that you want to configure, and then click Properties.
5.      Go to Access Tab Click on Authentication and Check Anonymous Access than click OK.
6.     

7.       Click On Relay and Choose All Except List Bellow


8.       Click On Delivery Tab, Outbound Security provide Credentials Click On OK
9.       Click on outbound Connections Change port 25 to 587
10.   Click on Advanced and following details
11.   Configure Outgoing mails from CA

SharePoint Search Center site

REFERENCE :- http://www.c-sharpcorner.com/UploadFile/Roji.Joy/how-to-configure-search-centre-in-sharepoint-2013/

https://technet.microsoft.com/en-us/library/hh582314.aspx


SharePoint Search Center site
  1. Verify that the user account that is performing this procedure is a member of the Farm Administrators group.
  2. On the home page of the Central Administration website, in the Application Management section, click Create site collections.
  3. On the Create Site Collection page, do the following:
    • In the Web Application section, select a web application to contain the new site collection. To use a web application other than the one that is displayed, click the web application that is displayed, and then click Change Web Application.
    • In the Title and Description section, in the Title box, type the name for the new Search Center site. Optionally, type a description in the Description box.
    • In the Web Site Address section, for the part of the URL immediately after the web application address, select /sites/, or select a managed path that was previously defined, and then type the final part of the URL.

      SharePoint-Search-Center-site.jpg





    • In the Template Selection section, do the following:
      • In the Select the experience version drop-down list, select 2013 to create a Search Center site that provides the SharePoint Server 2013 user experience, or select 2010 to create a Search Center site that provides the SharePoint 2010 Products user experience.
      • In the Select a template subsection, click the Enterprise tab, and then do one of the following:
      • If you are using SharePoint Foundation 2013, select the Basic Search Center template.
      • Otherwise, if you are using SharePoint Server 2013, select the Enterprise Search Center template.
     
  4. In the Primary Site Collection Administrator section, in the User name box, type the user name of the primary site collection administrator for this site collection in the form domain\user name.
  5. In the Secondary Site Collection Administrator section, type the user name of a secondary site collection administrator in the form domain\user name.
  6. In the Quota Template section, select No Quota.
  7. A Search Center site is not intended to be a data repository. Therefore, you do not have to select a quota template.
  8. Click OK.
  9. On the Top-Level Site Successfully Created page, click the link to the Search Center site that you created.

    Created-Search-Center-site.jpg
     
  10. After you create the Search Center site, you must grant site access to users so that they can perform search queries and view search results. Use the following procedure to grant site access to users.
To grant access to the SharePoint Search Center
Use the following to grant access to the SharePoint Search Center:
  1. Verify that the user account that is performing this procedure is a member of the Owners group on the Search Center site.
  2. In a web browser, go to the Search Center site.

    grant-access-to-the-SharePoint-Search-Center.jpg
     
  3. Open the Site menu by clicking the gear icon in the upper-right portion of the page, and then click Site Permissions.

    Sharepoint-Site-Permissions.jpg
     
  4. In the Shared with dialog box, click Invite people.

    Shared-with-dialog-box.jpg
     
  5. In the Share <SearchCenterName> dialog box, in the Enter users separated with semicolons text box, type the names of the Windows user groups and Windows users to whom you want to grant permissions for submitting queries and viewing search results in the Search Center.

    Share-SearchCenterName.jpg
     
  6. For example, to grant access to the Search Center to all Windows users, type NT Authority\authenticated users.
  7. Click Show options.
  8. Clear the Send an email invitation check box.
  9. In the Select a group or permission level drop-down list, select <SearchCenterName> Visitors [Read].
  10. Click Share.  

Tuesday, July 21, 2015

Migration SharePoint 2007 to SharePoint 2013

There are two way for migration SharePoint 2007 to SharePoint 2013 and the way is
1. Database attach

2. Content migration
 
Database attach:
- This option upgrades the database schema by attaching a content database from SharePoint 2007 to SharePoint 2010.

-Then you upgrade again by attaching it to SharePoint 2013. This requires an intermediate environment of SharePoint 2010.

- Essentially, it involves twice the migration effort and an extra environment to build and support.

Content migration:
- This option allows for direct migration of content from SharePoint 2007 to SharePoint 2013.

- It does not involve the upgrade of the database schema.

- It requires a third-party migration tool and can be run directly on the target SharePoint 2013 environment. In short, the tool scans the current SharePoint 2007 sites and libraries, creates new sites and structures in 2013, and copies content to the new libraries and lists while retaining the metadata, security and other properties.

These are tool's
1. AvePoint DocAve

2. Axceler ControlPoint

3. Sharegate

4. Metalogix Migration Manager for SharePoint

5. Metavis Migration Suite

6. Quest Migration Manager for SharePoint


Saturday, May 30, 2015

SharePoint 2013 REST Services Architecture

Developers can interact remotely with SharePoint 2013 by way of REST services introduced in SharePoint 2013. SharePoint data and objects can be accessed using any technology that supports REST web requests like the ones shown in the picture below. This ability of SharePoint 2013 opens the boundaries of integration and collaboration with other REST based platforms and devices. 

REST service architecture

As the REST service architecture in the preceding figure shows, a HTTP request using the OData protocol is sent to SharePoint and your application will receive the response in JSON or ATOM format that your client application needs to parse and utilize. The HTTP request is handled by the "client.svc" web service in SharePoint 2013. The "client.svc" web service internally calls the server object model that retrieves data from the SharePoint content database as shown below. SharePoint Apps are built using these architectural concepts.

server object model call

For example: If you want to retrieve a SharePoint List by its Title then you can create a request as follows:
http://server/site/_api/lists/getbytitle('ListName')

A concrete example:
http://win-4f44sec6iug:34480/sites/ts/_api/lists/getbytitle('ProductList')

In my case the response I receive is as follows:

display feed in IE

Oops!! So IE cannot display the feed;  but I have received the feed from SharePoint. So I right-click and do a view source. I see the entire XML is being sent by SharePoint. To see the XML in IE 10 you need to use the following procedure:
  • "Tools" > "Internet Options"
  • Select the "Content" Tab
  • Under Feeds and Web Slices, select "Settings"

    Feeds and Web Slices
  • Under Advanced section untick "Turn on Feed reading view". Refresh the request; you will see the details in XML format, something as in the following:

    XML format
The following figure (from the MSDN documentation) shows the general syntax structure of SharePoint REST URIs. (Please refer to http://msdn.microsoft.com/en-US/library/office/dn292556.aspx for more details.) The following is the SharePoint REST URI syntax structure.

REST URI syntax structure

The following are some special cases that deviate from this syntax structure:
  • Methods that require complex types as parameters.
  • If the corresponding client object model method requires that complex types be passed as parameters.
  • Static methods and properties.
REFERENCE  : http://www.c-sharpcorner.com/UploadFile/d2ee01/sharepoint-2013-rest-services-architecture/

Get to know the SharePoint 2013 REST service

SharePoint REST service architecture-2013

SharePoint 2013 introduces a Representational State Transfer (REST) service that is comparable to the existing SharePoint client object models. Now, developers can interact remotely with SharePoint data by using any technology that supports REST web requests. This means that developers can perform CreateRead,Update, and Delete (CRUD) operations from their apps for SharePoint, solutions, and client applications, using REST web technologies and standard Open Data Protocol (OData) syntax.
How the SharePoint 2013 REST service works

SharePoint 2013 adds the ability for you to remotely interact with SharePoint sites by using REST. Now, you can interact directly with SharePoint objects by using any technology that supports standard REST capabilities.
To access SharePoint resources using REST, construct a RESTful HTTP request, using the Open Data Protocol (OData) standard, which corresponds to the desired client object model API. For example:
Client object model method:
List.GetByTitle(listname)
REST endpoint:
http://server/site/_api/lists/getbytitle('listname')
The client.svc web service in SharePoint handles the HTTP request, and serves the appropriate response in either Atom or JSON (JavaScript Object Notation) format. Your client application must then parse that response. The figure below shows a high-level view of the SharePoint REST architecture.
SharePoint REST service architecture

SharePoint REST service architecture
Because of the functionality and ease of use that client object models provide, they remain the primary development option for communicating with SharePoint sites by using .NET Framework managed code, Silverlight, or JavaScript.

Use HTTP commands with the SharePoint 2013 REST service

To use the REST capabilities that are built into SharePoint 2013, you construct a RESTful HTTP request, using the OData standard, which corresponds to the client object model API you want to use. The client.svc web service handles the HTTP request and serves the appropriate response in either Atom or JavaScript Object Notation (JSON) format. The client application must then parse that response.
The endpoints in the SharePoint 2013 REST service correspond to the types and members in the SharePoint client object models. By using HTTP requests, you can use these REST endpoints to perform typical CRUD operations against SharePoint entities, such as lists and sites.
In general:
If you want to do this to an endpoint
Use this HTTP request
Keep in mind
Read a resource
GET
Create or update a resource
POST
Use POST to create entities such as lists and sites. The SharePoint 2013 REST service supports sending POST commands that include object definitions to endpoints that represent collections.
For POST operations, any properties that are not required are set to their default values. If you attempt to set a read-only property as part of a POST operation, the service returns an exception.
Update or insert a resource
PUT
Use PUT and MERGE operations to update existing SharePoint objects.
Any service endpoint that represents an object property set operation supports both PUT requests and MERGErequests.
  • For MERGE requests, setting properties is optional; any properties that you do not explicitly set retain their current property.
  • For PUT requests, if you do not specify all required properties in object updates, the REST service returns an exception. In addition, any optional properties you do not explicitly set are set to their default properties.
Delete a resource
DELETE
Use the HTTP DELETE command against the specific endpoint URL to delete the SharePoint object represented by that endpoint.
In the case of recyclable objects, such as lists, files, and list items, this results in a Recycle operation.

Construct REST URLs to access SharePoint resources

Whenever possible, the URI for these REST endpoints closely mimics the API signature of the resource in the SharePoint client object model. The main entry points for the REST service represent the site collection and site of the specified context.
To access a specific site collection, use the following construction:
http://server/site/_api/site
To access a specific site, use the following construction:
http://server/site/_api/web
In each case, server represents the name of the server, and site represents the name of, or path to, the specific site.
From this starting point, you can then construct more specific REST URIs by ''walking" the object model, using the names of the APIs from the client object model separated by a forward slash (/).
This syntax doesn’t apply to the SocialFeedManager or SocialFollowingManager REST APIs. See Social feed REST API reference for SharePoint 2013 andFollowing people and content REST API reference for SharePoint 2013 for more information.
See Determine SharePoint REST service endpoint URIs for more guidelines for determining SharePoint REST endpoint URIs from the signature of the corresponding client object model APIs.

SharePoint REST endpoint examples

The following table contains typical REST endpoint URL examples to get you started working with SharePoint data. Prepend http://server/site/_api/ to the URL fragments shown in the table to construct a fully qualified REST URL. Where necessary for POST commands, the table contains sample data you must pass in the HTTP request body to create the specified SharePoint item. Items in italics represent variables that you must replace with your values.
Description
URL endpoint
HTTP method
Body content
Retrieves the title of a list
web/title
GET
Not applicable
Retrieves all lists on a site
lists
GET
Not applicable
Retrieves a single 'list's metadata
lists/getbytitle('listname')
GET
Not applicable
Retrieves items within a list
lists/getbytitle('listname')/items
GET
Not applicable
Retrieves a specific property of a document. (In this case, the document title.)
lists/getbytitle('listname')?select=Title
GET
Not applicable
Creates a list
lists
POST
{
  '_metadata':{'type':SP.List},
  'AllowContentTypes': true,
  'BaseTemplate': 104,
  'ContentTypesEnabled': true,
  'Description': 'My list description',
  'Title': 'RestTest'
}
Adds an item to a list
lists/getbytitle('listname')/items
POST
{
  '_metadata':{'type':SP. listnameListItem},
  'Title': 'MyItem'
}


Update or edit status filed in JIRA issue

the status field is a special case and can't be updated directly, which is the second problem here. Changing a status in Jira is called ...