Thursday, February 7, 2019

coinpayments gatway integration in asp.net c# using coinpayments.net API

Bitcoin integration in asp.net c# using coinpayments.net

Coinpayment is payment gateway providing buy now buttons, shopping carts, and more to accept Bitcoin, Litecoin  and more than 165 currencies.

Coinpayment  have plugins for WordPress and php developers that provide you an easy way to integrate to your website.

For developers who don't want to write coding just create html form and button to hit coinpayments server

Example 1.


<form action="https://www.coinpayments.net/index.php" method="post">
 <input type="hidden" name="cmd" value="_pay">
 <input type="hidden" name="reset" value="1">
 <input type="hidden" name="merchant" value="606a89bb575311badf510a4a8b79a45e">
 <input type="hidden" name="currency" value="LTC">
 <input type="hidden" name="amountf" value="10.00">
 <input type="hidden" name="item_name" value="Test Item"> 
 <input type="image" src="https://www.coinpayments.net/images/pub/buynow-grey.png" alt="Buy Now with CoinPayments.net">
</form>
For ASP.NET developer.

Please create your class with the following code and call api with your public and private key





public class CoinPaymentAPIClass
    {
        private string s_privkey = "youraccountprivatekey";
        private string s_pubkey = "youraccountpublickey";
        private static readonly Encoding encoding = Encoding.UTF8;
        public CoinPaymentAPIClass(string privkey, string pubkey)
        {
            s_privkey = privkey;
            s_pubkey = pubkey;
            if (s_privkey.Length == 0 || s_pubkey.Length == 0)
            {
                throw new ArgumentException("Private or Public Key is empty");
            }
        }
        public Dictionary<string, dynamic> CallAPI(string cmd, SortedList<string, string> parms = null)
        {
            if (parms == null)
            {
                parms = new SortedList<string, string>();
            }
            parms["version"] = "1";
            parms["key"] = s_pubkey;
            parms["cmd"] = cmd;
            string post_data = "";
            foreach (KeyValuePair<string, string> parm in parms)
            {
                if (post_data.Length > 0) { post_data += "&"; }
                post_data += parm.Key + "=" + Uri.EscapeDataString(parm.Value);
            }
            byte[] keyBytes = encoding.GetBytes(s_privkey);
            byte[] postBytes = encoding.GetBytes(post_data);
            var hmacsha512 = new System.Security.Cryptography.HMACSHA512(keyBytes);
            string hmac = BitConverter.ToString(hmacsha512.ComputeHash(postBytes)).Replace("-", string.Empty);
            // do the post:
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
            System.Net.WebClient cl = new System.Net.WebClient();
            cl.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
            cl.Headers.Add("HMAC", hmac);
            cl.Encoding = encoding;
            var ret = new Dictionary<string, dynamic>();
            try
            {
                string resp = cl.UploadString("https://www.coinpayments.net/api.php", post_data);
                var decoder = new System.Web.Script.Serialization.JavaScriptSerializer();
                ret = decoder.Deserialize<Dictionary<string, dynamic>>(resp);
            }
            catch (System.Net.WebException e)
            {
                ret["error"] = "Exception while contacting CoinPayments.net: " + e.Message;
            }
            catch (Exception e)
            {
                ret["error"] = "Unknown exception: " + e.Message;
            }
            return ret;
        }
    }
----------------------------------------------------------------------------------
in my controller class i have just call this class callapi method.
 CoinPayments.CoinPaymentAPIClass coinPayObject = new CoinPayments.CoinPaymentAPIClass(s_privkey, s_pubkey);
            //coinPayObject.CallAPI("get_basic_info", null);
            // coinPayObject.CallAPI("rates", null);
            // coinPayObject.CallAPI("get_tx_ids", null);
            SortedList<string, string> lstSortedList = new SortedList<string, string>();
            lstSortedList.Add("amount", "500");
            lstSortedList.Add("currency1", "USD");
            lstSortedList.Add("currency2", "LTC");
            lstSortedList.Add("ipn_url", "http://localhost:3996/Home/SuccessfullyCompleted");
            lstSortedList.Add("buyer_email", "hostcoders@gmail.com");
            var result = coinPayObject.CallAPI("create_transaction", lstSortedList);
  












Google Analytics Video Tracking / jwplayer google analytics event tracking

Google Analytics  with Jwplayer Video Events tracking last time i was stuck to find some good solution related to jwplayer event tracking and i got that hear are my solution

create an HTML and past the code you will see the play,pause,complete,volume event in jquery.

  <html>
<head>
    <title>test page</title>
    <script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
    <script src="http://code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
    <script type="text/javascript" src="http://www.longtailvideo.com/jwplayer/jwplayer.js"></head>
<body>
    <div id="mediaplayer">
    </div>
    <ul>
        <li>State: <span id="stateText">IDLE</span></li>
        <li>time: <span id="elapsedText">0</span></li>
    </ul>
    <script type="text/javascript">        jwplayer.key = "yourkey=";</script>
    <script type="text/javascript">

        jwplayer("mediaplayer").setup({
            file: 'yourvideofile.mp4',
            width: 465,
            height: 300,
            autostart: true,
            events: {
                onComplete: function (event) {


                    var elapsedTime = jwplayer("mediaplayer").getPosition();
                    var timedurationvalue = ((elapsedTime / 60).toFixed(2));
                    updateValues();
                    //ga('send', 'event', 'Video Completes', 'ULR of video or Title', 'Page URL', timedurationvalue);
                },
                onReady: function (event) {
                    var elapsedTime = jwplayer("mediaplayer").getPosition();
                    var timedurationvalue = ((elapsedTime / 60).toFixed(2));
                    updateValues();
                    //  ga('send', 'event', 'Video Plays', 'ULR of video or Title', 'Page URL', timedurationvalue);
                },
                onPlay: function (event) {
                    var elapsedTime = jwplayer("mediaplayer").getPosition();
                    var timedurationvalue = ((elapsedTime / 60).toFixed(2));
                    //  ga('send', 'event', 'Video Plays', 'ULR of video or Title', 'Page URL', timedurationvalue);

                    //                    ga('send', 'event', 'category', 'action', 'label', value);
                },
                onVolume: function (event) {
                    updateValues();
                    alert("onvolume called!");
                },
                onPause: function (event) {


                    var elapsedTime = jwplayer("mediaplayer").getPosition();
                    var timedurationvalue = ((elapsedTime / 60).toFixed(2));
                    //  ga('send', 'event', 'Video Paused', 'ULR of video or Title', 'Page URL', timedurationvalue);
                    updateValues();
                    alert("onpause called!");
                }
            }
        });
        function setText(id, messageText) {
            document.getElementById(id).innerHTML = messageText;
        }

                function updateValues() {
                    var state = jwplayer("mediaplayer").getState();
                    var elapsed = jwplayer("mediaplayer").getPosition();
                    setText("stateText", state);
                    setText("elapsedText", (elapsed / 60).toFixed(2));
                }
    </script>
</body>
</html>

HTML5 video not playing in IE8


IE8 now support HTML5 Video

Internet Explorer 8

  Get IE8 to Support HTML5 video with JWplayer , IE8 Issue with Jwplayer and Html5
As we know this is one of the earlier version of IE so its actually more buggy  . i have faced lot of issue while using IE8 , in my project i have used a scenario which is JWplayer with Html 5 

HTML5 is new and all the browsers are trying support as much HTML5 features possible in their current and upcoming versions. HTML5 is not back compatible with older version of browsers.

My Problem and Solution

I was unable to play html5 video with jwplayer in IE8 actaully it was working in all other browsers.
what i do here is my code .
<!DOCTYPE html>
<head>

    <title>test </title>
    <meta name="description" content="">
    <meta name="author" content="">
    <title>test video </title>


 <script type='text/javascript' src='https://s3.amazonaws.com/files.infopave.com/jwplayer.js'></script>
   <script type="text/javascript">       jwplayer.key = "MyKey";</script>
    <style type="text/css">
        html, body
        {
            height: 100%;
            width: 100%;
            padding: 0;
            margin: 0;
        }
        #player
        {
            height: 100%;
            width: 100%;
            padding: 0;
            margin: -3px;
        }
    </style>

    
<!--[if lt IE 9]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->

</head>
<body>
    <div id='my-video'>
    </div>
    <script type='text/javascript'>
        jwplayer('my-video').setup({
     //  flashplayer: 'player.swf', (fix do not use this if you are using HTML5 bcs your video will not get run
  file: 'rtmp://s1nu7pjztotbeg.cloudfront.net/cfx/st/mp4:Help/How_To/GettingStarted_V2-Sm_x264.mp4',
            width: '50%',
            height: '80%',
            stretching: 'exactfit'
        });
    </script>
</body>
</html>

You can see HTML5 browsers testing here
http://html5test.com/compare/browser/mybrowser/firefox-26/ie-11/ie-10/ie-9.html

Happy Coding.
Noor Ur Rahman
Skype: webdeveloper84
Facebook :My Facebook Page





Google analytics integration to google search appliance GA to GSA



How to integrate Google Analytics to Google Search Appliance

What is a Google Search Appliance (GSA) ? 

Google Search Appliance combines the search expertise of Google with features that meet today’s business requirement

What is google analytics ( GA) ?

The Google Analytics Platform lets you measure user interactions with your business across various devices and  environments, at Google speed and scale.Gain new insights and optimize the
performance of your business
Details.
At the basic level of integration, the GA tracking script is added to all pages served from a specific GSA front end. In GA, you can see the number of visits, page views, average time on page, and specific pages that were viewed. The Site Search tab is also enabled within GA, providing reports on top search terms as well as search engagement. With this data, you are able to provide simple, elegant, and free analytics. This, coupled with Advanced Search Reporting and search logs can demonstrate ROI and assist in quantifying the business value of search.

Integration

If you have already created  XSLT
Then just put your account Id so you will be able to get tracking of your search appliances in Google analytics account

  <!-- *** analytics information *** -->
  <xsl:variable name="analytics_account">Update your Account ID here</xsl:variable>

  <!-- **********************************************************************
 Analytics script (do not customize)
     ********************************************************************** -->
  <xsl:template name="analytics">
    <xsl:if test="string-length($analytics_account) != 0">
      <script type="text/javascript" src="{$analytics_script_url}"></script>
      <script type="text/javascript">
        var pageTracker = _gat._getTracker("<xsl:value-of select='$analytics_account'/>");
        pageTracker._trackPageview();
      </script>
    </xsl:if>
  </xsl:template>



Benefits.
What Result We will Get by integrating of Google analytics to Google Search Appliances.

After integration we are able to generate graphs and reports in GA panel for the following aspects:

● Most relevant search terms for new visitors and returning visitors
● Percentage of visitors on your external website that perform searches
● The pages on your external site where these searches originate
● Percentage of search refinements and search depth ratio 

In the attached screen shots we can see what result we will get 









 

 

 

 

 

 

 

Technical implementation

1. Create a Google Analytics account, or obtain admin access to an existing account for your
domain.

Once you add a web property to an account, Analytics creates the first profile for the property.

2. Create a different profile for each front end that you would like to gather data from.

3. In Google Analytics, go to the Admin console of your profile and open the Tracking Code tab.

4. In the Admin Console of the GSA, go to Search Search Features > Front Ends (Previous to Version 7.2: Serving > Front Ends) and edit the front end you would like to track. In the Page
Layout Helper, expand the Global Attributes section and paste your analytics Tracking ID into
the Analytics Account field.

5. For more information on granting other users access to GA reports, see Add/modify/delete users.

6. Enable Site Search Tracking, as described in Set up and configure Site Search.

You may want to familiarize yourself with the various GSA Request Parameters that you can use
when setting up site search tracking. The default query parameter is q . 

Best of Luck!:)

Hope it helps some one.

Feel free to ask any question.





















Jquery vertical Timeline in ASP.NET C#



Jquery vertical Timeline  in ASP.NET C#

How to implement jQuery timeline in C# ASP.NET.

i have implement timeline in asp.net  MVC4, here is the details.

Step 1- You need these script files in your web from or View.

<script type="text/javascript" src="~/Scripts/js/Timeline/libs/handlebars-1.0.rc.1.min.js"></script>
<script type="text/javascript" src="~/Scripts/js/Timeline/libs/tabletop-zzolo.master-20130402.min.js"></script>
<script type="text/javascript" src="~/Scripts/js/Timeline/libs/jquery.isotope.v1.5.21.min.js"></script>
<script type="text/javascript" src="~/Scripts/js/Timeline/libs/jquery.ba-resize.v1.1.min.js"></script>
<script type="text/javascript" src="~/Scripts/js/Timeline/libs/jquery.imagesloaded.v2.1.0.min.js"></script>
<script type="text/javascript" src="~/Scripts/js/Timeline/jquery-veritcal-timeline.js"></script>
<link href="~/Content/Timeline/style.css" rel="stylesheet" />
<script src="~/Scripts/library/jquery-ui-1.8.24.js"></script>
<script src="~/Scripts/js/Timeline/TimeLine.js"></script>


Step 2- Create HTML Div like

This is the div where time line render in your view or web form.

 <div id="TimeLineDiv" class="timeline-jquery-TimeLine">

 </div>

Step 3- Creat your your method to get timeline data in your MVC controller 


  [HttpGet]
        public ActionResult GetTimeLineDate()
        {

  var ProductID = 2242; 
 var TimelineMileStoneData = _iEAppService.getTimeLineData(ProductID);
 var yearList = TimelineMileStoneData.Select(x => x.DATE_ADDED.Value.Year).Distinct().ToList();
 return Json(new { TimelineMileStoneData = TimelineMileStoneData, yearList = yearList }, JsonRequestBehavior.AllowGet);

        }

Step 4- Write your query in repository if you are using repository pattern


 #region [Time Line Data]
        public List<TimeLine> getTimeLineData(long ProductId)
        {
            try
            {
                var TimeLineData =
             (from j in _dataContext.ADM_PRODUCT_MILESTONE
              join k in _dataContext.ADM_TC_MILESTONE on j.MILESTONE_ID equals k.MILESTONE_ID
              where k.TECHNICAL_COMMITTEE_ID == 18
              && j.EVALUATION_REQUEST_ID == 358
              && j.PRODUCT_ID == 2242
              select new TimeLine
              {
                  DATE_ADDED = j.DATE_ADDED,
                  MILE_STONE_TYPE_ID = j.MILESTONE_TYPE_ID,
                  CATEGORY_COLOR = "",
                  // photourl = "#"
                  readmoreurl = "#",
                 // TITLE_ICON = "",
                  //  DISPLAY_DATE =tl.DATE_ADDED.ToString(), // + " " + "May", ///TODO get month name like May
                  body = k.MILESTONE_MESSAGE
              }).Union(from a in _dataContext.ADM_PRODUCT_INFORMATIONAL_MILESTONE
                       select new TimeLine
                       {
                           DATE_ADDED = a.DATE_ADDED,
                           MILE_STONE_TYPE_ID = 4,
                           CATEGORY_COLOR = "#F8E27C",
                           // photourl = "#"
                           readmoreurl = "#",
                         //  TITLE_ICON = "",
                           body = a.INFORMATIONAL_NOTE

                       }).OrderByDescending(o => o.DATE_ADDED).ToList();
                foreach (var item in TimeLineData)
                {
                   
                    if (Convert.ToInt32(item.MILE_STONE_TYPE_ID) > 0)
                    {
                        item.CATEGORY_COLOR = SetColorCode(Convert.ToInt32(item.MILE_STONE_TYPE_ID));
                    }   
                    item.DISPLAY_DATE = item.DATE_ADDED.Value.Date.Day.ToString() + ", " + item.DATE_ADDED.Value.ToString("MMM");
                }

                return TimeLineData;

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public string SetColorCode(int? MileStoneTypeId)
        {
            string ColorCode = "";

            if (MileStoneTypeId == 1)
            {
                ColorCode = "#B7CC8A"; // Past Milestone.
            }
            if (MileStoneTypeId == 2)
            {
                ColorCode = "#8DB1E2"; //Active Nilestone.
            }

            if (MileStoneTypeId == 3)
            {
                ColorCode = "#E5B9B5"; //Recommended Re-evaluation
            }

            if (MileStoneTypeId == 4)
            {
          
                ColorCode = "#F8E27C"; //Informational Notes
            }
          



            return ColorCode;
        }



Run your code you can see your time line like.







if any buddy need complete code then let me know 

Email: rahman.qau80@gmail.com
Skype: webdeveloper84
Cell: +92 333 5440 951


Thanks
















Tuesday, October 18, 2016

How to count Left and Right Member of MLM binary Tree in C#

How to count Left and Right Member of MLM binary Tree in C#.

 SQL table structure.

 -------------------------------------------------------
Id(int) | Parent_Id (int) | Placement (varchar(10))
-------------------------------------------------------
 1          0                        -
2          1                        Left
3          1                        Right
4          2                        Left
5          2                        Right

 ---------------------------------------------------

 private void pNodeR(string node, string place)
{
     string sql = "select * from biodata_master where parent_no='" + node + "'";

      DataTable dt = new DataTable();
      dt = obj.SelectData(sql);

      if (dt.Rows.Count == 1)
      {
          Cr = Cr + 1;
      }
      else if (dt.Rows.Count > 0)
      {
           Cr = Cr + 2;
           pNodeR(dt.Select("PLACEMENT='Left'")[0].ItemArray[0].ToString(), "LEFT");
           pNodeR(dt.Select("PLACEMENT='Right'")[0].ItemArray[0].ToString(), "RIGHT");
      }
}

 /// <summary>
 /// To Count left node
 /// </summary>
 /// <param name="node"></param>
 /// <param name="place"></param>
private void pNodeL(string node,string place)
{
      string sql = "select * from biodata_master where parent_no='"+node+"'";

       DataTable dt = new DataTable();
       dt = obj.SelectData(sql);

       if (dt.Rows.Count == 1)
       {
           Cl = Cl + 1;
       }
       else if (dt.Rows.Count > 1)
       {
            Cl = Cl + 2;
            pNodeL(dt.Select("PLACEMENT='Left'")[0].ItemArray[0].ToString(), "LEFT");
            pNodeL(dt.Select("PLACEMENT='Right'")[0].ItemArray[0].ToString(), "RIGHT");
       }
}


/* SelectData Method & Connection string */

SqlConnection con = new SqlConnection(WebConfigurationManager.ConnectionStrings["ConnectionString"].ToString());

public System.Data.DataTable SelectData(string sql)
{
      try
      {
          SqlDataAdapter da = new SqlDataAdapter(sql, con);
          DataTable dt = new DataTable();
          da.Fill(dt);
          return dt;
      }
      catch
      {
          throw;
      }
}

 ---------------------------------------

Monday, May 18, 2015

Jquery Timeline in ASP.NET C#

Jquery vertical Timeline  in ASP.NET C#

How to implement jQuery timeline in C# ASP.NET.

i have implement timeline in asp.net  MVC4, here is the details.

Step 1- You need these script files in your web from or View.

<script type="text/javascript" src="~/Scripts/js/Timeline/libs/handlebars-1.0.rc.1.min.js"></script>
<script type="text/javascript" src="~/Scripts/js/Timeline/libs/tabletop-zzolo.master-20130402.min.js"></script>
<script type="text/javascript" src="~/Scripts/js/Timeline/libs/jquery.isotope.v1.5.21.min.js"></script>
<script type="text/javascript" src="~/Scripts/js/Timeline/libs/jquery.ba-resize.v1.1.min.js"></script>
<script type="text/javascript" src="~/Scripts/js/Timeline/libs/jquery.imagesloaded.v2.1.0.min.js"></script>
<script type="text/javascript" src="~/Scripts/js/Timeline/jquery-veritcal-timeline.js"></script>
<link href="~/Content/Timeline/style.css" rel="stylesheet" />
<script src="~/Scripts/library/jquery-ui-1.8.24.js"></script>
<script src="~/Scripts/js/Timeline/TimeLine.js"></script>


Step 2- Create HTML Div like

This is the div where time line render in your view or web form.

 <div id="TimeLineDiv" class="timeline-jquery-TimeLine">

 </div>

Step 3- Creat your your method to get timeline data in your MVC controller 


  [HttpGet]
        public ActionResult GetTimeLineDate()
        {

  var ProductID = 2242; 
 var TimelineMileStoneData = _iEAppService.getTimeLineData(ProductID);
 var yearList = TimelineMileStoneData.Select(x => x.DATE_ADDED.Value.Year).Distinct().ToList();
 return Json(new { TimelineMileStoneData = TimelineMileStoneData, yearList = yearList }, JsonRequestBehavior.AllowGet);

        }

Step 4- Write your query in repository if you are using repository pattern


 #region [Time Line Data]
        public List<TimeLine> getTimeLineData(long ProductId)
        {
            try
            {
                var TimeLineData =
             (from j in _dataContext.ADM_PRODUCT_MILESTONE
              join k in _dataContext.ADM_TC_MILESTONE on j.MILESTONE_ID equals k.MILESTONE_ID
              where k.TECHNICAL_COMMITTEE_ID == 18
              && j.EVALUATION_REQUEST_ID == 358
              && j.PRODUCT_ID == 2242
              select new TimeLine
              {
                  DATE_ADDED = j.DATE_ADDED,
                  MILE_STONE_TYPE_ID = j.MILESTONE_TYPE_ID,
                  CATEGORY_COLOR = "",
                  //photourl = "#",
                  readmoreurl = "#",
                 // TITLE_ICON = "",
                  //  DISPLAY_DATE =tl.DATE_ADDED.ToString(), // + " " + "May", ///TODO get month name like May
                  body = k.MILESTONE_MESSAGE
              }).Union(from a in _dataContext.ADM_PRODUCT_INFORMATIONAL_MILESTONE
                       select new TimeLine
                       {
                           DATE_ADDED = a.DATE_ADDED,
                           MILE_STONE_TYPE_ID = 4,
                           CATEGORY_COLOR = "#F8E27C",
                           //photourl = "#",
                           readmoreurl = "#",
                         //  TITLE_ICON = "",
                           body = a.INFORMATIONAL_NOTE

                       }).OrderByDescending(o => o.DATE_ADDED).ToList();
                foreach (var item in TimeLineData)
                {
                   
                    if (Convert.ToInt32(item.MILE_STONE_TYPE_ID) > 0)
                    {
                        item.CATEGORY_COLOR = SetColorCode(Convert.ToInt32(item.MILE_STONE_TYPE_ID));
                    }   
                    item.DISPLAY_DATE = item.DATE_ADDED.Value.Date.Day.ToString() + ", " + item.DATE_ADDED.Value.ToString("MMM");
                }

                return TimeLineData;

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public string SetColorCode(int? MileStoneTypeId)
        {
            string ColorCode = "";

            if (MileStoneTypeId == 1)
            {
                ColorCode = "#B7CC8A"; // Past Milestone.
            }
            if (MileStoneTypeId == 2)
            {
                ColorCode = "#8DB1E2"; //Active Nilestone.
            }

            if (MileStoneTypeId == 3)
            {
                ColorCode = "#E5B9B5"; //Recommended Re-evaluation
            }

            if (MileStoneTypeId == 4)
            {
          
                ColorCode = "#F8E27C"; //Informational Notes
            }
          



            return ColorCode;
        }



Run your code you can see your time line like.







if any buddy need complete code then let me know 

Email: hostcoders@gmail.com
Skype: hostcoders@hotmail.com
Cell: +92 333 5440 951


Thanks