Monday, August 6, 2012

Installing sharepoint server 2013 preview in stand alone system

After lot of fight with my machine, at the end I was able to install sharepoint 2013 preview version my stand-alone system. While installing, most of the time I faced pre-requisites issue .So, Please makes sure that your system is supporting and having all pre-requisites software which was recommended by Microsoft. Afterthat jump into installation steps.

Below listed pre-requisites software’s are needed to run sharepoint 2013 preview in your machine
 
1) Windows server 2008 R2 sp1 or later
2) SQL server 2008 R2 sp1 or later
 
You can get above mentioned software from Microsoft download site as trial version .In case, you are already having registered version of windows server 2008 R2 and Sql server 2008 R2 version, you have to upgrade your software before starting the sharepoint 2013 preview installation process.

To upgrade Windows server 2008 R2 to sp1 version, click following link http://download.microsoft.com/download/0/A/F/0AFB5316-3062-494A-AB78-7FB0D4461357/windows6.1-KB976932-X64.exe
, download sp1 executable file and run it in your machine .It will take few minutes to install sp1 and in between in the installation process, it will automatically restart your machine.
For upgrading sql server 2008 R2 to sp1 version is also same process. You have to download sql server 2008 r2 sp1 executable file from Microsoft download center site, run it in your machine and follow the upgrade wizard steps
Sorry, I couldn’t cover in this article what are the hardware’s needed to run SharePoint 2013 server preview in stand-alone machine. However, you can see Hardware requirements for SharePoint 2013 Preview in the below link
http://technet.microsoft.com/en-us/library/cc262485%28v=office.15%29.aspx#section3

After install pre- requisites software in your machine, download sharepoint 2013 server preview from below url . You need an hotmail email id to download the file.
http://technet.microsoft.com/en-us/evalcenter/hh973397.aspx
Once you download the file, extract your .img file by using some extracting software such as Magic iso, daemon tool.

After extract operation complete, go to extracted file location and double click “Prerequisiteintaller.exe” file to check  all pre-requisites software has been installed in your machine, if not ,it will throw the error and read error and do appropriate action for error message .The prerequisiteinstaller will prefer environment to install sharepoint 2013 server preview and install windows app fabric, wcf software in your machine to support  sharepoint 2013 server latest service .Please make sure that your system is connected with internet while running prerequisitesinstaller file.

 
After installation of prerequisite software, this is a time to run share point 2013 server preview setup file .Run setup and enter product key that you can find in link which you used to download sharepoint 2013 server preview software.

 

Installation process will take some minutes to complete. After install sharepoint server 2013 preview  , you have to run configuration wizard steps which actually create configuration database in sql server system and follow the configuration wizard steps to complete full cycle of sharepoint 2013 server preview  process.At the end of configuration wizard steps, you will see a screen look like below .

 

Now, go and open browser and type your central administration site url, you can view your central administrator site looks like below screen.

 
You may feel that most of the steps are same as sharepoint 2010 installation .yes, I have already told that installation process is same if you preferred hardware and software requirements for sharepoint server 2013 preview.
 
If you face any issue during installation in your environments. Please let me know .I am very glad to help you.

Thanks for reading and my admin

Monday, July 16, 2012

Create custom Timer jobs in sharepoint 2010

In this article, I am going to show you how to create custom timer jobs in SharePoint 2010.

Formally creating a custom Timer jobs using visual studio 2010 is very straight forward. Open your visual studio, Select New project in File menu, choose “Empty SharePoint Project” option, then enter your project and solution name and click OK.

SharePoint wizard window shows two type of trust level option. In these, select “Deploy as a farm solution” option (The timer jobs dll will be put it on GAC folder), click Finish. Now, the empty SharePoint project is created.

Add a new class in your project and inherits Microsoft.SharePoint.Administration.SPJobDefinition class into your created class. To implement Timer jobs, you have to create few constructor and Execute method in your class file. After creating constructor and Execute method you can see your class file look like below code.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;
using System.Net.Mail;
namespace Sending_Email_Using_Timer_jobs
{
    class SendingEmail:SPJobDefinition
    {
        public SendingEmail():base()
        {

        }
          public SendingEmail(string jobName, SPService service, SPServer server, SPJobLockType targetType): base(jobName, service, server, targetType)
        {

        }

          public SendingEmail(string jobName, SPWebApplication webApplication): base(jobName, webApplication, null, SPJobLockType.ContentDatabase)
        {
            this.Title = "Creating list";
        }

        public override void Execute(Guid contentDbId)
        {
            // get a reference to the current site collection's content database
            SPWebApplication webApplication = this.Parent as SPWebApplication;
            SPContentDatabase contentDb = webApplication.ContentDatabases[contentDbId];

            // get a reference to the "Creating list" in the RootWeb of the first site collection in the content database
            SPList Listjob = contentDb.Sites[0].RootWeb.Lists["List"+DateTime.Today.ToString()];
            // create a new list Item, set the Title to the current day/time, and update the item
            SPListItem newList = Listjob.Items.Add();
            newList["Title"] = DateTime.Now.ToString();
            newList.Update();

            /*sending email after list created successfully in site*/

            if (!string.IsNullOrEmpty(Convert.ToString(contentDb.Sites[0].RootWeb.Lists.TryGetList("List" + DateTime.Today.ToString()))))
            {
                SmtpClient smtpClient = new SmtpClient();
                MailMessage message = new MailMessage();
                smtpClient.Host = "your host address";
                message.IsBodyHtml = true;
                message.From = new MailAddress("balamurugan@mail.com");
                message.To.Add("smmani@mail.com");
                message.Subject = "Test Timer jobs";
                AlternateView htmlView = AlternateView.CreateAlternateViewFromString("The list has been created successfully<br/>" + contentDb.Sites[0].RootWeb.Lists["List" + DateTime.Today.ToString()].DefaultViewUrl + "", null, "text/html");
                message.AlternateViews.Add(htmlView);
                message.Priority = MailPriority.Normal;
                smtpClient.Send(message);
            }
        }
    }
}


In code, you can see “SPJobLockType” enum method which indicates timer jobs instance running level. I will explain this in my later post. Keep focusing on timer job creation.

Execute method is a place for writing our business logic in the timer jobs. Override Execute method and write your business logic. In my example, I have added a sending email code after the list created in the site.

To create a feature to deploy your timer jobs in your environment .Go to Feature folder, right click and add Feature. Right now, we have created a feature to activate the timer jobs . 


To install/uninstall the timer jobs on server, we have to do a little bit of code stuff. To create Event receiver code, Go to just now created feature file, Right click and choose Add Event Receiver Option. Now, you can see a new event receiver class file added into your solution package 



Add install and uninstall timer jobs code in Feature activated and feature deactivated method. In my code, I am activating createlist timer jobs in web application level and running in every 5 minutes interval.

The following class is providing you to run the timer jobs as per business criteria using code

    SPOneTimeSchedule –Represents a schedule that specifies the time range during which the job will run.
    SPMinuteSchedule – runs job a minute schedule
    SPHourlySchedule – runs job an Hourly schedule
    SPDailySchedule – runs job a Daily schedule
    SPMonthlySchedule – runs job a Monthly schedule
    SPWeeklySchedule – runs job a Weekly schedule
    SPYearlySchedule – runs job a Yearly schedule

using System;
using System.Runtime.InteropServices;
using System.Security.Permissions;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Security;
using Microsoft.SharePoint.Administration;

namespace Sending_Email_Using_Timer_jobs.Features.Timer_jobs
{
    /// <summary>
    /// This class handles events raised during feature activation, deactivation, installation, uninstallation, and upgrade.
    /// </summary>
    /// <remarks>
    /// The GUID attached to this class may be used during packaging and should not be modified.
    /// </remarks>

    [Guid("e550963a-1a8c-4751-9f53-eeaa0200ec03")]
    public class Timer_jobsEventReceiver : SPFeatureReceiver
    {
       
        const string Create_list = "Creating list";
        // Uncomment the method below to handle the event raised after a feature has been activated.

        public override void FeatureActivated(SPFeatureReceiverProperties properties)
        {
            SPWebApplication webapplication = properties.Feature.Parent as SPWebApplication;

            // make sure the job isn't already registered

            foreach (SPJobDefinition job in webapplication.JobDefinitions)
            {

                if (job.Name == Create_list)

                    job.Delete();

            }

            // install the job

            SendingEmail createlistJob = new SendingEmail(Create_list, webapplication);
            SPMinuteSchedule schedule = new SPMinuteSchedule();
            schedule.BeginSecond = 0;
            schedule.EndSecond = 59;
            schedule.Interval = 5;
            createlistJob.Schedule = schedule;
            createlistJob.Update();

        }

        // Uncomment the method below to handle the event raised before a feature is deactivated.

        public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
        {
            SPWebApplication webapplication = properties.Feature.Parent as SPWebApplication;

            // delete the job

            foreach (SPJobDefinition job in webapplication.JobDefinitions)
            {

                if (job.Name == Create_list)

                    job.Delete();

            }

        }
    }
}


Select correct feature scope before deploying your solution. I have used web application scope to run my timer jobs.


After select correct scope, our package is ready to deploy .Right click solution and select Build, and then Deploy.





Tuesday, May 29, 2012

Business connectivity services


BCS is one of great feature in SharePoint platform that integrates SharePoint solution based application to external system. In this article, I illustrates  a step-by-step procedure that how to connect SharePoint application to external system,  how to create an external content type using SharePoint designer as well visual studio  and in which and where we have to use visual studio for developing external content type .

External content type which is a fundamental block of BCS and describes how to connect external system from SharePoint by using metadata in the xml program. For those familiar with SharePoint 2007 BDC, it was called as BDC entity and they can understand the pain of creating external content type in SharePoint 2007 environment .But, in SharePoint 2010 it is very easy and straight forward to create external content type from SharePoint designer. But in some situation we couldn’t use SPD for creating external type such as calling complex data type , calling multiple external system and calling one external system and writing output to another external system .In the remaining of article I will explain more elaborately .Let us take a look how to create external content type from SPD 2010

How to create external content type from SPD 2010

This is a great starting point for who are newly introduced to BCS and Information knowledge worker.
Open SharePoint designer 2010 from desktop and enter your site url where you want to show the external system data .Click external content type in the site objects window, and then  click External Content Type link under external content type menu 






I hope that you are in the same window .After click New external content type menu, you can view see same window with your new external content type properties that content type display name,name,version and etc.



After change external content type display name and name as meaningful, Click “Click here to discover external data sources and define operation” link under external content type information box, which navigate you to new screen same as below.

This is the place where we are going to create an external data source connection. Click Add connection button and then select your data source type i.e. in which platform based application do you want to connect , in this example, I am using sql server as a data source . Once select your data source type, click OK.


It will pop-up a data connection properties screen and enter your database server, database name and select  authentication identity option button which talks to external system during connection time  and pass the credential depends on your selection in the window then Click OK button.


Once successfully configured connection, you can view your external source data inside data source explorer box.


Right click your table; it will pop –up menu looks like below screen and click “create all operations” option. It takes you to   all operation screen and then click next button.


After click Next button, you are in parameter configuration screen same as below screen with your table properties.

In the errors and warnings box, you can see all errors and warning message. In our window also, you can see an error message that “At least one identifier should be specified”. Yes, we have to set one field property as a map to identifier .Here, I have set it map to identifier property to Customer id field. After setting map to identifier property, you can see that error message goes off from the error and warning box and then Click Finish button and save your content type. Finally, we create our new external content type successfully.
Now, we have to create an external list to display our external data on our site .They are two ways to create external list, one is from SPD and another one is directly from site. In my example, I am creating an external list from SharePoint site.
Before going to create an external list, just check that our external content type has been successfully and external content type was imported in the central administrator. For checking in central admin, Open your central admin, click “manage service application” under application management and then select your BCS application services which will navigate you to external application service information page, here, you can see your external content type .

`


Now we ensure that our external content type has been imported and resided under central admin. Let us go to our site view all site setting page, click create link and choose “External List” list type from list category.

After creation of external list, you will be in the same as below screen.

In this screen ,you enter your list name ,quick launch menu option and at the end select your external content type which we has been created and imported on the central admin .If you have confusion while selecting your content type .Please follow below screen numerical notation .Select your external content type , Click create button .
Now, you can see your external list with your external system data .Some time, you may see the famous error that “Access denied by Business Data Connectivity”. The reason of the issue is that you don’t have sufficient permission to access the external system data. Go to Central admin where your external content type file was imported.

Select your external content type check option and click “Set Metadata Store Permission” .you can find that no one user account has been configured for permission .Add your credentials and select all permission check box then click Ok button.
Now, Go to your external list and refresh .Right now, your external system data will be listed on your external list but at the end we will achieve our goal.
Let us check our functionality, Add a new item in the external list, it will automatically reflect on your external system same as vice versa.
It is working perfectly fine .I hope you enjoyed and learned new feature ;)
I’ll explain you in my next article that how to create external content using Visual studio 2010.