Esempio n. 1
0
 private void setAutheniticated(string username)
 {
     try
     {
         DT_WebGISEntities MyContext  = new DT_WebGISEntities();
         CSF_Users_DAO     objUserDao = new CSF_Users_DAO();
         var user = objUserDao.GetByUserName(username);
         if (user == null)
         {
             CSF_Users obj = new CSF_Users();
             obj.UserName     = username;
             obj.FullName     = username;
             obj.Status       = 1;
             obj.RegisterDate = DateTime.Now;
             obj.Email        = username + "@monre.gov.vn";
             obj.Password     = Encryptor.MD5Hash("e10adc3949ba59abbe56e057f20f883e");
             MyContext.CSF_Users.Add(obj);
             MyContext.SaveChanges();
             if (obj.ID > 0)
             {
                 int          IDRegistedGroup = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["IDRegistedGroup"]);
                 CSF_UserRole objUR           = new CSF_UserRole();
                 objUR.RoleID = IDRegistedGroup;
                 objUR.UserID = obj.ID;
                 MyContext.CSF_UserRole.Add(objUR);
                 MyContext.SaveChanges();
             }
         }
         FormsAuthentication.SetAuthCookie(username, false);
     }
     catch (Exception ex)
     {
         Logs.WriteLog(ex);
     }
 }
Esempio n. 2
0
 public int Insert(CMS_TypeOfDocument entity)
 {
     try
     {
         MyContext.CMS_TypeOfDocument.Add(entity);
         MyContext.SaveChanges();
         return(entity.ID);
     }
     catch (Exception ex)
     {
         Logs.WriteLog(ex);
         throw;
     }
 }
Esempio n. 3
0
 public int Insert(CSF_RoleFunction entity)
 {
     try
     {
         MyContext.CSF_RoleFunction.Add(entity);
         MyContext.SaveChanges();
         return(entity.ID);
     }
     catch (Exception ex)
     {
         Logs.WriteLog(ex);
         throw;
     }
 }
Esempio n. 4
0
 public int Insert(CMS_Videos entity)
 {
     try
     {
         entity.CreateDate = System.DateTime.Now;
         MyContext.CMS_Videos.Add(entity);
         MyContext.SaveChanges();
         return(entity.ID);
     }
     catch (Exception ex)
     {
         Logs.WriteLog(ex);
         throw;
     }
 }
Esempio n. 5
0
 public bool Update(CMS_TypeOfMap entity)
 {
     try
     {
         CMS_TypeOfMap obj = MyContext.CMS_TypeOfMap.Find(entity.ID);
         obj.Name        = entity.Name;
         obj.Description = entity.Description;
         MyContext.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         Logs.WriteLog(ex);
         return(false);
     }
 }
Esempio n. 6
0
 public int Insert(CSF_Functions entity)
 {
     try
     {
         entity.CreateDate = System.DateTime.Now;
         entity.ParentID   = entity.ParentID != null ? entity.ParentID : 0;
         MyContext.CSF_Functions.Add(entity);
         MyContext.SaveChanges();
         return(entity.ID);
     }
     catch (Exception ex)
     {
         Logs.WriteLog(ex);
         throw;
     }
 }
Esempio n. 7
0
        public ActionResult ConfirmEmail(string Token, string Email)
        {
            var user = _db.CSF_Users.SingleOrDefault(m => m.ActiveCode.ToUpper() == Token.ToUpper());

            if (user != null)
            {
                if (user.Email == Email)
                {
                    user.Status     = 1;
                    user.ActiveDate = DateTime.Now;
                    user.ActiveCode = Guid.NewGuid().ToString();
                    _db.SaveChanges();
                }
                else
                {
                    return(RedirectToAction("Confirm", "Home", new { Email = user.Email }));
                }
            }
            else
            {
                return(RedirectToAction("Confirm", "Home", new { Email = "" }));
            }

            // Login
            FormsAuthentication.SetAuthCookie(user.UserName.Trim(), false);
            string url = System.Configuration.ConfigurationManager.AppSettings["SiteUrl"];

            //Hiển thời để redirect về trang cập nhật thông tin
            return(Redirect(url + @"/admin/nan_tochuc/updateinformation"));
        }
Esempio n. 8
0
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            try
            {
                var descriptor               = filterContext.ActionDescriptor;
                var actionName               = descriptor.ActionName;
                var controllerName           = descriptor.ControllerDescriptor.ControllerName;
                DT_WebGISEntities MyContext  = new DT_WebGISEntities();
                CSF_Users_DAO     objUserDao = new CSF_Users_DAO();
                string            username   = filterContext.HttpContext.User.Identity.Name;

                if (!string.IsNullOrEmpty(username))
                {
                    int        intGuestGroup    = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["IDGuestGroup"]);
                    List <int> listUserRole     = objUserDao.GetRoleIDByUserName(username, intGuestGroup);
                    string     ControllerAction = controllerName + "-" + actionName;
                    var        ListPermission   = (from a in MyContext.CSF_RoleFunction
                                                   join b in MyContext.CSF_Functions on a.FunctionID equals b.ID
                                                   where listUserRole.Contains(a.RoleID)
                                                   select new { ca = b.Controller_Action.ToLower() }).ToList();
                    //write log
                    int intUserID = objUserDao.GetUserIDByUserName(username);
                    if (intUserID > 0)
                    {
                        CSF_Logs objLog = new CSF_Logs();
                        objLog.Controller_Action = controllerName + "-" + actionName;
                        objLog.CreateDate        = System.DateTime.Now;
                        objLog.UserCreate        = intUserID;
                        //objLog.Content = descriptor.ToString();
                        MyContext.CSF_Logs.Add(objLog);
                        MyContext.SaveChanges();
                    }
                    var permission = ListPermission.Where(x => x.ca.Contains(ControllerAction.ToLower())).FirstOrDefault();
                    if (permission == null && username.ToLower().Trim() != "host")
                    {
                        base.OnActionExecuting(filterContext);
                        filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary {
                            { "controller", "home" }, { "action", "index" }, { "area", "" }
                        });
                    }
                }
                else
                {
                    //filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary { { "controller", "home" }, { "action", "login" }, { "area", "" } });

                    filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary {
                        { "Area", "" },
                        { "Controller", "home" },
                        { "Action", "login" },
                        { "RedirectUrl", filterContext.HttpContext.Request.Url }
                    }
                                                                     );
                }
            }
            catch (Exception ex)
            {
                Logs.WriteLog(ex);
            }
        }
Esempio n. 9
0
 public bool Update(CMS_Notifications entity)
 {
     try
     {
         CMS_Notifications obj = MyContext.CMS_Notifications.Find(entity.ID);
         obj.Title    = entity.Title;
         obj.Contents = entity.Contents;
         obj.Publish  = entity.Publish;
         MyContext.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         Logs.WriteLog(ex);
         return(false);
     }
 }
Esempio n. 10
0
 public bool EditModules(CSF_Modules entity)
 {
     try
     {
         var module = MyContext.CSF_Modules.Find(entity.ID);
         module.Name        = entity.Name;
         module.Description = entity.Description;
         module.IsActive    = entity.IsActive.HasValue;
         MyContext.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         Logs.WriteLog(ex);
         throw;
     }
 }
Esempio n. 11
0
 public int Insert(CSF_Users entity)
 {
     try
     {
         entity.RegisterDate = System.DateTime.Now;
         entity.Password     = Encryptor.MD5Hash(entity.Password);
         entity.Status       = 1;
         MyContext.CSF_Users.Add(entity);
         MyContext.SaveChanges();
         return(entity.ID);
     }
     catch (Exception ex)
     {
         Logs.WriteLog(ex);
         throw;
     }
 }
Esempio n. 12
0
 public bool Update(CSF_Partials entity)
 {
     try
     {
         CSF_Partials obj = MyContext.CSF_Partials.Find(entity.ID);
         obj.Name       = entity.Name;
         obj.Key        = entity.Key;
         obj.ModuleID   = entity.ModuleID;
         obj.Controller = entity.Controller;
         MyContext.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         Logs.WriteLog(ex);
         return(false);
     }
 }
Esempio n. 13
0
 public int Insert(CSF_Pages entity)
 {
     try
     {
         entity.CreateDate = DateTime.Now;
         entity.IsActive   = entity.IsActive == null ? false : entity.IsActive;
         entity.IsAdmin    = entity.IsAdmin == null ? false : entity.IsAdmin;
         entity.IsHost     = entity.IsHost == null ? false : entity.IsHost;
         entity.IsBlank    = entity.IsBlank == null ? false : entity.IsBlank;
         MyContext.CSF_Pages.Add(entity);
         MyContext.SaveChanges();
         return(entity.ID);
     }
     catch (Exception ex)
     {
         Logs.WriteLog(ex);
         throw;
     }
 }
Esempio n. 14
0
        public bool Update(CMS_Maps entity)
        {
            try
            {
                CMS_Maps obj = MyContext.CMS_Maps.Find(entity.ID);
                obj.Name        = entity.Name;
                obj.Description = entity.Description;
                obj.TypeOfMapID = entity.TypeOfMapID;
                obj.UserCreate  = entity.UserCreate;
                //obj.Thumbnail = string.IsNullOrEmpty(obj.Thumbnail) ? "thumbnail_DEFAULT.jpg" : entity.Thumbnail;

                MyContext.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                Logs.WriteLog(ex);
                return(false);
            }
        }
Esempio n. 15
0
 public bool Update(CMS_Categories entity)
 {
     try
     {
         CMS_Categories obj = MyContext.CMS_Categories.Find(entity.ID);
         obj.NAME        = entity.NAME;
         obj.DESCRIPTION = entity.DESCRIPTION;
         obj.PICTURE     = entity.PICTURE;
         obj.PUBLISH     = entity.PUBLISH;
         obj.KEY         = entity.KEY;
         obj.ORDERS      = entity.ORDERS;
         MyContext.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         Logs.WriteLog(ex);
         return(false);
     }
 }
Esempio n. 16
0
 public bool Update(CMS_Contact entity)
 {
     try
     {
         CMS_Contact obj = MyContext.CMS_Contact.Find(entity.ID);
         obj.Name     = entity.Name;
         obj.Address  = entity.Address;
         obj.Title    = entity.Title;
         obj.Mobile   = entity.Mobile;
         obj.Email    = entity.Email;
         obj.Contents = entity.Contents;
         obj.Address  = entity.Address;
         MyContext.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         Logs.WriteLog(ex);
         return(false);
     }
 }
Esempio n. 17
0
 public ActionResult Index(CSF_Templates obj)
 {
     ViewBag.URLIMAGE = System.Configuration.ConfigurationManager.AppSettings["UrlImage"];
     if (ModelState.IsValid)
     {
         DT_WebGISEntities MyContext = new DT_WebGISEntities();
         MyContext.Entry(obj).State = System.Data.Entity.EntityState.Modified;
         MyContext.SaveChanges();
         SetAlert("Lưu giao diên thành công", AlertType.Success);
     }
     return(View(obj));
 }
Esempio n. 18
0
 public bool Update(CMS_AdImages entity)
 {
     try
     {
         CMS_AdImages obj = MyContext.CMS_AdImages.Find(entity.ID);
         obj.Name        = entity.Name;
         obj.Description = entity.Description;
         obj.Publish     = entity.Publish;
         obj.Orders      = entity.Orders;
         obj.FileName    = entity.FileName;
         obj.Location    = entity.Location;
         obj.Url         = entity.Url;
         MyContext.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         Logs.WriteLog(ex);
         return(false);
     }
 }
Esempio n. 19
0
 public bool Update(CMS_Organization entity)
 {
     try
     {
         CMS_Organization obj = MyContext.CMS_Organization.Find(entity.ID);
         obj.Name      = entity.Name;
         obj.ShortName = entity.ShortName;
         obj.ParentID  = entity.ParentID;
         obj.Mobile    = entity.Mobile;
         obj.Email     = entity.Email;
         obj.Website   = entity.Website;
         obj.Address   = entity.Address;
         MyContext.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         Logs.WriteLog(ex);
         return(false);
     }
 }
Esempio n. 20
0
        public ActionResult Create(CSF_HCXa obj)
        {
            ViewBag.QuanHuyen = DVHC_QuanHuyen_SelectAll();
            try
            {
                if (ModelState.IsValid)
                {
                    var model = SelectByMaPhuongXa(obj.MaPhuongXa);
                    if (model != null)
                    {
                        ModelState.AddModelError("", "Đã tồn tại phường xã có mã: " + obj.MaPhuongXa);
                    }
                    else
                    {
                        obj.CreatedBy   = User.Identity.Name;
                        obj.CreatedDate = DateTime.Now;
                        db.CSF_HCXa.Add(obj);
                        obj.IsDelete = false;
                        if (db.SaveChanges() > 0)
                        {
                            SetAlert("Thêm dữ liệu thành công", AlertType.Success);
                            return(RedirectToAction("Index", "CSF_PhuongXa"));
                        }
                        else
                        {
                            ModelState.AddModelError("", "Thêm dữ liệu không thành công");
                        }
                    }

                    return(View("Create"));
                }
                return(View());
            }
            catch (Exception ex)
            {
                SetAlert("Lỗi" + ex.Message.ToString(), AlertType.Error);
                Logs.WriteLog(ex);
                return(View());
            }
        }
Esempio n. 21
0
        public JsonResult editUrlMap(string url)
        {
            var id = Session["idMap"];
            DT_WebGISEntities db = new DT_WebGISEntities();
            var GT         = db.CMS_Maps.Find(id);
            var service    = db.CMS_MapService.Where(x => x.MapID == GT.ID).FirstOrDefault();
            var serviceMap = db.CMS_Services.Where(x => x.ID == service.ServiceID).FirstOrDefault();

            serviceMap.URL             = url;
            db.Entry(serviceMap).State = EntityState.Modified;
            db.SaveChanges();
            return(Json(new { status = true, message = "" }, JsonRequestBehavior.AllowGet));
        }
Esempio n. 22
0
        public ActionResult Create(DT_KhuVuc obj)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var model = SelectByTen(obj.Ten);
                    if (model != null)
                    {
                        ModelState.AddModelError("", "Đã tồn tại thời điểm có tên: " + obj.Ten);
                    }
                    else
                    {
                        obj.IsActive    = false;
                        obj.CreatedBy   = User.Identity.Name;
                        obj.CreatedDate = DateTime.Now;
                        db.DT_KhuVuc.Add(obj);
                        if (db.SaveChanges() > 0)
                        {
                            SetAlert("Thêm dữ liệu thành công", AlertType.Success);
                            return(RedirectToAction("Index", "DT_KhuVuc"));
                        }
                        else
                        {
                            ModelState.AddModelError("", "Thêm dữ liệu không thành công");
                        }
                    }

                    return(View("Create"));
                }
                return(View());
            }
            catch (Exception ex)
            {
                SetAlert("Lỗi" + ex.Message.ToString(), AlertType.Error);
                Logs.WriteLog(ex);
                return(View());
            }
        }
Esempio n. 23
0
        public JsonResult CopyPageSetup(string pagenguon, string pagedich)
        {
            try
            {
                int IDPageNguon             = Convert.ToInt32(pagenguon);
                int IDPageDich              = Convert.ToInt32(pagedich);
                DT_WebGISEntities MyContext = new DT_WebGISEntities();
                MyContext.CSF_Pages_CopyPage(IDPageNguon, IDPageDich);//delete ban ghi cu
                var             listPageNguon = MyContext.CSF_PagePartial.Where(x => x.PageID == IDPageNguon).ToList();
                CSF_PagePartial objPP;
                foreach (var item in listPageNguon.Where(x => x.IsBox == true))
                {
                    int idItem = item.ID;
                    objPP        = new CSF_PagePartial();
                    objPP        = item;
                    objPP.PageID = IDPageDich;
                    MyContext.CSF_PagePartial.Add(objPP);
                    MyContext.SaveChanges();
                    var newID = objPP.ID;
                    foreach (var itemC in listPageNguon.Where(x => x.BoxParent == idItem))
                    {
                        objPP           = new CSF_PagePartial();
                        objPP           = itemC;
                        objPP.PageID    = IDPageDich;
                        objPP.BoxParent = newID;
                        MyContext.CSF_PagePartial.Add(objPP);
                        MyContext.SaveChanges();
                    }
                }

                return(Json(new { state = true, message = "Copy pageSetup thành công" }, JsonRequestBehavior.AllowGet));
                //return Json(new { state = false, message = "Lỗi copy pageSetup" }, JsonRequestBehavior.AllowGet);
            }
            catch (Exception ex)
            {
                return(Json(new { state = false, message = ex }, JsonRequestBehavior.AllowGet));
            }
        }
Esempio n. 24
0
 public bool Update(CMS_Schedules entity)
 {
     try
     {
         CMS_Schedules obj = MyContext.CMS_Schedules.Find(entity.ID);
         obj.Title            = entity.Title;
         obj.Contents         = entity.Contents;
         obj.StartDate        = entity.StartDate;
         obj.EndDate          = entity.EndDate;
         obj.Place            = entity.Place;
         obj.Participants     = entity.Participants;
         obj.UserPrepare      = entity.UserPrepare;
         obj.Ministry_leaders = entity.Ministry_leaders;
         obj.Leaders          = entity.Leaders;
         MyContext.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         Logs.WriteLog(ex);
         return(false);
     }
 }
Esempio n. 25
0
 public int Insert(CMS_MapService entity)
 {
     try
     {
         MyContext.CMS_MapService.Add(entity);
         MyContext.SaveChanges();
         return(entity.ID);
     }
     catch (Exception ex)
     {
         Logs.WriteLog(ex);
         throw;
     }
 }
Esempio n. 26
0
 public bool Delete(int id)
 {
     try
     {
         var obj = MyContext.CSF_Logs.Find(id);
         MyContext.CSF_Logs.Remove(obj);
         MyContext.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         Logs.WriteLog(ex);
         return(false);
     }
 }
Esempio n. 27
0
 public bool Update(CMS_Services entity)
 {
     try
     {
         CMS_Services obj = MyContext.CMS_Services.Find(entity.ID);
         obj.Name        = entity.Name;
         obj.Description = entity.Description;
         obj.URL         = entity.URL;
         obj.Publish     = entity.Publish;
         obj.Source      = entity.Source;
         obj.XMax        = entity.XMax;
         obj.XMin        = entity.XMin;
         obj.YMax        = entity.YMax;
         obj.YMin        = entity.YMin;
         obj.TypeOfMapID = entity.TypeOfMapID;
         MyContext.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         Logs.WriteLog(ex);
         return(false);
     }
 }
Esempio n. 28
0
 public int Insert(int UserID, int RoleID)
 {
     try
     {
         CSF_UserRole entity = new CSF_UserRole();
         entity.UserID = UserID;
         entity.RoleID = RoleID;
         MyContext.CSF_UserRole.Add(entity);
         MyContext.SaveChanges();
         return(entity.ID);
     }
     catch (Exception ex)
     {
         Logs.WriteLog(ex);
         throw;
     }
 }
Esempio n. 29
0
 public JsonResult DeletePagePartial(string id)
 {
     try
     {
         DT_WebGISEntities ett = new DT_WebGISEntities();
         int ID          = Convert.ToInt32(id);
         var pagePartial = ett.CSF_PagePartial.Find(ID);
         var lPartial    = ett.CSF_PagePartial.Where(x => x.BoxParent == ID);
         if (pagePartial != null && (lPartial == null || lPartial.Count() == 0))
         {
             ett.CSF_PagePartial.Remove(pagePartial);
             ett.SaveChanges();
             return(Json(new { state = true, message = "Xóa thành công" }, JsonRequestBehavior.AllowGet));
         }
         return(Json(new { state = false, message = "Lỗi xóa dữ liệu" }, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         return(Json(new { state = false, message = ex }, JsonRequestBehavior.AllowGet));
     }
 }
Esempio n. 30
0
 public JsonResult GuiDuyet(string newsid)
 {
     try
     {
         DT_WebGISEntities entity = new DT_WebGISEntities();
         int NEWSID = Convert.ToInt32(newsid);
         var news   = entity.CMS_News.Find(NEWSID);
         if (news != null && (news.ID_NEWS_STATUS == 1 || news.ID_NEWS_STATUS == 3 || news.ID_NEWS_STATUS == 6))
         {
             news.ID_NEWS_STATUS      = 2;
             entity.Entry(news).State = EntityState.Modified;
             entity.SaveChanges();
         }
         SetAlert("Gửi duyệt thành công", AlertType.Success);
         return(Json(new { state = true, message = "" }, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         return(Json(new { state = false, message = ex }, JsonRequestBehavior.AllowGet));
     }
 }