public ResponseGetMobileNO uploadA4scan(SubmitMandateImageInput context)
        {
            ResponseGetMobileNO pathInfo = new ResponseGetMobileNO();

            if (context.AppID == "" || context.AppID == null)
            {
                pathInfo.message = "Incomplete data";
                pathInfo.status  = "Failure";
                return(pathInfo);
            }
            else if (context.MandeteId == "" || context.MandeteId == null)
            {
                pathInfo.message = "Incomplete data";
                pathInfo.status  = "Failure";
                return(pathInfo);
            }

            else if (context.UserId == "" || context.UserId == null)
            {
                pathInfo.message = "Incomplete data";
                pathInfo.status  = "Failure";
                return(pathInfo);
            }
            //else if (context.ImageBytes == "" || context.ImageBytes == null)
            //{
            //    pathInfo.message = "Incomplete data";
            //    pathInfo.status = "Failure";
            //    return pathInfo;
            //}
            //else if (context.ImageBytes.Length < 0 || context.ImageBytes == null)
            //{
            //    pathInfo.message = "Incomplete data";
            //    pathInfo.status = "Failure";
            //    return pathInfo;
            //}
            if (CheckMandateInfo.CheckMandateId(context.AppID, context.MandeteId) != "1")
            {
                pathInfo.message = "Invalid MandateId";
                pathInfo.status  = "Failure";
                return(pathInfo);
            }
            if (CheckImageSubmitted(context.MandeteId, context.AppID))
            {
                pathInfo.message = "Image already uploaded and submitted to bank";
                pathInfo.status  = "Failure";
                return(pathInfo);
            }
            else
            {
                pathInfo.message = "Image uploaded successfully";
                pathInfo.status  = "Success";
                return(pathInfo);
            }
        }
Пример #2
0
        public GetSubmitMandateResponse GetSubmitMandateInfo(GetSubmitMandateReq Data)
        {
            GetSubmitMandateResponse response = new GetSubmitMandateResponse();

            try
            {
                if (Data.AppID == "")
                {
                    response.Message = "Incomplete data";
                    response.Status  = "Failure";
                    response.ResCode = "ykR20020";
                    return(response);
                }
                else if (Data.AppID != "" && CheckMandateInfo.ValidateAppID(Data.AppID) != true)
                {
                    response.Message = "Invalid AppId";
                    response.Status  = "Failure";
                    response.ResCode = "ykR20023";

                    return(response);
                }
                //else if (ValidatePresement.CheckAccess(Data.AppId.Trim(), "A") != true)
                //{
                //    response.Message = "Unauthorized user";
                //    response.Status = "Failure";
                //    response.ResCode = "ykR20038";
                //    return response;
                //}
                else if (Data.MdtID == "")
                {
                    response.Message = "Incomplete data";
                    response.Status  = "Failure";
                    response.ResCode = "ykR20020";
                    return(response);
                }

                else if (!CheckMandateInfo.CheckManadateID(Data.MdtID, Data.AppID))
                {
                    response.Message = "Invalid MandateId";
                    response.Status  = "Failure";
                    response.ResCode = "ykR20022";
                    return(response);
                }
                //else if (!CheckMandateInfo.CheckAccountValidation(Data.MdtID, Data.AppID))
                //{
                //    response.Message = "Account should be validated";
                //    response.Status = "Failure";
                //    response.ResCode = "ERR0004";
                //    return response;
                //}
                else if (CheckMandateInfo.CheckENachValidation(Data.MdtID, Data.AppID))
                {
                    response.Message = "Mandate type already selected as eMandate";
                    response.Status  = "Failure";
                    response.ResCode = "ykR20030";
                    return(response);
                }
                else if (!CheckMandateInfo.CheckImageValidation(Data.MdtID, Data.AppID))
                {
                    response.Message = "Mandate Image not found";
                    response.Status  = "Failure";
                    response.ResCode = "ykR20048";
                    return(response);
                }
                else if (Data.MerchantKey == "")
                {
                    response.Message = "Incomplete data";
                    response.Status  = "Failure";
                    response.ResCode = "ykR20020";
                    return(response);
                }
                //else if (Data.MerchantKey == "")
                //{
                //    response.Message = "Incomplete data";
                //    response.Status = "Failure";
                //    response.ResCode = "ERR000";
                //    return response;
                //}

                else if (Data.MerchantKey != "" && CheckMandateInfo.ValidateEntityMerchantKey(Data.MerchantKey, Data.AppID) != true)
                {
                    response.Message = "Invalid MerchantKey";
                    response.Status  = "Failure";
                    response.ResCode = "ykR20021";
                    return(response);
                }
                else
                {
                    SqlConnection con  = new SqlConnection(ConfigurationManager.ConnectionStrings[Convert.ToString(Data.AppID)].ConnectionString);
                    bool          Flag = false;
                    // string temp = ConfigurationManager.AppSettings["EnitityMarchantKey" + Data.AppID];
                    string UserId = "";
                    string query  = "Sp_WebAPI";
                    //if (temp.Trim() == DBsecurity.Decrypt(Data.MerchantKey))
                    //{
                    SqlCommand cmd = new SqlCommand(query, con);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@QueryType", "GetEntityUser");
                    cmd.Parameters.AddWithValue("@appId", Data.AppID);
                    SqlDataAdapter da = new SqlDataAdapter(cmd);
                    DataTable      dt = new DataTable();
                    da.Fill(dt);
                    if (dt.Rows.Count > 0)
                    {
                        UserId = Convert.ToString(dt.Rows[0][0]);
                        Flag   = true;
                    }
                    // }

                    if (Flag)
                    {
                        try
                        {
                            con.Open();
                            query           = "Sp_WebAPI";
                            cmd             = new SqlCommand(query, con);
                            cmd.CommandType = CommandType.StoredProcedure;
                            cmd.Parameters.AddWithValue("@QueryType", "GetSubmitMandateResponse");
                            cmd.Parameters.AddWithValue("@UserId", UserId);
                            cmd.Parameters.AddWithValue("@MandateId", Data.MdtID);
                            da = new SqlDataAdapter(cmd);
                            dt = new DataTable();
                            da.Fill(dt);
                            con.Close();
                            if (dt != null && dt.Rows.Count > 0)
                            {
                                response.Message   = "Mandate submitted to Bank successfully";
                                response.ResCode   = "ykR20034";
                                response.Status    = "Success";
                                response.MandateId = Data.MdtID;
                            }
                        }
                        catch (Exception ex)
                        {
                            //Console.Out.WriteLine("-----------------");
                            //Console.Out.WriteLine(ex.Message);
                        }
                    }
                    else
                    {
                        response.Status  = "Failure";
                        response.ResCode = "ykR20020";
                        response.Message = "Incomplete data";
                        return(response);
                    }
                }
            }
            catch (Exception ex)
            {
                response.Status  = "Failure";
                response.ResCode = "ykR20020";
                response.Message = "Incomplete data";
            }
            return(response);
        }
Пример #3
0
        public BankResponseData GetBankdata(GetMandateReq Data)
        {
            BankResponseData    response = new BankResponseData();
            List <BankResponse> ListView = new List <BankResponse>();

            if (Data.AppID == "")
            {
                response.Message = "Incomplete data";
                response.Status  = "Failure";
                response.ResCode = "ykR20020";
                return(response);
            }
            else if (Data.AppID != "" && CheckMandateInfo.ValidateAppID(Data.AppID) != true)
            {
                response.Message = "Invalid AppId";
                response.Status  = "Failure";
                response.ResCode = "ykR20023";

                return(response);
            }
            else if (Data.MerchantKey == "")
            {
                response.Message = "Incomplete data";
                response.Status  = "Failure";
                response.ResCode = "ykR20020";
                return(response);
            }
            else if (Data.MerchantKey != "" && CheckMandateInfo.ValidateEntityMerchantKey(Data.MerchantKey, Data.AppID) != true)
            {
                response.Message = "Invalid MerchantKey";
                response.Status  = "Failure";
                response.ResCode = "ykR20021";
                return(response);
            }
            else
            {
                string        query = "Sp_WebAPI";
                SqlConnection con   = new SqlConnection(ConfigurationManager.ConnectionStrings[Convert.ToString(Data.AppID)].ConnectionString);
                SqlCommand    cmd   = new SqlCommand(query, con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@QueryType", "GetLiveBank");
                // cmd.Parameters.AddWithValue("@appId", Data.AppID);
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                DataTable      dt = new DataTable();
                da.Fill(dt);
                foreach (DataRow row in dt.Rows)
                {
                    BankResponse bnk = new BankResponse();
                    bnk.BankCode         = row["BankCode"].ToString();
                    bnk.BankName         = row["BankName"].ToString();
                    bnk.LiveOnDebitCard  = row["LiveOnDebitCard"].ToString();
                    bnk.LiveOnNetBanking = row["LiveOnNetBanking"].ToString();
                    ListView.Add(bnk);
                }
                response.BankData = ListView;
                response.Message  = "All Live Bank Data On NPCI received successfully";
                response.ResCode  = "ykR20035";
                response.Status   = "Success";
                return(response);
            }
        }
Пример #4
0
        public GetMandateResponse GetMandateInfo(GetMandateReq Data)
        {
            GetMandateResponse response = new GetMandateResponse();

            if (Data.AppID == "")
            {
                response.Message = "Incomplete data";
                response.Status  = "Failure";
                response.ResCode = "ykR20020";
                return(response);
            }
            else if (Data.AppID != "" && CheckMandateInfo.ValidateAppID(Data.AppID) != true)
            {
                response.Message = "Invalid AppId";
                response.Status  = "Failure";
                response.ResCode = "ykR20023";

                return(response);
            }
            //else if (ValidatePresement.CheckAccess(Data.AppID.Trim(), "A") != true)
            //{
            //    response.Message = "Unauthorized user";
            //    response.Status = "Failure";
            //    response.ResCode = "ykR20038";
            //    return response;
            //}
            else if (Data.MdtID == "")
            {
                response.Message = "Incomplete data";
                response.Status  = "Failure";
                response.ResCode = "ykR20020";
                return(response);
            }

            else if (!CheckMandateInfo.CheckManadateID(Data.MdtID, Data.AppID))
            {
                response.Message = "Invalid MandateId";
                response.Status  = "Failure";
                response.ResCode = "ykR20022";
                return(response);
            }
            else if (Data.MerchantKey == "")
            {
                response.Message = "Incomplete data";
                response.Status  = "Failure";
                response.ResCode = "ykR20020";
                return(response);
            }
            else if (Data.MerchantKey != "" && CheckMandateInfo.ValidateEntityMerchantKey(Data.MerchantKey, Data.AppID) != true)
            {
                response.Message = "Invalid MerchantKey";
                response.Status  = "Failure";
                response.ResCode = "ykR20021";
                return(response);
            }
            else
            {
                SqlConnection con  = new SqlConnection(ConfigurationManager.ConnectionStrings[Convert.ToString(Data.AppID)].ConnectionString);
                bool          Flag = false;
                //string temp = ConfigurationManager.AppSettings["EnitityMarchantKey" + Data.AppID];
                string UserId = "";
                string query  = "Sp_WebAPI";
                //if (temp.Trim() == DBsecurity.Decrypt(Data.MerchantKey))
                //{
                SqlCommand cmd = new SqlCommand(query, con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@QueryType", "GetEntityUser");
                cmd.Parameters.AddWithValue("@appId", Data.AppID);
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                DataTable      dt = new DataTable();
                da.Fill(dt);
                if (dt.Rows.Count > 0)
                {
                    UserId = Convert.ToString(dt.Rows[0][0]);
                    Flag   = true;
                }
                //}

                if (Flag)
                {
                    try
                    {
                        con.Open();
                        query           = "Sp_WebAPI";
                        cmd             = new SqlCommand(query, con);
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.AddWithValue("@QueryType", "GetMandateStatus");
                        cmd.Parameters.AddWithValue("@MandateId", Data.MdtID);
                        da = new SqlDataAdapter(cmd);
                        dt = new DataTable();
                        da.Fill(dt);
                        con.Close();
                        if (dt != null && dt.Rows.Count > 0)
                        {
                            string Nach              = Convert.ToString(dt.Rows[0]["Nach"]) == "True" ? "Yes" : "No";
                            string Aadhar            = Convert.ToString(dt.Rows[0]["IsLiveInNACH"]) == "True" ? "Yes" : "No";
                            string Netbanking        = Convert.ToString(dt.Rows[0]["Netbanking"]) == "1" ? "Yes" : "No";
                            string Debitcard         = Convert.ToString(dt.Rows[0]["DebitCard"]) == "1" ? "Yes" : "No";
                            string UPI               = Convert.ToString(dt.Rows[0]["Is_UPI"]) == "True" ? "Yes" : "No";
                            string Lateststatus      = Convert.ToString(dt.Rows[0]["status"]);
                            string StatusDescription = Convert.ToString(dt.Rows[0]["StatusDescription"]);
                            string isAggr            = "";
                            if (Convert.ToString(dt.Rows[0]["IsAggregator"]).ToLower() == "true")
                            {
                                isAggr = "1";
                            }
                            else
                            {
                                isAggr = "0";
                            }
                            response.Message       = "Mandate Status received";
                            response.ResCode       = "ykR20035";
                            response.Status        = "Success";
                            response.MandateId     = Data.MdtID;
                            response.Mandatestatus = Convert.ToString(dt.Rows[0]["status"]);
                            //response.MandateData = "<MandateData><AppID>" + Data.AppID + "</AppID><MerchantKey>" + Data.MerchantKey + "</MerchantKey><MandateId>" + Data.MdtID + "</MandateId><MandateMode> " + Convert.ToString(dt.Rows[0]["MandateType"]) + " </MandateMode><DateOnMandate> " + Convert.ToString(dt.Rows[0]["DateOnMandate"]) + "</DateOnMandate><SponsorCode>" + Convert.ToString(dt.Rows[0]["SponsorbankCode"]) + "</SponsorCode><UtilityCode> " + Convert.ToString(dt.Rows[0]["UtilityCode"]) + " </UtilityCode ><ToDebit>" + Convert.ToString(dt.Rows[0]["ToDebit"]) + "</ToDebit ><BankName>" + Convert.ToString(dt.Rows[0]["BankName"]) + "</BankName><AcNo>" + Convert.ToString(dt.Rows[0]["AcNo"]) + "</AcNo><IFSC> " + Convert.ToString(dt.Rows[0]["IFSC"]) + " </IFSC><MICR>" + Convert.ToString(dt.Rows[0]["MICR"]) + "</MICR><AmountRupees>" + Convert.ToString(dt.Rows[0]["AmountRupees"]) + "</AmountRupees><Frequency>" + Convert.ToString(dt.Rows[0]["Frequency"]) + "</Frequency><DebitType>" + Convert.ToString(dt.Rows[0]["DebitType"]) + "</DebitType><Refrence1> " + Convert.ToString(dt.Rows[0]["Refrence1"]) + " </Refrence1><Refrence2> " + Convert.ToString(dt.Rows[0]["Refrence2"]) + " </Refrence2>< PhNumber> " + Convert.ToString(dt.Rows[0]["PhoneNumber"]) + " </PhNumber><EmailId> " + Convert.ToString(dt.Rows[0]["EmailId"]) + " </EmailId><From> " + Convert.ToString(dt.Rows[0]["FromDate"]) + "</From><To> " + Convert.ToString(dt.Rows[0]["Todate"]) + " </To>< Customer1> " + Convert.ToString(dt.Rows[0]["Customer1"]) + " </Customer1><Customer2> " + Convert.ToString(dt.Rows[0]["Customer2"]) + "</Customer2><Customer3> " + Convert.ToString(dt.Rows[0]["Customer3"]) + "</Customer3><Nach>" + Nach + "</Nach><EMandateAadhar>" + Aadhar + "</EMandateAadhar><EMandateNetBanking>" + Netbanking + "</EMandateNetBanking><EMandateDebitCard>" + Debitcard + "</EMandateDebitCard><EMandateUPI>" + UPI + "</EMandateUPI><MandateStatus>" + Lateststatus + "</MandateStatus><IsAggregator>" + isAggr + "</IsAggregator><SubMerchantId>" + Convert.ToString(dt.Rows[0]["IsAggregatorValue"]) + "</SubMerchantId><CategoryCode>" + Convert.ToString(dt.Rows[0]["CategoryCode"]) + "</CategoryCode></MandateData>";
                            response.MandateData = "<MandateData><AppID>" + Data.AppID + "</AppID><MerchantKey>" + Data.MerchantKey + "</MerchantKey><MdtID>" + Data.MdtID + "</MdtID><MType>" + Convert.ToString(dt.Rows[0]["MandateType"]) + "</MType><MDate>" + Convert.ToString(dt.Rows[0]["DateOnMandate"]) + "</MDate><SpBankCode>" + Convert.ToString(dt.Rows[0]["SponsorbankCode"]) + "</SpBankCode><UTLSCode>" + Convert.ToString(dt.Rows[0]["UtilityCode"]) + "</UTLSCode><TDebit>" + Convert.ToString(dt.Rows[0]["ToDebit"]) + "</TDebit><BankName>" + Convert.ToString(dt.Rows[0]["BankName"]) + "</BankName><BankAc>" + Convert.ToString(dt.Rows[0]["AcNo"]) + "</BankAc><IFSC>" + Convert.ToString(dt.Rows[0]["IFSC"]) + "</IFSC><MICR>" + Convert.ToString(dt.Rows[0]["MICR"]) + "</MICR><Amt>" + Convert.ToString(dt.Rows[0]["AmountRupees"]) + "</Amt><Frequency>" + Convert.ToString(dt.Rows[0]["Frequency"]) + "</Frequency><DType>" + Convert.ToString(dt.Rows[0]["DebitType"]) + "</DType><Ref1>" + Convert.ToString(dt.Rows[0]["Refrence1"]) + "</Ref1><Ref2>" + Convert.ToString(dt.Rows[0]["Refrence2"]) + "</Ref2><Phone>" + Convert.ToString(dt.Rows[0]["PhoneNumber"]) + "</Phone><Email>" + Convert.ToString(dt.Rows[0]["EmailId"]) + "</Email><PFrom>" + Convert.ToString(dt.Rows[0]["FromDate"]) + "</PFrom><PTo>" + Convert.ToString(dt.Rows[0]["Todate"]) + "</PTo><Cust1>" + Convert.ToString(dt.Rows[0]["Customer1"]) + "</Cust1><Cust2>" + Convert.ToString(dt.Rows[0]["Customer2"]) + "</Cust2><Cust3>" + Convert.ToString(dt.Rows[0]["Customer3"]) + "</Cust3><Nach>" + Nach + "</Nach><EMandateAadhar>" + Aadhar + "</EMandateAadhar><EMandateNetBanking>" + Netbanking + "</EMandateNetBanking><EMandateDebitCard>" + Debitcard + "</EMandateDebitCard><EMandateUPI>" + UPI + "</EMandateUPI><MandateStatus>" + Lateststatus + "</MandateStatus><IsAggregator>" + isAggr + "</IsAggregator><SubMerchantId>" + Convert.ToString(dt.Rows[0]["IsAggregatorValue"]) + "</SubMerchantId><CategoryCode>" + Convert.ToString(dt.Rows[0]["CategoryCode"]) + "</CategoryCode><AcceptRefNo>" + Convert.ToString(dt.Rows[0]["AcceptRefNo"]) + "</AcceptRefNo><MndtReqId>" + Convert.ToString(dt.Rows[0]["MSGId"]) + "</MndtReqId><NPCIRefMsgId>" + Convert.ToString(dt.Rows[0]["NPCIMsgId"]) + "</NPCIRefMsgId><StatusDescription>" + StatusDescription + "</StatusDescription><UMRN>" + Convert.ToString(dt.Rows[0]["UMRN"]) + "</UMRN></MandateData>";
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.Out.WriteLine("-----------------");
                        Console.Out.WriteLine(ex.Message);
                    }
                }
                else
                {
                    response.Status  = "Failure";
                    response.ResCode = "ykR20020";
                    response.Message = "Invalid data";
                    return(response);
                }
            }
            return(response);
        }
Пример #5
0
        public ResponseDataorg uploadA4scan(CustomerModel context)
        {
            string TempMandateId = "";
            var    retList       = new List <ResponseDataorg>();
            //ResponseDataorg retList = new ResponseDataorg();

            ResponseDataorg pathInfo = new ResponseDataorg();

            //if (context.PrintQr == "1")
            //{
            //    TempMandateId = ReadQrCode(context.base64, context.MandateId);

            //}


            if (context.AppID == "")
            {
                pathInfo.Message = "Incomplete data";
                pathInfo.Status  = "Failure";
                pathInfo.ResCode = "ykR20020";
                retList.Add(pathInfo);
                return(pathInfo);
            }
            else if (context.AppID != "" && CheckMandateInfo.ValidateAppID(context.AppID) != true)
            {
                pathInfo.Message = "Invalid AppId";
                pathInfo.Status  = "Failure";
                pathInfo.ResCode = "ykR20023";
                retList.Add(pathInfo);
                return(pathInfo);
            }
            else if (context.MdtID == "")
            {
                pathInfo.Message = "Incomplete data";
                pathInfo.Status  = "Failure";
                pathInfo.ResCode = "ykR20020";
                retList.Add(pathInfo);
                return(pathInfo);
            }
            else if (!CheckMandateInfo.CheckManadateID(context.MdtID, context.AppID))
            {
                pathInfo.Message = "Invalid MandateId";
                pathInfo.Status  = "Failure";
                pathInfo.ResCode = "ykR200203";
                retList.Add(pathInfo);
                return(pathInfo);
            }
            else if (context.MerchantKey == "")
            {
                pathInfo.Message = "Incomplete data";
                pathInfo.Status  = "Failure";
                pathInfo.ResCode = "ykR20020";
                retList.Add(pathInfo);
                return(pathInfo);
            }
            else if (context.MerchantKey != "" && CheckMandateInfo.ValidateEntityMerchantKey(context.MerchantKey, context.AppID) != true)
            {
                pathInfo.Message = "Invalid MerchantKey";
                pathInfo.Status  = "Failure";
                pathInfo.ResCode = "ykR20021";
                retList.Add(pathInfo);
                return(pathInfo);
            }
            else if (context.ScannedImage == "")
            {
                pathInfo.Message = "Incomplete data";
                pathInfo.Status  = "Failure";
                pathInfo.ResCode = "ykR20020";
                retList.Add(pathInfo);
                return(pathInfo);
            }


            //else if (!CheckMandateInfo.CheckAccountValidation(context.MdtID, context.AppID))
            //{
            //    pathInfo.Message = "Account should be validated";
            //    pathInfo.Status = "Failure";
            //    pathInfo.ResCode = "ykR200204";
            //    retList.Add(pathInfo);
            //    return pathInfo;
            //}
            else if (CheckMandateInfo.CheckENachValidation(context.MdtID, context.AppID))
            {
                pathInfo.Message = "Mandate type already selected as eMandate";
                pathInfo.Status  = "Failure";
                pathInfo.ResCode = "ykR20030";
                retList.Add(pathInfo);
                return(pathInfo);
            }

            //else if (TempMandateId.Trim() != context.MdtID.Trim() && context.PrintQr == "1")
            //{
            //    pathInfo.Message = "Scan MandateId is not equal to the passed mandateId";
            //    pathInfo.Status = "Failure";
            //    pathInfo.ResCode = "ykR200203";
            //    retList.Add(pathInfo);
            //    return pathInfo;
            //}
            else
            {
                SqlConnection con  = new SqlConnection(ConfigurationManager.ConnectionStrings[Convert.ToString(context.AppID)].ConnectionString);
                bool          Flag = false;
                // string temp = ConfigurationManager.AppSettings["EnitityMarchantKey" + context.AppID];
                string UserId = "";
                string query  = "Sp_WebAPI";
                //if (temp.Trim() == DBsecurity.Decrypt(context.MerchantKey))
                //{
                SqlCommand cmd = new SqlCommand(query, con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@QueryType", "GetEntityUser");
                cmd.Parameters.AddWithValue("@appId", context.AppID);
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                DataTable      dt = new DataTable();
                da.Fill(dt);
                if (dt.Rows.Count > 0)
                {
                    UserId = Convert.ToString(dt.Rows[0][0]);
                    Flag   = true;
                }
                //}
                if (Flag)
                {
                    Boolean Greater;
                    try
                    {
                        string ID                 = Convert.ToString(context.MdtID);
                        string No                 = CheckMandateInfo.GetRefNO(context.MdtID, context.AppID);//Convert.ToString(context.RefrenceNo);
                        string fileName           = string.Empty;
                        string filePath           = string.Empty;
                        string extension          = string.Empty;
                        string targetPath         = string.Empty;
                        string TIFFilepath        = string.Empty;
                        string JPGFilepath        = string.Empty;
                        string OrgFilepath        = string.Empty;
                        byte[] bytes              = System.Convert.FromBase64String(context.ScannedImage);
                        float  mb                 = (bytes.Length / 1024f) / 1024f;
                        System.IO.MemoryStream mm = new System.IO.MemoryStream();
                        mm.Write(bytes, 0, bytes.Length);
                        System.Drawing.Image img = System.Drawing.Image.FromStream(mm);
                        if (Convert.ToInt32(img.HorizontalResolution) >= 300 && mb <= 3)
                        {
                            try
                            {
                                if (!Directory.Exists(ConfigurationManager.AppSettings["FileUploadPath" + context.AppID] + @"FullMandate\" + ID))
                                {
                                    Directory.CreateDirectory(ConfigurationManager.AppSettings["FileUploadPath" + context.AppID] + @"FullMandate\" + ID);
                                }
                                System.IO.DirectoryInfo di = new DirectoryInfo(ConfigurationManager.AppSettings["FileUploadPath" + context.AppID] + @"FullMandate\" + ID);
                                foreach (FileInfo file in di.GetFiles())
                                {
                                    file.Delete();
                                }
                                fileName = ConfigurationManager.AppSettings["DownloadFileName" + context.AppID].ToString() + "_" + DateTime.Now.ToString("ddMMyyyy") + "_" + No + ".jpg";
                                filePath = Path.Combine(ConfigurationManager.AppSettings["FileUploadPath" + context.AppID] + @"\ColouredImage\", fileName);
                                if (!Directory.Exists(ConfigurationManager.AppSettings["FileUploadPath" + context.AppID] + @"\ColouredImage\"))
                                {
                                    Directory.CreateDirectory(ConfigurationManager.AppSettings["FileUploadPath" + context.AppID] + @"\ColouredImage\");
                                }
                                using (System.Drawing.Image image = new Bitmap(new MemoryStream(bytes)))
                                {
                                    image.Save(filePath, ImageFormat.Png);
                                    int newWidth   = 4960; // New Width of Image in Pixel
                                    int newHeight  = 7015; // New Height of Image in Pixel
                                    var thumbImg   = new Bitmap(newWidth, newHeight);
                                    var thumbGraph = Graphics.FromImage(thumbImg);
                                    thumbGraph.CompositingQuality = CompositingQuality.HighQuality;
                                    thumbGraph.SmoothingMode      = SmoothingMode.HighQuality;
                                    thumbGraph.InterpolationMode  = InterpolationMode.HighQualityBicubic;
                                    var imgRectangle = new Rectangle(0, 0, newWidth, newHeight);
                                    thumbGraph.DrawImage(image, imgRectangle);
                                    // Save the file  d
                                    targetPath = ConfigurationManager.AppSettings["FileUploadPath" + context.AppID] + @"\FullMandate\" + ID + @"\" + fileName;
                                    thumbImg.Save(targetPath, image.RawFormat);
                                    OrgFilepath = @"\FullMandate\" + ID + @"\" + fileName;
                                }
                                fileName = ConfigurationManager.AppSettings["DownloadFileName" + context.AppID].ToString() + "_" + DateTime.Now.ToString("ddMMyyyy") + "_" + No + ".tif";
                                if (File.Exists(filePath))
                                {
                                    File.Delete(filePath);
                                }
                            }

                            catch (Exception ex)
                            {
                                // lblMsg.Text = "Oops!! error occured : " + ex.Message.ToString();
                            }
                            finally
                            {
                                extension = string.Empty;
                                fileName  = string.Empty;
                                filePath  = string.Empty;
                            }
                            if (!Directory.Exists(ConfigurationManager.AppSettings["FileUploadPath" + context.AppID] + @"\MandateFile\" + ID))
                            {
                                Directory.CreateDirectory(ConfigurationManager.AppSettings["FileUploadPath" + context.AppID] + @"\MandateFile\" + ID);
                            }
                            else
                            {
                                System.IO.DirectoryInfo di = new DirectoryInfo(ConfigurationManager.AppSettings["FileUploadPath" + context.AppID] + @"\MandateFile\" + ID);

                                foreach (FileInfo file in di.GetFiles())
                                {
                                    file.Delete();
                                }
                            }
                            string XCoordinate     = "";
                            string YCoordinate     = "";
                            string Width           = "";
                            string Height          = "";
                            string croppedFileName = string.Empty;
                            string croppedFilePath = string.Empty;
                            filePath = Path.Combine(ConfigurationManager.AppSettings["FileUploadPath" + context.AppID] + @"\FullMandate\" + ID + "", ConfigurationManager.AppSettings["DownloadFileName" + context.AppID].ToString() + "_" + DateTime.Now.ToString("ddMMyyyy") + "_" + No + ".jpg");
                            //Check if file exists on the path i.e. in the UploadedImages folder.
                            if (File.Exists(filePath))
                            {
                                //Get the image from UploadedImages folder.
                                System.Drawing.Image orgImg = System.Drawing.Image.FromFile(filePath);
                                XCoordinate = "0";
                                YCoordinate = "0";
                                Width       = Convert.ToString(orgImg.Width);
                                Height      = Convert.ToString((Convert.ToInt32(orgImg.Height) / 3));
                                Rectangle areaToCrop = new Rectangle(Convert.ToInt32(XCoordinate),
                                                                     Convert.ToInt32(YCoordinate),
                                                                     Convert.ToInt32(Width),
                                                                     Convert.ToInt32(Height));
                                try
                                {
                                    Bitmap bitMap = new Bitmap(areaToCrop.Width, areaToCrop.Height, System.Drawing.Imaging.PixelFormat.Format16bppRgb555);
                                    //Create graphics object for alteration
                                    using (Graphics g = Graphics.FromImage(bitMap))
                                    {
                                        //Draw image to screen
                                        g.DrawImage(orgImg, new Rectangle(0, 0, bitMap.Width, bitMap.Height), areaToCrop, GraphicsUnit.Pixel);
                                        g.CompositingQuality = CompositingQuality.HighQuality;
                                        g.SmoothingMode      = SmoothingMode.HighQuality;
                                        g.InterpolationMode  = InterpolationMode.HighQualityBicubic;
                                    }
                                    bitMap.SetResolution(96, 96);
                                    //name the cropped image
                                    croppedFileName = ConfigurationManager.AppSettings["DownloadFileName" + context.AppID].ToString() + "_" + DateTime.Now.ToString("ddMMyyyy") + "_" + No + ".jpg";
                                    //Create path to store the cropped image
                                    if (!Directory.Exists(ConfigurationManager.AppSettings["FileUploadPath" + context.AppID] + @"\CropImage\"))
                                    {
                                        Directory.CreateDirectory(ConfigurationManager.AppSettings["FileUploadPath" + context.AppID] + @"\CropImage\");
                                    }
                                    croppedFilePath = Path.Combine(ConfigurationManager.AppSettings["FileUploadPath" + context.AppID] + @"\CropImage\", croppedFileName);
                                    bitMap.Save(croppedFilePath);
                                    var CropImagePath = Path.Combine(ConfigurationManager.AppSettings["FileUploadPath" + context.AppID] + @"\CropImage\", ConfigurationManager.AppSettings["DownloadFileName" + context.AppID].ToString() + "_" + DateTime.Now.ToString("ddMMyyyy") + "_" + No + ".jpg");
                                    System.Drawing.Image CropImage = System.Drawing.Image.FromFile(CropImagePath);
                                    using (var image = CropImage)
                                    {
                                        //int newWidth = 4200; // New Width of Image in Pixel
                                        //int newHeight = 1750; // New Height of Image in Pixel

                                        int newWidth     = 827; // New Width of Image in Pixel
                                        int newHeight    = 356; // New Height of Image in Pixel
                                        var thumbImg     = new Bitmap(newWidth, newHeight, System.Drawing.Imaging.PixelFormat.Format16bppRgb555);
                                        var thumbGraph   = Graphics.FromImage(thumbImg);
                                        var imgRectangle = new Rectangle(0, 0, newWidth, newHeight);
                                        thumbGraph.DrawImage(image, imgRectangle);
                                        thumbImg.SetResolution(100, 100);
                                        System.Drawing.Bitmap b0 = CopyToBpp(thumbImg, 8);
                                        b0.SetResolution(100, 100);
                                        croppedFileName = ConfigurationManager.AppSettings["DownloadFileName" + context.AppID].ToString() + "_" + DateTime.Now.ToString("ddMMyyyy") + "_" + No + ".jpg";
                                        croppedFilePath = Path.Combine(ConfigurationManager.AppSettings["FileUploadPath" + context.AppID] + @"\MandateFile\" + ID + @"\", croppedFileName);
                                        JPGFilepath     = "../MandateFile/" + ID + "/" + croppedFileName;
                                        ImageCodecInfo jpgEncoder = GetEncoder(ImageFormat.Jpeg);
                                        System.Drawing.Imaging.Encoder myEncoder = System.Drawing.Imaging.Encoder.Quality;
                                        EncoderParameters myEncoderParameters    = new EncoderParameters(1);
                                        EncoderParameter  myEncoderParameter     = new EncoderParameter(myEncoder, 50L);
                                        myEncoderParameters.Param[0] = myEncoderParameter;
                                        b0.Save(croppedFilePath, jpgEncoder, myEncoderParameters);
                                        // b0.Save(croppedFilePath, image.RawFormat);
                                    }
                                    var CropImagePath1 = Path.Combine(ConfigurationManager.AppSettings["FileUploadPath" + context.AppID] + @"\CropImage\", ConfigurationManager.AppSettings["DownloadFileName" + context.AppID].ToString() + "_" + DateTime.Now.ToString("ddMMyyyy") + "_" + No + ".jpg");
                                    System.Drawing.Image CropImage1 = System.Drawing.Image.FromFile(CropImagePath1);
                                    using (var image1 = CropImage1)
                                    {
                                        int newWidth      = 827 * 2;
                                        int newHeight     = 356 * 2;
                                        var thumbImg1     = new Bitmap(newWidth, newHeight);
                                        var thumbGraph1   = Graphics.FromImage(thumbImg1);
                                        var imgRectangle1 = new Rectangle(0, 0, newWidth, newHeight);
                                        thumbGraph1.DrawImage(image1, imgRectangle1);
                                        thumbImg1.SetResolution(200, 200);
                                        System.Drawing.Bitmap b1 = CopyToBpp(thumbImg1, 1);
                                        b1.SetResolution(200, 200);
                                        croppedFileName = ConfigurationManager.AppSettings["DownloadFileName" + context.AppID].ToString() + "_" + DateTime.Now.ToString("ddMMyyyy") + "_" + No + ".tif";
                                        croppedFilePath = Path.Combine(ConfigurationManager.AppSettings["FileUploadPath" + context.AppID] + @"\MandateFile\" + ID + @"\", croppedFileName);
                                        TIFFilepath     = "../MandateFile/" + ID + "/" + croppedFileName;
                                        ImageCodecInfo jpgEncoder = GetEncoder(ImageFormat.Tiff);
                                        System.Drawing.Imaging.Encoder myEncoder = System.Drawing.Imaging.Encoder.Compression;
                                        EncoderParameters myEncoderParameters    = new EncoderParameters(1);
                                        EncoderParameter  myEncoderParameter     = new EncoderParameter(myEncoder,
                                                                                                        (long)EncoderValue.CompressionCCITT4);
                                        myEncoderParameters.Param[0] = myEncoderParameter;
                                        b1.Save(croppedFilePath, jpgEncoder, myEncoderParameters);
                                        //  b1.Save(croppedFilePath, image1.RawFormat);
                                    }
                                    orgImg.Dispose();
                                    con.Open();
                                    cmd             = new SqlCommand("Sp_Mandate", con);
                                    cmd.CommandType = CommandType.StoredProcedure;
                                    cmd.Parameters.AddWithValue("@QueryType", "UpdatePNGTIP");
                                    cmd.Parameters.AddWithValue("@TIPPath", TIFFilepath);
                                    cmd.Parameters.AddWithValue("@PNGPath", JPGFilepath);
                                    cmd.Parameters.AddWithValue("@MandateId", context.MdtID);
                                    cmd.Parameters.AddWithValue("@UserId", UserId);
                                    try
                                    {
                                        cmd.ExecuteNonQuery();
                                    }
                                    catch (Exception ex)
                                    {
                                        pathInfo.Message = ex.Message;
                                    }
                                    finally { con.Close(); }
                                    if (File.Exists(CropImagePath1))
                                    {
                                        File.Delete(CropImagePath1);
                                    }
                                    if (File.Exists(ConfigurationManager.AppSettings["FileUploadPath" + context.AppID] + @"\CropImage\" + ConfigurationManager.AppSettings["DownloadFileName" + context.AppID].ToString() + "_" + DateTime.Now.ToString("ddMMyyyy") + "_" + No + ".jpg"))
                                    {
                                        File.Delete(ConfigurationManager.AppSettings["FileUploadPath" + context.AppID] + @"\CropImage\" + ConfigurationManager.AppSettings["DownloadFileName" + context.AppID].ToString() + "_" + DateTime.Now.ToString("ddMMyyyy") + "_" + No + ".jpg");
                                    }
                                    bitMap = null;

                                    //Show cropped image
                                    croppedFileName  = ConfigurationManager.AppSettings["DownloadFileName" + context.AppID].ToString() + "_" + DateTime.Now.ToString("ddMMyyyy") + "_" + No + ".jpg";
                                    pathInfo.Status  = "Success";
                                    pathInfo.ResCode = "ykR20033";
                                    pathInfo.Message = "Image uploaded successfully";
                                    pathInfo.MdtID   = context.MdtID;
                                    //   pathInfo.FullImagePath = ConfigurationManager.AppSettings["FilePath" + context.AppID].ToString() + "/" + OrgFilepath;
                                    pathInfo.JpgImage = ConfigurationManager.AppSettings["FilePathURL" + context.AppID].ToString() + "/" + JPGFilepath.Substring(3, JPGFilepath.Length - 3);
                                    pathInfo.TifImage = ConfigurationManager.AppSettings["FilePathURL" + context.AppID].ToString() + "/" + TIFFilepath.Substring(3, TIFFilepath.Length - 3);
                                }
                                catch (Exception ex)
                                {
                                    // lblMsg.Text = "Oops!! error occured : " + ex.Message.ToString();
                                }
                                finally
                                {
                                    fileName        = string.Empty;
                                    filePath        = string.Empty;
                                    croppedFileName = string.Empty;
                                    croppedFilePath = string.Empty;
                                }
                            }

                            retList.Add(pathInfo);
                            return(pathInfo);
                        }
                        else
                        {
                            pathInfo.ResCode  = "ykR20027";
                            pathInfo.Status   = "Failure";
                            pathInfo.Message  = "Image resolution should be greater than or equal to 300 DPI-This is for only uploading A4 Scan";
                            pathInfo.JpgImage = "";
                            pathInfo.TifImage = "";
                        }
                    }
                    catch (Exception e)
                    {
                        pathInfo.ResCode  = "ykR20020";
                        pathInfo.Status   = "Failure";
                        pathInfo.Message  = "Incomplete data";
                        pathInfo.JpgImage = "";
                        pathInfo.TifImage = "";
                    }
                    retList.Add(pathInfo);
                    return(pathInfo);
                }
                else
                {
                    pathInfo.ResCode = "ykR20020";
                    pathInfo.Status  = "Failure";
                    pathInfo.Message = "Incomplete data";
                    retList.Add(pathInfo);
                    return(pathInfo);
                }
            }
        }
Пример #6
0
        public ResChkESignData CheckEsign(DataChkESign context)
        {
            ResChkESignData pathInfo = new ResChkESignData();

            if (context.AppID == "")
            {
                pathInfo.Message = "Incomplete data";
                pathInfo.Status  = "Failure";
                pathInfo.ResCode = "ykR20020";

                return(pathInfo);
            }
            else if (context.AppID != "" && CheckMandateInfo.ValidateAppID(context.AppID) != true)
            {
                pathInfo.Message = "Invalid Application Id";
                pathInfo.Status  = "Failure";
                pathInfo.ResCode = "ykR20023";

                return(pathInfo);
            }
            else if (context.MdtID == "")
            {
                pathInfo.Message = "Incomplete data";
                pathInfo.Status  = "Failure";
                pathInfo.ResCode = "ykR20020";

                return(pathInfo);
            }
            else if (!CheckMandateInfo.CheckManadateID(context.MdtID, context.AppID))
            {
                pathInfo.Message = "MandateId is not exist";
                pathInfo.Status  = "Failure";
                pathInfo.ResCode = "ykR200203";

                return(pathInfo);
            }
            else if (context.MerchantKey == "")
            {
                pathInfo.Message = "Incomplete data";
                pathInfo.Status  = "Failure";
                pathInfo.ResCode = "ykR20020";

                return(pathInfo);
            }
            else if (context.MerchantKey != "" && CheckMandateInfo.ValidateEntityMerchantKey(context.MerchantKey, context.AppID) != true)
            {
                pathInfo.Message = "Invalid EnitityMarchantKey";
                pathInfo.Status  = "Failure";
                pathInfo.ResCode = "ykR20021";

                return(pathInfo);
            }

            else
            {
                SqlConnection con  = new SqlConnection(ConfigurationManager.ConnectionStrings[Convert.ToString(context.AppID)].ConnectionString);
                bool          Flag = false;

                string UserId = "";
                string query  = "Sp_WebAPI";

                SqlCommand cmd = new SqlCommand(query, con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@QueryType", "GetEntityUser");
                cmd.Parameters.AddWithValue("@appId", context.AppID);
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                DataTable      dt = new DataTable();
                da.Fill(dt);
                if (dt.Rows.Count > 0)
                {
                    UserId = Convert.ToString(dt.Rows[0][0]);
                    Flag   = true;
                }

                if (Flag)
                {
                    try
                    {
                        con.Open();
                        query           = "Sp_WebSevice";
                        cmd             = new SqlCommand(query, con);
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.AddWithValue("@QueryType", "ChkEsignDone");
                        cmd.Parameters.AddWithValue("@MandateId", context.MdtID);

                        da = new SqlDataAdapter(cmd);
                        DataTable ds = new DataTable();
                        da.Fill(ds);


                        if (ds != null && ds.Rows.Count > 0)
                        {
                            if (Convert.ToString(ds.Rows[0]["enach"]).ToUpper() == "TRUE" && Convert.ToString(ds.Rows[0]["AcceptRefNo"]) != "" && Convert.ToString(ds.Rows[0]["MandateStatus"]).ToUpper() == "TRUE")
                            {
                                pathInfo.Status        = "Success";
                                pathInfo.Message       = "Emandate registered successfully";
                                pathInfo.Error         = "";
                                pathInfo.ResCode       = Convert.ToString(ds.Rows[0]["errorcode"]);
                                pathInfo.MandateStatus = Convert.ToString(ds.Rows[0]["Status"]);
                                pathInfo.AcceptRefNo   = Convert.ToString(ds.Rows[0]["AcceptRefNo"]);
                            }
                            else
                            {
                                pathInfo.Status      = "failure";
                                pathInfo.Message     = "Emandate not registered successfully";
                                pathInfo.Error       = Convert.ToString(ds.Rows[0]["errorcode"]);
                                pathInfo.ResCode     = Convert.ToString(ds.Rows[0]["errorcode"]);
                                pathInfo.AcceptRefNo = Convert.ToString(ds.Rows[0]["AcceptRefNo"]);
                            }
                        }


                        con.Close();
                    }
                    catch (Exception ex)
                    {
                        pathInfo.Status  = "failure";
                        pathInfo.Message = ex.Message;
                    }
                }
                return(pathInfo);
            }
        }
        public GetMandateResponseforQRcode ScanQRCode(ScanQRImage Data)
        {
            GetMandateResponseforQRcode response = new GetMandateResponseforQRcode();

            try
            {
                if (Data.AppId == "")
                {
                    response.message = "Incomplete data";
                    response.status  = "Failure";
                    response.ResCode = "ERR000";
                    return(response);
                }
                else if (Data.AppId != "" && CheckMandateInfo.ValidateAppID(Data.AppId) != true)
                {
                    response.message = "Invalid ApplicationId";
                    response.status  = "Failure";
                    response.ResCode = "ykR20023";

                    return(response);
                }
                else if (ValidatePresement.CheckAccess(Data.AppId.Trim(), "A") != true)
                {
                    response.message = "Unauthorized user";
                    response.status  = "Failure";
                    response.ResCode = "ykR20038";
                    return(response);
                }
                else if (Data.EnitityMarchantKey == "")
                {
                    response.message = "Incomplete data";
                    response.status  = "Failure";
                    response.ResCode = "ERR000";
                    return(response);
                }

                else if (Data.EnitityMarchantKey != "" && CheckMandateInfo.ValidateEntityMerchantKey(Data.EnitityMarchantKey, Data.AppId) != true)
                {
                    response.message = "Invalid EnitityMarchantKey";
                    response.status  = "Failure";
                    response.ResCode = "ykR20021";
                    return(response);
                }



                else
                {
                    SqlConnection con  = new SqlConnection(ConfigurationManager.ConnectionStrings[Convert.ToString(Data.AppId)].ConnectionString);
                    bool          Flag = false;
                    //  string temp = ConfigurationManager.AppSettings["EnitityMarchantKey" + Data.AppId];
                    string UserId = "";
                    string query  = "Sp_WebAPI";
                    //if (temp.Trim() == DBsecurity.Decrypt(Data.EnitityMarchantKey))
                    //{
                    SqlCommand cmd = new SqlCommand(query, con);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@QueryType", "GetEntityUser");
                    cmd.Parameters.AddWithValue("@appId", Data.AppId);
                    SqlDataAdapter da = new SqlDataAdapter(cmd);
                    DataTable      dt = new DataTable();
                    da.Fill(dt);
                    if (dt.Rows.Count > 0)
                    {
                        UserId = Convert.ToString(dt.Rows[0][0]);
                        Flag   = true;
                    }
                    // }


                    if (Flag)
                    {
                        con.Open();
                        query           = "Sp_WebAPI";
                        cmd             = new SqlCommand(query, con);
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.AddWithValue("@QueryType", "GetMandateStatus");
                        cmd.Parameters.AddWithValue("@MandateId", Data.MandateID);
                        da = new SqlDataAdapter(cmd);
                        dt = new DataTable();
                        da.Fill(dt);
                        con.Close();
                        if (dt != null && dt.Rows.Count > 0)
                        {
                            response.message       = "Successfully received";
                            response.ResCode       = "KPY000";
                            response.status        = "Success";
                            response.MandateId     = Data.MandateID;
                            response.Mandatestatus = Convert.ToString(dt.Rows[0]["status"]);
                        }
                    }
                }

                if (Data.ScanImage == "")
                {
                    response.message = "Incomplete data";
                    response.status  = "Failure";
                    response.ResCode = "ERR000";
                    return(response);
                }
                if (Data.ScanImage == null)
                {
                    response.message = "Incomplete data";
                    response.status  = "Failure";
                    response.ResCode = "ERR000";
                    return(response);
                }
                if (Data.MandateID == "")
                {
                    response.message = "Incomplete data";
                    response.status  = "Failure";
                    response.ResCode = "ERR000";
                    return(response);
                }
                if (Data.MandateID == null)
                {
                    response.message = "Incomplete data";
                    response.status  = "Failure";
                    response.ResCode = "ERR000";
                    return(response);
                }

                else if (!CheckMandateInfo.CheckManadateID(Data.MandateID, Data.AppId))
                {
                    response.message = "MandateId is not exist";
                    response.status  = "Failure";
                    response.ResCode = "ERR0003";
                    return(response);
                }

                else
                {
                    byte[] data     = Convert.FromBase64String(Data.ScanImage);
                    var    filename = Data.MandateID + ".jpg";
                    var    path     = "/QRCodeImage/";
                    bool   exists   = System.IO.Directory.Exists(HttpContext.Current.Server.MapPath(path));

                    if (!exists)
                    {
                        System.IO.Directory.CreateDirectory(HttpContext.Current.Server.MapPath(path));
                    }

                    var file = HttpContext.Current.Server.MapPath(path + filename);
                    System.IO.File.WriteAllBytes(file, data);
                    path = path + filename;

                    Bitmap          bitmap1 = new Bitmap(file);
                    int             x = 0, y = 0, width = 1531, height = 486;
                    Bitmap          CroppedImage = bitmap1.Clone(new System.Drawing.Rectangle(x, y, width, height), bitmap1.PixelFormat);
                    LuminanceSource source;
                    source = new BitmapLuminanceSource(CroppedImage);
                    BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
                    Result       result = new MultiFormatReader().decode(bitmap);

                    string finalresult = result.ToString();
                    response.message = finalresult;
                    bitmap1.Dispose();
                    CroppedImage.Dispose();
                    System.GC.Collect();
                    System.GC.WaitForPendingFinalizers();
                    File.Delete(file);
                    return(response);
                }
            }
            catch (Exception Ex)
            {
                response.message = "Incomplete data";
                return(response);
            }
        }