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/