Blog

Sitecore Content Migration Basics

Horizontal Integration

Challenge:

For one of our project, we did some research on all the available options for migrating content from other sources like SQL, CSV, XLS, XML, HTML, docx, zip file in to Sitecore.

We Invested good amount of time to do so. And we thought it will be a good idea to share it with you as well!

We at HI, Invest good amount of time before implementing anything for our clients. Because it’s always good to use widely accepted, proven solution, rather than creating new one from scratch (Yes, agree at times you’ve to be the first one). It will not only save bit of your development efforts. But you will be able to provide robust solution to your client, and that’s what we (And we are sure you as well, Correct?) strive for!

So, If you are looking for :

  1. A solution to migrate content in to your…

View original post 482 more words

Solr Configuration for providing search suggestions

Hi All,

Today we discuss how we configure solr for provide search suggestion.

For that I follow 2 blogs which are listed below the blog.

Configuring Solr to provide search suggestions

http://www.nttdatasitecore.com/Blog/2017/January/Faceted-Autocomplete-for-a-Sitecore-Multilingual-site-using-SOLR-Suggester-API

By using help of these blog I can configure solr with auto suggest. I use 1st blog for setup solr and using 2nd blog Building jQuery Autocomplete jquery : jquery function for autocomplete suggestion.

Note:

1.Keep in mind while follow first blog for updating solrconfig.xml field str contain the name of the field for example:

<searchComponent name=”suggest” class=”solr.SuggestComponent”>

<lst name=”suggester”>

<str name=”name”>fuzzySuggester</str>

<str name=”field”>page_title_t</str>

</lst>

<lst name=”suggester”>

<str name=”name”>infixSuggester</str>

<str name=”field”>page_title_t</str>

</lst>

</searchComponent>

2. While using 2nd blog jquery function its give cross platform error , solution also provide in that blog but i am not able to resolve that so i use my solution that are below:

$(‘#search-field’).autocomplete({

source: function (request, response) {

var currentLanguage = ‘en’;

var url = “http://localhost:8983/solr/custom_index_autocomplete/suggest?suggest.q=&#8221; + request.term + “&suggest.cfq=” + currentLanguage + “&wt=json&json.wrf=?“;

$.getJSON(url, function (data) {

//response($.map(data.suggest.suggester[request.term].suggestions, function (value) { return value.term }));

response($.map(data.suggest.fuzzySuggester[request.term].suggestions, function (value) { return value.term }));

});

}

});

Configure solr for sitecore 8.1 initial version

Hi All,

Today I am going to tell you about how to configure the Solr instead of lucene.

Here we using solr via Tomacat server. So these points I need to cover.

  • Install/Configure the tomcat
  • Install/Configure solr
  • Configure for sitecore

 

Install Tomcat:

  1. 1. Install Java jre from below URL:

http://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html

  1. Install Windows Service Installer for apache tomcat from below URL:

http://tomcat.apache.org/download-80.cgi

Note: Please select host manager option ticked and default location for tomcat is:

C:\Program Files\Apache Software Foundation\Tomcat 8.0

The default port used by Tomcat is 8080 (used to be 8983) but you may elect to use some other port. Don’t choose port 80.

Note: If you want run more then one tomcat on on system then use different connector port and shutdown port.

Eg: connector port: 8983, 8038, 8039 etc.

Shutdown port: 8005, 8025 etc.

  1. Type configure tomcat and select automatic mode.
  2. you can also select for alias name for tomacat by update in conf/server.xml in tomcat directory.

<Alias>tomcat</Alias>

 

 

Install Solr:

Download Solr 4.10.3 from http://lucene.apache.org/solr/downloads.html. Since we are installing on a Windows machine, you will want to get the .zip file version of the download.

Note: Archives for all past versions of Solr are available at the Apache archives.

  1. Extract the contents of the .zip to a temporary location of your choice.
  2. Find the \dist folder in the extracted solr-4.10.3 directory. Rename the solr-4.10.3.war to solr.war and copy the file to the Tomcat’s \webapps folder. The path in my environment was C:\Program Files\Apache Software Foundation\Tomcat 8.0\webapps.
  3. Create an empty Solr home folder. This will be the permanent place of residence on your machine for your Solr instance. For example, D:\solr is where I put my Solr instance.
  4. Find the \example\solr folder in the extracted solr-4.10.3 directory. Copy the contents of \example\solr to the empty Solr home folder you just created in step 4.
  5. Find the \example\lib\ext folder in the extracted solr-4.10.3 directory. Copy the contents of \example\lib\ext to Tomcat’s \lib folder. The path in my environment was C:\Program Files\Apache Software Foundation\Tomcat 8.0\lib.
  6. Set the home directory for Solr in Tomcat. This is done by adding a new Java option with the Monitor Tomcat program. In my case, the option was -Dsolr.solr.home=D:\solr
  7. Stop/start Tomcat and try browsing to your Solr instance. For example,http://tomcat:8983/solr.

 

Configure for Sitecore:

  1. Stop the Tomcat service.
  2. Go to the root of your Solr instance, in my case, D:\solr. We need to modify the “collection1” directory to serve as one of the cores (folders with config files and index data) required by Sitecore.
    1. Rename the folder to “sitecore_analytics_index”
    2. Inside the folder you will find a file called “core.properties” which you may edit with a text editor. You need to change the “name” value to the name of your core. For example, when I create the “sitecore_analytics_index” core, then I will edit the “core.properties” file to have the value name=sitecore_analytics_index

 

  1. Start the Tomcat service and visit the Solr administration page. You may need to reload your browser page if it was already up. Click on the “Core Admin” menu item. If you modified the old “collection1” core correctly you should now see a sitecore_analytics_index core.

 

  1. Stop the Tomcat service. Now we need to fix the schema of our “sitecore_analytics_index” core, otherwise Sitecore cannot parse the xml correctly. Edit the file at \sitecore_analytics_index\conf\schema.xml according to Sitecore’s knowledge base article: https://kb.sitecore.net/articles/227897. Don’t forget to define the field type for pint since we are using a version of Solr later than 4.9! Start Tomcat and reload the Core Admin page.
  2. Next we must generate a new, Sitecore-specific schema. Sitecore provides a tool for this. Navigate to the Control Panel of your Sitecore instance. Look for the “Generate the Solr Schema.xml file” link and click it. Provide a path for the source and target files (they can’t be the same file.) Once you have generated your new schema, replace the old schema with it. Restart the Tomcat service and make sure the core loads correctly.
  3. A vanilla install of Sitecore 8 update 2 requires 13 cores to work correctly. So far we have one, but don’t despair, now that we have a generated a schema this process is much easier.  Essentially, we are going to use our sitecore_analytics_index core as a template to create the others. To do this:
    1. Copy the sitecore_analytics_index folder.
    2. Repeat steps 2a and 2b for each copy.
    3. When you are done, your Solr home folder should contain the following cores

 

  1. If you have done everything correctly you should be able to restart Tomcat and see all the cores listed above on the Core Admin page.
  1. Update (3-7-2015): I decided to create a PowerShell shortcutfor this step. Save yourself time!

    Still with me? Hang in there, we are halfway home! Next, we must tell Sitecore to start using Solr instead of Lucene. This is done by appending or removing “disabled” as an extension of a configuration file’s name.

    1. Config files to DISABLE:

      \App_Config\Include\Sitecore.ContentSearch.Lucene.DefaultConfigurations.config.disabled
      \App_Config\Include\Sitecore.ContentSearch.Lucene.Index.Analytics.config.disabled
      \App_Config\Include\Sitecore.ContentSearch.Lucene.Index.Core.config.disabled
      \App_Config\Include\Sitecore.ContentSearch.Lucene.Index.Master.config.disabled
      \App_Config\Include\Sitecore.ContentSearch.Lucene.Index.Web.config.disabled
      \App_Config\Include\Sitecore.ContentSearch.Lucene.Indexes.Sharded.Core.config.example (left as is)
      \App_Config\Include\Sitecore.ContentSearch.Lucene.Indexes.Sharded.Master.config.example (left as is)
      \App_Config\Include\Sitecore.ContentSearch.Lucene.Indexes.Sharded.Web.config.example (left as is)
      \App_Config\Include\Sitecore.Marketing.Definitions.MarketingAssets.Repositories.Lucene.Index.Master.config.disabled
      \App_Config\Include\Sitecore.Marketing.Definitions.MarketingAssets.Repositories.Lucene.Index.Web.config.disabled
      \App_Config\Include\Sitecore.Marketing.Definitions.MarketingAssets.Repositories.Lucene.IndexConfiguration.config.disabled
      \App_Config\Include\ContentTesting\Sitecore.ContentTesting.Lucene.IndexConfiguration.config.disabled
      \App_Config\Include\FXM\Sitecore.FXM.Lucene.Index.DomainsSearch.config.disabled
      \App_Config\Include\ListManagement\Sitecore.ListManagement.Lucene.Index.List.config.disabled
      \App_Config\Include\ListManagement\Sitecore.ListManagement.Lucene.IndexConfiguration.config.disabled
      \App_Config\Include\Social\Sitecore.Social.Lucene.Index.Master.config.disabled
      \App_Config\Include\Social\Sitecore.Social.Lucene.Index.Web.config.disabled
      \App_Config\Include\Social\Sitecore.Social.Lucene.IndexConfiguration.config.disabled

    2. Config files to ENABLE:

      \App_Config\Include\Sitecore.ContentSearch.Solr.DefaultIndexConfiguration.config
      \App_Config\Include\Sitecore.ContentSearch.Solr.Index.Analytics.config
      \App_Config\Include\Sitecore.ContentSearch.Solr.Index.Core.config
      \App_Config\Include\Sitecore.ContentSearch.Solr.Index.Master.config
      \App_Config\Include\Sitecore.ContentSearch.Solr.Index.Web.config
      \App_Config\Include\Sitecore.Marketing.Definitions.MarketingAssets.Repositories.Solr.Index.Master.config
      \App_Config\Include\Sitecore.Marketing.Definitions.MarketingAssets.Repositories.Solr.Index.Web.config
      \App_Config\Include\Sitecore.Marketing.Definitions.MarketingAssets.Repositories.Solr.IndexConfiguration.config
      \App_Config\Include\ContentTesting\Sitecore.ContentTesting.Solr.IndexConfiguration.config
      \App_Config\Include\FXM\Sitecore.FXM.Solr.Index.DomainsSearch.config
      \App_Config\Include\ListManagement\Sitecore.ListManagement.Solr.Index.List.config
      \App_Config\Include\ListManagement\Sitecore.ListManagement.Solr.IndexConfiguration.config
      \App_Config\Include\Social\Sitecore.Social.Solr.Index.Master.config
      \App_Config\Include\Social\Sitecore.Social.Solr.Index.Web.config
      \App_Config\Include\Social\Sitecore.Social.Solr.IndexConfiguration.config

  2. So I know that last step was pretty tedious, but if you’ve made it this far then the rest will be easier. Download the Solr Support Packagefrom Sitecore and extract the contents of the zip file.
  3. Copy the following DLLs from the Solr Support Package into the \bin folder of your Sitecore Instance [N.B.: Castle Windsor is my Inversion of Control preference as Glass also uses it. Aside from Castle Windsor, Sitecore supports AutoFac, Ninject, StructureMap, and Unity.]:
    • Facilities.SolrNetIntegration.dll
    • Practices.ServiceLocation.dll
    • ContentSearch.Linq.Solr.dll
    • ContentSearch.SolrProvider.CastleWindsorIntegration.dll
    • ContentSearch.SolrProvider.dll
    • dll

      Update (3-3-2015): If you are upgrading from Sitecore 8 update 1, then you only need to replace Sitecore.ContentSearch.SolrProvider.XXXXXIntegration.dll with the latest version from the Solr Support Package. All other DLLs remain unchanged.

 

  1. Download the Nuget package for Castle Windsor. Unzip the package by renaming the extension from .nupkg to .zip and extracting its contents. Copy the Castle.Windsor.dll from \lib\net40-client to the \bin folder of your Sitecore instance.
  2. Repeat step 10 for the CoreNuget package. Copy the Castle.Core.dll from \lib\net40-client to the \bin folder of your Sitecore instance.
  3. Since we are going to use IoC, we need to make our Sitecore instance aware of it by replacing the Application directive in the global.asax file with the following:

    <%@Application Language=’C#’ Inherits=”Sitecore.ContentSearch.SolrProvider.CastleWindsorIntegration.WindsorApplication” %>

  4. In order for Sitecore to talk to Solr, we need to give it a URL. This setting is maintained in the Sitecore.ContentSearch.Solr.DefaultIndexConfiguration.config file (remember, your address may differ from mine):

    <setting name=”ContentSearch.Solr.ServiceBaseAddress” value=”http://tomcat:8983/solr&#8221; />

  5. When you browse to your Sitecore site you won’t encounter any yellow screens of death. If you see a YSOD complaining about “Connection error to search provider [Solr] : Unable to connect to [http://tomcat:8983/solr]” then you are likely either missing a core or made typo when creating one. Assuming you are error free, the final step is to re-index. Go to the Control Panel and look for the “Indexing manager” link. Select all indexes and click the “Rebuild” button.

 

Note: Might be you face conflict in Castle.core and Castle.windsor dll because there different-2 version used by solr and glassmapper so you need to update the assembly binding in web.config for overcome that issue as below:

 

<dependentAssembly>

<assemblyIdentity name=”Castle.Windsor” publicKeyToken=”407dd0808d44fbdc” culture=”neutral” />

<bindingRedirect oldVersion=”3.1.0.0-3.1.9.0″ newVersion=”3.3.0.0″ />

</dependentAssembly>

<dependentAssembly>

<assemblyIdentity name=”Castle.Core” publicKeyToken=”407dd0808d44fbdc” culture=”neutral” />

<bindingRedirect oldVersion=”3.1.0.0-3.1.9.0″ newVersion=”3.3.0.0″ />

</dependentAssembly>

 

References:

http://sitecoreblog.patrickperrone.com/2015/02/sitecore-8-solr-part-13-install-tomcat.html

http://stackoverflow.com/questions/28836047/how-to-use-glass-mapper-3-3-with-sitecore-7-x-and-solr-4-7

 

 

Mongo Shell

Hi All,

Today we discuss about Mongo Shell.

For this I wanna give special thanks to Kiran patil.

For Such a lovely blog here.

So lets start :-

Mongo Shell

Mongo Shell – Helps you to validate your mongo connection, and do basic mongo checks. Like Test Connection, Get Collection Names, Get Collection, Get Stats, Find All Users

For few projects, I noticed that me and few of my colleagues/friends had issue validating whether mongo connection is right or not, and if yes whether data is going through or not. Mongo Client tools (e.g. Mongo Management Studio) are there. But what If you can’t install Mongo Client Tool on server and Firewall is blocked to open mongo connection out of network?

This tool will help you for that!

Basically, this tool is inspired from. SQL Shell – Sitecore tool to query SQL Data,https://github.com/SitecoreSupport/TestMongoDBConnection

BIG Thanks to them!

Mongo Shell

Main Features

  1. To validate your mongo connection directly from your Sitecore application
  2. You can Get collection names of particular DB
  3. You can view collection records
  4. You can view Mongo stats
  5. You can find all users
  6. Security has been applied — User needs to be logged in to access it.
  7. Responsive UI

How to Download and Install?

Option 1

  1. If you would like to do it manually you can download files from here [Sitecore/admin directory]
  2. Copy-Paste MongoShell.. files under \Sitecore\Admin folder.
  3. Access your page using http:///sitecore/admin/Mongoshell.aspx
  4. That’s it! Enjoy! 🙂

Option 2

  1. Download Sitecore Package from Data\Packages\V1 folder, Which will copy the files at required place.
  2. Install using Sitecore Installation Wizard. Once done, Just access your page using http:///sitecore/admin/Mongoshell.aspx
  3. That’s it! Enjoy! 🙂
Note:As I am not using c# 6.0 , so that why some funtions gives error in my case.
So I update the code according to that you can found the updated package here

How Setup SMTP email Server for Sitecore

For setting the email server you need to setup some basic config via path config as below:

<setting name="MailServer" value="smtp.gmail.com"/>
  <!--  MAIL SERVER USER
        If the SMTP server requires login, enter the user name in this setting
  -->
  <setting name="MailServerUserName" value="xxxx@gmail.com"/>
  <!--  MAIL SERVER PASSWORD
        If the SMTP server requires login, enter the password in this setting
  -->
  <setting name="MailServerPassword" value="xxxxx"/>
  <!--  MAIL SERVER PORT
        If the SMTP server requires a custom port number, enter the value in this setting.
        The default value is: 25
  -->
  <setting name="MailServerPort" value="587"/>


Just ad the below node in web.config at the last but before:

Manage Blog comments on CM and CD environments without web services

At first really thankful to my senior Yogeshwer Sharma for this blog.

While working with Sitecore WeBlog module we found that some times with configuration of our CM and CD environments, the CD server doesn’t allow calling of the WeBlog web service, which is responsible for creating comment items on the CM server. As we know WeBlog stores the blog comments on CM server via a web service called from the CD servers.

We have seen similar issue with our configuration also and due to some security constraints on the CD servers the WeBlog web service was not able to be executed.

Here we started thinking about some alternate solution to manage blog comments in the Sitecore CM server without any web service.

Now with our one day analysis we came up with an idea to manage blog comments same as WeBlog is managing with the help of a custom SQL database.

Blog Comments

We divided our approach in below steps –

  1. Create a custom database to store comment details.
  2. Add connection string for custom database in connectionString.config file.
  3. Store comment details in custom database table.
  4. Create a Sitecore scheduler to migrate the data from Custom database to Sitecore content tree.

With the help of this approach we don’t need to tweak any of the security settings on the CD server.

Now we will go through above steps in details –

1.   Create a custom database to store comment details –

 We have created a custom DB which will be common for all CD server’s as well as it will be accessible from the CM server. In this database we have created a table with all the fields of Comment Form as well as we have also added some additional fields as given below.

  1. BlogID – To store blog detail page id to map with comments.
  2. FullName – FullName field value of comment form.
  3. Email – Email field value of comment form.
  4. Comment – Comment field value of comment form.
  5. IsSync -Using as a flag to keep track of sync process of moving comments from custom DB to Sitecore.
  6. CommentDateTime – Comment adding date and time.
  7. UpdateDateTime – Sync date and time with Sitecore.

Click here to download SQL script to create database and table.

Note – This script file also contains some stored procedures, which we will use in later steps. You can execute complete script so you don’t need to put efforts in later steps.

2.   Add connection string for custom database in connectionString.config file. –

Add new connection string for custom DB in connectionString.config file as given below.

<add name=”custom” connectionString=”user id=[username];password=[password];Data Source=[Datasource];Database=[Database Name]” />

3.   Store comment details in the custom database table –

We have written code to store comment form details in custom database with the help of ADO.NET and SQL procedures.

After submitting the comments form we are storing data into our custom database. Here we are storing comment form fields (Fullname, Email and Comment), BlogID current blog page item ID, IsSync (I will explain the uses of this field later), CommentDateTime (Comment Entry date and time) and UpdateDateTime.

Now let me explain why we are using BlogID and IsSync fields.

Blog ID – We are using this field to map the comment items with associated blog detail page while moving comment data from custom database to Sitecore.

IsSync – Default value of this field is set to 0 (Zero). We are using scheduler to migrate data from custom DB to Sitecore and after successfully migrate the record we are updating this field value by 1 (One).  So next time scheduler will execute and it will ignore the record which contains IsSync field value 1(One).

We can store data in SQL server with multiple ways. We have used SQL stored procedure to do this task.

Click here to find SQL script of stored procedures. If you have already executed complete SQL script file as per given in step 1 then you don’t need to run it again.

 

We have created a method in C# class which will run on click of comment form submit button. This method is storing comment form data into custom database, see below code –

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

public void AddComment(string name, string email, string comment, String itemID)

        {

            using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["custom"].ToString()))

            {

                using (SqlCommand cmd = new SqlCommand("usp_AddComment", con))

                {

                    try

                    {

                        cmd.CommandType = CommandType.StoredProcedure;

                        cmd.Parameters.Add("@FullName", SqlDbType.VarChar).Value = name;

                        cmd.Parameters.Add("@Email", SqlDbType.VarChar).Value = email;

                        cmd.Parameters.Add("@Comment", SqlDbType.VarChar).Value = comment;

                        cmd.Parameters.Add("@BLogID", SqlDbType.VarChar).Value = itemID;

                        con.Open();

                        cmd.ExecuteNonQuery();

                        

                    }

                    catch (Exception ex)

                    {

                        Sitecore.Diagnostics.Log.Info(ex.Message, this);

                    }

                }

            }

     }

4.   Create a Sitecore scheduler to migrate the data from Custom database to Sitecore content tree (CM Server).

This is the last step of our functionality and in this step we have created a Sitecore Scheduler, if you are not familiar with how to create scheduler in Sitecore please read this post.

With the help of this scheduler we are performing 2 tasks. One is moving comment data from custom DB to Sitecore (CM server) and other one is updating IsSync field of the custom database if the record is successfully added into Sitecore.

To perform this we have created 2 stored procedures in SQL server.

    1. GetUnProcessedComments – This stored procedure will return all the data with IsSync field value 0 (Zero).
  1. UpdateProcessedResults – This stored procedure will update the field value of IsSync with 1 (One) for all successfully processed records. Also we have added custom table type field for the stored procedure input parameters.

Click here to find SQL script of stored procedures. If you have already executed complete SQL script file as per given in step 1 then you don’t need to run it again.

We have created a C# class file for Sitecore scheduler and scheduler will execute this class file code in specific time interval.

  1. Get all un-processed records from custom DB and create comment items under appropriate blog detail page.
  2. If the comment item is successfully created then the IsSync field value is set to 1 (One) so next time when scheduler will go to custom DB for new records (comment items) it will only get data which IsSync field contains value 0 (Zero).

See below C# code to perform above actions –

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

public void Execute(Item[] items, Sitecore.Tasks.CommandItem command, Sitecore.Tasks.ScheduleItem schedule)

        {

            try

            {

                Sitecore.Security.Accounts.User user = Sitecore.Security.Accounts.User.FromName(@"extranet\Anonymous"true);

                using (new UserSwitcher(user))

                {

                    DataSet getUnprocessedComments = new DataSet();

                    using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["custom"].ToString()))

                    {

                        using (SqlCommand cmd = new SqlCommand("usp_GetUnProcessedComments", con))

                        {

                            cmd.CommandType = CommandType.StoredProcedure;

                            using (SqlDataAdapter da = new SqlDataAdapter(cmd))

                            {

                                da.Fill(getUnprocessedComments);

                            }

                        }

 

                        Database master = Sitecore.Configuration.Factory.GetDatabase("master");

                        TemplateItem template = master.GetTemplate("[Comment Data Template ID]"); //TODO: Please enter your comment data template ID

            string workflowID = template.StandardValues[Sitecore.FieldIDs.DefaultWorkflow];

                        bool IsSuccessfullyAdded = false;

                        foreach (DataRow DBValue in getUnprocessedComments.Tables[0].Rows)

                        {

                            Item parent = master.Items[DBValue["BlogID"].ToString()];

                            string validItemName = ItemUtil.ProposeValidItemName(DBValue["FullName"].ToString()).Trim();

                            Item item = parent.Add("comments by " + validItemName, template);

                            try

                            {

                                //TODO: Please update field name of comment template

                item.Editing.BeginEdit();

                                item.Fields["Name"].Value = DBValue["FullName"].ToString();

                                item.Fields["Email"].Value = DBValue["Email"].ToString();

                                item.Fields["Comment"].Value = DBValue["Comment"].ToString();

                               

                 if (!string.IsNullOrEmpty(workflowID))

                                {

                                    item.Editing.BeginEdit();

                                    item.Fields[Sitecore.FieldIDs.Workflow].Value = workflowID;

                                    IWorkflow wf = master.WorkflowProvider.GetWorkflow(workflowID);

                                    wf.Start(item);

                                }

                                item.Editing.EndEdit();

                                IsSuccessfullyAdded = true;

                            }

                            catch (Exception ex)

                            {

                                IsSuccessfullyAdded = false;

                                Sitecore.Diagnostics.Log.Info("Comment Scheduler: Error in adding comment item under blog item " + ex.Message, this);

                                break;

                            }

                        }

                        if (IsSuccessfullyAdded == true)

                        {

                            using (SqlCommand cmd = new SqlCommand("usp_UpdateProcessedResults", con))

                            {

                                try

                                {

                                    cmd.CommandType = CommandType.StoredProcedure;

                                    cmd.Parameters.AddWithValue("@commentItems", getUnprocessedComments.Tables[0]);

                                    con.Open();

                                    cmd.ExecuteNonQuery();

                                    con.Close();

                                }

                                catch (Exception ex)

                                {

                                    Sitecore.Diagnostics.Log.Info("Comment Scheduler: Error in updating flag entry for added comment items " + ex.Message, this);

                                    con.Close();

                                }

                            }

                        }

                    }

                }

            }

            catch (Exception ex)

            {

                Sitecore.Diagnostics.Log.Info("Comment Scheduler: Error in Create Comment Scheduler " + ex.Message, this);

            }

        }

Click Here to find the code files and SQL script file on the GitHub. If you have any queries please enter your comments in below comment section.

Sitecore Scheduled Task

At first thanks to JEFFREY RONDEAU For such a good post.

I am always confuse with Schedule Fields time entry.By help of below post my queries related to time is resolved.


To create a scheduled task in Sitecore, first you must create the .NET class that will contain the logic that you wish to execute.  In the example below I’m simply logging a message whenever the task is run.

public void Execute(Item[] items, Sitecore.Tasks.CommandItem command, Sitecore.Tasks.ScheduleItem schedule){
Sitecore.Diagnostics.Log.Info("My Sitecore scheduled task is being run!", this);
}

Your method must accept three arguments:

  1. An array of items that can be specified in a later step when you define the command’s schedule
  2. The Sitecore task CommandItem
  3. The Sitecore task ScheduleItem

Once you have your logic defined, you can then create your task command in Sitecore. To do this, navigate to the commands folder under System/Tasks and create a new command as shown below.

Create_Sitecore_Task_Command

In the Type field, enter the assembly qualified type name as shown above, and in the Method field enter the name of the method to be called in your class.

Now you must define the task schedule for your command in Sitecore. To do this, navigate to the Schedules folder under System/Tasks and create a new schedule as shown below.

Create_Sitecore_Task_Schedule

To define your schedule

  1. Under the Command field select the command you just created
  2. If you wish to define items that will populate the items array in your class, you can do so under the Items field. This can be done using a Sitecore query without the ‘query:’ prefix or a pipe (“|”) delimited list of items.
  3. The Schedule field can be a bit tricky. You’ll notice in my example above that I have several piped values. They are defined as follows:
    1. The start date in yyyyMMdd format.
    2. The end date in yyyyMMdd format.
    3. The days of the week that the task should be run. Each day is assigned a value: 1 = Sunday, 2 = Monday, 4 = Tuesday, 8 = Wednesday, 16 = Thursday, 32 = Friday, and 64 = Saturday. For example to run a task Monday through Friday you’d enter 62 (2 + 4 + 8 + 16 + 32). I have my task set up to run every day (1 + 2 + 4 + 8 + 16 + 32 + 64 = 127).
    4. The minimum interval the task is to be run in HH:mm:ss format. The example above is set to run once every 24 hours.
  4. The last run field will be updated by Sitecore whenever your task is run. When creating your schedule you don’t have to set this, but if you do, Sitecore will think that was the last time it invoked your command.
  5. Checking the Async field will cause your task to be run asynchronously.
  6. Checking the Auto Remove field will cause Sitecore to automatically remove the schedule definition item when the task has expired.

How to Identify Correct W3WP Process in Visual Studio while debugging

This article taken from here

This article explains about how to identify the correct w3wp process for “Attach to Process” in visual studio while debugging.

In most of the time, being a developer, we will be attaching to the W3WP Process. But when we try to attach the process using the Visual Studio, we will be seeing many w3wp processes running. We will be in a dilemma to which we need to attach and at-last, as usual, we will be attaching to all the w3wp processes.

This happens because, the Attach to Process popup doesn’t show the Application Pool details.

clip_image002

To identify the Process for our Application Pool, Open the command prompt as administrator.

Navigate to the folder C:\Windows\System32\inetsrv\. Enter the command “appcmd.exe list wp”. This will list all the worker process associated with the Application Pools.

clip_image004

We know our Application Pool name. Note down the ID corresponding to the Application Pool.

Now coming back to visual studio and click “Attach to Process”. Attach the process with a specific ID which we noted. That’s it. Now we are done with “Attach to Process”. Happy debugging.