| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205 |
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Threading.Tasks;
- using System.Web;
- using System.Web.Mvc;
- using Abp.Auditing;
- using Abp.Domain.Repositories;
- using Abp.MultiTenancy;
- using Abp.Runtime.Caching;
- using Abp.Timing;
- using Abp.Web.Models;
- using Abp.Web.Mvc.Authorization;
- using Abp.Web.Security.AntiForgery;
- using WePlatform.Authorization;
- using WePlatform.Authorization.Roles;
- using WePlatform.BaseInfo;
- using WePlatform.BaseSystem.AuditLog;
- using WePlatform.BaseSystem.Sessions.Dto;
- using WePlatform.Configuration;
- using IwbZero.Auditing;
- using IwbZero.Authorization.Base.Users;
- using IwbZero.ToolCommon.LogHelpers;
- using IwbZero.ToolCommon.StringModel;
- namespace WePlatform.Controllers
- {
- [DisableAuditing]
- [AbpMvcAuthorize(PermissionNames.PagesSystemMg), AuditLog("系统信息管理")]
- public class BaseSystemController : IwbControllerBase
- {
- public BaseSystemController(ICacheManager cacheManager, IRepository<Role> roleRepository, IRepository<SysFunction> functionRepository, IAuditLogsAppService logsAppService)
- {
- RoleRepository = roleRepository;
- FunctionRepository = functionRepository;
- LogsAppService = logsAppService;
- CacheManager = cacheManager;
- }
- private IRepository<Role> RoleRepository { get; }
- private IRepository<SysFunction> FunctionRepository { get; }
- private IAuditLogsAppService LogsAppService { get; }
- [AbpMvcAuthorize(PermissionNames.PagesSystemMgTenantMg), AuditLog("系统租户")]
- public async Task<ActionResult> SysTenants()
- {
- if (AbpSession.MultiTenancySide != MultiTenancySides.Host)
- {
- ThrowError(IwbLanguageMessage.NoPermissionOperation);
- }
- ViewBag.IsActive = await StatesManager.GetSelectListAsync("Active", "Status");
- return View();
- }
- [AbpMvcAuthorize(PermissionNames.PagesSystemMgRoleMg), AuditLog("系统角色")]
- public async Task<ActionResult> SysRoles()
- {
- var user = AbpSession.GetCurrentUser();
- ViewBag.IsActive = await StatesManager.GetSelectListAsync("Active", "Status");
- ViewBag.RoleType = await StatesManager.GetSelectListAsync("UserRole", "UserRoleType");
- var accountType = await StatesManager.GetSelectListAsync("Account", "AccountType");
- ViewBag.AccountType = accountType;
- ViewBag.AccountTypeName = accountType.FirstOrDefault(a => a.Value == (user.AccountType + ""))?.Text ?? "";
- ViewBag.CurrentUser = user;
- return View();
- }
- [AbpMvcAuthorize(PermissionNames.PagesSystemMgUserMg), AuditLog("系统用户")]
- public async Task<ActionResult> SysUsers()
- {
- var user = AbpSession.GetCurrentUser();
- ViewBag.IsActive = await StatesManager.GetSelectListAsync("Active", "Status");
- ViewBag.UserType = await StatesManager.GetSelectListAsync("UserRole", "UserRoleType");
- var accountType = await StatesManager.GetSelectListAsync("Account", "AccountType");
- ViewBag.AccountType = accountType;
- ViewBag.AccountTypeName = accountType.FirstOrDefault(a => a.Value == (user.AccountType + ""))?.Text ?? "";
- ViewBag.CurrentUser = user;
- if (AbpSession.UserType == UsersAndRolesTypeDefinition.Supper ||
- AbpSession.UserType == UsersAndRolesTypeDefinition.System)
- {
- var sList = new List<SelectListItem>();
- var list = RoleRepository.GetAllList(a =>
- (AbpSession.UserName == UserBase.AdminUserName || a.RoleType > AbpSession.UserType) &&
- (AbpSession.AccountType == AccountTypeDefinition.System || a.AccountType == AbpSession.AccountType));
- foreach (var l in list)
- {
- sList.Add(new SelectListItem { Text = l.DisplayName, Value = l.Name });
- }
- ViewBag.Roles = sList;
- }
- return View();
- }
- [AbpMvcAuthorize(PermissionNames.PagesSystemMgStateMg), AuditLog("系统字典")]
- public ActionResult SysStates()
- {
- return View();
- }
- [AbpMvcAuthorize(PermissionNames.PagesSystemMgSettingMg), AuditLog("系统配置")]
- public ActionResult SysSettings()
- {
- return View();
- }
- [AbpMvcAuthorize(PermissionNames.PagesSystemMgFunctionMg), AuditLog("功能菜单")]
- public async Task<ActionResult> SysFunctions()
- {
- ViewBag.FunctionType = await StatesManager.GetSelectListAsync("Function", "FunctionType");
- return View();
- }
- [AbpMvcAuthorize(PermissionNames.PagesSystemMgLogMg), AuditLog("系统日志")]
- public ActionResult SysLogs()
- {
- ViewBag.ServiceNames = LogsAppService.GetLogServiceSelectListStrs();
- return View();
- }
- public ActionResult Notification()
- {
- return View();
- }
- [AbpMvcAuthorize(PermissionNames.PagesSystemMgHelpMg), AuditLog("系统帮助")]
- public async Task<ActionResult> SysHelps()
- {
- ViewBag.Classification = await StatesManager.GetSelectListAsync("SysHelp", "Classification");
- var funs = await FunctionRepository.GetAllListAsync(a =>
- a.FunctionType == FunctionTypeDefinition.Catalog || a.FunctionType == FunctionTypeDefinition.Menu);
- ViewBag.FunctionMenu = "";
- foreach (var fun in funs)
- {
- ViewBag.FunctionMenu += fun.ParentNo == "0"
- ? $"<option value=\"{fun.FunctionNo}\" disabled selected>{fun.FunctionName}</option>"
- : $"<option value=\"{fun.FunctionNo}\" parent=\"{fun.ParentNo}\">{fun.FunctionName}</option>";
- }
- return View();
- }
- [DisableAbpAntiForgeryTokenValidation]
- [DontWrapResult]
- public ActionResult KindEditorUploadFile()
- {
- try
- {
- if (!int.TryParse(SettingManager.GetValue(IwbSettingNames.UploadFileMaxSize), out int maxSize))
- {
- maxSize = 10;
- }
- maxSize = maxSize < 1 ? 1 : maxSize > 100 ? 100 : maxSize;
- HttpPostedFileBase file = Request.Files["imgFile"];
- if (file == null)
- {
- return Json(new { error = 1, message = L("FileUploadNoFile") });
- }
- if (file.ContentLength >= 1024 * 1024 * maxSize)
- {
- return Json(new { error = 1, message = string.Format(L("FileUploadMaxSize"), $"{maxSize}M") });
- }
- var fileName = $"{Clock.Now:yyyyMMddHHmmss}_{file.FileName}";
- string lcPath = SettingManager.GetValue(IwbSettingNames.DownloadPath) + "/KindEditorUploadFile";
- string dir = Request["dir"];
- if (!string.IsNullOrEmpty(dir))
- {
- lcPath = Path.Combine(lcPath, dir);
- }
- var filePath = Server.MapPath($"~/{lcPath}");
- if (!Directory.Exists(filePath))
- {
- Directory.CreateDirectory(filePath);
- }
- file.SaveAs(Path.Combine(filePath, fileName));
- return Json(new { error = 0, url = Path.Combine(lcPath, fileName), fileName = file.FileName }, "text/html;charset=UTF-8");
- }
- catch (Exception e)
- {
- this.LogError(e);
- return Json(new { error = 1, message = L("FileUploadException") }, "text/html;charset=UTF-8");
- }
- }
- }
- [DisableAuditing]
- [AbpMvcAuthorize(PermissionNames.PagesUserHelpInfo), AuditLog("系统帮助")]
- public class HelpController : IwbControllerBase
- {
- public HelpController(IRepository<SysHelp> helpRepository)
- {
- HelpRepository = helpRepository;
- }
- private IRepository<SysHelp> HelpRepository { get; }
- [AbpMvcAuthorize(PermissionNames.PagesUserHelpInfo), AuditLog("系统帮助")]
- public async Task<ActionResult> Index()
- {
- var helps = (await HelpRepository.GetAllListAsync()).OrderBy(a => a.Sequence).ToList();
- return View(helps);
- }
- }
- }
|