Tuesday, December 16, 2014

How to Integerate FaceBook Login Button In a Page.

In this article i will explain how to integrate  facebook login button in your aspnet website.

First,we have to create a application for this 
Click on the below link  http://developers.facebook.com/setup/ then it will display window like this




Click on Close

Click on Register Now.





Click on No Button

Click on Register Now,



Click on Done Button.

Click on WebSite


Click on Skip and Create App ID





Click on Create Apple ID


Click on Submit

After clicking on Submit , the following screen is displayed


Now, click on Test Apps in the left side menu




Click on Create Test App

Click on Create Test App


Click on  Getting Started.


Now, Give your site URL.




And Click on Next Button

Click on Skip Quick Start

Now, copy this app id 


Now, Go to Default222.aspx page and  write the following code as below


<table align="center">
            <tbody>
                <tr>
                    <td align="center" style="color#33ccfffont-sizelargefont-weightboldtext-transformcapitalize;"></td>
                </tr>
                <tr>
                    <td align="center" style="margin-top350px;">
                        <script type="text/javascript">
                            // Load the SDK Asynchronously  
                            (function (d) {
                                var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
                                if (d.getElementById(id)) { return; }
                                js = d.createElement('script'); js.id = id; js.async = true;
                                js.src = "//connect.facebook.net/en_US/all.js";
                                ref.parentNode.insertBefore(js, ref);
                            }(document));

                            // Init the SDK upon load  
                            window.fbAsyncInit = function () {
                                FB.init({
                                    appId: '000000000000'// App ID  
                                    channelUrl: '//' + window.location.hostname + '/channel'// Path to your Channel File  
                                    status: true// check login status  
                                    cookie: true// enable cookies to allow the server to access the session  
                                    xfbml: true  // parse XFBML  
                                });

                                // listen for and handle auth.statusChange events  
                                FB.Event.subscribe('auth.statusChange'function (response) {
                                    if (response.authResponse) {
                                        // user has auth'd your app and is logged into Facebook  
                                        FB.api('/me'function (me) {
                                            if (me.name) {
                                                document.getElementById('auth-displayname').innerHTML = me.name;
                                            }
                                        })
                                        document.getElementById('auth-loggedout').style.display = 'none';
                                        document.getElementById('auth-loggedin').style.display = 'block';
                                    } else {
                                        // user has not auth'd your app, or is not logged into Facebook  
                                        document.getElementById('auth-loggedout').style.display = 'block';
                                        document.getElementById('auth-loggedin').style.display = 'none';
                                    }
                                });
                                $("#auth-logoutlink").click(function () { FB.logout(function () { window.location.reload(); }); });
                            }
                        </script>



                        <h1>asp.net facebook login</h1>
                        <div id="auth-status">
                            <div id="auth-loggedout">
                                <div autologoutlink="true" class="fb-login-button" scope="email,user_checkins">
                                    Login with Facebook
                                </div>
                            </div>
                            <div id="auth-loggedin" style="displaynone;">
                                Hi, <span id="auth-displayname">dotnet developers</span>(<a href="http://www.dfdsfasdfasfs.com/post-edit.g?blogID=892712659100500876&postID=sdafdsfsfsfsfsfsf#" id="auth-logoutlink">Signout</a>)
                            </div>
                        </div>
                    </td>
                </tr>
            </tbody>
        </table>



Run, your page Default222.aspx and see the output






Click on Login with FaceBook



Click on okay button


Monday, December 15, 2014

SQL SERVER NO LOCK

SQL Server NOLOCK 
Here is a query that returns all of the data from the Table Emp
run in query window 1
select * from Employee





I can see there is only one record that has a Salary





Let's say another user runs the  query to updates the records, but it is not yet committed to the database so the records are locked.

Now, open  new window and run the below query 
run in query window 2
BEGIN TRAN
UPDATE Employee SET Salary = '3333'
-- ROLLBACK or COMMIT

If I run the same query from above again you will notice that it never completes, because the
 UPDATE has not yet been committed.

run in query window 1
select * from Employee

Now when i Run  

sp_who2    I can see that the SELECT statement is being blocked. I will need to either cancel this query or COMMIT or ROLLBACK the query in window two for this to complete. For this example I am going to cancel the SELECT query





To get around the locked records, I can use the NOLOCK hint as shown below and the query 
will complete even though the query in window  is still running and has not been committed or 
rolled back.


If you notice below the SALARY  column now has 3333 for all records. This is because the UPDATE in window 2 updated these records. Even though that transaction has not been committed, since we are using the NOLOCK hint SQL Server ignores the locks and returns the data. If the UPDATE is rolled back the data will revert back to what it looked like before, so this is considered a Dirty Read.

If I rollback the UPDATE using the ROLLBACK command and rerun the SELECT query we can see the SALARY is back to what it looked like before.


-- run in query window 2
ROLLBACK
-- run in query window 1
select * from Employee(NOLOCK)
OR
SELECT * FROM Employee





Working With Xml DataTypes

DECLARE @StudentDetails XML='<StudentsDetails><StudentHeader Code="lt8990" JoiningDate="12 Nov 2014" OpeningDate="12 Nov 2014" ExpiryDate="12 Nov 2014" RollNumber="ref333">
</StudentHeader></StudentsDetails>'

DECLARE @StudentDetail AS TABLE 
(
Code NVARCHAR(200), 
JoiningDate DATETIME, 
OpeningDate DATETIME, 
ExpiryDate DATETIME, 
RollNumber NVARCHAR(300)
)
INSERT INTO @StudentDetail
(
Code, 
JoiningDate, 
OpeningDate, 
ExpiryDate, 
RollNumber
)
SELECT
Students.value('(@Code)', 'NVARCHAR(200)'),
Students.value('(@JoiningDate)', 'DateTime'),
Students.value('(@OpeningDate)', 'DateTime'),
Students.value('(@ExpiryDate)', 'DateTime'),
Students.value('(@RollNumber)', 'NVARCHAR(200)')
FROM @StudentDetails.nodes('/StudentsDetails/StudentHeader') 
AS Data(Students)

SELECT * FROM @StudentDetail






DECLARE @StudentDetails XML='<StudentsDetails>
       <StudentHeader>lt8990</StudentHeader>
       <JoiningDate>12 Nov 2014</JoiningDate>
       <OpeningDate>12 Nov 2014</OpeningDate>
   </StudentsDetails>'

   DECLARE @StudentDetail AS TABLE 
(
StudentHeader NVARCHAR(200), 
JoiningDate DATETIME, 
OpeningDate DATETIME
)
INSERT INTO @StudentDetail
(
StudentHeader, 
JoiningDate, 
OpeningDate
)
SELECT
Students.value('(StudentHeader[1])', 'NVARCHAR(200)'),
Students.value('(JoiningDate[1])', 'DateTime'),
Students.value('(OpeningDate[1])', 'DateTime')
FROM @StudentDetails.nodes('/StudentsDetails') AS Data(Students)

SELECT * FROM @StudentDetail



Kubernetes

Prerequisites We assume anyone who wants to understand Kubernetes should have an understating of how the Docker works, how the Docker images...