public ActionResult DetailAuth(string a_i, string m)
        {
            try
            {
                int menuId;
                var mid = SmartObj.Decrypt(m);
                var ai  = SmartObj.Decrypt(a_i);
                if (int.TryParse(mid, out menuId) && decimal.TryParse(ai, out authId))
                {
                    var obj = new AuthViewObj();
                    var det = repoAuth.Find(authId);
                    //var d = _repo.GetSession(0, true);

                    ViewBag.HeaderTitle = "Authorize Detail for Role";
                    //ViewBag.StatusVisible = true;
                    if (det != null)
                    {
                        obj.AuthId      = authId;
                        obj.RecordId    = det.RECORDID.GetValueOrDefault();
                        obj.BatchId     = det.BATCHID;
                        obj.PostType    = det.POSTTYPE;
                        obj.MenuId      = det.MENUID.GetValueOrDefault();
                        ViewBag.Message = TempData["msg"];
                        var stat = ViewBag.Message != null ? null : "open";
                        var rec  = _repo.GetFrequency((int)det.RECORDID, false, status: stat, isTemp: true); //repoSession.FindAsync(id);
                        if (rec != null && rec.Count > 0)
                        {
                            var model = rec.FirstOrDefault();
                            obj.Status          = det.STATUS;
                            obj.EventType       = det.EVENTTYPE;
                            obj.DateCreated     = det.CREATEDATE.GetValueOrDefault().ToString("dd-MMM-yyyy");
                            obj.User            = model.CREATED_BY;
                            ViewBag.Auth        = obj;
                            ViewBag.DisplayAuth = det.STATUS == open && !(model.USERID == User.Identity.Name);

                            ViewBag.RecordStatus = new SelectList(SmartObj.GetStatus(), "Code", "Description");
                            // return null;

                            return(View("DetailAuth", model));
                        }
                        //  return Json(rec, JsonRequestBehavior.AllowGet);
                        //var obj1 = new { model = rec.FirstOrDefault(), RespCode = 0, RespMessage = "Success" };
                        // return Json(obj1, JsonRequestBehavior.AllowGet);
                    }


                    return(View("DetailAuth"));
                }
                else
                {
                    return(View("Error", "Home"));
                }
            }
            catch (Exception ex)
            {
                return(View("DetailAuth"));
            }
        }
        void BindCombo2()
        {
            var rec = _repo.GetInstitution(0, true, "Active").Where(d => d.CBN_CODE != null).ToList(); // repoInst.All.Where(e => e.STATUS.ToLower() == active.ToLower()).Select(e => new { Code = e.ITBID, Description = e.INSTITUTION_NAME }).ToList();

            ViewBag.BankList = new SelectList(rec, "CBN_CODE", "INSTITUTION_NAME");
            var scheme = _repo.GetCardScheme(0, true, "Active"); // repoInst.All.Where(e => e.STATUS.ToLower() == active.ToLower()).Select(e => new { Code = e.ITBID, Description = e.INSTITUTION_NAME }).ToList();

            ViewBag.SchemeList   = new SelectList(scheme, "CARDSCHEME", "CARDSCHEME_DESC");
            ViewBag.RecordStatus = new SelectList(SmartObj.GetStatus(), "Code", "Description");
        }
示例#3
0
        public string EncryptQueryString(string m, string ai, string pt, string url, string retUrl)
        {
            // url =string.Format("/{0}/DetailAuth",url);
            var menuId = HttpUtility.UrlEncode(SmartObj.Encrypt(m));
            var a_i    = HttpUtility.UrlEncode(SmartObj.Encrypt(ai));
            // var postType = HttpUtility.UrlEncode(SmartObj.Encrypt(pt));
            // var rId = HttpUtility.UrlEncode(SmartObj.Encrypt(r));
            var ret = string.Format("{0}/DetailAuth?m={1}&a_i={2}", url, menuId, a_i); // Eval("URL") + "?m=" + HttpUtility.UrlEncode(Eval("MENUID").ToString()) + "&r=" +HttpUtility.UrlEncode(Eval("RECORDID").ToString()) + "&a_i=" + HttpUtility.UrlEncode(Eval("ITBID").ToString())+ "&pt=" + HttpUtility.UrlEncode(Eval("POSTTYPE").ToString()) + "&ReturnUrl=" + Request.RawUrl %>' runat = "server" > View Detail </ asp:HyperLink >

            return(ret);
            // string technology = HttpUtility.UrlEncode(SmartObj.Encrypt(ddlTechnology.SelectedItem.Value));
            // Response.Redirect(string.Format("~/CS2.aspx?name={0}&technology={1}", name, technology));
        }
示例#4
0
        public async Task <ActionResult> Add(int id = 0, string m = null)
        {
            try
            {
                BindCombo();
                ViewBag.MenuId = HttpUtility.UrlDecode(m);

                if (id == 0)
                {
                    ViewBag.HeaderTitle   = "Add ServiceChannel";
                    ViewBag.StatusVisible = false;
                    ViewBag.ButtonText    = "Save";
                    GetPriv();
                    return(View("Add", new SERVICEChannelObj()));

                    // return Json(new { RespCode = 99, RespMessage = "Bad Request" }, JsonRequestBehavior.AllowGet);
                }
                else
                {
                    //var d = _repo.GetSession(0, true);
                    ViewBag.HeaderTitle   = "Edit ServiceChannel";
                    ViewBag.StatusVisible = true;
                    ViewBag.ButtonText    = "Update";
                    var rec = await _repo.GetServiceChannelAsync(id, false);

                    if (rec == null)
                    {
                        //bad request
                        // return Json(null, JsonRequestBehavior.AllowGet);
                        //var obj = new { RespCode = 1, RespMessage = "Record Not Found" };
                        // return Json(obj, JsonRequestBehavior.AllowGet);
                        TempData["msg"] = "Record Not Found";
                        return(View("Index"));
                    }
                    var model = rec.FirstOrDefault();
                    ViewBag.RecordStatus = new SelectList(SmartObj.GetStatus(), "Code", "Description");
                    GetPriv();
                    return(View("Add", model));
                }
            }
            catch (Exception ex)
            {
                //var obj1 = new { RespCode = 2, RespMessage = ex.Message };
                //return Json(obj1, JsonRequestBehavior.AllowGet);
                ViewBag.Message = ex.Message;
                return(View("Add"));
            }
        }
示例#5
0
        private bool ResetUser(string bATCHID, string uSERID)
        {
            int cnt = 0;
            var rec = repoReset.AllEager(d => d.BatchId == bATCHID && d.UserId == uSERID).ToList();

            foreach (var t in rec)
            {
                t.Status = approve;

                var user = UserManager.FindByName(t.UserName);
                if (user == null)
                {
                    continue; // Json(new { RespCode = 1, RespMessage = "Invalid." });
                }
                var passLength = 8;
                var bt         = _repo.GetCompanyProfile(0, false);
                if (bt != null)
                {
                    passLength = bt.PASSWORDLENGTH.GetValueOrDefault();
                }
                // bt.PASSWORDLENGTH;
                if (user != null)
                {
                    var            newPass = SmartObj.GenerateRandomPassword(passLength);
                    var            rem     = UserManager.RemovePassword(user.Id);
                    IdentityResult rem2    = null;
                    if (rem.Succeeded)
                    {
                        rem2 = UserManager.AddPassword(user.Id, newPass);
                        if (rem2.Succeeded)
                        {
                            // user.LastPasswordChangeDate = DateTime.Now;
                            user.ForcePassword     = true;
                            user.LockoutEndDateUtc = null;
                            user.Status            = active;
                            var res = UserManager.Update(user);
                            cnt++;
                            SendMailToUser(user.Email, user.UserName, newPass, user.FullName);
                        }
                    }
                }
            }
            if (cnt > 0)
            {
                return(true);
            }
            return(false);
        }
        public static int GetMenuId(string m)
        {
            int menuId = 0;

            if (!string.IsNullOrEmpty(m))
            {
                var decrypt = SmartObj.Decrypt(m);
                // var m = HttpContext.Current.Request.QueryString["m"];
                if (int.TryParse(decrypt, out menuId))
                {
                    //var urlHelper = new UrlHelper();
                    // urlHelper.Action("Login", "Account");
                    return(menuId);
                }
            }
            return(0);
        }
示例#7
0
        public async Task <ActionResult> Detail(string a_i, string m)
        {
            var mid = SmartObj.Decrypt(m);
            var ai  = SmartObj.Decrypt(a_i);

            if (int.TryParse(mid, out menuId) && decimal.TryParse(ai, out authId))
            {
                var controller = await _repo.GetMenuById(menuId);

                ViewBag.Controller = controller;
                ViewBag.Key        = authId;
                // ViewBag.ReturnUrl = returnUrl;
                return(View());
            }
            else
            {
                return(View("Error", "Home"));
            }
        }
        public ActionResult DownloadSetRecon(string id)
        {
            try
            {
                //Call to get Excel byte array.
                string fileName   = string.Format("System Settlement Reconciliation for {0}.xlsx", DateTime.Now.ToString("dd-MM-yyyy"));
                var    rv         = new SetReconUpldSession();
                var    data       = rv.GetSetRecon(User.Identity.Name);
                var    dt         = SmartObj.ToDataTable(data);
                var    excelBytes = DumpExcelLoginUser(dt, fileName);

                //Set file name.

                return(excelBytes != null?File(excelBytes, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", fileName) : null);
            }
            catch
            {
                return(null);
            }
        }
        public static int PostAudit2(SM_AUDIT obj)
        {
            var p = new DynamicParameters();

            p.Add("COLUMNNAME", obj.COLUMNNAME, DbType.String);
            p.Add("AUTHID", obj.AUTHID, DbType.String);
            p.Add("EVENTDATE", obj.EVENTDATE, DbType.DateTime);
            p.Add("EVENTTYPE", obj.EVENTTYPE, DbType.String);
            p.Add("INSTITUTION_ITBID", obj.INSTITUTION_ITBID, DbType.Int32);
            p.Add("NEWVALUE", obj.NEWVALUE, DbType.String);
            p.Add("ORIGINALVALUE", obj.ORIGINALVALUE, DbType.String);
            p.Add("RECORDID", obj.RECORDID, DbType.String);
            p.Add("TABLENAME", obj.TABLENAME, DbType.String);
            p.Add("USERID", obj.USERID, DbType.String);
            p.Add("IPADDRESS", SmartObj.getip(), DbType.String);
            using (var con = new RepoBase().OpenConnection(null))
            {
                var TT = con.Execute("POST_AUDITTRAIL", p, commandType: CommandType.StoredProcedure);
                return(TT);
            }
        }
        public async Task <ActionResult> DownloadLoginUser(string fromdate, string todate, string userid)
        {
            try
            {
                //Call to get Excel byte array.
                string fileName = string.Format("Login User Report {0}.xlsx", DateTime.Now.ToString("dd-MM-yyyy"));

                var data = await _repo.GetLoginUserAsync();

                var dt         = SmartObj.ToDataTable(data);
                var excelBytes = DumpExcelLoginUser(dt, fileName);

                //Set file name.

                return(excelBytes != null?File(excelBytes, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", fileName) : null);
            }
            catch
            {
                return(null);
            }
        }
        public async Task <ActionResult> DownloadAudit(string fromdate, string todate, string userid)
        {
            try
            {
                //Call to get Excel byte array.
                string   fileName = string.Format("Audit Trail Report {0}.xlsx", DateTime.Now.ToString("dd-MM-yyyy"));
                DateTime start_date;
                DateTime end_date;
                var      stSuc = DateTime.TryParse(GetDate(fromdate), out start_date);
                var      adSuc = DateTime.TryParse(GetDate(todate), out end_date);
                var      data  = await _repo.GetRptAuditAsync(institutionId, start_date, end_date, userid : userid, isAll : true);

                var dt         = SmartObj.ToDataTable(data);
                var excelBytes = DumpExcelAudit(dt, fileName);

                //Set file name.

                return(excelBytes != null?File(excelBytes, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", fileName) : null);
            }
            catch
            {
                return(null);
            }
        }
        public static int PostAudit(object oldRecord, object newRecord, string postType, string userId, string authId, DateTime eventDate, string key, string tableName, int instId)
        {
            var cnt = 0;

            FieldInfo[] fieldsA;
            FieldInfo[] fieldsB; // newRecord.GetType().GetFields();
            if (postType == "I")
            {
                if (newRecord == null)
                {
                    return(0);
                }
                //var gh = newRecord.GetType().GetFields();
                fieldsB = newRecord.GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);

                using (var con = new RepoBase().OpenConnection(null))
                {
                    for (int i = 0; i < fieldsB.Length; i++)
                    {
                        var val  = fieldsB[i].GetValue(newRecord);
                        var name = fieldsB[i].Name;
                        var p    = new DynamicParameters();
                        p.Add("COLUMNNAME", name, DbType.String);
                        p.Add("AUTHID", authId, DbType.String);
                        p.Add("EVENTDATE", eventDate, DbType.DateTime);
                        p.Add("EVENTTYPE", postType, DbType.String);
                        p.Add("INSTITUTION_ITBID", instId, DbType.Int32);
                        p.Add("NEWVALUE", val, DbType.String);
                        p.Add("ORIGINALVALUE", null, DbType.String);
                        p.Add("RECORDID", key, DbType.String);
                        p.Add("TABLENAME", tableName, DbType.String);
                        p.Add("USERID", userId, DbType.String);
                        p.Add("IPADDRESS", SmartObj.getip(), DbType.String);

                        cnt = con.Execute("POST_AUDITTRAIL", p, commandType: CommandType.StoredProcedure);
                    }
                }
            }
            else if (postType == "M")
            {
                fieldsA = oldRecord.GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
                fieldsB = newRecord.GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
                using (var con = new RepoBase().OpenConnection(null))
                {
                    for (int i = 0; i < fieldsA.Length; i++)
                    {
                        object a = 1;
                        object b = 1;
                        if (a.Equals(b))
                        {
                            object c = 2;
                        }
                        // var b = fieldsB[i].GetValue(newRecord);

                        var newVal = fieldsB[i].GetValue(newRecord);
                        var oldVal = fieldsA[i].GetValue(oldRecord);
                        var name   = fieldsB[i].Name;
                        if ((oldVal != null && newVal != null && !oldVal.Equals(newVal)) || (oldVal == null && newVal != null) || (oldVal != null && newVal == null))
                        {
                            //var tt1 = newVal.GetType();
                            //var tt2 = newVal.GetType();
                            var p = new DynamicParameters();
                            p.Add("COLUMNNAME", name, DbType.String);
                            p.Add("AUTHID", authId, DbType.String);
                            p.Add("EVENTDATE", eventDate, DbType.DateTime);
                            p.Add("EVENTTYPE", postType, DbType.String);
                            p.Add("INSTITUTION_ITBID", instId, DbType.Int32);
                            p.Add("NEWVALUE", newVal, DbType.String);
                            p.Add("ORIGINALVALUE", oldVal, DbType.String);
                            p.Add("RECORDID", key, DbType.String);
                            p.Add("TABLENAME", tableName, DbType.String);
                            p.Add("USERID", userId, DbType.String);
                            p.Add("IPADDRESS", SmartObj.getip(), DbType.String);

                            cnt = con.Execute("POST_AUDITTRAIL", p, commandType: CommandType.StoredProcedure);
                        }
                    }
                }
            }
            return(cnt);
        }
        public ActionResult Add(int MenuId, int NoLevel, string m)
        {
            try
            {
                string bid      = SmartObj.GenRefNo2();
                var    errorMsg = "";
                if (ModelState.IsValid)
                {
                    //using (var txscope = new TransactionScope(TransactionScopeOption.RequiresNew))
                    //{
                    SM_APPROVAL_ROUTE_TEMP BType = new SM_APPROVAL_ROUTE_TEMP()
                    {
                        // BType.PARTY_CODE = int.Parse(txtpartyCode.Value);
                        MENUID     = MenuId,
                        NOLEVEL    = NoLevel,
                        STATUS     = open,
                        CREATEDATE = DateTime.Now,
                        BATCHID    = bid,
                        USERID     = User.Identity.Name,
                        //RECORDID = model.ITBID,
                    };

                    repoAppRouteTemp.Insert(BType);
                    var rst = uow.Save(User.Identity.Name) > 0 ? true : false;
                    if (rst)
                    {
                        SaveRouteOfficerTemp(eventEdit, bid);

                        SM_AUTHLIST auth = new SM_AUTHLIST()
                        {
                            CREATEDATE        = DateTime.Now,
                            EVENTTYPE         = eventEdit,
                            MENUID            = menuId,
                            RECORDID          = BType.ITBID,
                            STATUS            = open,
                            URL               = Request.FilePath,
                            USERID            = User.Identity.Name,
                            POSTTYPE          = Single,
                            BATCHID           = bid,
                            INSTITUTION_ITBID = institutionId
                        };
                        repoAuth.Insert(auth);
                        var rst1 = uow.Save(User.Identity.Name);
                        if (rst1 > 0)
                        {
                            EmailerNotification.SendForAuthorization(menuId, fullName, deptCode, institutionId, "Approval Route Record");

                            //txscope.Complete();
                            //TempData["msg"] = "Record Created SuccessFully...Authorization Pending.";
                            return(Json(new { RespCode = 0, RespMessage = "Record Created SuccessFully...Authorization Pending." }));
                            //return RedirectToAction("Index", new { m = m });
                        }
                    }
                    //}


                    // If we got this far, something failed, redisplay form
                    return(Json(new { RespCode = 1, RespMessage = errorMsg }));
                }
            }
            catch (SqlException ex)
            {
                //BindCombo();
                //ViewBag.PartyAcct = GetRvHeadLines();
                //ViewBag.Message = ex.Message;
                //return View("Add", model);
                return(Json(new { RespCode = 1, RespMessage = ex.Message }));
            }
            catch (Exception ex)
            {
                //BindCombo();
                //ViewBag.PartyAcct = GetRvHeadLines();
                //ViewBag.Message = ex.Message;
                //return View("Add", model);
                return(Json(new { RespCode = 1, RespMessage = ex.Message }));
            }
            //BindCombo();
            //ViewBag.PartyAcct = GetRvHeadLines();
            //ViewBag.Message = "Problem Processing Request, Try again or Contact Administrator.";
            //return View("Add", model);
            return(Json(new { RespCode = 1, RespMessage = "Problem Processing Request, Try again or Contact Administrator." }));
        }
        public ActionResult Reject(decimal AuthId, int?m, string Narration)
        {
            try
            {
                var rec2 = repoAuth.Find(AuthId);
                if (rec2 == null)
                {
                    respMsg = "Problem processing request. Try again or contact Administrator.";
                    //TempData["msg"] = respMsg;
                    //return RedirectToAction("DetailAuth", new { a_i = SmartObj.Encrypt(rec2.ITBID.ToString()), m = SmartObj.Encrypt(rec2.MENUID.GetValueOrDefault().ToString()) });
                    return(Json(new { RespCode = 1, RespMessage = respMsg }));
                }
                else if (rec2.STATUS.ToLower() != "open")
                {
                    respMsg = "This request has already been processed by an authorizer.";
                    //TempData["msg"] = respMsg;
                    //return RedirectToAction("DetailAuth", new { a_i = SmartObj.Encrypt(AuthId.ToString()), m = SmartObj.Encrypt(m.GetValueOrDefault().ToString()) });
                    return(Json(new { RespCode = 1, RespMessage = respMsg }));
                }
                int recordId = 0;
                // bool suc = false;
                //using (var txscope = new TransactionScope(TransactionScopeOption.RequiresNew))
                //{
                var d = new AuthListUtil();
                //menuId = 5;
                var dd = d.GetCheckerRecord(m.GetValueOrDefault(), AuthId, 0, institutionId);
                if (dd.authListObj.Count < checkerNo)
                {
                    var chk = new SM_AUTHCHECKER()
                    {
                        AUTHLIST_ITBID = AuthId,
                        CREATEDATE     = DateTime.Now,
                        NARRATION      = Narration,
                        STATUS         = reject,
                        USERID         = User.Identity.Name,
                    };
                    repoAuthChecker.Insert(chk);
                    var rst = uow.Save(User.Identity.Name);
                    if (rst > 0)
                    {
                        var noA = dd.authListObj.Where(f => f.CHECKERSTATUS == approve).Count();
                        noA += 1;
                        if (noA == checkerNo)
                        {
                            recordId = (int)rec2.RECORDID;
                            //menuId = rec2.MENUID.GetValueOrDefault();
                            var recc = repoFreqTemp.Find(recordId);
                            if (recc != null)
                            {
                                recc.STATUS = reject;
                            }

                            rec2.STATUS = reject;
                            var t = uow.Save(User.Identity.Name);
                            if (t > 0)
                            {
                                sucNew = true;
                                // txscope.Complete();
                            }
                        }
                    }
                }
                //}
                if (sucNew)
                {
                    EmailerNotification.SendApprovalRejectionMail(rec2.USERID, rec2.EVENTTYPE, reject, "Frequency Rejection", null, fullName);
                    respMsg = "Record Rejected. A mail has been sent to the user.";
                    return(Json(new { RespCode = 0, RespMessage = respMsg, status = reject }));
                }
                respMsg = "Problem processing request. Try again or contact Administrator.";

                return(Json(new { RespCode = 1, RespMessage = respMsg }));
            }
            catch (Exception ex)
            {
                //return Json(new { RespCode = 99, RespMessage = "Problem processing request. Try again or contact Administrator." });
                respMsg         = "Problem processing request. Try again or contact Administrator.";
                TempData["msg"] = respMsg;
                return(RedirectToAction("DetailAuth", new { a_i = SmartObj.Encrypt(AuthId.ToString()), m = SmartObj.Encrypt(m.GetValueOrDefault().ToString()) }));
            }
        }
示例#15
0
        public ActionResult ResetLockout(string[] selected_value)
        {
            try
            {
                //ViewBag.MenuId = menuId; //HttpUtility.UrlDecode(m);
                var bid      = SmartObj.GenRefNo2();
                var errorMsg = "";
                if (ModelState.IsValid)
                {
                    if (selected_value != null)
                    {
                        foreach (var d in selected_value)
                        {
                            var BType = new SM_RESETLOCKOUT_TEMP()
                            {
                                BatchId    = bid,
                                UserName   = d,
                                Status     = open,
                                UserId     = User.Identity.Name,
                                CreateDate = DateTime.Now,
                            };
                            repoReset.Insert(BType);
                        }

                        if (uow.Save(User.Identity.Name) > 0)
                        {
                            SM_AUTHLIST auth = new SM_AUTHLIST()
                            {
                                CREATEDATE = DateTime.Now,
                                EVENTTYPE  = eventInsert,// model.STATUS == active ? eventEdit : model.STATUS,
                                MENUID     = menuId,
                                BATCHID    = bid,

                                //MENUNAME = "",
                                //RECORDID = BType.ITBID,
                                STATUS = open,
                                // TABLENAME = "ADMIN_DEPARTMENT",
                                URL               = Request.FilePath,
                                USERID            = User.Identity.Name,
                                INSTITUTION_ITBID = institutionId,
                                POSTTYPE          = Single
                            };
                            repoAuth.Insert(auth);
                            var rst = uow.Save(User.Identity.Name) > 0 ? true : false;
                            if (rst)
                            {
                                EmailerNotification.SendForAuthorization(menuId, fullName, deptCode, institutionId, "Lockout Reset Record");

                                return(Json(new { RespCode = 0, RespMessage = "Record Updated SuccessFully...Authorization Pending." }));
                            }
                            else
                            {
                                return(Json(new { RespCode = 1, RespMessage = "Problem Processing Record." }));
                            }
                        }
                    }
                    else
                    {
                        return(Json(new { RespCode = 1, RespMessage = "Problem Processing Record." }));
                    }
                }
                // If we got this far, something failed, redisplay form
                return(Json(new { RespCode = 1, RespMessage = errorMsg }));
            }
            catch (SqlException ex)
            {
                var msg = "Problem Updating Record.";
                return(Json(new { RespCode = 1, RespMessage = msg }));
            }
            catch (Exception ex)
            {
                var msg = "Problem Updating Record.";
                return(Json(new { RespCode = 1, RespMessage = msg }));
            }
        }
示例#16
0
        public async Task <ActionResult> DetailAuth(string a_i, string m)
        {
            try
            {
                int menuId;
                var mid = SmartObj.Decrypt(m);
                var ai  = SmartObj.Decrypt(a_i);
                if (int.TryParse(mid, out menuId) && decimal.TryParse(ai, out authId))
                {
                    var obj = new AuthViewObj();
                    var det = repoAuth.Find(authId);
                    //var d = _repo.GetSession(0, true);

                    ViewBag.HeaderTitle = "Authorize Detail for Company Profile";
                    //ViewBag.StatusVisible = true;
                    if (det != null)
                    {
                        //ViewBag.AuthId = authId;
                        //ViewBag.RecordId = det.RECORDID;
                        //ViewBag.BatchId = det.BATCHID;
                        //ViewBag.PostType = det.POSTTYPE;
                        //ViewBag.MenuId = det.MENUID;
                        obj.AuthId      = authId;
                        obj.BatchId     = det.BATCHID;
                        obj.RecordId    = det.RECORDID.GetValueOrDefault();
                        obj.PostType    = det.POSTTYPE;
                        obj.MenuId      = det.MENUID.GetValueOrDefault();
                        ViewBag.Message = TempData["msg"];
                        var stat = ViewBag.Message != null ? null : "open";
                        var rec  = await _repo.GetCompanyProfileAsync((int)det.RECORDID, true, status : stat);   //repoSession.FindAsync(id);

                        if (rec != null)
                        {
                            var model   = rec;
                            var country = await _repo.GetCountryAsync(0, true, "Active");

                            ViewBag.Country = new SelectList(country, "COUNTRY_CODE", "COUNTRY_NAME");
                            var state = await _repo.GetStateAsync(0, true, "Active", countryCode : rec.COMPANY_COUNTRY);

                            ViewBag.State = new SelectList(state, "STATECODE", "STATENAME");
                            var banks = await _repo.GetInstitutionAsync(0, true, "Active");

                            ViewBag.BankList = new SelectList(banks.Where(d => d.IS_BANK != null && d.IS_BANK.ToLower() == "y").ToList(), "CBN_CODE", "INSTITUTION_NAME");
                            BindCity(rec.COMPANY_COUNTRY, rec.COMPANY_CITY);
                            ViewBag.DisplayAuth = det.STATUS == open && !(model.USERID == User.Identity.Name);
                            obj.EventType       = det.EVENTTYPE;
                            obj.DateCreated     = det.CREATEDATE.GetValueOrDefault().ToString("dd-MMM-yyyy");
                            obj.User            = model.CREATED_BY;
                            obj.Status          = det.STATUS;
                            ViewBag.Auth        = obj;
                            if (det.TABLENAME != null)
                            {
                                return(View("DetailAuth", model));
                            }
                            else
                            {
                                ViewBag.HeaderTitle = "Authorize Detail for Srcurity Policy";

                                return(View("DetailAuthPL", model));
                            }
                        }
                        //  return Json(rec, JsonRequestBehavior.AllowGet);
                        //var obj1 = new { model = rec.FirstOrDefault(), RespCode = 0, RespMessage = "Success" };
                        // return Json(obj1, JsonRequestBehavior.AllowGet);
                    }


                    return(View("DetailAuth"));
                }
                else
                {
                    return(View("Error", "Home"));
                }
            }
            catch (Exception ex)
            {
                return(View("DetailAuth"));
            }
        }
示例#17
0
        public ActionResult ApprovePL(decimal AuthId, int?m)
        {
            var sucNew = false;

            try
            {
                var rec2 = repoAuth.Find(AuthId);
                if (rec2 == null)
                {
                    respMsg = "Problem processing request. Try again or contact Administrator.";
                    //TempData["msg"] = respMsg;
                    //return RedirectToAction("DetailAuth", new { a_i = SmartObj.Encrypt(rec2.ITBID.ToString()), m = SmartObj.Encrypt(rec2.MENUID.GetValueOrDefault().ToString()) });
                    return(Json(new { RespCode = 1, RespMessage = respMsg }));
                }
                else if (rec2.STATUS.ToLower() != "open")
                {
                    respMsg = "This request has already been processed by an authorizer.";
                    //TempData["msg"] = respMsg;
                    //return RedirectToAction("DetailAuth", new { a_i = SmartObj.Encrypt(AuthId.ToString()), m = SmartObj.Encrypt(m.GetValueOrDefault().ToString()) });
                    return(Json(new { RespCode = 1, RespMessage = respMsg }));
                }
                int  recordId = 0;
                bool suc      = false;
                //using (var txscope = new TransactionScope(TransactionScopeOption.RequiresNew))
                //{
                var d = new AuthListUtil();
                //menuId = 5;
                var dd = d.GetCheckerRecord(m.GetValueOrDefault(), AuthId, 0, institutionId);
                if (dd.authListObj.Count < checkerNo)
                {
                    var chk = new SM_AUTHCHECKER()
                    {
                        AUTHLIST_ITBID = AuthId,
                        CREATEDATE     = DateTime.Now,
                        NARRATION      = null,
                        STATUS         = approve,
                        USERID         = User.Identity.Name,
                    };
                    repoAuthChecker.Insert(chk);
                    var rst = uow.Save(User.Identity.Name);
                    if (rst > 0)
                    {
                        var noA = dd.authListObj.Where(f => f.CHECKERSTATUS == approve).Count();
                        noA += 1;
                        if (noA == checkerNo)
                        {
                            recordId = (int)rec2.RECORDID;
                            menuId   = rec2.MENUID.GetValueOrDefault();
                            switch (rec2.EVENTTYPE)
                            {
                            case "Modify":
                            {
                                suc = ModifyMainRecordPL(recordId);
                                break;
                            }

                            default:
                            {
                                break;
                            }
                            }


                            if (suc)
                            {
                                rec2.STATUS = approve;
                                var t = uow.Save(rec2.USERID, User.Identity.Name);
                                if (t > 0)
                                {
                                    sucNew = true;
                                    //txscope.Complete();
                                }
                            }
                            else
                            {
                                //return Json(new { RespCode = 99, RespMessage = "Problem processing request. Try again or contact Administrator." });
                                //respMsg = "Problem processing request. Try again or contact Administrator.";
                                //TempData["msg"] = respMsg;
                                //return RedirectToAction("DetailAuth", new { a_i = SmartObj.Encrypt(rec2.ITBID.ToString()), m = SmartObj.Encrypt(rec2.MENUID.GetValueOrDefault().ToString()) });
                                return(Json(new { RespCode = 1, RespMessage = respMsg }));
                            }
                        }

                        //if (!isApprove)
                        //{
                        //    pnlResponse.Visible = true;
                        //    pnlResponse.CssClass = "alert alert-success alert-dismissable alert-bold fade in";

                        //    pnlResponseMsg.Text = "Record Successfully Approved";
                        //}
                    }
                }
                // return Json(new { RespCode = 99, RespMessage = "This request has already been processed by an authorizer." });
                //respMsg = "This request has already been processed by an authorizer.";
                //TempData["msg"] = respMsg;
                //return RedirectToAction("DetailAuth", new { a_i = SmartObj.Encrypt(AuthId.ToString()), m = SmartObj.Encrypt(m.GetValueOrDefault().ToString()) });
                //}
                if (sucNew)
                {
                    EmailerNotification.SendApprovalRejectionMail(rec2.USERID, rec2.EVENTTYPE, approve, "Security Policy Approval", null, fullName);

                    respMsg = "Record Authorized Successfully. A mail has been sent to the user.";

                    return(Json(new { RespCode = 0, RespMessage = respMsg, status = approve }));
                }
                return(Json(new { RespCode = 1, RespMessage = respMsg }));
            }
            catch (Exception ex)
            {
                //return Json(new { RespCode = 99, RespMessage = "Problem processing request. Try again or contact Administrator." });
                respMsg         = "Problem processing request. Try again or contact Administrator.";
                TempData["msg"] = respMsg;
                return(RedirectToAction("DetailAuthPL", new { a_i = SmartObj.Encrypt(AuthId.ToString()), m = SmartObj.Encrypt(m.GetValueOrDefault().ToString()) }));
            }
        }
        // [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 }));
        }
        private void ExportDataTableToPdf(DataTable dt, DateTime setDate, string fileName, string reportName, string logoPath)
        {
            Rectangle rec = new Rectangle(PageSize.A4);

            rec.BackgroundColor = new BaseColor(System.Drawing.Color.Olive);
            Document doc = new Document(rec);

            doc.SetPageSize(PageSize.A4.Rotate());
            PdfWriter writer = PdfWriter.GetInstance(doc, Response.OutputStream);

            doc.Open();

            PdfPTable table = new PdfPTable(2);

            table.TotalWidth      = 700f;
            table.WidthPercentage = 100;
            table.LockedWidth     = true;
            table.SetWidths(new float[] { 1f, 2f });
            ////table.SpacingAfter = 20f;
            ////Company Logo
            var cell2 = ImageCell(logoPath, 75f, Element.ALIGN_LEFT, true);

            table.AddCell(cell2);
            doc.Add(table);
            ////Company Name and Address

            var phrase = new Phrase();

            phrase.Add(new Chunk("Xpress Payments\n".ToUpper(), FontFactory.GetFont("Calibri", 16, Font.BOLD, BaseColor.BLACK)));
            phrase.Add(new Chunk(reportName.ToUpper(), FontFactory.GetFont("Calibri", 14, Font.BOLD, BaseColor.BLACK)));

            cell2 = PhraseCell(phrase, Element.ALIGN_CENTER);
            cell2.VerticalAlignment = Element.ALIGN_MIDDLE;
            table.AddCell(cell2);
            doc.Add(table);
            //Creating paragraph for header

            BaseFont bfntHead = BaseFont.CreateFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
            Font     fntHead  = new iTextSharp.text.Font(bfntHead, 16, 1, iTextSharp.text.BaseColor.ORANGE);
            //Paragraph prgHeading = new Paragraph();
            //prgHeading.Alignment = Element.ALIGN_CENTER;
            //prgHeading.Add(new Chunk(logoPath, fntHead));
            //prgHeading.Add(new Chunk("Xpress Payments".ToUpper(), fntHead));
            //doc.Add(prgHeading);

            //Creating sub title
            //iTextSharp.text.Font fntSubTitle = new iTextSharp.text.Font(bfntHead, 12, 1, iTextSharp.text.BaseColor.ORANGE);
            //Paragraph prgSubTitle = new Paragraph();
            //prgSubTitle.Alignment = Element.ALIGN_CENTER;
            //prgSubTitle.Add(new Chunk(reportName.ToUpper(), fntSubTitle));
            //doc.Add(prgSubTitle);

            //Adding paragraph for report generated by
            Paragraph prgGeneratedBY = new Paragraph();
            BaseFont  btnAuthor      = BaseFont.CreateFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);

            iTextSharp.text.Font fntAuthor = new iTextSharp.text.Font(btnAuthor, 8, 2, iTextSharp.text.BaseColor.BLUE);
            prgGeneratedBY.Alignment = Element.ALIGN_RIGHT;
            //prgGeneratedBY.Add(new Chunk("Report Generated by : ASPArticles", fntAuthor));
            prgGeneratedBY.Add(new Chunk("\nSettlement Date : " + setDate.ToShortDateString(), fntAuthor));
            doc.Add(prgGeneratedBY);

            //Adding a line
            Paragraph p = new Paragraph(new Chunk(new iTextSharp.text.pdf.draw.LineSeparator(0.0F, 100.0F, iTextSharp.text.BaseColor.BLACK, Element.ALIGN_LEFT, 1)));

            doc.Add(p);

            //Adding line break
            doc.Add(new Chunk("\n", fntHead));

            //Adding  PdfPTable
            table = new PdfPTable(dt.Columns.Count);
            table.WidthPercentage = 100.0f;
            // Options: Element.ALIGN_LEFT (or 0), Element.ALIGN_CENTER (1), Element.ALIGN_RIGHT (2).
            table.HorizontalAlignment = Element.ALIGN_LEFT;

            for (int i = 0; i < dt.Columns.Count; i++)
            {
                string   cellText = Server.HtmlDecode(dt.Columns[i].ColumnName);
                PdfPCell cell     = new PdfPCell();
                cell.Phrase          = new Phrase(cellText, new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 8, 1, new BaseColor(System.Drawing.ColorTranslator.FromHtml("#000000"))));
                cell.BackgroundColor = new BaseColor(System.Drawing.ColorTranslator.FromHtml("#ff9800"));
                //cell.Phrase = new Phrase(cellText, new Font(Font.FontFamily.TIMES_ROMAN, 10, 1, new BaseColor(grdStudent.HeaderStyle.ForeColor)));
                //cell.BackgroundColor = new BaseColor(grdStudent.HeaderStyle.BackColor);
                cell.HorizontalAlignment = Element.ALIGN_LEFT;
                //cell.PaddingBottom = 5;
                table.AddCell(cell);
            }

            //writing table Data
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                for (int j = 0; j < dt.Columns.Count; j++)
                {
                    string   cellText = "";
                    PdfPCell cell     = new PdfPCell();
                    if (dt.Rows[i][j].GetType() == typeof(decimal))
                    {
                        decimal value;
                        var     suc = decimal.TryParse(dt.Rows[i][j].ToString(), out value);
                        if (suc)
                        {
                            cellText = SmartObj.FormatMoney(value.ToString("F"));
                            cell.HorizontalAlignment = Element.ALIGN_RIGHT;
                        }
                        else
                        {
                            cell.HorizontalAlignment = Element.ALIGN_RIGHT;
                        }
                    }
                    else if (dt.Rows[i][j].GetType() == typeof(DateTime))
                    {
                        DateTime date;
                        var      suc = DateTime.TryParse(dt.Rows[i][j].ToString(), out date);
                        if (suc)
                        {
                            cellText = date.ToString("dd-MM-yyyy");
                            cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        }
                        else
                        {
                            cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        }
                    }
                    else
                    {
                        cellText = dt.Rows[i][j].ToString();
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                    }



                    // cell.BackgroundColor = new BaseColor(System.Drawing.ColorTranslator.FromHtml("#ff9800"));
                    //cell.Phrase = new Phrase(cellText, new Font(Font.FontFamily.TIMES_ROMAN, 10, 1, new BaseColor(grdStudent.HeaderStyle.ForeColor)));
                    //cell.BackgroundColor = new BaseColor(grdStudent.HeaderStyle.BackColor);
                    cell.Phrase = new Phrase(cellText, new Font(Font.FontFamily.TIMES_ROMAN, 8, 1, new BaseColor(System.Drawing.ColorTranslator.FromHtml("#000000"))));

                    table.AddCell(cell);
                }
            }

            doc.Add(table);
            doc.Close();

            writer.Close();
            Response.ContentType = "application/pdf";
            Response.AddHeader("content-disposition", "attachment;" + string.Format("filename={0}.pdf", fileName));
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.Write(doc);
            Response.End();
            //File(doc, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
        }
示例#20
0
        static NapsObj ValidateUpload(NapsObj t)
        {
            // List<MerchantUpldObj> lst = new List<MerchantUpldObj>();

            //var rec = Naps.GetNaps(User.Identity.Name,null);

            int totalErrorCount = 0;
            //foreach (var t in rec)
            //{
            int     errorCount             = 0;
            var     validationErrorMessage = new List <string>();
            decimal mid;

            //int specialCount = 0;
            if (!decimal.TryParse(t.DEBITBANKCODE, out mid))
            {
                errorCount++;
                //  totalErrorCount++;
                validationErrorMessage.Add(string.Format("DEBITBANKCODE must be number"));
            }
            if (t.DEBITBANKCODE.Length != 3)
            {
                errorCount++;
                //  totalErrorCount++;
                validationErrorMessage.Add(string.Format("DEBITBANKCODE must be {0} Character", 3));
            }
            if (!decimal.TryParse(t.DEBITACCTNO, out mid))
            {
                errorCount++;
                //  totalErrorCount++;
                validationErrorMessage.Add(string.Format("DEBITACCTNO must be number"));
            }
            if (t.DEBITACCTNO.Length != 10)
            {
                errorCount++;
                //  totalErrorCount++;
                validationErrorMessage.Add(string.Format("DEBITACCTNO must be {0} Character", 10));
            }
            if (!decimal.TryParse(t.BENEFICIARYBANKCODE, out mid))
            {
                errorCount++;
                //  totalErrorCount++;
                validationErrorMessage.Add(string.Format("BENEFICIARYBANKCODE must be number"));
            }
            if (t.BENEFICIARYBANKCODE.Length != 3)
            {
                errorCount++;
                //  totalErrorCount++;
                validationErrorMessage.Add(string.Format("BENEFICIARYBANKCODE must be {0} Character", 3));
            }
            if (!decimal.TryParse(t.BENEFICIARYACCTNO, out mid))
            {
                errorCount++;
                //  totalErrorCount++;
                validationErrorMessage.Add(string.Format("BENEFICIARYACCTNO must be number"));
            }
            if (t.BENEFICIARYACCTNO.Length != 10)
            {
                errorCount++;
                //  totalErrorCount++;
                validationErrorMessage.Add(string.Format("BENEFICIARYACCTNO must be {0} Character", 10));
            }

            if (errorCount == 0)
            {
                t.VALIDATIONERRORSTATUS  = false;
                t.VALIDATIONERRORMESSAGE = "";
            }
            else
            {
                totalErrorCount++;
                t.VALIDATIONERRORSTATUS  = true;
                t.VALIDATIONERRORMESSAGE = SmartObj.GetStringFromList(validationErrorMessage);
            }
            //var rst = Naps.PostNaps(t, 2);
            //SessionHelper.GetCart(Session).UpdateItem(t);
            // }

            //  lst.AddRange(lst);
            //if (rec.Count > 0)
            //{
            //    if (totalErrorCount > 0)
            //    {

            //        //pnlResponse.Visible = true;
            //        //pnlResponse.CssClass = "alert alert-danger alert-dismissable alert-bold";
            //        //pnlResponseMsg.Text = string.Format("{0} Record(s) Failed Validation from Batch...", totalErrorCount);
            //        //if (totalErrorCount == rec.Count)
            //        //{
            //        //    btnProcess.Enabled = false;
            //        //}
            //        //else
            //        //{
            //        //    btnProcess.Enabled = true;
            //        //}

            //    }
            //    else
            //    {
            //        //pnlResponse.Visible = true;
            //        //pnlResponse.CssClass = "alert alert-success alert-dismissable alert-bold";
            //        //pnlResponseMsg.Text = "Batch Validated Successfully...You can now save for further processing";
            //        // btnProcess.Enabled = false;
            //        //btnProcess.Enabled = true;
            //    }
            //}
            return(t);
            //}
            //catch (Exception ex)
            //{
            //    return -1;
            //}
        }