Announcement: SocialShare Starter Kit (v1.0) is Released

SocialShare Starterkit v1.0 Relaesed. SocialShare Starter Kit is a kick start application that illustrate a wide range of features that needed to build a social site. And includes features like Status sharing,Blogs,Forums & more. Any one need a lightweight quick solution for his social portal,SocialShare Starter Kit is the savior.SocialShare Starter Kit uses T-4 templates to build logical layers (i.e. DAL/BLL) . The logical layers implemented here are based on Entity Framework 4.0. Its also a good example to learn T4 template and  how to utilize them work with asp.net data bound controls with minimum effort. I am continuously adding and fine tuning the existing feature list and performance. Checkout the app from codeplex SocialShare Starter Kit Home also documentation is available SocialShare Starter Kit documentation

MongoDB Tip & Tricks

Commands

Update a specific field value for a collection:

Example: Update “CampaignId” field across entire collection

db.Prospects.update(
{}, {$set: {CampaignId: ObjectId('54ec891dc8efe23e3e0fb1ef')}}, { multi: true }
)

Removea specific field value for a collection:

Example: Remove “CampaignId” field across entire collection

db.Prospects.update(
   { CampaignId: "54ec891dc8efe23e3e0fb1ef" },
   { $unset: { ZipCode: ""} }
)

MongoDB Bulk Data Import From CSV

Background

mongoimport is a very handy tool for bulk data import. For the most simplest form of importing data in your collection is is the only built in tool available. Alternatively for import one can built an utility .At present this tool as limited capability and can import data from Extended JSON, CSV, or TSV only.

For your help, I have provided an fully functional data import file with 1.3 million+ records. You can download it from here and use as you like.

Using Import Utility

The process of data importing is very easy. Let me elaborate the process by steps.

Create a *.csv file for import where column/header names are at first row.

1) Place the import data file under MONGO_ROOT/BIN/

2) From shell navigate to bin under MONGO installation directory

3) You have to execute following command

mongoimport -d [DB_NAME] -c tmpprospect --type csv --file 
[IMPORT_FILE_NAME].csv --headerline

If you take the import file I provided, command looks like this,
where DB_NAME is “hawk” & [IMPORT_FILE_NAME] is “hawk-prospect-data”

mongoimport -d hawk -c tmpprospect --type csv 
--file hawk-prospect-data.csv --headerline

4) You will see mongoimport utility will split the import file into small chunks of 10k records and importing one by one.

mongoimport

As you can see in the above screenshot, the csv file column name became property name in BASON document. So each record of CSV file will insert as a new BASON document is specified collection.

Limitations

1) In few occasions error messages while importing is not detailed enough to diagnosis.
2) This tool do not support importing to collection that consists of embedded documents, if you do so it will simply ignore the embedded document part and import rest of the documents.
3) Can only import into a single collection, at a time.

Whatever the limitations are, for the very basic importing need, this tool is time saver.

MongoDB Force a Member to Become Primary in a ReplicaSet

Problem Background

The primary is the only member in the replica set that receives write operations. If for some reason primary may becomes unavailable & an election determines the new primary. Which is not expected in few occasion. Election happens due to hardware issue or may be someone accidentally shutdown the primary which lead to this unwanted selection.On other note you may want one of your secondary to act as primary. You can achieve this forcefully and here is how you do it.

Solution To Problem

Say we have 3 note replica set, 3 physically separated machines.

192.168.1.0 – the current primary.
192.168.1.1 – a secondary.
192.168.1.2 – a secondary .

Our goal is to make 192.168.1.2 primary

From mongo shell, connect to current primary. use the following sequence of operations.

mongo 192.168.1.0:27017
rs.stepDown(120)

Now connect to a secondary. use the following sequence of operations.

mongo 192.168.1.1:27017
rs.freeze(120)

wait for 120 seconds

mongo 192.168.1.2:27017
rs.Status()

You will see machine with IP 192.168.1.2 is now became primary.

Dotnetters Tech Summit at RUET

This June we have successfully able to conduct a long technical event titled “DotNetters Tech Summit – 2015 RUET”, was held on Saturday, 6th June at RUET (Rajshahi University of Engineering & Technology). This event was organized by Microsoft technical community group ‘DotNetters‘. The event was heavily appreciated and draw immense response from CSE students of RUET. Inaugurated at late afternoon by honorable vice-chancellor of RUET Prof. Dr. Mohd. Rafiqul Alam Beg, event was crowded with over 200 participants.

Being a part of DotNetters is amazing, professionals from different established companies are voluntarily involve with such community effort. Seeing such interest I have founded DotNetters  years back with group of .Net geeks. Since then we often organizes knowledge exchange community events to bridge the gap between next generation software development professionals with industry development practices and challenges. This event particularly focused web application development, cloud, big data, SPA, Node & BI

Talking in front of RUET students was amazing, they were interested and eager to learn from the professionals. Even after events we discussed with students about their thoughts, expectations and difficulties.

Full house @RUET

Full house @RUET

Speakers at the event was renowned software architects and engineers from different reputed software companies in Bangladesh.  Most attractive part of the session was an interactive development drills participated by all the speakers lead by me.  DotNetters often organizes knowledge exchange community events to bridge the gap between next generation software development professionals with industry development practices and challenges.

Explaining application development tools

Explaining application development tools

The panel of speakers include Shahriar Iqbal Chowdhury, CTO at Desme & Founder of DotNetters, Shahriar Hossain, tech author & technical community speaker at Microsoft, Ronald Roni Saha, Sr. System Developer at SoftwarePeople, Delwar Hossain, Sr. Software Engineer at Desme, Sohel Rana founder of Nerddevs, Sk. Tajbir, Sr. Software Engineer from Desme and Maksud Saifullah Pulak Software, Engineer from Aprosoft.

Speakers

Speakers

Renowned Canadian software development community ‘CodeProject’, USA based software company ‘Desme’ and ‘Aprosoft Consulting and Training Corp. Ltd’ were the community partners for this event, while ‘HiFi Public’ acted as the media partner.

Mango City [Photo-blog]

Cool Gears for Software Development Part 1

There was a time when development community was not very strong , neither companies commercially valued the importance of the tolls or plugins for Development. Now that is no longer is the case. Development of a product without tools or plugins, I dint think no one now does that. Using right set of tools or a plugin that ease the development effort or increase the product experience is equally appreciable.

At times there was only tools or plugins for the desktop applications, now look around, we are not limited to desktop anymore, we are blessed and charmed with hundreds of tools/plugins/utility for web/devices even focused to technology. I personally admire of such tools that make my development life easier. Through this not so short engineering experience life I have experienced lots of cool tools. Now I think its a shame If I do not share those experiences with my fellows. So from now one I will occasionally will try to come up with an experience sharing post with few tools that I have used or using.

Lets start with the fairly newest one, recently I was working on a product that requires a MS word to pdf conversion. System hosts a on premiss small utility service that receives  MS word formatted document from various sources and put watermark on those docs and upload those to server for review and so on and on. Fairly simple  idea, but when comes to conversion to PDF that no longer simple. Based upon document formatting and the content converting pdf might turn into a tricky task. And lets not forget the performance, we were expecting a huge conversion hourly. We dint want put too much effort on this one as its a tiny part of the big picture, so its time to go for a tool/utility that will do the job for us.

Though there is many open-source solution available but we decided to give it a try Spire pdf converter, why after going through the tutorials It seems fairly easy to integrate, but concerns was two,

  1. how well it can handle loads
  2. how good is the quality of the converted pdf’s

But I find it very helpful, the converted pdf’s was good quality, with embedded media (images) or plain text file with formatting. Converted pdf can keep the formatting intact from source document. Interesting tip about the tool is there is desktop application available to convert to pdf from diff sources along with .net library to build your self. For same purpose application you can try it also.  That library you can download from here and for the same codes you can see here. I see there is a free to test version is also available, so enjoy :)

Despite of many good features I believe there is still some feature enhancement can be introduced in the list of existing feature. Like I want to invoke a service may be REST to convert my document , such feature might come handy in cloud applications I believe.

 

Solve Mongo DB Element does not match any field or property of class

Introduction

Due to non schema nature of mongodb collection, one collection may contains distinct number of fields.Its not recommended though, its possible to contain different number of fields due to business requirements. So for example say we have a collection “Client”, under which there is 2 document. Second document lacks 1 field “City”. So while binding back to POCO via c# driver , we get exception “Element does not match any field or property of class”.

sample-1

Solution

When a BSON document is deserialized back to POCO, the name of each element is used to look up a matching field or property in the class map, when deserializer do not find  the mapping property its throws an exception, that we have in this scenario. If we want to ignore those extra properties, there is two possible ways, during deserialization or during initialization of the BsonClassMap. I prefer the while I do the mapping, I live to keep my POCO clean.

sample-2

As you can see the above  code block,  SetIgnoreExtraElements methods is used to specify inside mapping to ignore extra elements from BSON document.

map.SetIgnoreExtraElements(true);

That’s it, now you can work with your POCO more easily.

Gears that will save your time to build a great web application

Template Start-up Kit

http://sidewaffle.com/

Automapper

https://github.com/AutoMapper/AutoMapper

POP3/IMAP Library

http://quia.cf/orange/pooxy4/nph-poxy.pl/es/20/https/github.com/bertjohnson/OpaqueMail

AddToCalendar – free widget button for event page

http://addtocalendar.com/

Free online tool to unminify

http://unminify.com/

How to solve The FastCGI process exited unexpectedly Error

Background

IIS with PHP is not new now days, there is lots of business needs that requires php applications need to host in IIS. Recent times PHP improved a lots in terms of integrating to IIS.Still few times few things fall apart, like the problem we are going to illustrate.

Problem

For a recent project I had to configure PHP with IIS 7.0 on Windows 2008 R2. Everything was seems fine, I even added the application pool with “No Managed Code”, configured handler mapping and sit tight to see php running,.

As soon as I hit http://localhost/phpinfo.php and boom, I see this error message.

error

 

 

Solution

After lots of googling I find the solution at last, solution was super easy, you have to install Visual C++ Redistributable for Visual Studio from here. Though it was specifically mentioned in the php download section, but I some how skipped that and wasted hours to find a solution.

Problem was PHP as FastCGI with IIS requires you to install the Non-Thread Safe (NTS) versions of PHP. And Recent releases binaries built with Visual Studio 2012 compiler , So while executing you need to have Visual C++ Redistributable for Visual Studio 2012 install in your server where you are trying to execute php scripts. And for proper installation follow these steps. Addition to these instructions you have to add an application pool with “No Managed Code” and Managed Pipeline Mode set to “Classic”. Then Go to “Advance Settings” of newly created application pool and Enable 32bit Application value to “True”

How to solve Log4Net Config Error

Background

While using log4net for logging and using a separate configuration file I encountered a strange error that log4net cant locate the configuration file, even though file and configurations are already there. This problem drive me nuts and finally i found few solutions to fix the problem.

log4net error

Problem Scope

My particular applications is designed as such

log4net-concept

So as shown in diagram, several type of app type will hookup with Log4Net wrapper to get logging facility and all logging related logic’s are implemented on Log4Net wrapper. As the problem states every time a client app is trying to invoke log4net wrapper it gets xml configuration error “Check your .config file for the <log4net> and <configSections>….”

Solution

There is few problem and few solution, Solution can very on context.

On the client project , select Log4Net config file and set this file to Build Action of Content with Copy to Output Directory of Copy Always.

Another alternative is look for  XmlConfigurator.Configure();. This line is responsible for initiating the log4net. This configuration should exist a single place where logging actually happen, not client app’s.

One of these 2 or both tricks should help to solve this problem.

Follow

Get every new post delivered to your Inbox.

Join 276 other followers