Pages

Thursday, January 12, 2017

BCS Post Graduate Diploma in IT Project Report

BCS Post Graduate Diploma in IT has a IT project which student should complete. Below is the project report which my wife has done. This can be use as a reference to do the BCS project report

BCS Post Graduate Project Report

Friday, December 9, 2016

How to create Multi Valued Optional Parameters Report with Telerik Reporting

Some times we may need to implement reports which has the ability to pick multiple parameters. If no parameter is selected it should run for all the values. Let's see how this can be achieved using Telerik Reporting. As an example let's consider a system which has banks and branches. Banks have many branches (One to many relationship). In this example banks are parameters. It's multi value. 



                                                                         Fig 1

If you take the Fig 1 User has run the report by selecting two banks. Then report will be generate for 2 banks. 
                                       

Fig 2

If you take the Fig 2 User has run the report without selecting any banks.Then report will be generated for all the banks. 

Let's see how we can achieve this kind of functionality using telerik reporting. 

After creating a new telerik report we have to add data source. In this example we will add Sql Data Source. To achieve this multy value parameter scenario we can't use stored procedures. We have to define SQL Statement in the report it self. 

Here is the Sql statement to achieve this functionality.  

SELECT B.BankName,B.ChequeNumberFormat,B.Active,                 BB.BranchName,BB.BranchCountry,BB.BranchSortCode
 FROM dbo.Bank B INNER JOIN dbo.BankBranch BB ON B.BankID = BB.BankID
 AND ((B.BankID IN  (@bankIds)) or COALESCE(@bankIds,null) is NULL) 

We have to define the parameter as B.BankID IN  @bankIds. When parameter is not selected by user to display records for all the banks, we have to add COALESCE(@bankIds,null) is NULL.
This part is not much documented in Telerik reporting documentation. 



                                                                    Fig 3

And it's really important to define parameters MultiValue  property as True during the setting Data source operation. Otherwise you will get an error. 

This can be achieved using Entity frame work data Sources as well. I hope to publish a post how to implement this scenario using Entity framework in the future. Please comment if you have anything to say regarding this. 





Saturday, September 7, 2013

Convert List to a ObservableCollection

Observable Collections are heavily used in Silverlight, WPF Applications instead of Lists. Observable Collection works essentially like a regular collection but it implements INotifyCollectionChanged and INotifyPropertyChanged interfaces. Because of that you can get to know when Collection is changed. ObservableCollection are optimized for databinding  purposes.

Sometimes you will need to convert your list to an ObservableCollection. This Extension method enables that. 

public static class CollectionExtensions
{
        public static ObservableCollection ToObservableCollection(this IEnumerable coll)
        {
            var c = new ObservableCollection();
            foreach (var e in coll)
                c.Add(e);
            return c;
        }
 }

Saturday, December 29, 2012

Happiness - 2



  • Happiness is my birthright.


  • I forgive myself for all of my mistakes--and celebrate the lessons they let me learn.


  • I am enough.  


  • What other people think of me is none of my business.


  • When in doubt, breathe.

Happiness - 1



The yamas for a happy, better life :)

  • Truthfulness
  • Non-harming
  • Non-stealing
  • Greadlessness
  • Sexual Responsibility




Dealing with Tragedy

Dealing with Tragedy - Really good, valuable  blog post from Spoiled Yogi.(http://spoiledyogi.blogspot.com/) This teaches us many things about the life.


I watched the news coverage in horror last week. Like most of the country, I was stunned and confused. How could anyone harm children as young as the victims in the school shooting in Connecticut? My mind raced as the reporters painted an all-too-real picture of the events that had taken place. I imagined how scared those children must have been—both the victims and the survivors. I thought about the teachers in the school that day, and I wondered how I would have handled being in that situation. I thought about the parents getting an email notifying them that their child’s school was on lock down. I felt the grief of the first responders. I felt sad for the shooter’s family and imagined how they must be feeling as the media painted their loved one as a monster. It was almost too much to bear. I turned off my TV.
I asked myself: Could feelings of such overwhelming sadness and hurt in my heart do more harm than good? Is it healthy to dwell on the bad things in the world? I realized that sitting in front of the TV with my mouth open didn’t do anything but leave me feeling melancholy and hopeless. And, frankly, in this situation the last thing the world needs is more darkness.
After such a tragic event, it’s hard to feel positive about the world we live in. But through my yoga practice, I’ve found that it is possible to maintain a hopeful optimism for the future. While I know I can’t control the world around me, I have some control over my own feelings and actions. I can’t stop bad things from happening, or undo the bad things that have already happened, I but can do my small part to bring about change. I remind myself of how the tiny changes in alignment (those little shifts that aren’t even noticeable to the untrained eye) can totally change the way I experience a pose over time. And I know that the little things we each do to support each other every day can have the same type of effect on the world.
Bad things happen. Sometimes they hit closer to home than others. We can look at it as a sign that the world is a bad place, unsafe for our children. We can get angry. Or we can use it to motivate us all to be kinder, more generous, and more loving so that the world will be better for all.
With that in mind, I unroll my mat. I breathe. I feel. I hope for peace.

Sunday, November 25, 2012

How to Install a Magento Extension Using FTP

I had to install a magento extension using FTP recently. These 2 blog posts helped me immensely regarding that.

http://www.aschroder.com/2010/05/installing-a-magento-extension-manually-via-ftp-or-ssh/

http://www.groovecommerce.com/ecommerce-blog/magento/developer-toolbox-a-guide-for-installing-magento-extensions/

If you refer these two blogs I am sure you would be able to manually install an extension manually even though you are not a hardcore magento guy.

Magento extensions are normally developed to install through magento connect. But sometimes you will have to install the extension manually using either FTP or SSH. It is said that it's not good to install too many extenions using Magento Connect. Your magento Site could crash.

Magento extensions come up with file structure. You have to upload to the correct location of your magento site installation.

Important things to consider when manually installing a magento extension.

1.) Don't install the extension without testing that in a testing site. Don't install the extension in a live site without testing. Results of the badly design extension could be catastrophic.

2.) Disable the cache prior to the installation.
        (System->Cache Management), selecting all caches, clicking ‘disable’ from the drop-down menu, and submitting the change.

3.) Disable the compilation mode.

Monday, August 27, 2012

Issues you might face when Setting Up Magento in GoDaddy Shared Hosting

Magento is a powerful open-source ecommerce web application. Recently I hosted magento in a Godaddy. While setting up magento in godaddy I ran into various issues. Here are some of the issues I faced and How I resolved them

1.) When site is installed you get the message "No input file specified"
To resolve that you should renam php.ini file in web directory to php5.ini. And you should put cgi.fix_pathinfo = 1 top of the php5.ini file. If you are still getting the error add this "Options -Multivies" to the top of .htaccess .

2.) Added products are not displayed in the front end of the site
Most possible cause can be when adding the product setting Stock availability option to "Out of Stock" in inventory section

3.) Added Images are not displayed in the front end
Image size should be around very lower(less than 40kb). You should remove .htaccess file
located in the media folder.

4.) When you try to access the site or admin panel you get the message "The Server is temporarily unable to service your request"
This happens when your store has been put to maintenance mode. To resolve this you have to delete maintenance.flag in the root directory.

5.) If you want to install Sample data from Magento run that script from phpmysql admin first of all. If you install sample data later you might end up with various errors.




Saturday, June 23, 2012

Date Selector - Silverlight Custom Control

I have created a silverlight custom control which can be used to select date in a user friendly way. It is similar to date selector control available to set birth date in facebook registration. Standard date picker control in silverlight and WPF is not user friendly and user has to perform several clicks to select a date. This control is skinable. I have open source it and hosted in codeplex. Hope to add localizations very soon. Contributions and ideas are Welcome :).
http://sldateselector.codeplex.com

Wednesday, July 27, 2011

Encryption in Silverlight and .NET Applications

I wanted to encrypt some sensitive data in a Silverlight application and decry pt that in the server. Sergey Barskiy's has written a good post about that. Here is the code.

Encryption functionality

using System;
using System.Text;
using System.Security.Cryptography;
using System.IO;

namespace Encryption
{
public static class EncryptionUtility
{

///
/// Encrypt the data
///

/// String to encrypt
/// Encrypted string
public static string Encrypt(string input, string password)
{

byte[] utfData = UTF8Encoding.UTF8.GetBytes(input);
byte[] saltBytes = Encoding.UTF8.GetBytes(password);
string encryptedString = string.Empty;
using (AesManaged aes = new AesManaged())
{
Rfc2898DeriveBytes rfc = new Rfc2898DeriveBytes(password, saltBytes);

aes.BlockSize = aes.LegalBlockSizes[0].MaxSize;
aes.KeySize = aes.LegalKeySizes[0].MaxSize;
aes.Key = rfc.GetBytes(aes.KeySize / 8);
aes.IV = rfc.GetBytes(aes.BlockSize / 8);

using (ICryptoTransform encryptTransform = aes.CreateEncryptor())
{
using (MemoryStream encryptedStream = new MemoryStream())
{
using (CryptoStream encryptor =
new CryptoStream(encryptedStream, encryptTransform,CryptoStreamMode.Write))
{
encryptor.Write(utfData, 0, utfData.Length);
encryptor.Flush();
encryptor.Close();

byte[] encryptBytes = encryptedStream.ToArray();
encryptedString = Convert.ToBase64String(encryptBytes);
}
}
}
}
return encryptedString;
}

Decryption functionality

///
/// Decrypt a string
///

/// Input string in base 64 format
/// Decrypted string
public static string Decrypt(string input, string password)
{


input = input.Replace(" ","+");
byte[] encryptedBytes = Convert.FromBase64String(input);
byte[] saltBytes = Encoding.UTF8.GetBytes(password);
string decryptedString = string.Empty;
using (var aes = new AesManaged())
{
Rfc2898DeriveBytes rfc = new Rfc2898DeriveBytes(password, saltBytes);
aes.BlockSize = aes.LegalBlockSizes[0].MaxSize;
aes.KeySize = aes.LegalKeySizes[0].MaxSize;
aes.Key = rfc.GetBytes(aes.KeySize / 8);
aes.IV = rfc.GetBytes(aes.BlockSize / 8);

using (ICryptoTransform decryptTransform = aes.CreateDecryptor())
{
using (MemoryStream decryptedStream = new MemoryStream())
{
CryptoStream decryptor =
new CryptoStream(decryptedStream, decryptTransform,CryptoStreamMode.Write);
decryptor.Write(encryptedBytes, 0, encryptedBytes.Length);
decryptor.Flush();
decryptor.Close();

byte[] decryptBytes = decryptedStream.ToArray();
decryptedString =
UTF8Encoding.UTF8.GetString(decryptBytes, 0, decryptBytes.Length);
}
}
}

return decryptedString;
}
}
}
In the decrpting part I had to include the line input = input.Replace(" ","+");
It seems 64-bic encoding does not work with spaces. Plus sign will be interpreted as a space when you call the FromBase64String method.





Saturday, March 19, 2011

HTML Parser - Java Library to extract html Elements


HTML Parser is a very cool java library which can be used to extract values in a html page.

Let's take the URL - http://www.google.ca/finance?q=BMO


Let's say we want to extract the value of the span tag - ( Mar 18 - Close.)

Here is the code

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import org.htmlparser.Node;
import org.htmlparser.Parser;
import org.htmlparser.filters.CssSelectorNodeFilter;
import org.htmlparser.util.NodeList;
import org.htmlparser.util.ParserException;

public class test {

/**
* @param args
*/

public static void main(String[] args) {

String URL = "http://www.google.ca/finance?q=BMO";

try {

URL url = new URL(URL);
URLConnection urlcon;
urlcon = url.openConnection();

Parser parser = new Parser(urlcon); // creating of HTML parser
// object
CssSelectorNodeFilter cssFilter = new CssSelectorNodeFilter(
"SPAN.nwp");
NodeList nodes = parser.parse(cssFilter); // getting nodes of
// span.nwp. Only NodeList created with one value

Node node = nodes.elementAt(0); //getting the first value of the nodes list
System.out.println(nodes.size());
String value = node.getFirstChild().getText(); //getting the value of the node
System.out.println(value);

} catch (MalformedURLException e) {
System.out.println("Malformed Exception :" + e.getMessage());
} catch (IOException e) {

e.printStackTrace();
} catch (ParserException e) {
e.printStackTrace();
}

}
}




Saturday, December 4, 2010

MySQL - Having reserved key word as a column name

In MySql you will run into trouble when you try to execute a query if you have a reserved keyword as a column name. As an example let's take "update google_mapping set Open_Market='N' where Group='Taiwan';. Group is a reserved keyword in MySql. Solution is to surround keyword with ``. So in the above example you have to modify the query like this.
"update google_mapping set Open_Market='N' where `Group`='Taiwan'";

Saturday, October 30, 2010

Esoteric programming language

Esoteric programming language - Wikipedia, the free encyclopedia

Escoteric programming languages! Well I heard about them today for the first time. These programming languages are not used in real world programming. They have mainly used to test the boundaries of computer programming language design, as a joke and as a prof of concept by hackers and hobbyists . You can find great deal about them in this wiki article.

Wednesday, October 20, 2010

David Parnas - Father of the Software Engineering

David Parnas - Wikipedia, the free encyclopedia

Recently I heard that David Parnas is considered as the father of modern day Software Engineering. . Geez, I am in the Software Engineering field
all these years with out knowing the father of Software Engineering. ;) He has published many papers regarding Software Architecture.

Friday, October 15, 2010

Brief Introduction to Object Oriented Programming Fundamentals

Main Fundamental concepts of Object Oriented Programming are

1. Data Abstraction
2. Encapsulation
3. Polymorphism
4. Inheritance

1. Data Abstraction - Process of Grouping together fields and methods and defining classes.

2.Data Encapsulation - Hiding the implementation details. Provides a barrier to prevent misuse.

3.Inheritance - Receiving responsibility of parents.

4. Polymorphism - Ability to substitute a one type for another type at runtime. It's also called dynamic binding and late binding. Overriding is directly related to this.

Friday, August 27, 2010

Huawei E220, the device has been disconnected or is unavailable

Huawei USB modem didn't work in my Windows Vista laptop. my2cent blog helped me to resolve the issue. :)
You can download Huawei E220 Vista Firmware (v11.110.05.00.00) from the link below.

As in the screen shot below shows Device manager should list Huawei in the Modems section if the device has been correctly install in the machine.



Few days after writing this blog post I dicovered what is causing me this problem. It's VMWare. I uninstall that and now device works fine. :)


Tuesday, April 27, 2010

Flowers


How to view .bin and .cue media files

I used powerISO and it was easy. You can find more info regarding this

Tried to use Demon Pro too. It didn't work out well. Maybe you might be lucky. ;)

Friday, April 16, 2010

Advance Google Searching

Google is the leader when it comes to search engines. With the google search engine here are some techniques to get various kind of usual information.


# (site:) - Domain restricted search. Shows how many URLs are indexed by Google from a directory including all the sub domains. Also shows sites of specific top level domain.
e.g; site:www.google.com, site: google.com, site: lk

# (inurl:) -Narrows the search to urls with the given word.
e.g: inurl:cricket This gives urls which contain word cricket

# (intitle:)- Narrows the seach to urls where title of the page contains the given parameter
e.g intitle:seo - This gives search results which contain seo in the title

# (inanchor:) -Narrows the seach to urls most powerful backlinks which contain the the given parameter
e.g inanchor:srilanka

# (intext:) - Find the pages with most optimized relevant body text.
e.g intext:seo

# (ext:)/(filetype:) - Seaches pages that ends with given extension
e.g ext:py , filetype:py

# (related:) - Gives similar sites which they are linked to.
e.g related:www.cricinfo.com

# (info:) - Gives information about a site such as web pages that are similar, web pages that link to the site, web pages that contain the given term etc.
e.g info:www.example.com

# (cache:) - See what the page looks like when google crawls it.

# ~keyword - Show key words that google think are related
e.g ~car ~rentals - Will give results that related to zoo car and rentals

# "" - Gives results with the exact words withing the quotes.
e.g "I love my country"