Tuesday, December 9, 2014

Sitecore: - How to use Fast Query in Sitecore



Sitecore: - How to use Fast Query in Sitecore
1)      Got to  Development Tools






2)      Xpath builder
3)      Sample data

4)      To get all record
fast:/sitecore//*
5)      To get single record main node
fast:/sitecore/*

Below are the steps to check the blog entries which have the blank date.

Step #1
                Login to Sitecore, Go to Development tool then Developer center
               
Step#2
                Go to Xpath Builder and execute the fast query to check the blank records.

               

Step#3  Query
fast://sitecore/content/Apparel/Lycra B2B Home/Blog//*[
(@@templateid = '{3A2F52BC-2434-4D0A-9D20-4315A2E97C3B}' or
@@templateid ='{17D77353-51B8-4B64-ABB3-424DDA69101D}'  or
@@templateid ='{E40B3177-6362-4240-91F9-6447066FF417}'  or
@@templateid ='{5C01A279-E6BC-488D-BDDE-F44F09BD3669}') and @Date = '']



Monday, December 1, 2014

Sitecore- Some basic operations

 //Operation # 1   /// Basic operations get userName
            var str = "Start";
            var listA = Sitecore.Context.GetUserName();
           
            // Result will be like extranet\Anonymous

           //Operation # 2   /// Get all items
            var list = Sitecore.Context.Database.Items["/sitecore/content/Jack/Our Team"];

            foreach (Item subitem in list.Children)
            {
                str = str + subitem.Name;
            }
           
            testDiv.InnerText = Convert.ToString(str);

Wednesday, November 19, 2014

Sitecore :- How to update build data through excel sheet, How to create template through code, How to add formating to HTML

using Sitecore.Data.Items;
using BusinessModules;
using Sitecore.Data.Fields;
using System.Text.RegularExpressions;
using System.Text;
using Sitecore.Data.Managers;
using Sitecore.Security.Accounts;
using System.Data.OleDb;
using HtmlAgilityPack;
using System.Text.RegularExpressions;
using System.IO;
using System.Xml;
namespace ABC.layouts
{
   
    public partial class ScriptsOnDemand : System.Web.UI.Page
    {
        private void Import()
        {
            Sitecore.Data.Database master = Sitecore.Configuration.Factory.GetDatabase("master", false);
            OleDbCommand command = null;
            string con = string.Empty;

            //connString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + strNewPath + ";Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=2\"";
            con = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\EpicCV.xls;Extended Properties='Excel 4.0;HDR=Yes;'";

            try
            {
                Sitecore.Data.Items.Item rootItem = master.GetItem("/sitecore/content/Global Content/People/A");

                List BiosItem = new List(rootItem.Axes.GetDescendants().Where(m => m.TemplateID.ToString() == "{EB65BFA3-5122-43F4-A1B0-02F430F645CA}"));

                StringBuilder sb = new StringBuilder();

                using (OleDbConnection connection = new OleDbConnection(con))
                {
                    connection.Open();
                    command = new OleDbCommand("select * from [Report1$]", connection);
                    sb.Append("");
                   
                    sb.Append(" ");
                    using (OleDbDataReader dr = command.ExecuteReader())
                    {
                        int counter = 0;
                        while (dr.Read())
                        {
                            counter = counter + 1;

                            string emailID = dr["BusinessEmail"].ToString().Trim();
                            string bioVersionName = bioVersionName = dr["lastName"].ToString().Trim() + " " + dr["FirstName"].ToString().Trim();
                            string mainBiographyNarrative = formatHTML(  dr["Bio Narrative"].ToString().Trim() );
                            string experienceNarrative = formatHTML( dr["Experience Narrative"].ToString().Trim());

                            List itemMainBioList = BiosItem.Where(x => x.Fields["Email"].ToString() == emailID).ToList();
                            foreach (Item itemMainBio in itemMainBioList)
                            {
                                sb.Append("
");
                                sb.Append(" ");
                                if (!String.IsNullOrEmpty(emailID))
                                {
                                    sb.Append(" ");
                                }
                                try
                                {
                                    if (itemMainBio.Fields["Email"] != null)
                                    {
                                        sb.Append(" ");

                                        sb.Append(" ");

                                        sb.Append(" ");
                                       
                                        TemplateItem template = master.GetTemplate("{8FFC3E2B-C6F5-4A80-913D-E2A54D02FC20}");
                                        User currentUser;
                                        string domainUser = @"sitecore\UserA";
                                        currentUser = Sitecore.Security.Accounts.User.FromName(domainUser, false);

                                        Item oldVersionItem = master.GetItem(itemMainBio.Paths.FullPath + "/Versions");

                                        if (oldVersionItem != null)
                                        {

                                            oldVersionItem.Add(bioVersionName, template);
                                            using (new UserSwitcher(currentUser))
                                            {
                                                Item versionItem = master.GetItem(itemMainBio.Paths.FullPath + "/Versions/" + bioVersionName);
                                                if (versionItem != null)
                                                {
                                                  

                                                    versionItem.Editing.BeginEdit();
                                                    versionItem.Fields["VersionName"].Value = dr["Title"].ToString().Trim();
                                                    versionItem.Fields["MainBiographyNarrative"].Value = mainBiographyNarrative;
                                                    versionItem.Fields["ExperienceNarrative"].Value = experienceNarrative;
                                                    versionItem.Fields["__Workflow"].Value = "{E534CB0A-B877-49EA-BBB1-927EBD7853FE}";                                                   
                                                    versionItem.Fields["__Workflow state"].Value = "{E2CF5329-65A0-40EE-8971-88BDE0F68574}";                                                   
                                                    versionItem.Fields["__Default workflow"].Value = "{E534CB0A-B877-49EA-BBB1-927EBD7853FE}";                                                   
                                                    versionItem.Editing.AcceptChanges();
                                                    versionItem.Editing.EndEdit();
                                                }
                                            }
                                        }
                                    }
                                    else
                                    {
                                        sb.Append("
                                        sb.Append(" ");

                                        sb.Append(" ");
                                    }
                                }
                                catch (Exception ex)
                                {
                                    string msg = ex.Message;
                                }

                                sb.Append(" ");

                            }

                        }

                    }

                    sb.Append("
Sr. No. Name Email Id on File Sitecore Email ID Version Name Match Found
" + counter + "" + dr["lastName"].ToString().Trim() + " " + dr["FirstName"].ToString().Trim() + "" + emailID + "" + itemMainBio.Fields["Email"].ToString() + "" + bioVersionName + "" + "Yes" + "    " + "No" + "
");
                    divItemList.InnerHtml = sb.ToString();
                   
                }

            }
            catch (Exception ex)
            {
                string msg = ex.Message;
            }

        }

        private string formatHTML(string inputHTML)
        {
             try
            {
                var document = new HtmlDocument();
                document.LoadHtml(inputHTML);
                StringWriter writer = new StringWriter();

                XmlWriterSettings settings = new XmlWriterSettings();
                settings.OmitXmlDeclaration = true;
                settings.ConformanceLevel = ConformanceLevel.Fragment;
                settings.CloseOutput = false;

                var xmlWriter = XmlWriter.Create(writer, settings);
                document.OptionOutputAsXml = true;                   
                document.Save(xmlWriter);
                 var newHtml = writer.ToString();

                 return Convert.ToString(newHtml);
            }
             catch (Exception ex)
             {
                 string msg = ex.Message;
                 return msg;
                
             }

        }}

Monday, November 17, 2014

Sitecore :- Step to setup cache in sitecore application

Below are the steps


1.  Go to “web.config” and set “DisableBrowserCaching” to false.
2. Increase and tune the size of the data, items, and prefetch caches. Bigger caches = better performance. We can change size of cache of whole Sitecore instance using below settings in web.config.


      300MB
      300MB
      5MB
      5MB
'

3. Tune the prefetch cache settings under the App_Config/Prefetch/ folder. Sample /App_Config/Prefetch/Web.Config is given below.

  300MB

4. Go to sub layout item in Sitecore and identify the items which are not changed frequently, apply cache as per below screenshot.
List of necessary sub layouts are available at “Stats” page. http://invistab2cuat.edynamic.co.in:91/sitecore/admin/stats.aspx
Example Item path:  /Sitecore/layout/Sublayouts/INVISTA/Apparel/Lycra B2C/Common/Footer
After doing below changes publish website and check the checkbox as per below screenshot.

For search, blog listing you need to check “Cacheable”, “Clear on Index Update”, “VaryByData”  and “VaryByParm” checkbox




 

Friday, November 14, 2014

Sitecore :- An integration platform with MSCRM 2015 and SharePoint 2013

Hi Folks,
Good Day!
Just for the kind information about MSCRM 2015 launch and future integration with Sitecore.
Here are some of the fruitful and research on these technologies with a collaboration and future association of “SITECORE” with MSCRM (Microsoft dynamic CRM), SharePoint and Microsoft Azure.
Microsoft Dynamics CRM 2015 (otherwise known as Vega) is here! The new exciting changes and enhancements that are coming!
As we know Sitecore is a leading web content and customer experience management solution and this is 100-percent .NET compatible and .NET developers can leverage the skills they already have, the tools they already know, and through the integration technology.
Some of the glimpse about Sitecore:-
1)    More than 150 Sitecore customers have integrated Sitecore with SharePoint. Eye Witness News (<http://ewn.co.za/>), in South Africa, uses SharePoint to manage its digital assets, with Sitecore drives the public-facing digital experience.
2)    Microsoft Dynamics CRM is relied on by 2.25 million users across 33,000 customers to manage and strengthen customer relationships.
3)    Sitecore offers out-of-the-box integration with Microsoft Dynamics CRM.
4)    More than 30 percent of Sitecore customers use Microsoft Dynamics CRM.
5)    Sitecore Azure Edition leverages the considerable advantages of Microsoft Azure for scalable, enterprise-class deployment
6)    MSN Sankei, Japan’s leading news portal, launched a new photo experience using Sitecore and Microsoft Azure. The new capability has delivered impressive stability and performance, handling more than 20 million accesses per month. The site exceeded even target traffic expectations as it became the go-to site for information on the Great East Japan Earthquake.
With Sitecore and SharePoint, We can:
·    Sitecore complements Microsoft SharePoint
·    Sitecore includes out-of-the-box integration with SharePoint
·    We can easily share content across intranets, extranets, and public-facing websites
With Sitecore and Dynamics, We can:
·    Better manage the customer experience from end to end
·    Use customer intelligence to enhance conversion rates
·    Automatically capture new leads and valuable prospect data directly into the CRM system
With Sitecore Azure Edition, We can
·    Scale websites quickly and easily to new geographies
·    Respond immediately to business needs and surges in demand
·    Enjoy low cost of entry and ongoing operations
I hope some of the information is useful for us.

Friday, October 31, 2014

Sitecore: - How to add source section to Droplink and Treelist

Source for DropLink:-

query:fast:/sitecore/content/XXX/ Home//*[@@templateid='{fsdfasdfasdf}']

Source for TreeList:-

/sitecore/content/ccccc/Home





Sitecore: - What happens if your debugger is not attached to Visual studio

Sometimes while working our system not able to attach visual studio, please follow the below steps to fix it.

1) Check the .pdb is existing in the bin folder (.DB is the referent of.dll and creating parallel to the .dll)
2) Check any issues in the visual studio, restart it once
3) Reset the skip settings of visual studio
Devenv /resetskippackages

Friday, October 17, 2014

Sitecore- Vulnerability -Transport Layer Protection and Cross-Frame Scripting

Some key points to handle the Vulnerability and Transport layer protection.

“Transport Layer Protection: Insecure Transmission”

Vulnerability Summary: -  As per standard the user type credential should not be exposed through the “get” method. A username was found in the query string of a GET request or Set-Cookie header.

Update and Action:- This is basically a case where in case item/template not  found, then the URL comes like below

Proposed Solution: - In case if item not found will redirect to the other specific URL, this section required some more investigation.

“Cross-Frame Scripting”

Vulnerability Summary: - A Cross-Frame Scripting (XFS) vulnerability can allow an attacker to load the vulnerable application inside an HTML iframe tag on a malicious page.


Solution: - Fix by including an X-Frame-Options header set to 'SAMEORGIN'. There are two options available either we can change in the web. Config or in the IIS settings.

Change in the web. config: - This is by default, setting and it’s available in the b2b web.config section.
 

Required change in the IIS: - Below are the steps for the IIS settings

  1. Open Internet Information Services (IIS) Manager.
  2. In the Connections pane on the left side, expand the Sites folder and select the site that you want to protect.
  3. Double-click the HTTP Response Header icon in the feature list in the middle.
  4. In the Actions pane on the right side, click Add.
  5. In the dialog box that appears, type X-Frame-Options in the Name field and type SAMEORIGIN in the Value field.
  6. Click OK to save your changes.
For more information :- http://support.microsoft.com/kb/2694329

Please feel free to post here, If have any questions

Wednesday, October 15, 2014

Sitecore :- How to restore deleted data/Item/template in sitecore

We have an option to restore the data through the Recycle Bin option.

Login to Sitecore through Admin User and you will find below option.

Sitecore :- How to deploy/install TDS package

- Go to the below path and upload the TDS package

.... Current Path.../sitecore/admin/Updateinstallationwizard.aspx


Sitecore :- How to reset the cookies and clear cache in Sitecore



Sometimes we may face some issues where our changes not get reflected, In that we need to check below steps

1) Reset the IIS
2) Clear the catch :-
 Go to below link :-..........sitecore/admin/cache.aspx

         

3) Check that item is published or not