Friday, July 14, 2023

Ad hoc queries

 select max(cast(convert(varchar, convert(datetime, [CR_DATE], 103), 101) as date))  from OPENDATASOURCE (        'SQLNCLI'

        ,'Data Source=*********;Initial Catalog=****;User ID=**;Password=***

        ).table

Wednesday, October 7, 2020

Difference Between SOAP And REST

 

 SOAP And REST😋

SOAP
REST
Slower due to defined specification
Faster as there is no defined specifications
Request and response format is always XML
Request and Response can be either in XML, JSON or plain text.
Requires bandwidth as the amount of data to transfer is a lot
Can work perfect even in case of low bandwidth
It is a protocol that defines some specifications which are to be followed strictly
Due to its architectural approach, it doesn’t have any strict specification
Less preferred due to its complex design
Easy to implement
Highly secure as it has its own security.
Doesn’t have its own security. Hence depends on application defined security
HTTP SSL Encryption and WS-Security encryption are used to secure SOAP messages
Data can be secured only by HTTP SSL Encryption
No need of caching mechanism
Requires caching mechanism
Can communicate over HTTP as well as SMTP
Can communicate only over HTTP

Integrating Google Sign-In into your web app

 Google Sign-In manages the OAuth 2.0 flow and token lifecycle, simplifying your integration with Google APIs. A user always has the option to revoke access to an application at any time.

This document describes how to complete a basic Google Sign-In integration.

Create authorization credentials

Any application that uses OAuth 2.0 to access Google APIs must have authorization credentials that identify the application to Google's OAuth 2.0 server. The following steps explain how to create credentials for your project. Your applications can then use the credentials to access APIs that you have enabled for that project.

  1. Go to the Credentials page.
  2. Click Create credentials > OAuth client ID.
  3. Select the Web application application type.
  4. Name your OAuth 2.0 client and click Create

After configuration is complete, take note of the client ID that was created. You will need the client ID to complete the next steps. (A client secret is also created, but you need it only for server-side operations.)

Load the Google Platform Library

You must include the Google Platform Library on your web pages that integrate Google Sign-In.

<script src="https://apis.google.com/js/platform.js" async defer></script>

Specify your app's client ID

Specify the client ID you created for your app in the Google Developers Console with the google-signin-client_id meta element.

<meta name="google-signin-client_id" content="YOUR_CLIENT_ID.apps.googleusercontent.com">

Add a Google Sign-In button

The easiest way to add a Google Sign-In button to your site is to use an automatically rendered sign-in button. With only a few lines of code, you can add a button that automatically configures itself to have the appropriate text, logo, and colors for the sign-in state of the user and the scopes you request.

To create a Google Sign-In button that uses the default settings, add a div element with the class g-signin2 to your sign-in page:

<div class="g-signin2" data-onsuccess="onSignIn"></div>

The following is an example of the default Google Sign-In button:

Get profile information

After you have signed in a user with Google using the default scopes, you can access the user's Google ID, name, profile URL, and email address.

To retrieve profile information for a user, use the getBasicProfile() method.

function onSignIn(googleUser) {
 
var profile = googleUser.getBasicProfile();
  console
.log('ID: ' + profile.getId()); // Do not send to your backend! Use an ID token instead.
  console
.log('Name: ' + profile.getName());
  console
.log('Image URL: ' + profile.getImageUrl());
  console
.log('Email: ' + profile.getEmail()); // This is null if the 'email' scope is not present.
}

Sign out a user

You can enable users to sign out of your app without signing out of Google by adding a sign-out button or link to your site. To create a sign-out link, attach a function that calls the GoogleAuth.signOut() method to the link's onclick event.

<a href="#" onclick="signOut();">Sign out</a>
<script>
 
function signOut() {
   
var auth2 = gapi.auth2.getAuthInstance();
    auth2
.signOut().then(function () {
      console
.log('User signed out.');
   
});
 
}
</script>

Thursday, May 7, 2020

Maintain session for different user in same browser but different tab

Put code under system.web

  <sessionState mode="InProc" cookieless="UseUri" timeout="20000"></sessionState>

Sunday, February 9, 2020

Order By REGEX exp

select * from RES_MSTPLOTMASTER order by
regexp_substr(NVL (plotnumber, PLOTNUMBER), '^\D*') nulls first,
  to_number(regexp_substr(NVL (plotnumber, PLOTNUMBER), '\d+'))

Thursday, February 6, 2020

EMAIL WITH C#

private void sendMail()
    {
        MailMessage msg = new MailMessage();
        string ToMail = "*******@gmail.com";
        try
        {
            msg.From = new MailAddress("*****@gmail.com");

            string[] multi=ToMail.Split(',');

            foreach (string mailTo in multi)
            {
                msg.To.Add(mailTo);
            }
           
            msg.Body = "Residential Property Details. </br> </br>Please Verify from the department!!. <br> Thank You.";
            msg.Attachments.Add(new Attachment(pdfFile));
            msg.Attachments.Add(new Attachment(pdfFile1));
            msg.IsBodyHtml = true;
            msg.Subject = "Property Details As On : " + DateTime.Now.ToString() + " date";
            SmtpClient smt = new SmtpClient("smtp.gmail.com");
            smt.Port = 587;
            smt.Credentials = new NetworkCredential("*****@gmail.com", "PASS***");
            smt.EnableSsl = true;
            smt.Send(msg);
            //string script = "<script>alert('Mail Sent Successfully')</script>";
            //ClientScript.RegisterStartupScript(this.GetType(), "mailSent", script);
            ClientScript.RegisterStartupScript(typeof(Page), "closePage", "window.open('close.htm', '_self', null);", true);
        }
        catch (Exception ex)
        {
        }
        finally
        {
            /*
                so that the error "The process cannot access the file because it is being used by another process" should not occur when we immediately
                try to send another mail after one has been sent.
                w3wp.exe:5800 CREATE D:\\Testcrystal.pdf
                w3wp.exe:5800 WRITE D:\\Testcrystal.pdf
                w3wp.exe:5800 CLOSE D:\\Testcrystal.pdf
                w3wp.exe:5800 OPEN D:\\Testcrystal.pdf
                w3wp.exe:5800 READ D:\\Testcrystal.pdf
                As you can see, it created the PDF, it wrote the PDF, it closed the PDF (expected).
                Then, there was an unexpected Open, Read, without close immediately after the file was created. So that's why we've to close the file after
sending
             * it through mail because msg will open and read the file but the file is not close automattically after sending it. There will no error while sending
the first
             * mail but when you try to send the next mail one after the other the above error will rise. to avoid this error we are using the Dispose methods
to release
             * all the resources which are being used.
            */
            msg.Dispose();
        }
    }

Friday, January 10, 2020

Casting in SQL

/****** Script for SelectTopNRows command from SSMS  ******/
SELECT TOP 1000 [Date]
      ,[Time]
      ,[Total_Discharge_Rate]
      ,CAST(Todays_Discharge  AS FLOAT) as Todays_Discharge,Todays_Discharge as old
      ,[Total_Inflow]
      ,[Dam_Available_Quantity]
      ,[Upstream_Level]
      ,[Downstream_Level]
  FROM [BIPS_SYS].[dbo].[Other_Data] where [Date]=cast('10/01/2020' as date)

Ad hoc queries

 select max(cast(convert(varchar, convert(datetime, [CR_DATE], 103), 101) as date))  from OPENDATASOURCE (        'SQLNCLI'         ...