Tuesday, July 17, 2012

error from asp.net 3.0 to asp.net 4.0

Error:
The type 'System.Web.Mvc.ModelClientValidationRule' exists in both 'd:\Program Files\Microsoft ASP.NET\ASP.NET Web Pages\v2.0\Assemblies\System.Web.WebPages.dll' and 'd:\Program Files\Microsoft ASP.NET\ASP.NET MVC 3\Assemblies\System.Web.Mvc.dll

Resolution:
Issue resolved as per http://www.asp.net/whitepapers/mvc4-release-notes#_Toc303253815

Methods (Copied from http://www.asp.net/whitepapers/mvc4-release-notes#_Toc303253815 for reference):



  1. In the root Web.config file, add a new <appSettings> entry with the key webPages:Version and the value 1.0.0.0.
  2. <appSettings>
        <add key="webpages:Version" value="1.0.0.0"/>
        <add key="ClientValidationEnabled" value="true"/>
        <add key="UnobtrusiveJavaScriptEnabled" value="true"/>
    </appSettings>
  3. In Solution Explorer, right-click the project name and then select Unload Project. Then right-click the name again and select Edit ProjectName.csproj.
  4. Locate the following assembly references:
    <Reference Include="System.Web.WebPages"/> <Reference Include="System.Web.Helpers" />
    Replace them with the following:
    <Reference Include="System.Web.WebPages, Version=1.0.0.0,
    Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL "/> <Reference Include="System.Web.Helpers, Version=1.0.0.0,
    Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
  5. Save the changes, close the project (.csproj) file you were editing, and then right-click the project and select Reload.


Friday, June 29, 2012

Creating a kanban board with javascript

At SyneITY we follow the lean agile development methodology and to aid in our development we needed a kanban board and thought why not develop it using javascript, jquery and knockoutjs.

As usual, we are just starting out with a basic version and here is a mockup of what we were trying to achieve in the first iteration
Technologies we will be using:

  • Javascript
  • Jquery
  • Knockoutjs
  • Ajax

Wednesday, June 27, 2012

PHP Call to undefined function curl_init()

while working on php in windows using VS.PHP i came across this exception:
"Call to undefined function curl_init()"
Earlier when i had come across this exception, we had used this answer on stackoverflow to resolve this issue.
However the next time, on another machine, this method was not solving the issue. On analysis this was found out to be an issue of using VS.php which overwrites the php.ini file everytime it runs. So using the video at this link i just put the ini path in the visual studio debug and viola, the issue was resolved.

Friday, June 22, 2012

Learning to use MOQ


MOQ
No i am not mocking you!!. MOQ is a mocking framework for .net and can be downloaded here.

What is a mocking framework?
It is basically a small piece of software that simulates the behavior of an interface, it is generally used for creating unit tests.

Confused??? let us just visualise a problem. let us visualise it as if you encountered it.
A Story to start using MOQ
You have a requirement to design a code generation application, for which you will be using some xml files with data required to generate the code. Now you get into work, do a lot of RND, work your brain day in and out and finish the code generation.

To test this out you write over 200 xml files and run your code, the code generation just takes 10 mins. Wow great, an entire application in 10 mins, Your team lead is impressed, he calls out for your manager, he comes over take a look and says, "Hey the application looks great but you have  forgotten to put the Billing address for the customer". You smile and say "Just a minute" and while the manager is there you make a slight change in the xml file and click generate. Voila in another 10 minutes, the issue is fixed. The manager is head over heels and you are sure of your next hike. 

Next day the manager calls you into the room and says "Man you are great!! and that work is so good that i am going to use it in my next meeting with the client. So get ready for the trip."

You are excited, tell your friends about it, make purchases for the trip and the next moment you are sitting with your manager in the flight. The next day at the client site, you and your manager stride up to the clients office. The client invites you inside, the manager introduces himself and then says "Hey Bill, this is John, the most talented developer in my company and we are here to solve your problems and that too in real time". 

You feel your head swelling with pride and you are quickly in the clouds though not the azure ones...

Your manager then starts the demo of the application, the client is impressed, then suddenly he squints and then roars "Hey don't you know english? Customer is spelled "CUSTOMER" not "CSUTOMER". You curse him  in your mind, "hey that is a typing error, why the hell doesn't he understand". Your manager soothes the customer and says "Hey that is a normal typing error, give me 10 minutes" and your manager glances at you. You quickly open a xml file make the necessary changes and click generate, 10 minutes down the lane, the generation screen closes, your manager wipes off the hint of sweat forming on his head and says "Bill, it is ready". The client is impressed, "Good finally you seem to have learnt programming".

The demo is then again in progress, yet again as usual the client gets hold of another issue, you smile, tweak your xml files and the demo continues. After 3-4 cycles of this same thing, you start noticing that the smile of your manager is slowly changing into a frown, and then Bill gets up and says "Guys! do one thing, will you just run over the application, make the required fixes and then get back, i just remembered i have a meeting with my boss.". 

You and your manager slowly packup your laptops and then go back to room, on the way back, you have lunch. Your manager doesn't talk much, you too feel the pressure. After lunch while trudging back to the room, your manager says, "Hmmm... That was a bad meeting, i thought we would close it for once and 
all. now i dont know how long it is going to take, John, can we do one thing, can we make this code generation faster?", you stop in your tracks and think, "In 10 minutes we are doing what 5-6 people did in 3 months time that too with more bugs & issues, and now he thinks 10 minutes is too much... ", you think for sometime and say "Maybe there is a way, i will check and see what can be done". Then you both re-enter into silence and go to your room.

You go, open the fridge, grab a can of beer. Still you cannot take your mind off things. to cool off a shower should be good, you quickly go in and take a shower, now beneath the shower you start thinking about the issue, suddenly everything falls into place, Why generate all the 200 files, why not just generate the files that are modified? yes why not. Looking back, now it looks silly, you had been such a stupid idiot. You run into your room, take the laptop and begin coding..... 

Saturday, June 2, 2012

Regular Expression to get the attribute value from html string


public static string ExtractAttributeValueFromHtmlElement(string elementOuterHtml, string attributeName)
        {
            Match m;
            string HRefPattern = "title\\s*=\\s*(?:\"(?<1>[^\"]*)\"|(?<1>\\S+))";
 
            m = Regex.Match(elementOuterHtml, HRefPattern,
                            RegexOptions.IgnoreCase | RegexOptions.Compiled);
            if (!m.Success)
            {
                return null;
            }
            return m.Groups[1].ToString();                            
        }


pattern = style=\s*(?:\"(?<1>[^\"]*)\"|(?<1>\\S+))
input   = <td style="width:100px;height:100px;">Pramod</td>
result  = 
             style="width:100px;height:100px;"
             width:100px;height:100px;

Tuesday, February 14, 2012

Sql Server Shrink Log file

 

For a business Intelligence application, we used a sql server 2008 database for consolidating data from different sources, since data was imported, we didn’t need backup facility, so the database was kept in Simple Logged Mode.

In this blog we will see how to shrink the log files for a simple logged database.

IMPORTANT : Use this only for Simple Logged Databases

Use [DatabaseToShrink]-- Replace this with your simple logged database

Declare @FileId Int
select @FileId = FILE_ID from sys.database_files Where type_desc = 'LOG'

DBCC ShrinkFile(@FileId, 1)

select * from sys.database_files

Monday, February 6, 2012

Html content in RDLC Microsoft Reporting

 

We have been using microsoft reporting for generating itineraries, hotel vouchers etc in TourMast, the tour operator software. In this post i will explain how we display html content in some places:

Step 1:

Select the placeholder,

image
Right click and then select PlaceHolder Properties, you will get the following screen where you must select “HTML-Intepret HTML Tags as styles” in the Markup Type section

image
Reference:

http://stackoverflow.com/questions/3786884/visual-studio-2010-rdlc-support-for-html

Friday, January 27, 2012

Prevent duplicate rows using unique index

create table test(id int identity(1,1), name varchar(10))create
insert
unique index ix_test on test(name) with IGNORE_DUP_KEY into test(name)values('ppv')select * from test

Friday, January 6, 2012

Reenable sql server index

SELECT
'ALTER INDEX ' + I.name + ' ON ' + T.name + ' REBUILD ' FROM SYS.indexes I INNER JOIN SYS.tables T ON I.object_id = T.object_idWHERE I.name LIKE 'IX%'

Wednesday, January 4, 2012

Disable all indexes in sql server

For a data marting application being done @ SyneITY, we needed to disable all indexes in our Sql Server 2008 database. We used the following query to get this done

SELECT 'ALTER INDEX ' + I.name + ' ON ' + T.name + ' DISABLE ' FROM SYS.indexes I INNER JOIN SYS.tables T ON I.object_id = T.object_id


WHERE I.name LIKE 'IX%'