Surendra Sharma

Surendra Sharma

Search This Blog

Wednesday, July 5, 2017

How to integrate any unfamiliar legacy system to Sitecore

Integrating legacy systems with Sitecore
Integrating legacy systems with Sitecore


Days are gone when one system was handling entire organization system. Nowadays you have to integrate multiple systems to your solution.

There are some legacy system which are running and working fine in many organizations, but they don’t have 

  • Code of existing system
  • No DEV team
  • Don’t have any document
However what they have?
  • Business user who know what exactly this system do
  • Front end Windows/web Application
  • Backend database
Your job is integrate this with your new solution. In our case, integrate it with Sitecore.

Let’s take an example of Order system as a part of legacy system and find out different helpful pointers to integrate this successfully.
  • Decide what exactly you have to integrate? Typically we don’t need to integrate entire legacy system however a part or module of this system need to integrate.
  • Ask business user to give demo of that module to understand how its working and what exactly it achieve?
  • Note the different control’s labels and heading text on front end.
  • We can’t change forms of windows application EXE without code, however all details of legacy system generally stored in database. So we entirely depend on database.
  • We need to understand the database structure of legacy system and find out tables where this system storing data? Big question is how to identify that?
  • Check the connection string of this system to get the database name and credentials.
  • Open this database and create database diagram to understand tables relationships.
  • Create excel file
               o    Store all table names of this database in one tab.
               o    Store all tables with their all columns name in second tab.
  • Find out only those tables which are related with this module. This is very crucial stage. How will you get to know which tables are used for storing data?
  • Generally table names reflect front end functionality. So if you understand front end functionality, you can guess or identify table names.
  • Some legacy system keep their tables names with numeric code like T89673, R6556757 etc. In this case our previous idea will not work. So what will you do now?
  • Refer labels and heading of front end screen controls and try to find out the similar name as columns name from our excel sheet. Note down all the tables where you will get these label names.
  • One more concrete way to find exact tables and column name is that enter and save some test data from front end and find out that data in all tables of that database. You can google such SQL script to find any particular word in all tables.
  • Use SQL server trace functionality to find out what exact queries are fired on SQL server when you click on SAVE button in front end. All these queries give you good insight of all referred tables for that functionality.
  • If you have EXE or DLL of the legacy system, use tool “ILSpy.exe” for reverse engineering and get the code of legacy system. Find out the data logic sections and get all referred tables, columns, queries and stored procedure in code.
  • Till this point you should get all the required tables and columns names. Now find our relationship among all these tables.
  • Most important is to find out the sequence of tables in which details are going to save.
  • You should fire some SAVE operations from front end to understand how his data is saving in tables and what its order.
  • Write some insert queries with sample data and check that if you are getting that data in front end as a valid record or not.
  • If not, then examine data again and check what data is missing? In this situation try to compare data saved from front end and data that you are inserting from INSERT queries and make adjustment in your insert queries.
  • If yes, then write a stored procedure to insert all the data in one go.
  • Write API at Sitecore side to send/receive required details to legacy system.
  • Create console application and schedule it to send / receive data from Sitecore.
  • Test end-to-end to send and receive data from and to legacy system and Sitecore side.

By following these steps you can integrate any legacy or unfamiliar system to your application.

I hope you like this article. Stay tuned for more related articles.

Please leave your comments or share this article if it’s useful for you.

Thursday, June 22, 2017

How to download Sitecore media library item on client browser programmatically


Sitecore Media Item Download
Sitecore Media Item Download


One of my friend struggling for downloading PDF file from Sitecore media library on client browser
. So I thought to write a code on the same.


Below code can force any media library item to be downloaded on client browser.

private void DownloadMediaLibraryItem()
{
    //Get Media Item
    var mediaItem = Sitecore.Data.Database.GetDatabase("master").GetItem(new ID("{5D8B8B5B-BD43-4F8E-B1B5-EACA7D78F0DE}"));
    var media = Sitecore.Resources.Media.MediaManager.GetMedia(mediaItem);

    //Get Media Stream in buffer
    var mediaStream = media.GetStream();
    byte[] buffer = new byte[(int)mediaStream.Length];
    mediaStream.Stream.Read(buffer, 0, (int)mediaStream.Length);

    //Send response to browser
    System.Web.HttpContext.Current.Response.Clear();
    System.Web.HttpContext.Current.Response.ClearContent();
    System.Web.HttpContext.Current.Response.ClearHeaders();
    System.Web.HttpContext.Current.Response.ContentType = "application/octet-stream";
    System.Web.HttpContext.Current.Response.AddHeader("Content-Length", buffer.Length.ToString());
    System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=" + mediaItem.Name + ".pdf");
    System.Web.HttpContext.Current.Response.BinaryWrite(buffer);
    System.Web.HttpContext.Current.Response.Flush();
    System.Web.HttpContext.Current.Response.End();
}

I hope you like this Sitecore article. Stay tuned for more Sitecore related articles.

Till that happy Sitecoring :)
 
Please leave your comments or share this code if it’s useful for you.

Sunday, June 18, 2017

How to replace Brightcove Adobe Flash player with HTML5 player in Sitecore


Use HTL5 player of Brightcove in Sitecore
Use HTL5 player of Brightcove in Sitecore

One of our site is using Brightcove Adobe Flash player which we have to replace with new Brightcove player which support HTML5. 
 
Follow below steps to configure Brightcove Video Cloud running as an HTML5 player

  • Step 1: Please navigate to section "Brightcove.StorageService" and change the "baseUrl" param value with your website URL and also set the "ContentDatabaseName" and "PublishDatabaseName" param values from Sitecore.MediaFramework.Services.Brightcove.Extended.config.disabled config file.
  • Step 2: Enable the config file named as "Sitecore.MediaFramework.Services.Brightcove.Extended.config.disabled".
  • Step 3: We need to add mimetype "text/vtt" with extension (.vtt) in IIS.
  • Add new player at “/sitecore/media library/Media Framework/Accounts/Default/Players” with unique player id.
  • Update “Default Video Player” field and “Default Playlist Player” to new player at “/sitecore/media library/Media Framework/Accounts/Default/Settings
  • Include “<script src="//players.brightcove.net/<licence id>/<Player_Id>_default/index.min.js"></script>” on all pages where you want to show Brightcove videos.
  • Publish all the Brightcove items
  • Test the page on which Brightcove videos are rendering.
I hope you like this Sitecore article. Stay tuned for more Sitecore related articles.

Till that happy Sitecoring :)

Please leave your comments or share this article if it’s useful for you.