public ActionResult AddNHOMCHUCNANG(ModuleChucnang obj)
        {
            if (ModelState.IsValid)
            {
                obj.ChucnangDESCRIPTION = obj.ChucnangDESCRIPTION.Trim();
                var checkname = _INHOMCHUCNANGService.Query.FirstOrDefault(x => x.DESCRIPTION.ToUpper() == obj.ChucnangDESCRIPTION.ToUpper());
                if (checkname == null)
                {
                    try
                    {
                        NHOMCHUCNANG item = new NHOMCHUCNANG();
                        item.MODULEID    = obj.MODULEID;
                        item.DESCRIPTION = obj.ChucnangDESCRIPTION;

                        _INHOMCHUCNANGService.CreateNew(item);
                        _INHOMCHUCNANGService.CommitChanges();
                        _iLogSystemService.CreateNew(HttpContext.User.Identity.Name, "Thêm mới Nhóm chức năng ", "Thực hiện chức năng thêm mới Nhóm chức năng", Helper.GetIPAddress.GetVisitorIPAddress(), HttpContext.Request.Browser.Browser);
                    }
                    catch (Exception e)
                    {
                        ViewData["EditError"] = e.Message;
                    }
                }
                else
                {
                    ViewData["EditError"] = "Tên đã tồn tại, xin chọn tên khác!";
                }
            }
            else
            {
                ViewData["EditError"] = "Bạn phải nhập đầy đủ thông tin!";
            }
            return(PartialView("NHOMCHUCNANGPartial", GetAllModuleChucnang()));
        }
Esempio n. 2
0
        public ActionResult Index()
        {
            var insertLog1 = _iLogSystemService.CreateNew(HttpContext.User.Identity.Name, "Truy cập chức năng QLND", "Truy cập chức năng QLND",
                                                          Helper.GetIPAddress.GetVisitorIPAddress(), HttpContext.Request.Browser.Browser);

            Session.Remove("Role_QLPQ");
            return(GetValue("Index", string.Empty));
        }
        public ActionResult DoAddNewRole(string name, string RoleTypeId)
        {
            string results = "OK";

            if (ModelState.IsValid && !string.IsNullOrEmpty(name) && !string.IsNullOrEmpty(RoleTypeId))
            {
                var checkExist = _iroleService.Query.FirstOrDefault(x => x.name.ToUpper() == name.ToUpper());
                if (checkExist == null)
                {
                    try
                    {
                        role p = new role();
                        p.AppID = 1;
                        p.name  = name.Trim();
                        List <string> lstPmsChange = new List <string>();

                        if (Session["ArrayPms"] != null)
                        {
                            lstPmsChange = (List <string>)Session["ArrayPms"];
                        }

                        foreach (string word in lstPmsChange)
                        {
                            _permission = _ipmsService.GetByName(word, 1);
                            Listpermission.Add(_permission);
                        }
                        p.Permissions = Listpermission;

                        _iroleService.BeginTran();
                        _iroleService.CreateNew(p);

                        typeRole = new TYPE_ROLE {
                            ROLE_ID = p.roleid, TYPE = int.Parse(RoleTypeId)
                        };

                        _iTypeRoleService.CreateNew(typeRole);
                        _iLogSystemService.CreateNew(HttpContext.User.Identity.Name, "Thêm mới Phân quyền ", "Thực hiện chức năng thêm mới Phân quyền", Helper.GetIPAddress.GetVisitorIPAddress(), HttpContext.Request.Browser.Browser);
                        _iroleService.CommitTran();
                    }
                    catch (Exception e)
                    {
                        _iroleService.RolbackTran();
                        results = e.Message;
                    }
                }
                else
                {
                    results = "ExistName";
                }
            }
            else
            {
                results = "NotOK";
            }
            Session["ArrayPms"]          = null;
            Session["ChangeCheckBoxPms"] = null;
            return(Content(results, "text/html"));
        }
Esempio n. 4
0
        public ActionResult Create(Category cate)
        {
            try
            {
                ICategoryService cateSrv = IoC.Resolve <ICategoryService>();

                int c = cateSrv.Query.Where(p => p.NameVNI == cate.NameVNI || p.NameENG == cate.NameENG || p.UrlName == cate.UrlName).Count();
                if (c > 0)
                {
                    Messages.AddErrorMessage("Tiêu đề hoặc đường dẫn cho chuyên mục đã tồn tại.");
                    CategoryModels model = new CategoryModels();
                    model.ArtCategory    = cate;
                    model.ParentCategory = cateSrv.Query.Where(p => p.ParentID == 0).OrderBy(p => p.NameVNI).ThenBy(p => p.NameENG).ToList();
                    return(View(model));
                }
                cate.CreatedBy = HttpContext.User.Identity.Name;
                cateSrv.CreateNew(cate);
                cateSrv.CommitChanges();
                Messages.AddFlashMessage("Thêm mới thành công.");
                logSrv.CreateNew(FXContext.Current.CurrentUser.userid, "Category - Create :" + cate.Id, "Create Category Success", LogType.Success, HttpContext.Request.UserHostAddress, HttpContext.Request.Browser.Browser);
                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                logSrv.CreateNew(FXContext.Current.CurrentUser.userid, "Category - Create :" + cate.Id, "Create Category Error :" + ex, LogType.Error, HttpContext.Request.UserHostAddress, HttpContext.Request.Browser.Browser);
                Messages.AddErrorMessage("Có lỗi xảy ra, vui lòng thực hiện lại.");
                ICategoryService artCateSrv = IoC.Resolve <ICategoryService>();
                CategoryModels   model      = new CategoryModels();
                model.ArtCategory    = cate;
                model.ParentCategory = artCateSrv.Query.Where(p => p.ParentID == 0).OrderBy(p => p.NameVNI).ThenBy(p => p.NameENG).ToList();
                return(View(model));
            }
        }
Esempio n. 5
0
        public ActionResult Create(Articles art, HttpPostedFileBase dataFile)
        {
            try
            {
                IArticlesService artSrv = IoC.Resolve <IArticlesService>();
                art.CreatedBy = HttpContext.User.Identity.Name;
                art.URLName   = FX.Utils.Common.TextHelper.ToUrlFriendly(art.NameVNI);
                if (!art.IsEvent)
                {
                    art.StartDate = DateTime.Now;
                    art.EndDate   = DateTime.Now;
                }
                if (dataFile != null && dataFile.ContentLength > 0)
                {
                    art.TypeData = dataFile.FileName.Substring(dataFile.FileName.LastIndexOf("."));
                    byte[] bf = new byte[dataFile.ContentLength];
                    dataFile.InputStream.Read(bf, 0, dataFile.ContentLength);
                    art.AttachData = bf;
                }
                artSrv.CreateNew(art);
                // tu động approved
                art.Approved  = true;
                art.ApproveBy = HttpContext.User.Identity.Name;
                art.Active    = true;

                artSrv.CommitChanges();
                Messages.AddFlashMessage("Thêm mới thành công.");

                logSrv.CreateNew(FXContext.Current.CurrentUser.userid, "Article - Create:" + art.Id, "Create Article complete", LogType.Success, HttpContext.Request.UserHostAddress, HttpContext.Request.Browser.Browser);
                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                logSrv.CreateNew(FXContext.Current.CurrentUser.userid, "Article - Create:" + art.Id, "Create Error" + ex, LogType.Error, HttpContext.Request.UserHostAddress, HttpContext.Request.Browser.Browser);
                Messages.AddErrorMessage("Có lỗi xảy ra, vui lòng thực hiện lại.");
                ICategoryService artCateSrv = IoC.Resolve <ICategoryService>();
                ArticleModels    model      = new ArticleModels();
                model.Article = art;

                model.Categories = artCateSrv.Query.Where(p => p.Active).OrderBy(p => p.NameVNI).ThenBy(p => p.NameENG).ToList();
                return(View(model));
            }
        }
Esempio n. 6
0
        public ActionResult SaveIntruction(Introduction model)
        {
            IIntroductionService introducSrv = IoC.Resolve <IIntroductionService>();

            try
            {
                model.CreateDate = DateTime.Now;
                model.CreateBy   = HttpContext.User.Identity.Name;
                introducSrv.Save(model);
                introducSrv.CommitChanges();
                logSrv.CreateNew(FXContext.Current.CurrentUser.userid, "SaveIntruction - Save : " + model.Id, "Save SaveIntruction Success", LogType.Success, HttpContext.Request.UserHostAddress, HttpContext.Request.Browser.Browser);
                return(RedirectToAction("Details", new { id = model.Id }));
            }
            catch (Exception ex)
            {
                logSrv.CreateNew(FXContext.Current.CurrentUser.userid, "SaveIntruction - Save", "Save SaveIntruction Error : " + ex.Message, LogType.Error, HttpContext.Request.UserHostAddress, HttpContext.Request.Browser.Browser);
                Messages.AddErrorMessage("Có lỗi xảy ra, vui lòng thực hiện lại");
                return(View("AddIntruction", model));
            }
        }
Esempio n. 7
0
 public ActionResult Create(Document model, HttpPostedFileBase dataFile)
 {
     try
     {
         if (dataFile != null && dataFile.ContentLength > 0)
         {
             byte[] bf = new byte[dataFile.ContentLength];
             dataFile.InputStream.Read(bf, 0, dataFile.ContentLength);
             model.Data       = bf;
             model.CreateBy   = HttpContext.User.Identity.Name;
             model.CreateDate = DateTime.Now;
             documentSrv.CreateNew(model);
             documentSrv.CommitChanges();
             Messages.AddFlashMessage("Tạo mới văn bản pháp quy thành công");
             logSrv.CreateNew(FXContext.Current.CurrentUser.userid, "Document - Create :" + model.Id, "Create Document Success", LogType.Success, HttpContext.Request.UserHostAddress, HttpContext.Request.Browser.Browser);
             return(RedirectToAction("Index"));
         }
         Messages.AddErrorFlashMessage("Chưa chọn file văn bản.");
         return(View(model));
     }
     catch (Exception e)
     {
         logSrv.CreateNew(FXContext.Current.CurrentUser.userid, "Document - Create", "Create Document Error : " + e, LogType.Error, HttpContext.Request.UserHostAddress, HttpContext.Request.Browser.Browser);
         Messages.AddErrorMessage("Có lỗi trong quá trình xử lý, vui lòng thực hiện lại.");
         return(View(model));
     }
 }
Esempio n. 8
0
        public ActionResult Create(VideoType type)
        {
            try
            {
                IVideoTypeService typeSrv = IoC.Resolve <IVideoTypeService>();
                var c = typeSrv.Query.Where(p => p.NameVNI == type.NameVNI || p.NameENG == type.NameENG).Count();
                if (c > 0)
                {
                    Messages.AddErrorMessage("Tiêu đề tin tức đã tồn tại");
                    VideoTypeModels model = new VideoTypeModels();
                    model.ArtVideoType = type;
                    return(View(model));
                }
                type.UrlName   = FX.Utils.Common.TextHelper.ToUrlFriendly(type.NameVNI);
                type.CreatedBy = HttpContext.User.Identity.Name;
                typeSrv.CreateNew(type);
                typeSrv.CommitChanges();
                Messages.AddFlashMessage("Thêm mới thành công.");
                logSrv.CreateNew(FXContext.Current.CurrentUser.userid, "VideoType - Create", "Create VideoType Success", LogType.Success, HttpContext.Request.UserHostAddress, HttpContext.Request.Browser.Browser);

                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                logSrv.CreateNew(FXContext.Current.CurrentUser.userid, "VideoType - Create", "Create VideoType Error : " + ex, LogType.Error, HttpContext.Request.UserHostAddress, HttpContext.Request.Browser.Browser);
                Messages.AddErrorMessage("Có lỗi xảy ra, vui lòng thực hiện lại.");
                VideoTypeModels model = new VideoTypeModels();
                model.ArtVideoType = type;
                return(View(model));
            }
        }
Esempio n. 9
0
        public ActionResult Delete(int id)
        {
            if (id <= 0)
            {
                throw new HttpRequestValidationException();
            }
            IRBACMembershipProvider _MemberShipProvider = IoC.Resolve <IRBACMembershipProvider>();
            user model = _MemberShipProvider.GetUser(id, false);

            if (HttpContext.User.Identity.Name.ToUpper() == model.username.ToUpper())
            {
                Messages.AddErrorFlashMessage("Không thể xóa tài khoản đang sử dụng!");
                return(RedirectToAction("index"));
            }
            if (!_MemberShipProvider.DeleteUser(id, true))
            {
                Messages.AddErrorFlashMessage("Chưa xóa được tài khoản.");
            }
            else
            {
                logSrv.CreateNew(FXContext.Current.CurrentUser.userid, "User - Delete : " + string.Format("Delete: {0} by {1}", model.username, HttpContext.User.Identity.Name), "Delete User Success ", LogType.Success, HttpContext.Request.UserHostAddress, HttpContext.Request.Browser.Browser);


                Messages.AddFlashMessage("Xóa tài khoản thành công!");
            }
            return(RedirectToAction("index"));
        }
Esempio n. 10
0
 public ActionResult AddNewObj(ObjectView obj)
 {
     if (ModelState.IsValid)
     {
         var checkname = _iService.Query.FirstOrDefault(x => x.name.ToUpper() == obj.name.ToUpper());
         if (checkname == null)
         {
             try
             {
                 objectRbac p = new objectRbac();
                 p.AppID  = 1;
                 p.locked = false;
                 p.name   = obj.name.Trim();
                 _iService.BeginTran();
                 _iService.CreateNew(p);
                 var _nhomchucnangobject = new NHOMCHUCNANG_OBJECT {
                     NHOMCHUCNANGID = obj.nhomchucnangid, OBJECTID = p.objectid
                 };
                 _INHOMCHUCNANG_OBJECTService.CreateNew(_nhomchucnangobject);
                 _iService.CommitTran();
                 _iLogSystemService.CreateNew(HttpContext.User.Identity.Name, "Thêm mới chức năng", "Thực hiện chức năng thêm mới chức năng", Helper.GetIPAddress.GetVisitorIPAddress(), HttpContext.Request.Browser.Browser);
             }
             catch (Exception e)
             {
                 _iService.RolbackTran();
                 ViewData["EditError"] = e.Message;
             }
         }
         else
         {
             ViewData["EditError"] = "Tên đã tồn tại, xin chọn tên khác!";
         }
     }
     else
     {
         ViewData["EditError"] = "Bạn phải nhập đầy đủ thông tin!";
     }
     return(PartialView("ObjectPartial", GetAllObjectView()));
 }
Esempio n. 11
0
        public ActionResult Detail(int id)
        {
            string       currentUser = HttpContext.User.Identity.Name;
            Notification notifi      = notiSrv.Getbykey(id);

            try
            {
                if (notifi != null)
                {
                    if (notifi.CreateBy.ToLower().Equals(currentUser.ToLower()))
                    {
                        int articleId               = notifi.ArticleId;
                        IArticlesService artSrv     = IoC.Resolve <IArticlesService>();
                        ICategoryService artCateSrv = IoC.Resolve <ICategoryService>();
                        ArticleModels    model      = new ArticleModels();
                        model.Article      = artSrv.Getbykey(id);
                        model.Categories   = artCateSrv.Query.OrderBy(p => p.NameVNI).ThenBy(p => p.NameENG).ToList();
                        model.Notification = notifi;
                        return(View(model));
                    }
                    else
                    {
                        Messages.AddErrorMessage("Có lỗi xảy ra, vui lòng thực hiện lại.");
                        return(View("Index"));
                    }
                }
                else
                {
                    Messages.AddErrorMessage("Có lỗi xảy ra, vui lòng thực hiện lại.");
                    return(View("Index"));
                }
            }
            catch (Exception ex)
            {
                logSrv.CreateNew(FXContext.Current.CurrentUser.userid, "Notification - Details : " + id, "Details Notification Error : " + ex, LogType.Error, HttpContext.Request.UserHostAddress, HttpContext.Request.Browser.Browser);
                Messages.AddErrorMessage("Có lỗi xảy ra, vui lòng thực hiện lại.");
                return(View("Index"));
            }
        }
Esempio n. 12
0
        public ActionResult ConfirmUpload(Videos video)
        {
            try
            {
                IVideosService videoSrv = IoC.Resolve <IVideosService>();
                video.LinkType  = LinkType.Local;
                video.CreatedBy = HttpContext.User.Identity.Name;
                video.VideoPath = "/VideosStore/video/" + video.VideoPath;
                //Hình ảnh

                video.URLName = FX.Utils.Common.TextHelper.ToUrlFriendly(video.NameVNI);
                ConvertVideo conv = new ConvertVideo(video.VideoPath);
                if (video.VideoPath.IndexOf("mp4") > 0)
                {
                    Thread thread = new Thread(new ThreadStart(conv.ConvertVideoToWebM));
                    thread.Start();
                }
                else if (video.VideoPath.IndexOf("webm") > 0)
                {
                    Thread thread = new Thread(new ThreadStart(conv.ConvertVideoToMp4));
                    thread.Start();
                }


                string videoFull = video.VideoPath.Split('/')[3];
                string videoName = videoFull.Split('.')[0];
                string imageName = "/UploadStore/Videos/" + videoName + ".jpg";

                video.ImagePath = imageName;
                videoSrv.CreateNew(video);
                videoSrv.CommitChanges();
                Messages.AddFlashMessage("Thêm mới thành công.");
                logSrv.CreateNew(FXContext.Current.CurrentUser.userid, "Video - Create", "Create Video Success", LogType.Success, HttpContext.Request.UserHostAddress, HttpContext.Request.Browser.Browser);

                return(new JsonResult()
                {
                    Data = "Tải Video thành công!"
                });
            }
            catch (Exception ex)
            {
                logSrv.CreateNew(FXContext.Current.CurrentUser.userid, "Video - Create", "Create Video Error : " + ex, LogType.Error, HttpContext.Request.UserHostAddress, HttpContext.Request.Browser.Browser);

                return(new JsonResult()
                {
                    Data = "Có lỗi xảy ra vui lòng thực hiện lại."
                });
            }
        }
Esempio n. 13
0
 protected bool TryLogSystem(string yourEvent, string yourComment)
 {
     try
     {
         ILogSystemService _iLogSystemService = IoC.Resolve <ILogSystemService>();
         var nguoidung = ((EISContext)FXContext.Current).CurrentNguoidung;
         _iLogSystemService.CreateNew(nguoidung.TENDANGNHAP.Trim(), yourEvent.Trim(), yourComment.Trim(),
                                      Helper.GetIPAddress.GetVisitorIPAddress(), HttpContext.Request.Browser.Browser);
         return(true);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         return(false);
     }
 }
Esempio n. 14
0
        public ActionResult Create(RoleModel model, string[] permissions)
        {
            IroleService            _RoleSrc            = IoC.Resolve <IroleService>();
            IpermissionService      _PermissionSrc      = IoC.Resolve <IpermissionService>();
            IRBACMembershipProvider _MemberShipProvider = IoC.Resolve <IRBACMembershipProvider>();

            try
            {
                if (permissions == null || permissions.Count() == 0)
                {
                    Messages.AddErrorMessage("Cần chọn permission.");
                    List <permission> lPermissions = _PermissionSrc.Query.Where(a => a.AppID == _MemberShipProvider.Application.AppID).ToList <permission>();
                    ViewData["Permissions"] = lPermissions;
                    model.Permissions       = new List <permission>();
                    return(View("Create", model));
                }
                int cRole = _RoleSrc.Query.Where(p => p.AppID == _MemberShipProvider.Application.AppID && p.name.ToUpper() == model.name.Trim().ToUpper()).Count();
                if (cRole > 0)
                {
                    Messages.AddErrorMessage("Tên quyền này đã tồn tại trong hệ thống.");
                    List <permission> lPermissions = _PermissionSrc.Query.Where(a => a.AppID == _MemberShipProvider.Application.AppID).ToList <permission>();
                    ViewData["Permissions"] = lPermissions;
                    model.Permissions       = new List <permission>();
                    return(View("Create", model));
                }
                role omodel = new role();
                model.Permissions = permissions == null ? new List <permission>() : _PermissionSrc.Query.Where(p => permissions.Contains(p.name)).OrderBy(p => p.Description).ToList <permission>();
                //lay cac thong tin cho role
                omodel.name        = model.name;
                omodel.Permissions = model.Permissions;
                omodel.AppID       = _MemberShipProvider.Application.AppID;
                _RoleSrc.CreateNew(omodel);
                _RoleSrc.CommitChanges();
                Messages.AddFlashMessage("Tạo quyền thành công.");
                logSrv.CreateNew(FXContext.Current.CurrentUser.userid, "Role - Create : " + omodel.roleid, "Create Role Success", LogType.Success, HttpContext.Request.UserHostAddress, HttpContext.Request.Browser.Browser);
                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                logSrv.CreateNew(FXContext.Current.CurrentUser.userid, "Role - Create", "Create Role Error : " + ex, LogType.Error, HttpContext.Request.UserHostAddress, HttpContext.Request.Browser.Browser);
                Messages.AddErrorMessage("Có lỗi xảy ra, vui lòng thực hiện lại.");
                List <permission> lPermissions = _PermissionSrc.Query.Where(a => a.AppID == _MemberShipProvider.Application.AppID).OrderBy(p => p.Description).ToList <permission>();
                ViewData["Permissions"] = lPermissions;
                model.Permissions       = new List <permission>();
                return(View("Create", model));
            }
        }
Esempio n. 15
0
        public ActionResult Create(GalleryType model, string ImageLib)
        {
            try
            {
                var c = galleryTypeSrv.Query.Where(p => p.TitleVNI == model.TitleVNI || p.TitleENG == model.TitleENG).Count();
                if (c > 0)
                {
                    Messages.AddErrorMessage("Tiêu đề ảnh đã tồn tại");

                    return(View(model));
                }
                string Mess = "";
                model.CreateBy   = HttpContext.User.Identity.Name;
                model.CreateDate = DateTime.Now;
                model.UrlName    = FX.Utils.Common.TextHelper.ToUrlFriendly(model.TitleVNI);
                string[]        str       = ImageLib.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                IList <Gallery> galleries = new List <Gallery>();
                foreach (var s in str)
                {
                    var it = new Gallery();
                    it.ImgPath    = s;
                    it.CreateBy   = model.CreateBy;
                    it.CreateDate = DateTime.Now;
                    it.Active     = true;
                    galleries.Add(it);
                }
                if (!galleryTypeSrv.CreateNew(model, galleries, out Mess))
                {
                    Messages.AddErrorMessage(Mess);
                    return(View(model));
                }
                Messages.AddFlashMessage("Tạo mới thành công");
                logSrv.CreateNew(FXContext.Current.CurrentUser.userid, "GalleryType - Create :" + model.Id, "Create GalleryType Success", LogType.Success, HttpContext.Request.UserHostAddress, HttpContext.Request.Browser.Browser);
                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                logSrv.CreateNew(FXContext.Current.CurrentUser.userid, "GalleryType - Create :" + model.Id, "Create GalleryType Error : " + ex.Message, LogType.Error, HttpContext.Request.UserHostAddress, HttpContext.Request.Browser.Browser);
                Messages.AddErrorMessage("Có lỗi trong quá trình xử lý, vui lòng thực hiện lại.");
                return(View(model));
            }
        }
Esempio n. 16
0
        public ActionResult InfoEdit(Contact model)
        {
            IContactService contactSrv = IoC.Resolve <IContactService>();

            try
            {
                model.Type = true;
                contactSrv.Update(model);
                contactSrv.CommitChanges();
                Messages.AddFlashMessage("Sửa thông tin thành công.");
                logSrv.CreateNew(FXContext.Current.CurrentUser.userid, "Contact - Update ", "InfoEdit Contact Success", LogType.Success, HttpContext.Request.UserHostAddress, HttpContext.Request.Browser.Browser);
                return(RedirectToAction("Info"));
            }
            catch (Exception ex)
            {
                return(View(model));
            }
        }
Esempio n. 17
0
 public ActionResult Create(Banners model)
 {
     try
     {
         model.CreatedBy    = HttpContext.User.Identity.Name;
         model.CreatedDate  = DateTime.Now;
         model.ModifiedDate = DateTime.Now;
         model.FromDate     = DateTime.Now;
         model.ToDate       = DateTime.MaxValue;
         bannerSrv.CreateNew(model);
         bannerSrv.CommitChanges();
         Messages.AddFlashMessage("Tạo mới banner thành công");
         logSrv.CreateNew(FXContext.Current.CurrentUser.userid, "Banner - Create :" + model.Id, "Create Banner Success", LogType.Success, HttpContext.Request.UserHostAddress, HttpContext.Request.Browser.Browser);
         return(RedirectToAction("Index"));
     }
     catch (Exception e)
     {
         logSrv.CreateNew(FXContext.Current.CurrentUser.userid, "Banner - Create :" + model.Id, "Create Banner Error: " + e.Message, LogType.Error, HttpContext.Request.UserHostAddress, HttpContext.Request.Browser.Browser);
         Messages.AddErrorMessage("Có lỗi trong quá trình xử lý, vui lòng thực hiện lại.");
         return(View(model));
     }
 }
Esempio n. 18
0
        public ActionResult Create(Menu model)
        {
            try
            {
                var c = menuBarSrv.Query.Where(p => p.NameVNI == model.NameVNI || p.NameENG == model.NameENG || p.NavigateUrl == model.NavigateUrl).Count();
                if (c > 0)
                {
                    ViewData["MenuParents"] = menuBarSrv.Query.Where(p => p.ParentID == 0).OrderBy(p => p.NameVNI).ToList();
                    Messages.AddErrorMessage("Tiêu đề hoặc đường dẫn đã tồn tại");
                    return(View(model));
                }
                if (model.ParentID != 0)
                {
                    Menu menubar = menuBarSrv.Getbykey(model.ParentID);
                    if (model.Position != menubar.Position)
                    {
                        model.Position = menubar.Position;
                    }
                }
                model.CreatedDate = DateTime.Now;
                menuBarSrv.CreateNew(model);
                menuBarSrv.CommitChanges();
                Messages.AddFlashMessage("Tạo mới menu thành công");
                logSrv.CreateNew(FXContext.Current.CurrentUser.userid, "Menu - Create : " + model.Id, "Create Menu Success ", LogType.Success, HttpContext.Request.UserHostAddress, HttpContext.Request.Browser.Browser);

                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                logSrv.CreateNew(FXContext.Current.CurrentUser.userid, "Menu - Create : " + model.Id, "Create Menu Error " + ex, LogType.Error, HttpContext.Request.UserHostAddress, HttpContext.Request.Browser.Browser);

                ViewData["MenuParents"] = menuBarSrv.Query.Where(p => p.ParentID == 0).OrderBy(p => p.NameVNI).ToList();
                Messages.AddErrorMessage("Có lỗi trong quá trình xử lý, vui lòng thực hiện lại.");
                return(View(model));
            }
        }
Esempio n. 19
0
        public ActionResult AddNewPms(ObjectPermission obpms)
        {
            if (ModelState.IsValid && Session["MultiType"] != null)
            {
                var checkPermissionInObject =
                    _iPMSService.Query.Where(m => m.ObjectRBAC.objectid == obpms.ObjectId)
                    .Select(n => n.permissionid)
                    .ToList();
                int count = checkPermissionInObject.Count;
                if (count < 8)
                {
                    var checkname = _iPMSService.Query.FirstOrDefault(x => x.name.ToUpper() == obpms.PmsName.ToUpper());
                    if (checkname == null)
                    {
                        try
                        {
                            objectRbac objRb = new objectRbac();
                            objRb.objectid = obpms.ObjectId;

                            permission p = new permission();
                            p.AppID       = 1;
                            p.name        = obpms.PmsName.Trim();
                            p.Description = obpms.DesPms.Trim();
                            p.ObjectRBAC  = objRb;
                            var    Type_pms             = new TYPE_PERMISSION();
                            string TYPE_PERMISSIONMULTI = Session["MultiType"].ToString();

                            _iPMSService.BeginTran();

                            _iPMSService.CreateNew(p);
                            Type_pms.PERMISSIONID         = p.permissionid;
                            Type_pms.TYPE_PERMISSIONMULTI = TYPE_PERMISSIONMULTI;
                            Type_pms.LOAI_PERMISSION      = obpms.LoaiPermission;
                            _ITYPE_PERMISSIONService.CreateNew(Type_pms);

                            _iPMSService.CommitTran();
                            _iLogSystemService.CreateNew(HttpContext.User.Identity.Name, "Thêm mới tác vụ ", "Thực hiện chức năng thêm mới tác vụ", Helper.GetIPAddress.GetVisitorIPAddress(), HttpContext.Request.Browser.Browser);
                        }
                        catch (Exception e)
                        {
                            _iPMSService.RolbackTran();
                            ViewData["EditError"] = e.Message;
                        }
                    }
                    else
                    {
                        ViewData["EditError"] = "Tên đã tồn tại, xin chọn tên khác!";
                    }
                }
                else
                {
                    ViewData["EditError"] = "Một chức năng chỉ chứa tối đa 8 tác vụ, nhóm hiện đã có 8 tác vụ, vui lòng chọn chức năng khác!";
                }
            }
            else
            {
                ViewData["EditError"] = "Bạn phải nhập đầy đủ thông tin";
            }
            Session["MultiType"]          = null;
            Session["MultiTypeCheckEdit"] = null;
            return(PartialView("PERMISSIONPartial", GetAllPms()));
        }
Esempio n. 20
0
        public ActionResult Login(string username, string password, string captcha)
        {
            string CapImaText = Convert.ToString(Session["Captcha"]);

            if (captcha != CapImaText)
            {
                return(Json(new { data = 3 }, JsonRequestBehavior.AllowGet));
            }
            Session["MustChangePW"] = false;
            _iLogSystemService.CreateNew(username.Trim(), "Đăng nhập hệ thống ", "Thực hiện đăng nhập hệ thống",
                                         Helper.GetIPAddress.GetVisitorIPAddress(), HttpContext.Request.Browser.Browser);
            try
            {
                Session["password"] = password;
                if (authenticationService.Logon(username.Trim(), password.Trim()))
                {
                    //isert log system_iLogSystemService.CreateNew(username.Trim(), "Đăng nhập hệ thống ", "Đăng nhập thành công",Helper.GetIPAddress.GetVisitorIPAddress(), HttpContext.Request.Browser.Browser);

                    //CheckChangePassword cc_password = new CheckChangePassword();
                    //bool isChange = cc_password.CheckChange(password);

                    //var currentUser = UserDataService.Query.FirstOrDefault(x => x.username.ToUpper() == username.ToUpper()) ?? new user();
                    //var nguoidungId = NguoidungService.Query.FirstOrDefault(x => x.TENDANGNHAP.ToUpper() == username.Trim().ToUpper()) ?? new NGUOIDUNG();

                    //if (currentUser.ISADMIN != true && nguoidungId.ISPQ != true && nguoidungId.DF_LOAITG == null)
                    //{
                    //    if (!isChange)
                    //    {
                    //        Session["MustChangePW"] = true;
                    //    }

                    //    System.Web.HttpContext.Current.Session["COSOKCB_Session"] = nguoidungId.COSOKCBS;
                    //    return Json(new { data = 5 }, JsonRequestBehavior.AllowGet);
                    //}

                    //if (!isChange)
                    //{
                    //    Session["MustChangePW"] = true;
                    //    return Json(new { data = 4 }, JsonRequestBehavior.AllowGet);
                    //}


                    #region tungns - lấy danh sách permission của Người dùng
                    var currentuser =
                        UserDataService.Query.FirstOrDefault(x => x.username.ToUpper() == username.ToUpper());
                    if (currentuser == null)
                    {
                        return(Json(new { data = 2 }, JsonRequestBehavior.AllowGet));
                    }
                    var currentuserRoles = currentuser.Roles;
                    var listPer          = new List <permission>();
                    foreach (var role in currentuserRoles)
                    {
                        listPer.AddRange(role.Permissions.ToList());
                    }
                    var lstPer = new HashSet <String>(listPer.Select(item => item.name)).ToList();

                    Session["LIST_PERMISSION"] = lstPer;
                    #endregion

                    return(Json(new { data = 1 }, JsonRequestBehavior.AllowGet));
                }
                return(Json(new { data = 2 }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception e)
            {
                log.Error(e.Message);
                return(Json(new { data = 6, message = e.Message, stack = e.StackTrace }, JsonRequestBehavior.AllowGet));
            }
        }