Sunday, December 08, 2013

Namokar Mantra –Peaceful mantra chant – new Windows app by Indiandotnet

 

Dear All,

It give me immense pleasure to share that we have launched a new windows app for all my Jain friends.

Namokarmantra_Banner

You can download the app from windows store.

Click on the  Download URL

Thanks & Best Regards,

Rajat Jaiswal

Monday, November 04, 2013

EOMONTH() - New function to get last date of month

 

Dear All,

First of all Wish you and your family a Happy deepawali.

Now “EOMONTH” is new function in SQL Server 2012 by the name you understand it give last date of month.

Please see below screen to understand it more

EOMONTH-End of Month

I hope you will enjoy  this function with deepawali festival.

Enjoy

Thanks & Best Regards,

Rajat Jaiswal

Monday, October 28, 2013

Sai mantra – New Windows app for peace, prosperity and joy

Dear All,

It give me immense pleasure to introduce new windows app  “Sai Mantra”.

Enjoy the sai mantra.

saiMantra_app

You can download the windows app from http://www.windowsphone.com/en-us/store/app/saimantra/653b08fc-36b4-4312-a754-8536a2398892

Thanks & Best Regards,

Rajat Jaiswal

Friday, October 25, 2013

New Windows Phone App – Mata Mantra Hurry up and download now.

 

Dear All,

How are you ?

It give me pleasure to introduce a new application develop by  “Indiandotnet”.  The application is all about “Durga Mantra” which increase peace, prosperity  so enjoy by downloading following windows app with following link.

http://www.windowsphone.com/en-us/store/app/mataji-mantra/dcfa42bd-09fc-4c9e-bd66-a9caa5e75864

Mataji_app

Enjoy :)

Thanks & Best Regards,

Rajat Jaiswal

Monday, October 21, 2013

How to determine list of all the databases and size of the database ?

 

Dear All,

Sometimes you require list of all the database and size.

To achieve this we need to write  following script

 

   1:  
   2: SELECT sd.name,Convert(Decimal(10,0),(mf.size /1024)) As size
   3: FROM 
   4: sysdatabases sd
   5: INNER JOIN sys.master_files mf ON mf.database_id = 
   6: sd.dbid
   7:  
   8: AND mf.type = 0 
   9: WHERE sd.Name Not IN ('MASTER','tempdb','Model','MSDB')

 



Hope it will resolve your query. Enjoy :)


Rajat Jaiswal

Monday, October 14, 2013

How to do 7zip programmatically using C# ?

Dear All,

Some times it may be possible you require to  make zip of  a file or directory.

so here is simple example.

To start it you have to download “SevenZipSharp.dll”, “7z.dll” you can download sdk from http://www.7-zip.org/sdk.html

Once you download sdk copy above 2 DLL in your project bin folder.

Now write below code which i am writing here

   1:  
   2: public bool CompressFolder(String 
   3: backupFolder)
   4:  
   5: {
   6:  
   7: try
   8:  
   9: {
  10:  
  11: SevenZipCompressor sz = new SevenZipCompressor(); 
  12:  
  13: SevenZip.SevenZipCompressor.SetLibraryPath(DLLPath);
  14:  
  15: sz.CompressionLevel = 
  16: CompressionLevel.Ultra;
  17:  
  18: sz.CompressionMode = 
  19: CompressionMode.Create;
  20:  
  21: sz.CompressionMethod = 
  22: CompressionMethod.Default;
  23:  
  24: sz.FastCompression = 
  25: true;
  26:  
  27: sz.CompressDirectory(backupFolder, BackupPath + "\\" + 
  28: DateTime.Now.Date.ToString("yyyyMMddHHmmss") + 
  29: "_7Zip.7z");
  30:  
  31: Directory.Delete(backupFolder,true);
  32:  
  33: return true;
  34:  
  35: }
  36:  catch (Exception 
  37: ex)
  38:  
  39: {
  40:  
  41: throw ex;
  42:  }



Now let me describe the code to you.


This is function which compress the folder to 7zip what ever pass as a paramter


in this function we have created a sevenzip compressor object


SevenZip.SevenZipCompressor.SetLibraryPath(DLLPath);


in the above line we set the DLLpath which is basically your bin folder path


sz.CompressionLevel = CompressionLevel.Ultra; is compress level which can be different according to your need.


sz.CompressDirectory(backupFolder, BackupPath + "\\" + DateTime.Now.Date.ToString("yyyyMMddHHmmss") + "_7Zip.7z");


above row compress the directory of backupfolder and rename with datetime_7zip.7z


I hope this will help you.


Enjoy 7zip.


Thanks & Best Regards,


Rajat Jaiswla

Monday, September 30, 2013

How to create RESTful WCF Service ?

 

Hello friends,

Many times you heard about RESTful services. I know most of you pretty much aware also but let me Introduce in my way.

The first question  come to your mind which is

What is REST?

So here is my answer it is Representational State Transfer.

Its all about using HTTP protocol.With the help of this you can perform various action like PUT,GET,POST,DELETE etc.

Suppose you have a student database and want to pull a particular roll number's record. then in that case you will do following thing
http://indiandotnet.in/GetData/Name

Where 123 is roll number. So with simple URL you can fetch the information similar way you can edit,delete and create student record also with similar type of URL(may be few parameters vary depending on your requirement)

How to create a RESTFUL WCF services ?

Creating RESTFUL WCF service is not a typical part Lets understand it by Step by Step Example

So lets start a new project WCF project as shown in below image i have added one project

 REST_Solution_1

Step 2:-

Now  i am adding two methods here which are  basically for showing two different format XML & JASON using REST WCF application. The important point

definedTwomethod

Step 3:-

Now to make this method as a RESTful service we need to add WebGET attribute as  i am dealing with only Fetching and GET method. as shown in above image.  I am using WebGet but you can try different method like, POST,DELETE,PUT using Web Invoke attribute.

To make this simple to understand i am using Student class with only two property first name & Last Name

Student_Class

Step 4: Below are the two methods in which from one method  we are responding XML & from one method we are returning the JASON.

Method_Definition

Step5:

Once step 4 is done we will configure most the most important part of RESTFUL WCF application which is binding , contract  information etc.

Capture

Once the above configuration is done just run the service.

lets run it with fiddler to understand it more.

When we  running the URL with GETData method as shown it below

  http://localhost:51550/Service1.svc/GetData/Name 

running_1

When we run it we get xml Response as shown below

Rest_Response_XML_2

Now we are running other method using JASON method (as shown in below method)

We will get following response.

Response_XML_3

So in this way we can create RESTFul application.

You can download  code from

Thanks & Best Regards,

Rajat Jaiswal

Friday, September 13, 2013

How to create SELF signed certificate with IIS ?

 

Dear friend,

How to create Self Signed Certificate with IIS ?

Sometimes you require Certificate to test various objectives. to achieve this task lets start with step by step as shown below

Step 1: Open IIS and click on server certificates options as shown below

Self_Signed_Certificate_1

 

Step 2:- Once you then server certificates option you will get below screen. If you see on right side there are couple of action items in this we have one action item which is “Create –Self Signed Certificate”. Now click on this action item.

create_Self_Signed_certificate_2

Step 3:- Once you clicked on “Create- Self Signed certificate” you will get below option you just need to write a friendly name and you are good to go.

Self_Signed_Certificate_2

Sep 4:- Once you full fill the detail and click on the finish button. your certificate is ready now you can use it just see in below image.

Self_Signed_Certificate_3

I hope you are good to go with this.

Thanks & Regards,

Rajat Jaiswal

Wednesday, September 11, 2013

Step by Step Example to implement FaceBook local currency payments (latest September-2013 changes) with JavaScript SDK in ASP.NET ?

 

Step by Step Example to implement FaceBook local currency payments (latest September-2013 changes) with JavaScript SDK in ASP.NET ?

Dear Friends,

I know you came to this blog because you really frustrated how to implement the chances which introduce by FaceBook in local currency payment changes of September 2013 because you not found any specific example so far with JavaScript SDK and ASP.NET .

So don’t worry actually i was also frustrated with latest changes because whatever i have implemented  before this changes is very easy straight forward and have proper example in Facebook developer forum but for this new changes i did not find any thing which is relevant.

With following example you can achieve Static pricing & Dynamic pricing with same line of code.

So here  is the basic steps which you need to follow to achieve Facebook payment dialog and process payment

1. Create a  new ASPX page i have created page with name “MyProductDetail.aspx” in attached sample

2. On this page add meta tags with and also add run at server property (if you want dynamic pricing) see below snap shot

facebook_Local_currency_payment_Sample_Step_1

3. Now for this page in page load event  (C# code) you need to write following things according to your requirement

in brief i can say on page load event we set all the meta tag at runtime according to query string parameter which will be dynamic . just check below screen.

facebook_Local_currency_payment_Sample_Step_2

4. Now open  the page on which you need to implement payment. Add the payment javascript as shown below to invoke payment dialog. You just need to copy the detail of JavaScript from facebook’s new  pay dialog example

facebook_Local_currency_payment_Sample_Step_3

Now you are good to go to run this.

You can test the product URL with value in facebook debugger

whole code can be download from download code.

I hope this will help you in developing the facebook payment integration.

 

Thanks

Rajat Jaiswal

Friday, September 06, 2013

Windows 8.1 & VS 2013 – WOW lets go for it.

 

Dear Friends,

Microsoft Shared in build 2013 about latest creation which is Windows 8.1 & VS 2013.

You can check out the video of build  keynote 1  at Keynote1

and Keynote 2 at Keynote2

Enjoy the videos.

You can enjoy preview version for windows 8.1 at http://www.microsoft.com/en-us/windows/enterprise/products-and-technologies/windows-8-1/default.aspx

You can take a look of  Visual studio 2013 preview version at http://www.microsoft.com/visualstudio/eng/2013-preview

Enjoy

Thank & Regards,

Rajat Jaiswal

What is Generic in .NET (Hindi)?

 

Hello Friends,

In today’s program i have discussed Generic in .NET with Arjun Singh. Enjoy the discussion and  please provide your feedback after viewing it.

You can watch it at

 

Generics in .NET by Indiandotnet

Thanks & Best Regards ,

Rajat Jaiswal

Change your database mode from Read only to Read write and vice versa

Dear Friends,

Some time you want to change your database mode like make your database to read only and then again read write mode. So the simple scripts which help you to make your database read only

 ALTER DATABASE YourDatabaseName  SET READ_ONLY WITH NO_WAIT

With the above command your database comes in Read only mode

Now how can you change the mode back to read write mode So below is the again simplest script

ALTER DATABASE YourDatabaseName SET READ_WRITE WITH NO_WAIT

With  the above command your database comes in read write mode

Thanks & best regards,

Rajat Jaiswal

Improve Query Performance by just a small change “OPTIMIZE FOR”

 

Dear All,

If your SQL statement is slow then sometimes just a little change help you a lot in my case it was helpful hope it will helpful in your problem also.

Suppose you want to fetch  data from two large tables  for a specific constant value. Let take example of this

suppose you have two table 1. Student table 2. student enrollment table both table have large amount of data.

Now you want to fetch max record of enrollment id student wise for  particular status in Student enrollment  table.

Then for this you need to write following query .

SELECT ISNULL(MAX(EnrollmentHistoryId),0) AS maxenrmollmentHistoryId ,     
          se.StudentId      
      FROM dbo.StudentEnrollment se WITH (NOLOCK)       
      INNER JOIN dbo.student s WITH (NOLOCK) ON s.studentId = sh.studentId       
                            AND s. YearId = @YearID
      WHERE sh.Statusid = @StatusActivateId 
      GROUP BY sh.serializationid

Now if you find here the StatusActivateId  is fixed in this case so  we need to optimize this statement   here we used optimize for option 

SELECT ISNULL(MAX(EnrollmentHistoryId),0) AS maxenrmollmentHistoryId ,     
           se.StudentId      
       FROM dbo.StudentEnrollment se WITH (NOLOCK)       
       INNER JOIN dbo.student s WITH (NOLOCK) ON s.studentId = sh.studentId       
                             AND s. YearId = @YearID
       WHERE sh.Statusid = @StatusActivateId 
       GROUP BY sh.serializationid
     OPTION (OPTIMIZE FOR (@StatusActivateId =21))

if you  compare above statements you will find there is only one difference in last line which is option (OPTIMIZE FOR)

As i shared earlier we know the fixed value so we explicitly added the variable name and value for which we need to optimization for the query.

In SQL Server 2008  this option ins more robust which taking any unknown option.

I hope it will help you some where . Just hit and try.

Learn & Share

Thanks

Rajat Jaiswal

How to Improve query by reducing CXPACKET WAIT type with simple option?

 

Dear All,

I am sure you have faced this problem that when you running query like Aggregation , grouping etc then due to default setting the query uses all the CPU available to machine and this case is parallelism.

Now you are thinking its very good your query will be faster if it distributed amount the multiple processor.

but sometime this is not the case due to this distribution suppose one process is processing slowly then  overall your combine result have to wait this wait is “CXPACKET WAIT”

Now you are wondering how to handle this. so no worries Microsoft provided option to tweak this setting with MAXDOP (Maximum degree of Parallelism ) option.

You can change overall SQL Server setting or for particular query.

see below screen from where you can change MAXDOP settings.

MAXDOP

Now the default value is “0” . It means can use all the CPU.

Now this is not we generally prefer instead of this we can use MAXDOP option in query option.

But before doing this you just need to cross check whether you require it or not ?

if your CXPACKET wait type  if too much then you can use this option

SELECT ISNULL(MAX(EnrollmentHistoryId),0) AS maxenrmollmentHistoryId ,     
           se.StudentId      
       FROM dbo.StudentEnrollment se WITH (NOLOCK)       
       INNER JOIN dbo.student s WITH (NOLOCK) ON s.studentId = sh.studentId       
                             AND s. YearId = @YearID
       WHERE sh.Statusid = @StatusActivateId 
       GROUP BY sh.StudentID
    OPTION (MAXDOP 1)

in the above query we used MAXDOP 1 which means query use only once CPU.

With this option the CXPACKET will reduce but it may be possible your query may take time so be careful.

But this is good option. It helped me to reduce the time.

Lets try if this can help you.

Enjoy  learning :)

Thanks & Best Regards,

Rajat Jaiswal

Monday, July 01, 2013

How to invoke a Java script after completion of server event of asp.net control ?

}

Dear All,

Sometime you fall in this situation where you need to invoke a java script just after your server event of asp.net control. Lets  understand with an example suppose you have a  asp.net server control button on your web page now after clicking this button page will post back and everything is added in database and then after you need to show  Java script alert like Record is Saved successfully.

so to achieve this task you need to do following things

1.) Write a Javascript function for showing custom alert message  just like below

<script type="text/javascript">
        function onSuccessful() {

              alert(‘Data Saved Successfully’);

}

function onError() {

alert (‘Data not saved successfully’);

}

2) In server side button event you need to do following thing

protected void btnFaceBookLogin_Click(object sender, EventArgs e)
     {
         try
         {
             if (CheckLogin())
             {

ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "RegisterSuccess", "onSuccessful();", true);

}

else {

ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "Registerfail", "onError();", true);

}

} catch (Exception ex) {

error.log(ex);

}

}

So when you compile it and run it after button click’s server side event javascript will fire according to checklogin  status.

Here the important note is to register the script with unique name.

I hope this will help you also.

Enjoy cheers :)

Rajat Jaiswal