January 22, 2017

To know about Swagger API framework

You can find all details regarding Swagger API framework here https://swagger.io/

You can find all details regarding Swagger API framework here
https://swagger.io/

January 21, 2017

Update Package Visual Studio framework

Update framework dependencies in project. Update-Package -Reinstall -ProjectName < Project Name >

Update framework dependencies in project.
Update-Package -Reinstall -ProjectName <Project Name>

January 20, 2017

Install Nuget Package for specific project only

Install-Package Newtonsoft.Json -Project < Your Project Name >

Install-Package Newtonsoft.Json -Project <Your Project Name>

January 19, 2017

How to Create Chrome Extension

How to create Chrome extension  Step 1: Create one file named Manifest.json with below content { "manifest_version":...

How to create Chrome extension 

Step 1:
Create one file named Manifest.json with below content

{

"manifest_version": 2,

"name": "Post",

"description": "Post",

"version": "1.0",

"content_scripts": [{

"js": ["Popup.js"],

"matches": ["http://*/*", "https://*/*"]

}],

"icons": {

"48": "icon.png"

},

"content_security_policy": "script-src 'self' <Specify all external urls with spaces>; object-src 'self'",

"permissions": [

"tabs", "<all_urls>","activeTab"

],

"browser_action": {

"default_icon": "icon.png",

"default_popup": "popup.html"

}

}

Step 2:
Create popup.html with below content

<!DOCTYPE html>
<html>
<body style="width: 500px;height:500px;background-color:lightgray;font-family:Arial; ">
<div>
<h1>My Chrome Extension</h1>
</div>
<table>
<tr>
<td style="vertical-align:top;width:2%;"></td>
<td>
<textarea id="postcontent" name="content" rows="15" cols="50" style="width:410px;"></textarea>
</td>
</tr>

</table>

<script type="text/javascript" src="Popup.js"></script>

</body>

</html>

Step 3:

Create Popup.js file with below content

chrome.tabs.executeScript({

code: "window.getSelection().toString();"

}, function (selection) {

if (selection[0] != "")

document.getElementsByTagName('textarea')[0].innerHTML = selection[0];

});

chrome.tabs.query({currentWindow: true, active: true}, function(tabs){

document.getElementById('hdnUrl').value = tabs[0].url;

});

chrome.tabs.query({

active: true,

currentWindow: true

}, function (tabs) {

chrome.tabs.executeScript(tabs[0].id, {

code: 'Array.prototype.map.call(document.images, function (i) { return i.src; });'

}, callback);

});

Now place all these files in One folder and load this folder Chrome "Load Unpacked .."
 

January 18, 2017

Sitecore Helix documentation and Habitat project

You can find all Sitecore Helix related information on below Url. http://helix.sitecore.net/ Sitecore Habitat project on Github ...

You can find all Sitecore Helix related information on below Url.

http://helix.sitecore.net/

Sitecore Habitat project on Github

https://github.com/Sitecore/Habitat

 

January 17, 2017

Call Custom API in Sitecore using JavaScript

Controller Logic here  using Sitecore.Configuration; using Sitecore.Data.Items; using Sitecore.Mvc.Controllers; using Sitecore.Resource...

Controller Logic here 
using Sitecore.Configuration;
using Sitecore.Data.Items;
using Sitecore.Mvc.Controllers;
using Sitecore.Resources.Media;
using Sitecore.SecurityModel;
using System.Web.Mvc;
public class ArticleDetailsController : SitecoreController
    {
       
        [HttpGet]
        public virtual ActionResult ArticleDetails()
        {
        //Read Query String values here
            // To Do Sitecore related activities here
         }
    }  

In JavaScript we will access

function ArticleDetails() {
 
   var HostUrl = "Your Host Url";  
   var xmlHttp = new XMLHttpRequest();
   var url = HostUrl + '/api/Sitecore/QuickPost/ArticlePost?QueryString
   xmlHttp.open("GET", url, false);
   xmlHttp.send(null);
   return xmlHttp.responseText;
}

January 16, 2017

Find all Solr versions here

You can find all Solr versions here https://archive.apache.org/dist/lucene/solr/  

You can find all Solr versions here

https://archive.apache.org/dist/lucene/solr/

 

January 15, 2017

Edit Media Field In Sitecore Programmatically

To edit media item's fieild in SItecore is little bit tricky. Sitecore.Data.Items.MediaItem imageItem = masterDB.GetItem( MediaItemI...

To edit media item's fieild in SItecore is little bit tricky.

Sitecore.Data.Items.MediaItem imageItem = masterDB.GetItem(MediaItemID);
Sitecore.Data.Fields.ImageField imageField = newItem.Fields["ArticleImage"];
imageField.MediaID = imageItem.ID;

January 14, 2017

Upload Media file in Sitecore from url

We can directly upload media file into Sitecore from url. private string UploadImageToMediaLibrary(string imageUrl,string FileName)      ...

We can directly upload media file into Sitecore from url.
private string UploadImageToMediaLibrary(string imageUrl,string FileName)
        {
            var webRequest = WebRequest.Create(imageUrl);
            string uploadedMediaImage = string.Empty;
            using (var webResponse = webRequest.GetResponse())
            {
                using (var stream = webResponse.GetResponseStream())
                {
                    if (stream != null)
                    {
                        using (var memoryStream = new MemoryStream())
                        {
                            stream.CopyTo(memoryStream);
                            var mediaCreator = new MediaCreator();
                            var options = new MediaCreatorOptions
                            {
                                FileBased = false,
                                Versioned = false,
                                AlternateText = FileName,
                                Database = Factory.GetDatabase("master"),
                                Destination = "/sitecore/media library/Articles" + "/" + FileName
                            };
                            using (new SecurityDisabler())
                            {
                                Item itm  = mediaCreator.CreateFromStream(memoryStream, FileName + ".jpeg", options);
                                uploadedMediaImage = itm.ID.ToString();
                            }
                         }
                    }
                }
            }
            return uploadedMediaImage;
        }

January 13, 2017

Deselect all checkbox inside Div

Using Jquery we can easily deselect all checkboxes inside div $('#DivID').find('input[type=checkbox]:checked').removeAtt...

Using Jquery we can easily deselect all checkboxes inside div

$('#DivID').find('input[type=checkbox]:checked').removeAttr('checked');

January 12, 2017

Get all selected checkbox value

Using Jquery we can easily get all selected chechbox value $("input:checkbox[class=chk]:checked").each(function () {      ...

Using Jquery we can easily get all selected chechbox value

$("input:checkbox[class=chk]:checked").each(function ()
{
            CBValues +=  $(this).val() ;
});

January 11, 2017

NSSM Service helper application

NSSM is a service helper appplication. This tool will help us to setup executable as a service. You can download NSSM from this url. https:/...

NSSM is a service helper appplication. This tool will help us to setup executable as a service.
You can download NSSM from this url.

https://nssm.cc/download

January 10, 2017

How to know C# version in Visual Studio

How can I know which C# version I am using in Visual Studio? We can know C# version by .Net framework . 1. C# 1.0  .NET 1.0 2. C# 1.2  ....

How can I know which C# version I am using in Visual Studio? We can know C# version by .Net framework .

1. C# 1.0  .NET 1.0

2. C# 1.2  .NET 1.1

3. C# 2.0  .NET 2.0

4. C# 3.0  .NET 3.5

5. C# 4.0  .NET 4

6. C# 5.0  .NET 4.5

7. C# 6.0  .NET 4.6

8. C# 7.0  .NET 4.6.2

To know .Net framework, Just right click on project, and select properties.

January 9, 2017

Website interaction data not reflecting in MongoDB

Recently I was stuck in one issue where my website interaction & contact data was not reflecting in MongoDB.   There are few points wher...

Recently I was stuck in one issue where my website interaction & contact data was not reflecting in MongoDB.  There are few points where you can do the fix for this.

1. Check you have added "<sc:VisitorIdentification ID="VisitorIdentification1" runat="server" />" this control or not on your layout.

2. In Sitecore.Analytics.Tracking.config file add your host name in value section.
<setting name="Analytics.ClusterName" value="YOUR HOST NAME" />

3. In Sitecore.Analytics.Tracking.config file add your host name in value section.
<setting name="Analytics.HostName" value="" />

January 8, 2017

Add profile image to Sitecore contact

You can use below method to associate image to Contact. using ( new SecurityDisabler ())       {           var image = "PASS MEDIA I...

You can use below method to associate image to Contact.

using (new SecurityDisabler())
      {
         
var image = "PASS MEDIA ITEM HERE"
;
         
MediaItem
getmediaItem = masterdb.GetItem(image.ID);
         
var
stream = getmediaItem.GetMediaStream();
         
var memoryStream = new MemoryStream
();
         
if (stream != null
) stream.CopyTo(memoryStream);
         
var pictureFacet = Tracker.Current.Contact.GetFacet<IContactPicture>("Picture"
);
          pictureFacet.Picture = memoryStream.ToArray();
          pictureFacet.MimeType = getmediaItem.MimeType;
      }

January 7, 2017

Show google map with multiple markers

You can use below code snippet to show Google map with multiple markers. < style >     #map_wrapper     {         height : 205px ;   ...

You can use below code snippet to show Google map with multiple markers.

<style>
   
#map_wrapper
    {
       
height: 205px
;
       
width: 298px
;
    }

   
#map_canvas

    {
       
width: 100%
;
       
height: 100%
;
    }
    
input[type=file]
{
       
color:transparent
;
    }
</style
>

<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_KEY_HERE&callback=initialize" async="async" defer="defer"></script>
<script>

   
function initialize() {
       
var
map;
       
var bounds = new
google.maps.LatLngBounds();
       
var
mapOptions = {
            mapTypeId:
'roadmap'

        };

        map =
new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
        map.setTilt(45);

       
var
markers = [
            [
'Marker1, Delhi'
, 24.524235, 77.165726],
            [
'Marker2, Delhi'
, 25.556695, 77.125543]
        ];

       
var
infoWindowContent = [
            [
'<div class="info">'
+
           
'<h3>DATA1</h3>'
+
           
'<p>PARA1</p>' + '</div>'
],
            [
'<div class="info">'
+
           
'<h3>DATA2</h3>'
+
           
'<p>PARA2</p>'
+
           
'</div>'
]
        ];

       
var infoWindow = new
google.maps.InfoWindow(), marker, i;

       
for
(i = 0; i < markers.length; i++) {
           
var position = new
google.maps.LatLng(markers[i][1], markers[i][2]);
            bounds.extend(position);
            marker =
new
google.maps.Marker({
                position: position,
                map: map,
                title: markers[i][0]
            });

            google.maps.event.addListener(marker,
'click', (function
(marker, i) {
               
return function
() {
                    infoWindow.setContent(infoWindowContent[i][0]);
                    infoWindow.open(map, marker);
                }
            })(marker, i));

            map.fitBounds(bounds);
        }

       
var boundsListener = google.maps.event.addListener((map), 'bounds_changed', function
(event) {
           
this
.setZoom(12);
            google.maps.event.removeListener(boundsListener);
        });

    }
</script
>

<div id="map_wrapper" class="map">

      <div id="map_canvas" class="mapping"></div>

</div>

 

January 6, 2017

Add image to media library programmatically in Sitecore

You can use below technique to add media file to media library in Sitecore. var options = new Sitecore.Resources.Media. MediaCreatorOption...

You can use below technique to add media file to media library in Sitecore.

var options = new Sitecore.Resources.Media.MediaCreatorOptions
   {
       AlternateText =
"",
       FileBased =
false
,
       IncludeExtensionInItemName =
false
,
       KeepExisting =
false
,
       Versioned =
false
,
       Destination =
"/sitecore/media library/Images/Contacts/"
+ ImageName,
       Database = Sitecore.Configuration.
Factory.GetDatabase("master"
)
   };

  
var
filename = Server.MapPath(Img.FileName);
  
var creator = new MediaCreator
();
  
var
mediaItem = creator.CreateFromStream(Img.PostedFile.InputStream, filename, options);

January 5, 2017

Read visitor profile details in Sitecore

We can read visitor’s personal details in Sitecore. if (Sitecore.Analytics. Tracker .Current.Contact != null )   {     var personalFacet =...

We can read visitor’s personal details in Sitecore.

if (Sitecore.Analytics.Tracker.Current.Contact != null)
  {
    var personalFacet =    Tracker.Current.Contact.GetFacet<IContactPersonalInfo>("Personal"
);
    if (personalFacet != null
)
    {
       
if (personalFacet.FirstName != null
)
        firstName = personalFacet.FirstName;
    }
  }