Step 2: Basic solution structure of an ASP.NET MVC in Visual Studio with Ninject

by sunil ravulapalli /15. June 2013 00:16 /software-design /Comments (0)

Add Ninject using Nuget to the Data and Service projects.

Add Ninject.Mvc3 using Nuget to the Web project.

In Data project add a class called DataNinjectModule which looks like this

using System;
using Ninject.Modules;
namespace Wishlist.Data.DependencyConfiguration
    public class DataNinjectModule : NinjectModule    
       public override void Load()        
           throw new NotImplementedException();

In Service project add a class ServiceNinjectModule which looks like this

using System;
using Ninject.Modules;
namespace Wishlist.Service
     public class ServiceNinjectModule : NinjectModule    
          public override void Load()        
                  throw new NotImplementedException();

In Web project add these lines of code to the RegisterServices class in the NinjectWebCommon class found in the App_Start folder.(Substitute "Wishlist" with your project name)


You can find the solution on GitHub.

Step 1: Basic solution structure of an ASP.NET MVC in Visual Studio

by sunil ravulapalli /8. June 2013 01:10 /software-design /Comments (0)

This is a basic solution structure of how to set up a web application like ASP.NET MVC in Visual Studio. 

Core, Data, Service are Class Library projects.

Web is a MVC 4 project.

Service.Test and Web.Tests are Unit Test projects.

 You can find the solution on GitHub.


Google analytics shows visitor from africa from the city zz

by sunil ravulapalli /7. June 2013 23:11 /other /Comments (0)

Recently, I added Google analytics to one of our company website. It is a very easy service to use and gives you valuable information about visitor behavior on your website.

There is a new section in google analytics dashboard called "Real Time", which shows you real time visitor information such as location and pages visited. Our company business is entirely based on in the US, so recently I was baffled to see that there was somebody visiting our website from off the coast of West Africa. Why? Was is from a boat? A hacker on a boat? After a lot of speculation and observation we saw that whenever our visitor from Africa showed up, the city showed up as "zz" when I moused over in on the map and as "(not set)" in pages visited section.

After reading about google analytics we learnt that google cannot always figure out the user location, especially when the visitor is using some browsers like Opera which route requests to their server first. Ok, so "zz" is a some default value which somebody forgot to review I guess. But, why the coast of Africa? Turns out, the location was actually Lat 0, Long 0.,0

Review: Trojan Horse by Mark Russinovich

by sunil ravulapalli /31. May 2013 19:13 /books /Comments (0)

The book started out nicely with a lot of technical details. Eventually it became an action novel. But I still thoroughly enjoyed the book. I highly recommend it any one looking for a peek into the hacker universe. His previous book, I thought was even better.

Powershell script to email event log error count

by sunil ravulapalli /23. May 2013 00:05 /powershell /Comments (0)

Below is the powershell script to email a summary of event log error count for the last four hours as soon as the script is executed. You can schedule a windows task to execute this script periodically.

$smtp_server = ""
$host_name = [System.Net.Dns]::GetHostName()
$from_email =  $host_name + ""
$to_emails = @(",")
$apps = @("App1", "App2")
$errors_end_datetime = Get-Date
$errors_start_datetime = $errors_end_datetime.AddHours(-4)

function sendMail($content)
     #SMTP server name
     $smtpServer = $smtp_server

     #Creating a Mail object
     $msg = new-object Net.Mail.MailMessage

     #Creating SMTP server object
     $smtp = new-object Net.Mail.SmtpClient($smtpServer)

     #Email structure 
     $msg.From = $from_email
	 foreach ($to_email in $to_emails)
     $msg.subject = "Error Summary after: " + $errors_start_datetime + ". Host: " + $host_name
     $msg.body = $content
	 $msg.IsBodyHtml = $true
     #Sending email 

$email_content = "
"; $email_content += ""; $email_content += "" + "" + "" + "" foreach ($app in $apps) { $error_count = 0; $error_count = (Get-EventLog $app | Where-Object {$_.EntryType -eq "Error" -and $_.TimeWritten -gt $errors_start_datetime}).count $email_content += "" + "" + "" + "" } $email_content += "
" + "App Name" + " " + "No. of errors" + "
" + $app + " " + $error_count + "
"; $email_content += "
sendMail $email_content

Magtek credit card reader with kioware

by sunil ravulapalli /17. May 2013 19:42 /kiosk /Comments (0)

When setting up the magtek Credit card reader with kioware, I was expecting to see an option like "Magtek USB HUD Card Reader" in the input devices drop down list in kioware, just like it said in one of the screen shots on the kioware website. However, I could not find that option. After some experimentation, the option "Semtek USB HID Card Reader" worked even with the magtek credit card reader I had. Below is a screen shot of my configuration. 

Call store procedure which does not return anything using Entity Framework

by sunil ravulapalli /10. May 2013 18:29 /entityframework /Comments (0)

This is the technique I am using currently, doesn't feel correct but works.

Main EF function

public int ExecWithStoreProcedure(string query, params object[] parameters)
   var _context = new CompanyDbContext();
   var ints = _context.Database.SqlQuery(query, parameters).ToList(); 
   return ints[0]; 

Caller function

public long InsertEmployee(string empName, decimal empSalary) 
   var lineIdParam = new SqlParameter("lineid", SqlDbType.BigInt) { Direction = ParameterDirection.Output, Size = 8 }; 
     var effectiveDateParam =  new SqlParameter("effectiveDate", SqlDbType.DateTime)  { Direction = ParameterDirection.Output, Size = 8 }; 

   ExecWithStoreProcedure("spInsertStuff @name, @salary, @lineid OUT, @effectiveDate OUT", 
                                      new SqlParameter("name", SqlDbType.Varchar)   { Value = empName }, 
                                      new SqlParameter("salary", SqlDbType.Decimal) { Value = empSalary}, 
   return lineIdParam.Value; 


Print Logo using Kioware on Zebra TTP 2030 Printer

by sunil ravulapalli /17. April 2013 00:59 /kiosk /Comments (0)
var image = [27, 103, 1, 0, 5, 0, 5];
window.external.KioOutputDevice(DeviceName, "PrintBytes", image);

var print = [12];
window.external.KioOutputDevice(DeviceName, "PrintBytes", print);

The above is the javascript which is need to load and print a image on the Zebra TTP 2030 using Kioware, assuming your logo is loaded at position 1. Use position 0 if you just want to test it out using the zebra logo.

27,103 - Print Logo

1 - Position of logo in the printer PROM

0,5 - X Co-ordinate

0,5 - Y Co-ordinate

Refer to Page 53 here:

Load logo into Zebra TTP 2030

by sunil ravulapalli /17. April 2013 00:47 /kiosk /Comments (0)

Download and install "Kiosk Printer Toolbox" from

Here is the link which describes how to load the logo using "Kiosk Printer Toolbox".
NOTE: These instructions seem to be using an older software version. Start from Tools > Graphic Conversion.

Make sure you have an "Monochrome Bitmap" image. This can be done using MS Paint.



Zebra TTP 2030 using Kioware

by sunil ravulapalli /11. April 2013 19:38 /kiosk /Comments (0)

When configuring external devices using Kioware, choose output devices as "Raw Windows Printer" and from the drop down next to in choose "Zebra TTP series"



The Javascript code to print and cut looks like this:

var bytes = [];
window.external.KioOutputDevice(DeviceName, "Print", "Hello Kioware");
window.external.KioOutputDevice(DeviceName, "PrintBytes", bytes);