Monday, December 31, 2007

THINK OUTSIDE OF THE BOX

Below are the Interview Questions.

No one will GET second chance to impress....

Very Impressive Questions and Answers..... ...

Question 1: You are driving along in your car on a wild, stormy night, it's
raining heavily, when suddenly you pass by a bus stop, and you see three
people waiting for a bus:

An old lady who looks as if she is about to die.
An old friend who saved your life once.
The perfect partner you have been dreaming about.

Which one would you choose to offer a ride to, knowing very well that there
could only be one passenger in your car?

This is a moral/ethical dilemma that was once actually used as part of a
job application.

* You could pick up the old lady, because she is going to die, and thus you
should save her first;
* or you could take the old friend because he once saved your life, and
this would be the perfect chance to! pay him back.
* However, you may never be able to find your perfect mate again.

The candidate who was hired (out of 200 applicants) had no trouble coming
up with his answer. Guess what was his answer?

He simply answered:

"I would give the car keys to my Old friend and let him take the lady to
the hospital. I would stay behind and wait for the bus with the partner of
my dreams."

Sometimes, we gain more if we are able to give up our stubborn thought
limitations. Never forget to "Think Outside of the Box."

Question 2: What will you do if I run away with your sister?"

The candidate who was selected answered " I will not get a better match for
my sister than you sir"

Question 3: Interviewer (to a student girl candidate) - What is one morning
you woke up & found that you were pregnant.

Girl - I will be very excited and take an off, to celebrate with my
husband.

Normally an unmarried girl will be shocked to hear this, but she managed it
well. Why I should think it in the wrong way, she said later when asked

Question 4: Interviewer: He ordered a cup of coffee for the candidate.
Coffee arrived kept before the candidate, and then he asked what is before
you?

Candidate: Instantly replied "Tea"

He got selected.

You know how and why did he say "TEA" when he knows very well that coffee
was kept before.

(Answer: The question was "What is before you (U - alphabet)
Reply was "TEA" ( T - alphabet)

Alphabet "T" was before Alphabet "U"

Question 5: Where Lord Rama would have celebrated his "First Diwali"?
People will start thinking of Ayodya, Mitila [Janaki's place], and Lanka
etc...

But the logic is, Diwali was a celebrated as a mark of Lord Krishna Killing
Narakasura. In Dusavataar, Krishnavathaar comes after Raamavathaar.

So, Lord Rama would not have celebrated the Diwali At all!

Question 6: The interviewer asked to the candidate "This is your last
question of the interview. Please tell me the exact position of the center
of this table where u has kept your files."

Candidate confidently put one of his finger at some point at the table and
told that this was the central point at the table. Interviewer asked how
did u get to know that this being the central point of this table, then he
answers quickly that sir u r not likely to ask any more question, as it was
the last question that u promised to ask.....

And hence, he was selected as because of his quick-wittedness. ........

This is what Interviewer expects from the Interviewee. ....

"THINK OUTSIDE OF THE BOX"
Source: via mail forward

Wednesday, December 26, 2007

Creating MS-Word document from C#

In my workplace, I am developing procurement application. In this application, one of the requirement is to auto generate the tender form in MS-Word format for the selected vendors in the application. Vendor details and related informations are taken from the backend.

To auto generate the document, I did the following.
  1. Get the MS-Word template file (filename.dot), in which the format the client wants, from the client
  2. From the developer side, I create the bookmarks in which they want to auto populate data.
  3. In the project workspace I added the reference of Word COMponent. ( I have used MS Office 2007 Component)
  4. Use the following code to generate the doc file.

    // Include the following namespaces
    using Microsoft.Office.Core;
    using Microsoft.Office.Interop.Word;

    ....
    ....
    ....

    Microsoft.Office.Interop.Word.

    ApplicationClass wordApp = new Microsoft.Office.Interop.Word. ApplicationClass();

    string fileDesPath = @"C:\temp\output.doc";    // Output file
    object oTemplate = @"C:\temp\template.dot";   // Template file

    object fileDes = fileDesPath;
    object missing = System.Reflection. Missing.Value;
    object Visible=true;

    Microsoft.Office.Interop.Word.

    Document adoc = wordApp.Documents.Add(ref oTemplate, ref missing, ref missing, ref missing);

    object oBookMark = "name"; // In template we have to find the bookmark "name" to replace the real data
    adoc.Bookmarks.get_Item(
    ref oBookMark).Range.Text = "Prakash";

    object filename = fileDes;

    adoc.SaveAs(

    ref filename, ref missing, ref missing, ref missing, ref missing, ref missing,
    ref missing, ref missing, ref missing, ref missing, ref missing, ref missing,
    ref missing, ref missing, ref missing, ref missing);

    wordApp.Visible =

    true;
    doc.Close(ref nullobj, ref nullobj, ref nullobj);

 

Monday, December 24, 2007

iTextSharp

Today, I got the work to create the PDF document from ASP.net application. Using google I have searched any components which are available for free download. At that time, I got this component, iTextSharp, from Souceforge.net. Initially it is developed in Java with the name of iText.

We can get the latest version of this component at http://sourceforge.net/projects/itextsharp/. In this link they provide the example code also. This component is very useful and easy to use for ASP.net developers.

Sample code

// step 1: creation of a document-object
Document document = new Document();
try
{
// step 2:
// we create a writer that listens to the document
// and directs a PDF-stream to a file
PdfWriter.GetInstance(document, new FileStream(@"C:\temp\Chap0101.pdf" , FileMode.Create));
// step 3: we open the document
document.Open();
// step 4: we Add a paragraph to the document
document.Add(new Paragraph( "Hello World"));
}
catch (DocumentException de)
{
Console.Error.WriteLine(de.Message);
}
catch ( IOException ioe)
{
Console.Error.WriteLine(ioe.Message);
}

// step 5: we close the document
document.Close();

Some Article Links

iTextSharp(iText#) example in asp.net - http://blog.rubypdf.com/2006/10/25/itextsharpitext-example-in-aspnet/
How to generate Arabic PDF files - http://www.developerfusion.co.uk/forums/p/40095/146877/

Friday, December 21, 2007

DLL Registration failure in VC++

Filter or DLL or .ocx registration Error :
-------------------------------------------


Eventhough the DLL compiles and links well  while registering the filter or DLL or.ocx using regsvr32 utility, I got this Error.

---------------------------
RegSvr32
---------------------------
.\Debug\HTTPWriterSinkFilterd.ax was loaded, but the DllRegisterServer entry point was not found.

.\Debug\HTTPWriterSinkFilterd.ax does not appear to be a .DLL or .OCX file.
---------------------------
OK  
---------------------------

Solution Steps :
---------------

 
 1.I Opened that DLL file in "Depends viewer" available in a visual studio tools
 2. no function is exported from the DLL or filter file.
 3.For Exporting the Functions, I used the .def file (module definition file).
 4. Next I have opened the DLL,ax files in "Depends viewer" that are successfully registered 
 There the Dependency viewer displays the exported functions.
 5. So the problem is in Exporting the functions
 6. Next I opened the Project->Settings-> Linker->input ...

 and I checked anywhere my .def file is specified there is nothing like that.

 So I added the the following options

  Project -> Settings-> Linker -> Input -> /DEF:My.def


Now I compiled the application and register it with regsvr32 utitily.
Now the registeration is done successfully .

if I opened that registered DLL in "Depends viewer", It displays the exported functions.

 

PostScript :
------------ 

 In Some DLLs,even though they created the application as DLL,
without including this  "/DEF:my.def", that dll also registers well.