public ActionResult UpdateMenu(Menu mn) { GetViewBag_Session(); if (ModelState.IsValid) { var dao = new MenuDAO(); var id = dao.Update(mn); // Written log var logEntity = new Log_Admin(); logEntity.createBy = ViewBag.Name_Session; logEntity.time = DateTime.Now; logEntity.action = "Cập nhật menu " + "<a href = \"/Admin/Menu/Update/" + mn.ID + "\">" + mn.ID + "</a>"; logEntity.description = ViewBag.Name_Session + " cập nhật menu trong hệ thống"; var wlog = new Log_AdminDAO().InsertLog(logEntity); if (id) { return(RedirectToAction("Index", "Menu")); } else { ModelState.AddModelError("", "Thêm menu thành công"); } } ListMenuType(mn.TypeID); return(View("UpdateMenu")); }
public ActionResult Create(Order entity) { GetViewBag_Session(); if (ModelState.IsValid) { entity.CreateDate = DateTime.Now; var model = new OrderDAO().Insert(entity); // Written log var logEntity = new Log_Admin(); logEntity.createBy = ViewBag.Name_Session; logEntity.time = DateTime.Now; logEntity.action = "Thêm mới đơn hàng " + "<a href = \"/Admin/Order/Update/" + entity.ID + "\">" + entity.ID + "</a>"; logEntity.description = ViewBag.Name_Session + " thêm mới đơn hàng vào hệ thống"; var wlog = new Log_AdminDAO().InsertLog(logEntity); if (model > 0) { return(RedirectToAction("Index", "Order")); } else { ModelState.AddModelError("", "Thêm thành công đơn hàng vào hệ thống"); } } GetProduct(); return(View("Create")); }
public ActionResult Create(Newsletter news, HttpPostedFileBase file) { GetViewBag_Session(); if (ModelState.IsValid) { var dao = new NewsletterDAO(); try { if (file.FileName != null && file.ContentLength > 0) { if (file.ContentType == "image/jpeg" || file.ContentType == "image/png") { if (file.ContentLength < 2000000) { string path = Path.Combine(Server.MapPath("~/images/images/Newsletter/"), Path.GetFileName(file.FileName)); file.SaveAs(path); news.Image = file.FileName; } else { ModelState.AddModelError("", "Ảnh đại diện phải nhỏ hơn 2MB"); } } else { ModelState.AddModelError("", "Ảnh phải có định dạng *png hoặc *jpg"); } } } catch { } if (string.IsNullOrEmpty(news.CreatedBy)) { news.CreatedBy = ViewBag.Name_Session; } news.CreatedDate = DateTime.Now; var metaTitle = Common.Tool.ChangeText(news.MetaTitle); news.MetaTitle = metaTitle; long id = dao.InsertNewsletter(news); // Written log var logEntity = new Log_Admin(); logEntity.createBy = ViewBag.Name_Session; logEntity.time = DateTime.Now; logEntity.action = "Thêm mới tin tức " + "<a href = \"/Admin/Newsletter/Update/" + news.ID + "\">" + news.ID + "</a>"; logEntity.description = ViewBag.Name_Session + " thêm mới tin vào hệ thống"; var wlog = new Log_AdminDAO().InsertLog(logEntity); if (id > 0) { return(RedirectToAction("Index", "Newsletter")); } else { ModelState.AddModelError("", "Thêm tin tức thành công"); } } GetNewsCategory(); return(View("Create")); }
public ActionResult Update(Product pr, HttpPostedFileBase file) { GetViewBag_Session(); if (ModelState.IsValid) { var dao = new ProductDAO(); #region Add Image try { if (file.FileName != null && file.ContentLength > 0) { if (file.ContentType == "image/png" || file.ContentType == "image/jpeg") { if (file.ContentLength < 2000000) { string path = Path.Combine(Server.MapPath("~/images/images/Products/"), Path.GetFileName(file.FileName)); file.SaveAs(path); pr.Image = file.FileName; } else { ModelState.AddModelError("", "Ảnh đại diện phải có kích thước nhỏ hơn 2MB"); } } else { ModelState.AddModelError("", "Ảnh đại diện phải có định dạng *png hoặc *jpg"); } } } catch { } #endregion pr.ModifiedBy = ViewBag.Name_Session; pr.ModifiedDate = DateTime.Now; var metaTitle = Common.Tool.ChangeText(pr.MetaTitle); pr.MetaTitle = metaTitle; var id = dao.Update(pr); // Written log var logEntity = new Log_Admin(); logEntity.createBy = ViewBag.Name_Session; logEntity.time = DateTime.Now; logEntity.action = "Cập nhật sản phẩm " + "<a href = \"/Admin/Product/Update/" + pr.ID + "\">" + pr.ID + "</a>"; logEntity.description = ViewBag.Name_Session + " cập nhật sản phẩm trong hệ thống"; var wlog = new Log_AdminDAO().InsertLog(logEntity); if (id) { return(RedirectToAction("Index", "Product")); } else { ModelState.AddModelError("", "Cập nhập sản phẩm thành công"); } } GetProductCategory(pr.CategoryID); return(View("Update")); }
/// <summary> /// 返回json数据 /// </summary> /// <param name="logAdmin"></param> /// <returns></returns> public async void LogAdmin(Log_Admin logAdmin, HttpContext http) { await Task.Run(() => { logAdmin.Ip = http.GetIp(); logAdmin.Url = HttpContextExtension.GetAbsoluteUri(http.Request); logAdmin.CrtDate = DateTime.Now; _repository.Insert(logAdmin); }); }
public ActionResult Editor(Theme entity, HttpPostedFileBase file) { GetViewBag_Session(); try { if (ModelState.IsValid) { try { if (file.ContentLength > 0 || file.FileName != null) { if (file.ContentLength < 3000000) { if (file.ContentType == "image/png" || file.ContentType == "image/jpeg") { string path = Path.Combine(Server.MapPath("~/images/images/Slides/"), Path.GetFileName(file.FileName)); file.SaveAs(path); entity.Header_image = file.FileName; } else { ModelState.AddModelError("", "Please choose file .png or .jpg"); } } else { ModelState.AddModelError("", "Image less than 3MB"); } } } catch (Exception) { } new ThemeDAO().Update(entity); // Written log var logEntity = new Log_Admin(); logEntity.createBy = ViewBag.Name_Session; logEntity.time = DateTime.Now; logEntity.action = "Thay đổi giao diện " + "<a href = \"/Admin/Theme\">Xem chi tiết</a>"; logEntity.description = ViewBag.Name_Session + " thay đổi giao diện trong hệ thống"; var wlog = new Log_AdminDAO().InsertLog(logEntity); } return(View("Index")); } catch (Exception) { return(View("Index")); } }
public JsonResult Update(string entity) { GetViewBag_Session(); var dao = new SystemNotificationDAO(); JavaScriptSerializer js = new JavaScriptSerializer(); SystemNotification model = js.Deserialize <SystemNotification>(entity); var result = new SystemNotificationDAO().Update(model); // Written log var logEntity = new Log_Admin(); logEntity.createBy = ViewBag.Name_Session; logEntity.time = DateTime.Now; logEntity.action = "Cập nhật nội dung thông báo" + "<a href = \"/Admin/Notification\">Xem chi tiết</a>"; logEntity.description = ViewBag.Name_Session + " cập nhật nội dung thông báo trong hệ thống"; var wlog = new Log_AdminDAO().InsertLog(logEntity); return(Json(new { status = result })); }
public bool Update(Log_Admin model) { throw new NotImplementedException(); }
/// <summary> /// 添加后台操作日志 /// </summary> /// <param name="model"></param> /// <returns></returns> public int Insert(Log_Admin model) { model.CrtDate = DateTime.Now; return(_repository.Insert(model)); }
public IActionResult AddSysUser([FromBody] FromAddSysUser model) { string code = "000000"; var user = AutoMapperExt.MapTo <Sys_User>(model); user.Password = Encrypt.EncryptPsw(user.Password); Log_Admin logAdmin = new Log_Admin(); var now = DateTime.Now; if (_sysUserService.IsAny(p => p.UserName == user.UserName)) { return(ReturnJson("100001")); } else { user.LastIp = HttpContextExtension.GetIp(HttpContext); user.LastLogDate = now; user.CrtUser = GetJwtIEntity().Name; user.CrtDate = now; user.Id = _sysUserService.Insert(user, false); if (user.Id > 0 && !string.IsNullOrEmpty(user.HeadImgUrl)) { //更改图片状态 _sysUploadService.UpdateUploadStatusAsync(UploadTypeEnum.image, user.HeadImgUrl, UploadStatusEnum.使用中); } if (user.Id > 0 && model.RoleList.Count > 0) { //异步执行角色权限配置 Task.Run(() => { var perList = new List <Sys_UserRole>(); foreach (var item in model.RoleList) { var perModel = new Sys_UserRole(); perModel.RoleId = item.RoleId; perModel.UserId = user.Id; perList.Add(perModel); } _sysUserService.InsertList(perList); }); } else if (user.Id == 0) { code = "000001"; } logAdmin.Remark = "账号:" + user.UserName + "注册成功"; logAdmin.TypeId = (int)EnumLogAdminType.add_sysUser;//添加用户时的类型Id } logAdmin.OtherId = user.Id.ToString(); logAdmin.CrtUserId = GetJwtIEntity().UserId; logAdmin.CrtUserName = GetJwtIEntity().Name; _logAdmin.LogAdmin(logAdmin, HttpContext); return(ReturnJson(code)); }
//Written log in admin pages when user using System admin public long InsertLog(Log_Admin entity) { db.Log_Admin.Add(entity); db.SaveChanges(); return(entity.ID); }
public IActionResult AddMenu([FromBody] FromAddMenu model) { var sysAdminMenu = AutoMapperExt.MapTo <Sys_AdminMenu>(model); string code = "000000"; Log_Admin logAdmin = new Log_Admin(); if (sysAdminMenu.Id == 0) { //新增 var maxMenu = _sysAdminMenuService.GetEntity(p => p.Pid == sysAdminMenu.Pid, p => p.Id, true); if (maxMenu == null) { var parentMenu = _sysAdminMenuService.GetEntityById(sysAdminMenu.Pid); if (parentMenu != null) { sysAdminMenu.Orders = 1; sysAdminMenu.Level = parentMenu.Level + 1; } else { return(ReturnJson("100004")); } } else { sysAdminMenu.Orders = maxMenu.Orders + 1; sysAdminMenu.Level = maxMenu.Level; } sysAdminMenu.CrtUser = GetJwtIEntity().Name; sysAdminMenu.CrtDate = DateTime.Now; logAdmin.OtherId = _sysAdminMenuService.Insert(sysAdminMenu).ToString(); } else { var adminMenu = _sysAdminMenuService.GetEntityById(sysAdminMenu.Id); if (adminMenu != null) { if (adminMenu.Orders != sysAdminMenu.Orders) { //修改排序 bool reuslt = _sysAdminMenuService.UpdateMenuOrders(sysAdminMenu.Orders, adminMenu); if (!reuslt) { code = "000001"; } } //修改其他字段 if (!_sysAdminMenuService.UpdateColumns(p => new { p.Tag, p.Icon, p.IsShow, p.MenuName, p.Url }, sysAdminMenu)) { return(ReturnJson("000001")); } logAdmin.OtherId = sysAdminMenu.Id.ToString(); } else { code = "100005"; } } logAdmin.CrtUserId = GetJwtIEntity().UserId; logAdmin.CrtUserName = GetJwtIEntity().Name; _logAdmin.LogAdmin(logAdmin, HttpContext); return(ReturnJson(code)); }