private static SetReconDualUpldObj addRecord(IList <string> rowData, IList <string> columnNames)
 {
     try
     {
         var obj = new SetReconDualUpldObj()
         {
             REFERENCENO         = rowData[0].Trim(),
             CARDTYPE            = rowData[1].Trim(),
             TRANSACTIONTYPE     = rowData[2].Trim(),
             TRANSACTIONDATETIME = rowData[3].ToDateTime(),
             SETTLEMENTDATE      = rowData[4].ToDateTime(),
             MASKEDPAN           = rowData[5].Trim(),
             MERCHANTID          = rowData[6].Trim(),
             MERCHANTACCOUNT     = rowData[7].Trim(),
             MERCHANTNAME        = rowData[8].Trim(),
             MERCHANTLOCATION    = rowData[9].Trim(),
             TERMINALID          = rowData[10].Trim(),
             TRANAMOUNT          = rowData[11].ToDecimal(),
             AMOUNTCHARGED       = rowData[12].ToDecimal(),
             SETTLEMENTAMOUNT    = rowData[13].ToDecimal(),
             MSCRATE             = rowData[14].ToDecimal(),
             // BATCHTYPE = rowData[15].Trim(),
             VALIDATIONERRORSTATUS = true,
         };
         return(obj);
     }
     catch (Exception ex)
     {
         return(new SetReconDualUpldObj());
     }
 }
        public ActionResult UploadFilesB()
        {
            IList <SetReconDualUpldObj> model = null;


            try
            {
                var rc = Request.Files;
                //  var dd = Request.Form["requestType"];
                if (rc != null)
                {
                    var file = rc[0];
                    if (file != null && file.ContentLength > 0)
                    {
                        var stream   = file.InputStream;
                        var fileName = Path.GetFileName(file.FileName);
                        var ext      = Path.GetExtension(file.FileName);
                        if (ext != ".xlsx")
                        {
                            return(Json(new { RespCode = 1, RespMessage = "Please Upload Using .xlsx file" }));
                        }

                        if (!Directory.Exists(Server.MapPath("~/UploadFiles")))
                        {
                            Directory.CreateDirectory(Server.MapPath("~/UploadFiles"));
                        }
                        var path = Path.Combine(Server.MapPath("~/UploadFiles"), fileName);
                        using (var fileStream = System.IO.File.Create(path))
                        {
                            stream.CopyTo(fileStream);
                        }

                        var dataList = ExcelReader.GetDataToList(path, addRecord); // ExxcellReaderClosedXml.GetDataToList(path, addRecord);
                                                                                   //int cnt = 0;
                        var rv  = new SetReconDualUpldSession();
                        var obj = new SetReconDualUpldObj();
                        //if (obj.BATCHTYPE == null)
                        //{
                        var cnt = rv.PostSetReconDualUploadBulkB(dataList.ToList(), User.Identity.Name);
                        if (cnt > 0)
                        {
                            var rst  = rv.GetSetReconDualUpload(User.Identity.Name);
                            var html = PartialView("_SetReconDualUpld", rst).RenderToString();
                            return(Json(new { data_html = html, RespCode = 0, RespMessage = "Please Upload Using .xlsx file" }));
                        }
                        else
                        {
                            var html = PartialView("_SetReconDualUpld").RenderToString();
                            return(Json(new { RespCode = 1, RespMessage = "Problem processing file upload." }));
                        }
                        //}
                        //else
                        //{
                        //    var cntb = rv.PostSetReconDualUploadBulkb(dataList.ToList(), User.Identity.Name);
                        //    if (cntb > 0)
                        //    {
                        //        var rst = rv.GetSetReconDualUpload(User.Identity.Name);
                        //        var html = PartialView("_SetReconDualUpld", rst).RenderToString();
                        //        return Json(new { data_html = html, RespCode = 0, RespMessage = "Please Upload Using .xlsx file" });
                        //    }
                        //    else
                        //    {
                        //        var html = PartialView("_SetReconDualUpld").RenderToString();
                        //        return Json(new { RespCode = 1, RespMessage = "Problem processing file upload." });
                        //    }
                        //}
                    }
                }
                // If we got this far, something failed, redisplay form
                //return Json(new { RespCode = 1, RespMessage = errorMsg });
            }
            catch (SqlException ex)
            {
                return(Json(new { data = model, RespCode = 1, RespMessage = ex.Message }));
            }
            catch (Exception ex)
            {
                return(Json(new { data = model, RespCode = 1, RespMessage = ex.Message }));
            }
            return(Json(new { data = model, BatchId = "", RespCode = 0, RespMessage = "File Uploaded Successfully" }));
        }