// [ValidateAntiForgeryToken]
        public ActionResult Process()
        {
            string batchId = "";

            try
            {
                var rv  = new SetReconDualUpldSession();
                var rec = rv.GetSetReconDualUpload(User.Identity.Name);
                //  isUp = userInstitutionItbid == 1 ? true : false;
                //using (var txscope = new TransactionScope(TransactionScopeOption.RequiresNew, new TimeSpan(0, 30, 0)))
                //{
                int errorcnt = 0;

                DateTime curDate = DateTime.Now;

                batchId = SmartObj.GenRefNo2();

                int i        = 0;
                int valCount = rec.Count(f => f.VALIDATIONERRORSTATUS == false);
                foreach (var d in rec)
                {
                    if (i == 0)
                    {
                        SM_AUTHLIST auth = new SM_AUTHLIST()
                        {
                            CREATEDATE = DateTime.Now,
                            EVENTTYPE  = eventInsert,
                            MENUID     = menuId,
                            //MENUNAME = "",
                            // RECORDID = objG.ITBID,
                            STATUS = open,
                            //TABLENAME = "SM_FREQUENCY",
                            URL               = Request.FilePath,
                            USERID            = User.Identity.Name,
                            INSTITUTION_ITBID = institutionId,
                            BATCHID           = batchId,
                            POSTTYPE          = Batch
                        };
                        repoAuth.Insert(auth);
                    }
                    i++;
                    if (d.VALIDATIONERRORSTATUS == true)
                    {
                        errorcnt++;
                        continue;
                    }

                    //    var obj = new SM_UPLOADSETRECON_TEMP()// SM_MERCHANTTERMINALUPLD()
                    //    {
                    //        REFERENCENO = d.REFERENCENO,
                    //        CARDTYPE = d.CARDTYPE,
                    //        TRANSACTIONTYPE = d.TRANSACTIONTYPE,
                    //        TRANSACTIONDATETIME = d.TRANSACTIONDATETIME,
                    //        SETTLEMENTDATE = d.SETTLEMENTDATE,
                    //        MASKEDPAN = d.MASKEDPAN,
                    //        MERCHANTID = d.MERCHANTID,
                    //        MERCHANTACCOUNT = d.MERCHANTACCOUNT,
                    //        MERCHANTNAME = d.MERCHANTNAME,
                    //        MERCHANTLOCATION = d.MERCHANTLOCATION,
                    //        TERMINALID = d.TERMINALID,
                    //        TRANAMOUNT = d.TRANAMOUNT,
                    //        AMOUNTCHARGED = d.AMOUNTCHARGED,
                    //        SETTLEMENTAMOUNT = d.SETTLEMENTAMOUNT,
                    //        MSCRATE = d.MSCRATE,
                    //        BATCHTYPE = d.BATCHTYPE,
                    //        BATCHID = batchId,
                    //        CREATEDATE = curDate,
                    //        STATUS = open,
                    //        USERID = User.Identity.Name,

                    //    };
                    //    repoSetReconDualUploadTemp.Insert(obj);
                    //    //cnt++;
                }


                var rst = uow.Save(User.Identity.Name);
                if (rst > 0)
                {
                    //SessionHelper.GetCart(Session).Clear();
                    rv.PurgeSetReconDualUpload(User.Identity.Name);

                    try
                    {
                        EmailerNotification.SendForAuthorization(menuId, fullName, deptCode, institutionId, string.Format("Setttlement Reconciliation Upload Batch #{0}", batchId));
                    }
                    catch
                    {
                    }
                    //txscope.Complete();
                }
                else
                {
                    return(Json(new { RespCode = 1, RespMessage = "Problem Processing Request." }));
                }
                //}
            }
            catch (Exception ex)
            {
                return(Json(new { RespCode = 1, RespMessage = ex.Message }));
            }
            var msg = string.Format("<i class='fa fa-check' ></i> Record with Batch-ID #{0} Processed SuccessFully and has been forwarded for authorization", batchId);

            return(Json(new { RespCode = 0, RespMessage = msg }));
        }
        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" }));
        }