Exemplo n.º 1
0
        /// <summary>
        /// Them moi tai khoan
        /// </summary>
        /// <param name="taiKhoan"></param>
        /// <returns></returns>
        public bool AddUser(TaiKhoanModels taiKhoan)
        {
            logger.Start("AddUser");
            bool resutl = false;

            try
            {
                sqlMap.BeginTransaction();
                Hashtable param = new Hashtable();
                param             = base.SetDataToHashtable(false, taiKhoan);
                param["xoa"]      = CST_Common.CST_NOT_DELETE;
                param["kichhoat"] = CST_Common.CST_ACTIVE;
                param["seqname"]  = "seq_m_taikhoan";
                string strid = sqlMap.ExecuteQueryForObject("Common.GetNextVal", param).ToString();
                param["mataikhoan"] = strid;
                sqlMap.Insert("COM_LoginService.AddUser", param);
                sqlMap.CommitTransaction();
            }
            catch (Exception ex)
            {
                logger.Error(ex);
            }
            logger.End("GetUserInfo");
            return(resutl);
        }
Exemplo n.º 2
0
        public TaiKhoanModels GetUserInfo(TaiKhoanModels clParam)
        {
            logger.Start("GetUserInfo");
            List <TaiKhoanModels> lstResult = new List <TaiKhoanModels>();

            try
            {
                Hashtable param = new Hashtable();
                param = base.SetDataToHashtable(false, clParam);
                IList ilist = sqlMap.ExecuteQueryForListNotLog("COM_LoginService.GetLogin", param);
                //chuyen doi du tu Ilist sang custom class
                CastDataType cast = new CastDataType();
                lstResult = cast.AdvanceCastDataToList <TaiKhoanModels>(ilist);
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
            }
            logger.End("GetUserInfo");
            if (lstResult.Count > 0)
            {
                return(lstResult[0]);
            }
            return(null);
        }
Exemplo n.º 3
0
        public ActionResult Create(TaiKhoanModels model)
        {
            //kiem tra tai khoan dang nhap
            if (!IsLogged())
            {
                return(BackToLogin());
            }

            return(View());
        }
Exemplo n.º 4
0
        /// <summary>
        /// Neu dang nhap thanh cong add session cho user
        /// </summary>
        ///
        private void AddSession(TaiKhoanModels model)
        {
            Log4Net.userID                 = model.mataikhoan;
            Session["userid"]              = model.mataikhoan;
            Session["fullname"]            = model.hoten;
            Session["loginid"]             = model.tendangnhap;
            Session["thudientu"]           = model.thudientu;
            Session["phongBanDonVi"]       = model.phongBanDonVis;
            Session["maphongban"]          = model.maphongban;
            Session["machucdanh"]          = model.machucdanh;
            Session["tenchucdanh"]         = model.tenchucdanh;
            Session["sodienthoai"]         = model.sodienthoai;
            Session["phongban_congtruong"] = model.phongban_congtruong;
            Session["manhansu"]            = model.manhansu;
            Session["chucdanhkpi"]         = model.chucdanhkpi;
            Session["ngaysinh"]            = model.ngaysinh;
            Session["grouptk"]             = model.grouptk;
            Session["macongtruong"]        = model.macongtruong;
            Session["loaicuochop"]         = model.loaicuochop;
            if (GetPhongBanDonVi() != null)
            {
                Session["tenchucvu"]  = GetPhongBanDonVi().tenchucdanh;
                Session["maphongban"] = GetPhongBanDonVi().maphongban;
            }
            else
            {
                Session["tenchucvu"] = model.tenchucdanh;
            }

            Session["manhansu"] = model.manhansu;
            //thong tin he thong
            Session["sessionid"] = Session.SessionID;
            Session["clientIP"]  = Log4Net.clientIP;
            Session["browser"]   = Log4Net.browser;
            //ma hoa session
            EncrypteSession();

            //khoi tao profile ban dau
            CommonHelper.CreateFirstProfileUser();

            //tao thu muc temp de user su dung trong qua trinh lam viec
            string pathCache = CommonHelper.GetFolderProfileUser();

            if (!Directory.Exists(pathCache))
            {
                Directory.CreateDirectory(pathCache);
            }
        }
Exemplo n.º 5
0
        //
        // GET: /Account/Profile
        public ActionResult Personal()
        {
            if (!IsLogged())
            {
                return(BackToLogin());
            }
            TaiKhoanServices service = new TaiKhoanServices();
            TaiKhoanModels   result  = service.SelectDetail(new M_TaiKhoan()
            {
                mataikhoan = Session["userid"].ToString()
            });

            if (result != null)
            {
                return(View(result));
            }
            return(View());
        }
Exemplo n.º 6
0
        /// <summary>
        /// lay danh sach phan quyen
        /// </summary>
        /// <returns></returns>
        public List <MenuRole> GetRoles(TaiKhoanModels clParam)
        {
            logger.Start("GetRoles");
            List <MenuRole> lstResult = new List <MenuRole>();

            try
            {
                Hashtable param = new Hashtable();
                param = base.SetDataToHashtable(false, clParam);
                IList iList = null;
                iList = sqlMap.ExecuteQueryForListNotLog("COM_LoginService.GetRoles", param);
                CastDataType cast = new CastDataType();
                lstResult = cast.AdvanceCastDataToList <MenuRole>(iList);
            }
            catch (Exception ex)
            {
                logger.Error(ex);
            }
            logger.End("GetRoles");
            return(lstResult);
        }
Exemplo n.º 7
0
        public TaiKhoanModels SelectDetail(M_TaiKhoan clParam)
        {
            logger.Start("SelectDetail");
            TaiKhoanModels result = new TaiKhoanModels();

            try
            {
                Hashtable param = new Hashtable();
                param = base.SetDataToHashtable(false, clParam);
                IList        ilist = sqlMap.ExecuteQueryForList("m_taikhoan.SelectDetail", param);
                CastDataType cast  = new CastDataType();
                if (ilist.Count > 0)
                {
                    result = cast.AdvanceCastDataToList <TaiKhoanModels>(ilist)[0];
                }
            }
            catch (Exception ex)
            {
                logger.Error("Loi ---> " + ex.Message);
            }
            logger.End("SelectDetail");
            return(result);
        }
Exemplo n.º 8
0
        public ActionResult Personal(M_TaiKhoan model, string returnUrl)
        {
            if (!IsLogged())
            {
                return(BackToLogin());
            }
            TaiKhoanServices service = new TaiKhoanServices();

            model.mataikhoan     = Session["userid"].ToString();
            model.nguoihieuchinh = Session["userid"].ToString();
            model.ngayhieuchinh  = "GETDATE()";
            service.UpdateProfile(model);
            TaiKhoanModels result = service.SelectDetail(new M_TaiKhoan()
            {
                mataikhoan = Session["userid"].ToString()
            });

            if (result != null)
            {
                return(View(result));
            }
            return(View());
        }
Exemplo n.º 9
0
        public bool UpdateUser(TaiKhoanModels taiKhoan, int nguoihieuchinh)
        {
            logger.Start("UpdateUser");
            bool resutl = false;

            try
            {
                sqlMap.BeginTransaction();
                Hashtable param = new Hashtable();
                param = base.SetDataToHashtable(false, taiKhoan);
                param["nguoihieuchinh"] = nguoihieuchinh;
                param["xoa"]            = CST_Common.CST_NOT_DELETE;
                param["kichhoat"]       = CST_Common.CST_ACTIVE;
                sqlMap.Update("COM_LoginService.UpdateUser", param);
                sqlMap.CommitTransaction();
                resutl = true;
            }
            catch (Exception ex)
            {
                logger.Error(ex);
            }
            logger.End("UpdateUser");
            return(resutl);
        }
        public TaiKhoanViewModels()
        {
            TENDANGNHAP      = "khang";
            DanhSachTaiKhoan = taikhoandal.sp_loadtaikhoan();
            bool QuyenAdmin = false, QuyenUser = false;

            rdAdmin = new RelayCommand <RadioButton>((p) => true, (p) =>
            {
                if (p.IsChecked == true)
                {
                    QuyenAdmin = true;
                    QuyenUser  = false;
                }
                else
                {
                    QuyenAdmin = false;
                    QuyenUser  = true;
                }
            });
            rdUser = new RelayCommand <RadioButton>((p) => true, (p) =>
            {
                if (p.IsChecked == true)
                {
                    QuyenUser  = true;
                    QuyenAdmin = false;
                }
                else
                {
                    QuyenUser  = false;
                    QuyenAdmin = true;
                }
            });
            TaoTaiKhoanComand = new RelayCommand <PasswordBox>((p) => true, (p) =>
            {
                if (TEN == null || TEN == "")
                {
                    ThongBao tb = new ThongBao("Chưa nhập họ tên", "CanhBao");
                    tb.ShowDialog();
                }
                else if (TENDANGNHAP == null || TENDANGNHAP == "")
                {
                    ThongBao tb = new ThongBao("Chưa nhập tên đăng nhập", "CanhBao");
                    tb.ShowDialog();
                }
                else if (p == null || string.IsNullOrEmpty(p.Password))
                {
                    ThongBao tb = new ThongBao("Chưa nhập mật khẩu", "CanhBao");
                    tb.ShowDialog();
                }
                else if (QuyenAdmin == false && QuyenUser == false)
                {
                    ThongBao tb = new ThongBao("Chưa chọn quyền tài khoản", "CanhBao");
                    tb.ShowDialog();
                }

                else
                {
                    try
                    {
                        TaiKhoanModels tk_md = new TaiKhoanModels();
                        tk_md.TENDANGNHAP    = TENDANGNHAP;
                        tk_md.MATKHAU        = fMaHoa(p.Password);
                        tk_md.HOTEN          = TEN;
                        if (QuyenAdmin == true)
                        {
                            tk_md.QUYEN = "Admin";
                        }
                        else if (QuyenUser == true)
                        {
                            tk_md.QUYEN = "User";
                        }
                        taikhoandal.sp_themtaikhoan(tk_md);
                        DanhSachTaiKhoan = taikhoandal.sp_loadtaikhoan();
                        TENDANGNHAP      = "";
                        p.Password       = "";
                        TEN = "";
                    }
                    catch
                    {
                        ThongBao tb = new ThongBao("Tên đăng nhập bị trùng, xin đặt tên khác", "CanhBao");
                        tb.ShowDialog();
                    }
                }
            });
            XoaTaiKhoanComand = new RelayCommand <object>((p) => true, (p) =>
            {
                if (SelectedTaiKhoan == null)
                {
                    ThongBao tb = new ThongBao("Chọn tài khoản trên danh sách để xóa", "CanhBao");
                    tb.ShowDialog();
                }
                else
                {
                    ThongBao tb = new ThongBao {
                        DataContext = this
                    };
                    tb.EventYesNo("Xóa tài khoản: " + SelectedTaiKhoan.TENDANGNHAP + " ?", "CauHoi");
                    tb.ShowDialog();
                    if (tb.Yes == true)
                    {
                        TaiKhoanModels tk_md = new TaiKhoanModels();
                        tk_md.TENDANGNHAP    = SelectedTaiKhoan.TENDANGNHAP;
                        taikhoandal.sp_xoataikhoan(tk_md);
                        DanhSachTaiKhoan = taikhoandal.sp_loadtaikhoan();
                    }
                }
            });
            ResetPassComand = new RelayCommand <object>((p) => true, (p) =>
            {
                if (SelectedTaiKhoan == null)
                {
                    ThongBao tb = new ThongBao("Chọn tài khoản trên danh sách để Reset mật khẩu.", "CanhBao");
                    tb.ShowDialog();
                }
                else
                {
                    ThongBao tb = new ThongBao {
                        DataContext = this
                    };
                    tb.EventYesNo("Mật khẩu sẽ được đặt lại là: 123", "CauHoi");
                    tb.ShowDialog();
                    if (tb.Yes == true)
                    {
                        TaiKhoanModels tk_md = new TaiKhoanModels();
                        tk_md.TENDANGNHAP    = SelectedTaiKhoan.TENDANGNHAP;
                        taikhoandal.sp_resetmatkhau(tk_md);
                        DanhSachTaiKhoan = taikhoandal.sp_loadtaikhoan();
                    }
                }
            });
            DangNhapCommand = new RelayCommand <PasswordBox>((p) => true, (p) =>
            {
                if (TENDANGNHAP == null || TENDANGNHAP == "")
                {
                    Console.WriteLine("abc");
                    TrangThai   = "Chưa điền tên đăng nhập";
                    ThongBao tb = new ThongBao("Chưa điền tên đăng nhập", "CanhBao");
                    tb.ShowDialog();
                }
                else if (p == null | p.Password == "")
                {
                    TrangThai   = "Chưa điền mật khẩu";
                    ThongBao tb = new ThongBao("Chưa điền mật khẩu", "CanhBao");
                    tb.ShowDialog();
                }
                else
                {
                    TaiKhoanModels tk_md = new TaiKhoanModels();

                    tk_md.TENDANGNHAP = TENDANGNHAP;
                    List <TaiKhoanModels> danhsachtaikhoan = new List <TaiKhoanModels>();
                    danhsachtaikhoan = taikhoandal.sp_kiemtradangnhap(tk_md);
                    if (danhsachtaikhoan.Count > 0)
                    {
                        if (fMaHoa(p.Password) == danhsachtaikhoan[0].MATKHAU)
                        {
                            BienDungChung.idnhanvien = danhsachtaikhoan[0].TENDANGNHAP;
                            CuaHang.fHome.capquyen(danhsachtaikhoan[0].QUYEN);
                            PageNen.pnen.setquyen(danhsachtaikhoan[0].HOTEN, danhsachtaikhoan[0].QUYEN);
                            PageDangNhap.dn.Close();
                        }
                        else
                        {
                            TrangThai = "Sai mật khẩu";
                        }
                    }
                    else
                    {
                        TrangThai = "Tên đăng nhập không đúng";
                    }
                }
            });
        }
Exemplo n.º 11
0
        public ActionResult Themmoi_capnhat_Account(string act, string mataikhoan, ManageUserViewModel model)
        {
            if (!IsLogged())
            {
                return(BackToLogin());
            }
            if (act == "create")
            {
                LoginServices    service     = new LoginServices();
                TaiKhoanServices serTaiKhoan = new TaiKhoanServices();
                TaiKhoanModels   modeltk     = new TaiKhoanModels();
                // Lay du lieu employee
                var user = service.GetLoginData(new M_TaiKhoan()
                {
                    tendangnhap = model.tendangnhap,
                    xoa         = CST_Common.CST_NOT_DELETE,
                    kichhoat    = CST_Common.CST_ACTIVE
                });
                if (user == null)
                {
                    TaiKhoanModels param = new TaiKhoanModels();
                    param.hoten       = model.hoten;
                    param.tendangnhap = model.tendangnhap;
                    if (model.matkhau != null)
                    {
                        param.matkhau = EncDec.EncodePassword(model.matkhau);
                    }
                    param.thudientu    = model.thudientu;
                    param.maphongban   = model.maphongban;
                    param.machucdanh   = model.machucdanh;
                    param.chucdanhkpi  = model.machucdanh.ToString();
                    param.macongtruong = model.macongtruong;
                    param.loaicuochop  = model.loaicuochop;

                    if (model.machucdanh.ToString().Trim() == "2" || model.machucdanh.ToString().Trim() == "4")
                    {
                        param.grouptk = "2";
                    }
                    else if (model.machucdanh.ToString() == "9")
                    {
                        param.grouptk = "1";
                    }
                    else
                    {
                        param.grouptk = "0";
                    }

                    param.madonvi = 1;
                    int nguoitao = int.Parse(Session["userid"].ToString());
                    TaiKhoanServices taikhoan = new TaiKhoanServices();
                    bool             kq       = taikhoan.AddUser(param, nguoitao);
                }
                else
                {
                    return(RedirectToAction("Manage", "Account"));
                }
            }
            else if (act == "update")
            {
                TaiKhoanModels param = new TaiKhoanModels();
                param.hoten       = model.hoten;
                param.tendangnhap = model.tendangnhap;

                if (model.machucdanh.ToString().Trim() == "2" || model.machucdanh.ToString().Trim() == "4")
                {
                    param.grouptk = "2";
                }
                else if (model.machucdanh.ToString() == "9")
                {
                    param.grouptk = "1";
                }
                else
                {
                    param.grouptk = "0";
                }


                if (model.kichhoat == "on")
                {
                    param.kichhoat = "1";
                }
                else
                {
                    param.kichhoat = "";
                }

                if (model.matkhau != null)
                {
                    param.matkhau = EncDec.EncodePassword(model.matkhau);
                }
                param.mataikhoan = mataikhoan;
                param.thudientu  = model.thudientu;
                param.maphongban = model.maphongban;
                //param.machucdanh = model.machucdanh;
                param.chucdanhkpi = model.machucdanh.ToString();
                param.madonvi     = 1;

                param.macongtruong = model.macongtruong;
                param.loaicuochop  = model.loaicuochop;

                int nguoihieuchinh        = int.Parse(Session["userid"].ToString());
                TaiKhoanServices taikhoan = new TaiKhoanServices();
                bool             kq       = taikhoan.UpdateUser(param, nguoihieuchinh);
            }
            else if (act == "del")
            {
                //ChucDanhModels param = new ChucDanhModels();
                //FunctionXML function = new FunctionXML(Functions.MapPath("~/Xml/Config/encryptionkeyEncodeLink.config"));
                //param.machucdanh = int.Parse(AES.DecryptText(mataikhoan, function.ReadXMLGetKeyEncrypt()));

                int nguoihieuchinh        = int.Parse(Session["userid"].ToString());
                TaiKhoanServices taikhoan = new TaiKhoanServices();

                bool result = taikhoan.DeletedUser(mataikhoan, nguoihieuchinh);
            }
            return(RedirectToAction("Manage", "Account"));
        }
Exemplo n.º 12
0
        public ActionResult Login(TaiKhoanModels model, string returnUrl, string captcha)
        {
            _logger.Start("Login");
            bool bCaptcha = false;

            ViewBag.isNhapCaptcha = false;
            LoginServices service = new LoginServices();

            try
            {
                //neu so lan user dang nhap vuot qua gioi han se bi lock
                if (Session[strSessionLoginFail] == null)
                {
                    Session[strSessionLoginFail] = 0;
                }
                int loginFail = (int)Session[strSessionLoginFail];
                if (!string.IsNullOrEmpty(captcha) && !string.IsNullOrWhiteSpace(captcha))
                {
                    if (captcha == Session[strSessionCaptcha].ToString())
                    {
                        bCaptcha = true;
                    }
                }
                if (loginFail < RICONS.Core.Constants.CST_Common.CST_Lock || bCaptcha)
                {
                    #region kiem tra user login tren he thong AD admin
                    bool   validAD          = false;
                    string matkhaudangnnhap = model.matkhau;
                    string tendangnhap      = model.tendangnhap.Trim().Split('@')[0].ToLower();
                    var    passWordDecrypt  = EncDec.DecryptStringAES(model.matkhau);
                    try
                    {
                        using (PrincipalContext context = new PrincipalContext(ContextType.Domain, "newtecons.vn", tendangnhap, passWordDecrypt))
                        {
                            validAD = context.ValidateCredentials(tendangnhap, passWordDecrypt);
                            UserPrincipal user_ad = UserPrincipal.FindByIdentity(context, IdentityType.SamAccountName, tendangnhap);
                            if (validAD)
                            {
                                #region
                                var user = service.GetLoginData(new M_TaiKhoan()
                                {
                                    tendangnhap = tendangnhap,
                                    xoa         = CST_Common.CST_NOT_DELETE,
                                    kichhoat    = CST_Common.CST_ACTIVE
                                });
                                TaiKhoanServices serTaiKhoan = new TaiKhoanServices();
                                TaiKhoanModels   modeltk     = new TaiKhoanModels();
                                // Lay du lieu employee
                                //var dlemployee = serTaiKhoan.GetDataEmployee(tendangnhap);
                                if (user == null)
                                {
                                    #region
                                    //if (dlemployee != null)
                                    //{
                                    //    modeltk.manhansu = dlemployee.manhansu;
                                    //    modeltk.hoten = dlemployee.hoten;
                                    //    modeltk.machucdanh = dlemployee.machucdanh;
                                    //    modeltk.tenchucdanh = dlemployee.tenchucdanh;
                                    //    modeltk.maphongban = dlemployee.maphongban;

                                    //    if (dlemployee.phongban_congtruong.ToString().ToLower() == "false")
                                    //        modeltk.phongban_congtruong = "0";
                                    //    else modeltk.phongban_congtruong = "1";

                                    //}
                                    modeltk.tendangnhap = tendangnhap;
                                    model.madonvi       = 1;
                                    modeltk.thudientu   = user_ad.EmailAddress;
                                    modeltk.chucdanhkpi = "1";
                                    bool kq = serTaiKhoan.AddUser(modeltk, 0);
                                    user = service.GetLoginData(new M_TaiKhoan()
                                    {
                                        tendangnhap = tendangnhap,
                                        xoa         = CST_Common.CST_NOT_DELETE,
                                        kichhoat    = CST_Common.CST_ACTIVE
                                    });
                                    #endregion
                                }
                                //else if (dlemployee != null)
                                //{
                                //    //Cập nhật manhansu,machucdanh,maphongban
                                //    user.manhansu = dlemployee.manhansu;
                                //    user.maphongban = dlemployee.maphongban;
                                //    user.machucdanh = dlemployee.machucdanh;
                                //    user.tenchucdanh = dlemployee.tenchucdanh;
                                //    user.hoten = dlemployee.hoten;
                                //    user.sodienthoai = dlemployee.sodienthoai;
                                //    user.thudientu = user_ad.EmailAddress;
                                //    user.ngaysinh = dlemployee.ngaysinh;
                                //    user.chucdanhkpi = user.chucdanhkpi;
                                //    if(dlemployee.phongban_congtruong.ToString().ToLower()=="false")
                                //        user.phongban_congtruong = "0";
                                //    else user.phongban_congtruong = "1";

                                //    if (user.chucdanhkpi.Trim() == "" || user.chucdanhkpi == null)
                                //        user.chucdanhkpi = "1";
                                //    bool kqcapnhat = serTaiKhoan.Updatemanhansu(user.mataikhoan, user.manhansu, user.machucdanh.ToString(), user.maphongban, user.hoten, user.chucdanhkpi, user.phongban_congtruong);
                                //}
                                var lstPhongBanDonVis = serTaiKhoan.SelectPhongBanDonVi(new M_TaiKhoan()
                                {
                                    mataikhoan = user.mataikhoan
                                });
                                user.phongBanDonVis = lstPhongBanDonVis;
                                AddSession(user);
                                UpdateLoginState(tendangnhap, false, loginFail);
                                //chuyen trang
                                _logger.End("Login");
                                return(RedirectToAction("Index", "WeedMeeting"));

                                //return RedirectToLocal(returnUrl);
                                #endregion
                            }
                            else if (!validAD)
                            {
                                #region
                                var user = service.GetLoginData(new M_TaiKhoan()
                                {
                                    tendangnhap = model.tendangnhap,
                                    matkhau     = EncDec.EncodePassword(passWordDecrypt),
                                    xoa         = CST_Common.CST_NOT_DELETE,
                                    kichhoat    = CST_Common.CST_ACTIVE
                                });
                                if (user != null)
                                {
                                    TaiKhoanServices serTaiKhoan = new TaiKhoanServices();
                                    var lstPhongBanDonVis        = serTaiKhoan.SelectPhongBanDonVi(new M_TaiKhoan()
                                    {
                                        mataikhoan = user.mataikhoan
                                    });
                                    user.phongBanDonVis = lstPhongBanDonVis;
                                    AddSession(user);
                                    UpdateLoginState(model.tendangnhap, false, loginFail);
                                    _logger.End("Login");
                                    return(RedirectToAction("Index", "WeedMeeting"));
                                }
                                else
                                {
                                    try
                                    {
                                        UpdateLoginState(model.tendangnhap, true, loginFail);
                                    }
                                    catch (Exception ex)
                                    {
                                        _logger.Error(ex);
                                    }
                                }
                                #endregion
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        validAD = false;
                        _logger.Info(ex);
                    }
                    #endregion

                    #region kiem tra user login local

                    if (!validAD)
                    {
                        var user = service.GetLoginData(new M_TaiKhoan()
                        {
                            tendangnhap = model.tendangnhap,
                            matkhau     = EncDec.EncodePassword(passWordDecrypt),
                            xoa         = CST_Common.CST_NOT_DELETE,
                            kichhoat    = CST_Common.CST_ACTIVE
                        });
                        if (user != null)
                        {
                            TaiKhoanServices serTaiKhoan = new TaiKhoanServices();
                            var lstPhongBanDonVis        = serTaiKhoan.SelectPhongBanDonVi(new M_TaiKhoan()
                            {
                                mataikhoan = user.mataikhoan
                            });
                            user.phongBanDonVis = lstPhongBanDonVis;
                            AddSession(user);
                            UpdateLoginState(model.tendangnhap, false, loginFail);
                            _logger.End("Login");
                            return(RedirectToAction("Index", "WeedMeeting"));
                        }
                        else
                        {
                            try
                            {
                                UpdateLoginState(model.tendangnhap, true, loginFail);
                            }
                            catch (Exception ex)
                            {
                                _logger.Error(ex);
                            }
                        }
                    }
                    #endregion
                }
                else
                {
                    ViewBag.isNhapCaptcha = true;
                    UpdateLoginState(model.tendangnhap, true, loginFail);
                }
            }
            catch (Exception ex)
            {
                _logger.Error(ex);
                _logger.End("CheckLogin");
            }
            // If we got this far, something failed, redisplay form
            return(View(model));
        }
Exemplo n.º 13
0
        private StringBuilder PrepareDataJson_DanhSachTaiKhoan(TaiKhoanModels model, int couter)
        {
            StringBuilder sbResult = new StringBuilder();

            try
            {
                sbResult.Append("{");
                sbResult.Append("\"col_class\":\"rows-box\",");
                sbResult.Append("\"col_id\":\"" + model.mataikhoan + "\",");
                sbResult.Append("\"col_value\":[");
                #region Data cell
                //colum checkbox
                string strHTML_Checkbox = string.Format("<input type='checkbox' onclick='Select(this);' class='chkCheck' codeid='{0}'/>", model.mataikhoan);
                sbResult.Append("{");
                sbResult.Append("\"colspan\":\"1\",");
                sbResult.Append("\"col_class\":\"ovh col1\",");
                sbResult.Append("\"col_id\":\"1\",");
                sbResult.Append("\"col_value\":\"" + strHTML_Checkbox + "\"");
                sbResult.Append("},");
                //stt
                sbResult.Append("{");
                sbResult.Append("\"colspan\":\"1\",");
                sbResult.Append("\"col_class\":\"ovh col2 stt\",");
                sbResult.Append("\"col_id\":\"2\",");
                sbResult.Append("\"col_value\":\"" + couter + "\"");
                sbResult.Append("},");

                //tinh trang
                FunctionXML fnc = new FunctionXML(Functions.MapPath("~/Xml/Const/Default.xml"));
                sbResult.Append("{");
                sbResult.Append("\"colspan\":\"1\",");
                sbResult.Append("\"col_class\":\"ovh col3\",");
                sbResult.Append("\"col_id\":\"3\",");
                sbResult.Append("\"title\":\"" + model.tinhtrang.Trim() + "\",");
                sbResult.Append("\"col_value\":\"" + fnc.ReadConst("kichhoat", int.Parse(model.tinhtrang)) + "\"");
                sbResult.Append("},");

                //noi dung
                sbResult.Append("{");
                sbResult.Append("\"colspan\":\"1\",");
                sbResult.Append("\"col_class\":\"ovh col4\",");
                sbResult.Append("\"col_id\":\"4\",");
                sbResult.Append("\"title\":\"" + model.grouptk + "\",");
                sbResult.Append("\"col_value\":\"" + model.tendangnhap + "\"");
                sbResult.Append("},");
                //ten dang nhap
                sbResult.Append("{");
                sbResult.Append("\"colspan\":\"1\",");
                sbResult.Append("\"col_class\":\"ovh col5\",");
                sbResult.Append("\"col_id\":\"5\",");
                sbResult.Append("\"title\":\"" + model.grouptk + "\",");
                sbResult.Append("\"col_value\":\"" + model.hoten + "\"");
                sbResult.Append("},");

                //Email
                sbResult.Append("{");
                sbResult.Append("\"colspan\":\"1\",");
                sbResult.Append("\"col_class\":\"ovh col6\",");
                sbResult.Append("\"col_id\":\"6\",");
                sbResult.Append("\"col_value\":\"" + model.thudientu + "\"");
                sbResult.Append("},");

                //phong ban
                sbResult.Append("{");
                sbResult.Append("\"colspan\":\"1\",");
                sbResult.Append("\"col_class\":\"ovh col7\",");
                sbResult.Append("\"col_id\":\"7\",");
                sbResult.Append("\"title\":\"" + model.maphongban.Trim() + "\",");
                sbResult.Append("\"col_value\":\"" + model.tenphongban + "\"");
                sbResult.Append("},");

                //chucdanh
                sbResult.Append("{");
                sbResult.Append("\"colspan\":\"1\",");
                sbResult.Append("\"col_class\":\"ovh col11\",");
                sbResult.Append("\"col_id\":\"11\",");
                sbResult.Append("\"title\":\"" + model.macongtruong.Trim() + "\",");
                sbResult.Append("\"col_value\":\"" + model.tencongtruong + "\"");
                sbResult.Append("},");

                //chucdanh
                sbResult.Append("{");
                sbResult.Append("\"colspan\":\"1\",");
                sbResult.Append("\"col_class\":\"ovh col12\",");
                sbResult.Append("\"col_id\":\"12\",");
                sbResult.Append("\"title\":\"" + model.loaicuochop + "\",");
                if (model.loaicuochop == 1)
                {
                    sbResult.Append("\"col_value\":\"" + "Trưởng PB/CT" + "\"");
                }
                else if (model.loaicuochop == 2)
                {
                    sbResult.Append("\"col_value\":\"" + "Thiết Bị" + "\"");
                }
                else if (model.loaicuochop == 3)
                {
                    sbResult.Append("\"col_value\":\"" + "HSSE" + "\"");
                }
                else if (model.loaicuochop == 4)
                {
                    sbResult.Append("\"col_value\":\"" + "QAQC" + "\"");
                }
                else if (model.loaicuochop == 5)
                {
                    sbResult.Append("\"col_value\":\"" + "MEP" + "\"");
                }
                else
                {
                    sbResult.Append("\"col_value\":\"" + "Khác" + "\"");
                }
                sbResult.Append("},");

                //chucdanh
                sbResult.Append("{");
                sbResult.Append("\"colspan\":\"1\",");
                sbResult.Append("\"col_class\":\"ovh col8\",");
                sbResult.Append("\"col_id\":\"8\",");
                sbResult.Append("\"title\":\"" + model.chucdanhkpi + "\",");
                sbResult.Append("\"col_value\":\"" + model.tenchucdanhkpi + "\"");
                sbResult.Append("},");

                //chucdanh
                sbResult.Append("{");
                sbResult.Append("\"colspan\":\"1\",");
                sbResult.Append("\"col_class\":\"ovh col9\",");
                sbResult.Append("\"col_id\":\"9\",");
                sbResult.Append("\"title\":\"" + model.madonvi + "\",");
                sbResult.Append("\"col_value\":\"" + model.tendonvi + "\"");
                sbResult.Append("},");



                //dinh kem tap tin
                string strHTML_Attachment = "";
                #region
                string link = Url.Action("Edit", "Account", new { id = EncDec.EncodeCrypto(model.mataikhoan) });
                strHTML_Attachment = "<a href='#' class='edit' ><i class='fa fa-pencil-square-o' ></i></a>&nbsp;    <a href='#' class='del'><i class='fa fa-trash-o' ></i></a>";
                #endregion
                sbResult.Append("{");
                sbResult.Append("\"colspan\":\"1\",");
                sbResult.Append("\"col_class\":\"ovh col10\",");
                sbResult.Append("\"col_id\":\"10\",");
                sbResult.Append("\"col_value\":\"" + strHTML_Attachment + "\"");
                sbResult.Append("}");

                ////chucdanh
                //sbResult.Append("{");
                //sbResult.Append("\"colspan\":\"1\",");
                //sbResult.Append("\"col_class\":\"ovh col11\",");
                //sbResult.Append("\"col_id\":\"11\",");
                //sbResult.Append("\"type\":\"hidden\",");
                //sbResult.Append("\"col_value\":\"" + model.mataikhoan + "\"");
                //sbResult.Append("}");


                #endregion

                sbResult.Append("]");
                sbResult.Append("},");
            }
            catch (Exception ex)
            {
                _logger.Error(ex);
            }
            return(sbResult);
        }