// [ValidateAntiForgeryToken] public ActionResult Process() { string batchId = ""; try { var rv = new SetReconUpldSession(); var rec = rv.GetSetReconUpload(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_SETRECONCILIATION_TEMP()// SM_MERCHANTTERMINALUPLD() { PAYREFNO = d.PAYREFNO, AMOUNT = d.AMOUNT, PAYMENTDATE = d.PAYMENTDATE, VALUEDATE = d.VALUEDATE, //RECEIPTNO = d.RECEIPTNO, CUSTOMERNAME = d.CUSTOMERNAME, PAYMENTMETHOD = d.PAYMENTMETHOD, //TRANSACTIONSTATUS = d.TRANSACTIONSTATUS, //DEPOSITSLIPNO = d.DEPOSITSLIPNO, BANKNAME = d.BANKNAME, //BRANCHNAME = d.BRANCHNAME, //PAYERID = d.PAYERID, //VALUEGRANTED = d.VALUEGRANTED, //RECONCILE = d.RECONCILE, BATCHID = batchId, CREATEDATE = curDate, STATUS = open, USERID = User.Identity.Name, }; repoSetReconciliationTemp.Insert(obj); //cnt++; } var rst = uow.Save(User.Identity.Name); if (rst > 0) { //SessionHelper.GetCart(Session).Clear(); rv.PurgeSetReconUpload(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 })); }
// [ValidateAntiForgeryToken] public ActionResult UploadFiles() { IList <SetReconUpldObj> 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 SetReconUpldSession(); var cnt = rv.PostSetReconUploadBulk(dataList.ToList(), User.Identity.Name); if (cnt > 0) { var rst = rv.GetSetReconUpload(User.Identity.Name); var html = PartialView("_SetReconUpld", rst).RenderToString(); return(Json(new { data_html = html, RespCode = 0, RespMessage = "Please Upload Using .xlsx file" })); } else { var html = PartialView("_SetReconUpld").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" })); }