Wednesday, December 22, 2021

Create ORACLE Query to Get Concated string Values from relational table

Below Query will help to get the requery result from concated string.

Create Table Schema

  CREATE TABLE "TBL_VKYC_CRMDETAILS" 

   (

   "ID" NUMBER(10,0) NOT NULL ENABLE, 

"PRODUCTTYPE" VARCHAR2(50 BYTE) NOT NULL ENABLE, 

"REFNO" VARCHAR2(50 BYTE) NOT NULL ENABLE, 

"CRMCASENO" VARCHAR2(50 BYTE) NOT NULL ENABLE, 

"CREATEDDATE" VARCHAR2(50 BYTE) NOT NULL ENABLE, 

"SQSREFID" VARCHAR2(100 BYTE) DEFAULT NULL, 

"CRMDOCRESPONSEID" VARCHAR2(100 BYTE) DEFAULT NULL, 

"SQSFILENAME" VARCHAR2(2000 BYTE) DEFAULT NULL

   );



CREATE SEQUENCE  SEQ_TBL_VKYC_CRMDETAILS

MINVALUE 1 MAXVALUE 9999999999999999999999999999 INCREMENT BY 1 START WITH 1 CACHE 20 NOORDER  NOCYCLE ;


CREATE OR REPLACE TRIGGER TBL_VKYC_CRMDETAILS_SEQ 

BEFORE INSERT ON TBL_VKYC_CRMDETAILS 

FOR EACH ROW

BEGIN

  SELECT SEQ_TBL_VKYC_CRMDETAILS.NEXTVAL

  INTO   :new.id

  FROM   dual;

END;

/


ALTER TRIGGER TBL_VKYC_CRMDETAILS_SEQ ENABLE;


--================

Like string is concatenated with comma seperate string/value, get the comma seperate value from relational table in rows, later get values for all rows and again convert into single column on ORACLE


Create table tblFirst(Id int, Name VARCHAR2(50), CompanyIds varchar2(50))

insert into tblFirst(id, Name, CompanyIds) values (1, 'Murli', '1')

insert into tblFirst(id, Name, CompanyIds) values (2, 'User 1', '1,2')

insert into tblFirst(id, Name, CompanyIds) values (3, 'User 2', '1,2')

insert into tblFirst(id, Name, CompanyIds) values (4, 'User 3', '1,2,3')

insert into tblFirst(id, Name, CompanyIds) values (5, 'User 0', '1,2')

select * from tblFirst

Commit

--------------------------------

Create table tblCompany(Id int, CompanyName varchar2(50))

insert into tblCompany(id, CompanyName) values (1, 'Company A');

insert into tblCompany(id, CompanyName) values (2, 'Company B');

insert into tblCompany(id, CompanyName) values (3, 'Company C');

select * from tblCompany

Commit

------------------------------

select t1.*, (select  listagg(CompanyName,',')  WITHIN GROUP (ORDER BY 1) --product_variant_name, product_category,product_variant_id

from tblCompany C 

where C.id in

  (select regexp_substr(t1.CompanyIds,'[^,]+', 1, level) 

   from dual 

   connect BY regexp_substr(t1.CompanyIds, '[^,]+', 1, level) 

   is not null)) "Company Names" from tblFirst t1

order by t1.id desc

Output will look like this



Wednesday, December 8, 2021

Create Seperate Port from Core Appliation

  "Kestrel": {

    "EndPoints": {

      "Http": {

        "Url": "http://localhost:4300"

      }

    }

  },


Add Above set of lines on appsettings.json

Monday, November 8, 2021

Disable Link from HTML

  $('#lnkReInitiate').on('click', function () {

                if ($("#lnkReInitiate").hasClass("disabled-link")) {

                    return false;

                } else {

                    $("#lnkReInitiate").addClass("disabled-link");

                }

            });


 .disabled-link{

                cursor: default;

                pointer-events: none;        

                text-decoration: none;

                /*color: grey;*/

                background: gray;

            }

Tuesday, October 19, 2021

Get ErrorMessage from Code Behind in .Net

Below Code is to get the error message from server side 

foreach (BaseValidator v in Page.Validators)

                {

                    if (!v.IsValid)

                    {

                        Response.Write(v.ErrorMessage);

                    }

                }

Tuesday, October 12, 2021

To Avoid Deadlock

 private static readonly object lockObject = new object();


lock (lockObject)
{


}

Friday, July 30, 2021

The page cannot be displayed because an internal server error has occurred.

IIS 6
<configuration>
    <system.web>
        <customErrors mode="Off"/>
        <compilation debug="true"/>
    </system.web>
</configuration>
IIS 7

<configuration>
    <system.webServer>
        <httpErrors errorMode="Detailed" />
        <asp scriptErrorSentToBrowser="true"/>
    </system.webServer>
    <system.web>
        <customErrors mode="Off"/>
        <compilation debug="true"/>
    </system.web>
</configuration>
IIS 8
<system.web>
   <customErrors mode="Off" />
</system.web>
<system.webServer>
   <httpErrors existingResponse="PassThrough" errorMode="Detailed"/>
</system.webServer>


For Details Check on Link

Friday, June 18, 2021

Porting Mobile to Desktop

After allowing Android debuggin mode, Type below line of code on desktop browser, Crome Browser will display all the opne website list in Mobile browser, Any you mobile browser change you can see on desktop. chrome://inspect/#devices

Tuesday, June 8, 2021

DeserializeObject JSON to Object in asp.net C#, OR We can say Convert JSON to C# Object

using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Web.Script.Serialization;

string example = System.IO.File.ReadAllText("D://Result.txt");
var JsonResult = JObject.Parse(example);
if (JsonResult["transaction_details"] != null)
{
 var success = JsonResult["transaction_details"].First.ToString();
 if (success != null)
 {
  int len = success.ToString().IndexOf(":") + 1;
  var FinalJson = JObject.Parse(success.Substring(len));
  if (FinalJson != null)
  {
    IntentFlowProperty flight = Newtonsoft.Json.JsonConvert.DeserializeObject(FinalJson.ToString());
  }
 }
}
        
        
public class IntentFlowProperty
    {
        public string mihpayid { get; set; }
        public object request_id { get; set; }
        public object bank_ref_num { get; set; }
        public string amt { get; set; }
        public string transaction_amount { get; set; }
        public string txnid { get; set; }
        public string additional_charges { get; set; }
        public string productinfo { get; set; }
        public string firstname { get; set; }
        public string bankcode { get; set; }
        public object udf1 { get; set; }
        public object udf3 { get; set; }
        public object udf4 { get; set; }
        public object udf5 { get; set; }
        public object field2 { get; set; }
        public object field9 { get; set; }
        public object error_code { get; set; }
        public string addedon { get; set; }
        public string payment_source { get; set; }
        public object card_type { get; set; }
        public string error_Message { get; set; }
        public string net_amount_debit { get; set; }
        public string disc { get; set; }
        public string mode { get; set; }
        public string PG_TYPE { get; set; }
        public string card_no { get; set; }
        public object udf2 { get; set; }
        public object field5 { get; set; }
        public object field7 { get; set; }
        public string status { get; set; }
        public string unmappedstatus { get; set; }
        public object Merchant_UTR { get; set; }
        public object Settled_At { get; set; }
        public object App_Name { get; set; }
    }
    
   
JSON Strting:- {"status":1,"msg":"1 out of 1 Transactions Fetched Successfully","transaction_details":{"SAOAO1000010147-20210608185806":{"mihpayid":"403993715523232833","request_id":null,"bank_ref_num":null,"amt":"1.00","transaction_amount":"1.00","txnid":"SAOAO1000010147-20210608185806","additional_charges":"0.00","productinfo":"ABCDEF","firstname":"MURLI","bankcode":"INTENT","udf1":null,"udf3":null,"udf4":null,"udf5":null,"field2":null,"field9":null,"error_code":null,"addedon":"2021-06-08 18:58:07","payment_source":"payuPureS2S","card_type":null,"error_Message":"","net_amount_debit":"0.00","disc":"0.00","mode":"UPI","PG_TYPE":"UPI-PG","card_no":"","udf2":null,"field5":null,"field7":null,"status":"pending","unmappedstatus":"in progress","Merchant_UTR":null,"Settled_At":null,"App_Name":null}}}

Check Is Android Device from Asp.net

 		private bool IsAndroidMobile()
        {
            //https://www.thecodingguys.net/blog/asp-net-mobile-detection
            try
            {
                string strUserAgent = Request.UserAgent.ToString().ToLower();
                bool MobileDevice = Request.Browser.IsMobileDevice;
                if (strUserAgent != null)
                {
                    if (MobileDevice == true && strUserAgent.Contains("android"))
                    {
                        return true;
                    }
                }
            }
            catch
            {
                //throw;
            }
            return false;
        }

Wednesday, June 2, 2021

Sonar Qube Executon step

SonarScanner.MSBuild.exe begin /k:"project-key" /d:sonar.login="GeneratedToken"
MSBuild.exe path to solution.sln /t:Rebuild
SonarScanner.MSBuild.exe end /d:sonar.login="GeneratedToken"
SonarScanner.MSBuild.exe begin /k:"PROJECT_XXXX" /d:sonar.login="ccdf3266ae033ade65a691854ac73c6b51c846a6"
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe" D:\Murli\Projects\XYZ\XYZ_SonarQube.sln /t:Rebuild /p:VisualStudioVersion=14.0
SonarScanner.MSBuild.exe end /d:sonar.login="ccdf3266ae033ade65a691854ac73c6b51c846a6"

To know more https://docs.sonarqube.org/latest/analysis/scan/sonarscanner-for-msbuild/

Monday, January 4, 2021

Javascript getElementById based on a partial string

document.querySelector('[id$="MySufixIdString"]').id;

The selector means: get an element where the attribute [id] ending with the string "MySufixIdString".

^ matches the start
* matches any position
$ matches the end