protected void btnCheckApproval_Click(object sender, EventArgs e)
    {
        lblSummMessage.Text = string.Empty;
        ifmAuth.Style.Add("display", "none");
        ClsTCUtilsUploadHash clsTCUtil = new ClsTCUtilsUploadHash();

        encrypt = new ClsEncryption();
        //clsGstr1 = new ClsGSTR1();
        string      doc_category = "OTHER";
        string      DownCs       = clsTCUtil.GetDownloadCS(ClsCommon.eSignAPIKEY, ClsCommon.uuid);
        var         response     = clsTCUtil.GetSignedStatus(ClsCommon.eSignDomain, doc_category, DownCs);
        XmlDocument xDoc         = new XmlDocument();
        string      status       = string.Empty;

        xDoc.LoadXml(response.ToString());
        var node = xDoc.SelectSingleNode("docstatus");

        if (node.ChildNodes.Count > 0)
        {
            foreach (XmlNode n in node.ChildNodes)
            {
                status = n.FirstChild.Value;
                break;
            }
        }
        if (status != "")
        {
            lblSummMessage.Text = "Data Successfully Signed.";
        }
    }
    public string EncriptedOtp(string otp)
    {
        encrypt = new ClsEncryption();
        //string otp = "575757";
        string enc_Otp_key = encrypt.OTP_EncryptWithPublicKey(otp, Appkey);

        return(enc_Otp_key);
    }
    public string GetParamsForOtprequest()
    {
        encrypt = new ClsEncryption();
        Dictionary <string, string> parameters = new Dictionary <string, string>();
        string timestamp = DateTime.Now.ToString(DATE_FORMAT_DDMMYYYYHHMMSS) + generateRandomNumber(6);

        parameters.Add("action", "OTPREQUEST");
        parameters.Add("username", SBUserID.ToLower());//ClsCommon.SBUserID.ToLower()
        Appkey        = encrypt.GetKey();
        EncodedAppkey = encrypt.Encoded_AppKeyWithPublicKey(Appkey);
        parameters.Add("app_key", EncodedAppkey);
        var Response = CallOTPApi(OTPRequest_URL, parameters);

        return(Response);
    }
    protected void btnSendOtp_Click(object sender, EventArgs e)
    {
        DivOTP.Style.Add("display", "none");
        GSTR1Desc.Text = string.Empty;
        encrypt        = new ClsEncryption();

        var Resp = GetKeyOfNSDL();

        if (Resp != null)
        {
            JObject jObj = JObject.Parse(Resp.ToString());
            if (jObj.GetValue("status_cd") != null && jObj.GetValue("status_cd").ToString() == "1" && jObj.GetValue("enc_key") != null)
            {
                RecEnc_Key  = jObj.GetValue("enc_key").ToString();
                Session_Key = jObj.GetValue("session_id").ToString();
                RespMsgID   = jObj.GetValue("message_id").ToString();
                msg         = jObj.GetValue("message").ToString();

                asp_secret = encrypt.generateASPEncryptedKey(RecEnc_Key, Secret_Key);

                string resp = GetParamsForOtprequest();
                //OTPDivNew.Style.Add("display", "block");
                //return true;
                if (resp != null && resp != string.Empty)
                {
                    JObject OptReq = JObject.Parse(resp);

                    if (OptReq.GetValue("status_cd").ToString() == "1")
                    {
                        GSTR1Desc.ForeColor = System.Drawing.Color.Green;
                        GSTR1Desc.Text      = "OTP Send Successfully In Your Mobile And Email-ID.";
                        DivOTP.Style.Add("display", "block");
                    }
                    else
                    {
                        GSTR1Desc.ForeColor = System.Drawing.Color.Red;
                        DivOTP.Style.Add("display", "none");
                        GSTR1Desc.Text = "OTP Not Send.";
                    }
                }
            }
            else if (jObj.GetValue("message") != null && jObj.GetValue("message").ToString() != string.Empty)
            {
                GSTR1Desc.Text = jObj.GetValue("message").ToString();
            }
        }
    }
    public string GetKeyOfNSDL()
    {
        encrypt = new ClsEncryption();

        Dictionary <string, string> parameters = new Dictionary <string, string>();
        string timestamp = DateTime.Now.ToString(DATE_FORMAT_DDMMYYYYHHMMSS) + generateRandomNumber(6);

        parameters.Add("timestamp", timestamp);
        string SignedContent = encrypt.sign(ASPID + timestamp);

        parameters.Add("signed_content", SignedContent);
        parameters.Add("filler1", "");
        parameters.Add("filler2", "");
        string resp = CallApi(API_GET_KEY, parameters);

        return(resp);
    }
    protected void btnDSC_Click(object sender, EventArgs e)
    {
        lblSummMessage.Text = string.Empty;
        ifmAuth.Style.Add("display", "none");
        ClsTCUtilsUploadHash clsTCUtil = new ClsTCUtilsUploadHash();

        encrypt = new ClsEncryption();
        //clsGstr1 = new ClsGSTR1();

        string status = string.Empty;
        string msg    = string.Empty;
        string did    = string.Empty;

        string doc_category = "OTHER";
        string Email        = "*****@*****.**"; //"*****@*****.**";
        string SendMail     = "YES";

        if (ClsCommon.did != null)
        {
            var         response = clsTCUtil.MarkForSignCorpfileDSC(ClsCommon.uuid, ClsCommon.cheksum, doc_category, Email, SendMail);
            XmlDocument xDoc     = new XmlDocument();
            xDoc.LoadXml(response.ToString());
            var node = xDoc.SelectSingleNode("response");
            if (node.ChildNodes.Count > 0)
            {
                foreach (XmlNode n in node.ChildNodes)
                {
                    status = n.FirstChild.Value;
                    break;
                }
            }
            if (status == "0")
            {
                DSC = true;
                //string url = ClsCommon.URLForDownProduction + ClsCommon.DownDSCUpdater;
                ////string url = "https://files.truecopy.in/esign/deploy/DSCUpdaterQA.zip";
                //Response.Write("<script>window.open('" + url + "','_blank');</script>");
                lblSummMessage.Text    = "Data Mark Successfully For Dsc Signing.";
                divsuccessmsg.CssClass = "alert alert-success";
                divsuccessmsg.Visible  = true;
                divsuccessmsg.CssClass = "alert alert-success";
            }
        }
    }
    public void UploadForSigning()
    {
        lblSummMessage.Text = string.Empty;
        ClsTCUtilsUploadHash clsTCUtil = new ClsTCUtilsUploadHash();

        encrypt = new ClsEncryption();
        //clsGstr1 = new ClsGSTR1();

        byte[] encodeJson    = UTF8Encoding.UTF8.GetBytes(txtSummary.Text.Trim());
        string base64Payload = Convert.ToBase64String(encodeJson);

        var sha256_hash = clsTCUtil.sha256_hash(base64Payload);

        string email = "*****@*****.**";

        ClsCommon.uuid = "OSWA" + "180717" + ClsCommon.SBGSTINNO.Substring(0, 6) + ClsCommon.generateRandomNumber(16);

        var         json4  = clsTCUtil.uploadHash(ClsCommon.uuid, email, sha256_hash.ToString());
        XmlDocument xDoc   = new XmlDocument();
        string      status = string.Empty;

        xDoc.LoadXml(json4.ToString());
        var node = xDoc.SelectSingleNode("response");

        if (node.ChildNodes.Count > 0)
        {
            foreach (XmlNode n in node.ChildNodes)
            {
                status = n.FirstChild.Value;
                break;
            }
        }
        if (status == "0")
        {
            ClsCommon.did          = ClsCommon.uuid;
            lblSummMessage.Text    = "Summary Successfully Generated.";
            divsuccessmsg.Visible  = true;
            divsuccessmsg.CssClass = "alert alert-success";
        }
    }
    protected void btnDownloadSign_Click(object sender, EventArgs e)
    {
        lblSummMessage.Text = string.Empty;
        ClsTCUtilsUploadHash clsTCUtil = new ClsTCUtilsUploadHash();

        encrypt = new ClsEncryption();
//        clsGstr1 = new ClsGSTR1();

        string DownCs = clsTCUtil.GetDownloadCS(ClsCommon.eSignAPIKEY, ClsCommon.uuid);

        if (ClsCommon.uuid != null && ClsCommon.uuid != string.Empty)
        {
            var     response = clsTCUtil.GetDownloadSignedData(ClsCommon.eSignDomain, DownCs);
            JObject jobj     = JObject.Parse(response.ToString());
            if (jobj.GetValue("status") != null && jobj.GetValue("status").ToString() == "0")
            {
                ClsCommon.AadhaarNo    = jobj.GetValue("aadhaarno") == null ? "" : jobj.GetValue("aadhaarno").ToString();
                ClsCommon.SignedData   = jobj.GetValue("PKCS7").ToString();
                divsuccessmsg.Visible  = true;
                divsuccessmsg.CssClass = "alert alert-success";
                lblSummMessage.Text    = "Successfully download signed data.";
                txtSummary.Text        = ClsCommon.SignedData;
                Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "$(document).ready(function(){$('#viewsubmit').modal('show');});", true);
            }
            else
            {
                divsuccessmsg.Visible  = true;
                divsuccessmsg.CssClass = "alert alert-danger";
                lblSummMessage.Text    = "Error in downloading signed data.";
            }
        }
        else
        {
            divsuccessmsg.Visible  = true;
            divsuccessmsg.CssClass = "alert alert-danger";
            lblSummMessage.Text    = "Error: uuid is null or blank.";
        }
    }