Check-In documents automatically after uploading to Sharepoint

For the last two days, we’ve been suffering from this problem where, we need the following features:

  • Support for Sharepoint library versioning
  • Documents need to be checked out before one can edit
  • Whenever a new document has been uploaded, it needs to be in checked-in state (we have a custom workflow which fires on document upload, it requires the document to be in checked-in state)

Now, if we disable the force checkout option from library settings, multiple persons can open and edit the same document, which obviously we don’t want. On the other hand, our workflow simply wont trigger on new document upload because the newly uploaded document remains checked-out. If we manually check-in the document, the workflow follows immediately. The bottom-line is, we need a post-upload event to check-in the uploaded document forcefully.

Sharepoint allows developers to create Event Receiver handlers which can be used to override sharepoint events on various levels. On this occasion, we need to override the ItemAdded method of Document Library. For this, we added a new Event Receiver item within our workflow project. Sandboxed mode was chosen for this purpose. From the Visual Studio wizard’s list of events, select An item was added from  List Item Events on Document Library. This will create a new class file with the ItemAdded method overridden. We just have to write our own code.


using System;
using System.Security.Permissions;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Security;
using Microsoft.SharePoint.Utilities;
using Microsoft.SharePoint.Workflow;

namespace CustomItemAdded.EventReceiver1
{
    public class EventReceiver1 : SPItemEventReceiver
    {
       public override void ItemAdded(SPItemEventProperties properties)
       {
           base.ItemAdded(properties);
           SPFile thisFile = properties.ListItem.File;

           if (!thisFile.CheckOutType.Equals(SPFile.SPCheckOutType.None))
           {
               thisFile.CheckIn("Checked in by custom event handler.");
           }
       }
    }
}

SOAP Calls using jQuery Ajax

Few days ago, I came across a situation where I had to get data from a .NET Web Service using jQuery Ajax. Here is a sample code:


var soapMessage =
    '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">'+
        '<soap:Body>'+
            '<SomeMethod>'+
                '<Arg1>Arg1 Value</Arg1>'+
                '<Arg2>Arg2 Value</Arg2>'+
            '</SomeMethod>'+
        '</soap:Body>'+
    '</soap:Envelope>';

$.ajax({
    url: "http://localhost/someService.svc",
    type: "POST",
    dataType: "xml",
    contentType: "text/xml; charset=\"utf-8\"",
    headers: {
        SOAPAction: "http://localhost/someService/SomeMethod"
    },
    data: soapMessage,
    success: function(soapResponse){
        //DO SOMETHING
    }
});
Panam City

Panam City

Panam is a locality in Sonargaon thana of Narayanganj district, located about 27 kilometre north east of Dhaka city and 2.5 km to the north of Dhaka-Chittagong highway from Mograpara point. Sonargaon (golden village in literal meaning), the administrative centre of eastern Bengal under the Muslim sultanate rulers of Bengal of medieval era survives at present in the name of a ‘upazila’ in the Narayanganj district.

Standard 3 bracketed shots (-2/0/+2). HRD tonemapped in Photomatix 4.0. Slightly retouched in PhotoShop CS5.

Devotee

Devotee

Langalband a Hindu holy place situated on the bank of old brahmaputra close to Dhaka-Chittagong highway, 20 kilometres to the southeast of Dhaka city. Every year on the 8th day of lunar fortnight in the Bengali month of Chaitra, thousands of Hindu devotees from home and abroad assemble there for Astami snan, a holy bath in the river. They believe that this bath will please Brahma and they will be relieved of their sins and distresses.

Blausee

Blausee

Blausee (literally: Blue Lake) is a small lake in the Kander valley above Kandergrund at 887 m, near the river Kander. Administratively, it belongs to the Bernese Oberland. The lake has an area of 0.64 ha. The lake can be reached by bus from the train stations of Frutigen or Kandersteg. It is a popular tourist destination.

সুইচোরা

Green Bee Eater (সুইচোরা )

The Green Bee-eater, Merops orientalis, (sometimes Little Green Bee-eater) is a near passerine bird in the bee-eater family. It is resident but prone to seasonal movements and is found widely distributed across sub-Saharan Africa from Senegal and The Gambia to Ethiopia, the Nile valley, western Arabia and Asia through India to Vietnam. They are mainly insect eaters and they are found in grassland, thin scrub and forest often quite far from water. Several regional plumage variations are known and several subspecies have been named.

Taken at Tanguar Haor, 2012

Basel Munster

Basel Münster

Biggest church in Basel, Switzerland. The Basel Münster (Basler Münster) is one of the main landmarks and tourist attractions of the Swiss city of Basel. It adds definition to the cityscape with its red sandstone architecture and coloured roof tiles, its two slim towers and the cross-shaped intersection of the main roof. The Münster is listed as a heritage site of national significance.

The Cellist

The Cellist

Freiestrasse is one of the most busy streets of Basel. Lots of activities are going on in each corner of the street. It was a 5 min walk from my hotel. Whenever I had time to do some streets, it was an obvious location.

This guy playing ‘Cello’ caught my eyes and heart with really intense and passionate music which made the surroundings like a movie from the 80′s.

Processed using DPP, Photoshop, Silver Efex

Matterhorn

Matterhorn

The Matterhorn (German), Monte Cervino (Italian) or Mont Cervin (French), is a mountain in the Pennine Alps on the border between Switzerland and Italy. Its summit is 4,478 metres (14,690 ft) high, making it one of the highest peaks in the Alps. The four steep faces, rising above the surrounding glaciers, face the four compass points. The mountain overlooks the town of Zermatt in the canton of Valais to the north-east and Breuil-Cervinia in the Aosta Valley to the south. The Theodul Pass, located at the eastern base of the peak, is the lowest passage between its north and south side.

Gold Web

Gold Web

Caught a spider bathing in the early morning sun while sitting in the middle of its web.

Location: Dooers forest, Shiliguri, West Bengal, India.
Lens: Canon 75-300mm f/4-5.6 USM III

Green Bee Eater

Green Bee Eater

The Green Bee-eater (সুইচোরা), Merops orientalis, (sometimes Little Green Bee-eater) is a near passerine bird in the bee-eater family. It is resident but prone to seasonal movements and is found widely distributed across sub-Saharan Africa from Senegal and The Gambia to Ethiopia, the Nile valley, western Arabia and Asia through India to Vietnam. They are mainly insect eaters and they are found in grassland, thin scrub and forest often quite far from water. Several regional plumage variations are known and several subspecies have been named.

Taken at Tanguar Haor, 2012.

First post!

Ahh! Finally I have the time to setup my own blog site! I always had big plans for this, probably too big! That’s why all those big ideas never turned to reality. This time I’ve decided to go as simple as possible and will be trying to gradually improve the site. I hope this new strategy works!