资源简介
VS2019 + Vue + ElementUI一款不错的组合
代码片段和文件信息
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.AspNetCore.Routing;
using System.Linq;
using System.Text;
using Xms.Identity;
using Xms.Infrastructure.Utility;
using Xms.Localization.Abstractions;
using Xms.Web.framework.Context;
using Xms.Web.framework.Mvc;
namespace Xms.Api.Core.Controller
{
///
/// 接口控制器基类
///
//[TypeFilter(typeof(IdentityFilterAttribute) Order = 1)]
[Authorize]
[ApiController]
[EnableCors(“CorsPolicy“)]//跨域
public class ApiControllerbase : Microsoft.AspNetCore.Mvc.Controller
{
#region fields
//上下文
public IWebAppContext WebContext;
public ICurrentUser CurrentUser
{
get
{
if (WebContext.CurrentUser != null)
{
return WebContext.CurrentUser;
}
return null;
}
}
protected ILocalizedTextProvider T
{
get
{
return WebContext.T;
}
}
#endregion
protected ApiControllerbase(IWebAppContext appContext)
{
WebContext = appContext;
}
public override void OnActionExecuting(ActionExecutingContext executingContext)
{
base.OnActionExecuting(executingContext);
var httpContext = executingContext.HttpContext;
WebContext.IsAjaxRequest = httpContext.IsAjaxRequest();
WebContext.IP = httpContext.GetClientIpAddress();
WebContext.Url = httpContext.GetThisPageUrl(includeQueryString: true);
WebContext.UrlReferrer = httpContext.GetUrlReferrer();
WebContext.Area = httpContext.GetRouteValue(“area“)?.ToString();//.ToLower();
WebContext.ControllerName = httpContext.GetRouteValue(“controller“).ToString();//.ToLower();
WebContext.ActionName = httpContext.GetRouteValue(“action“).ToString();//.ToLower();
}
///
/// 获取模型绑定错误信息
///
///
///
protected string GetModelErrors(ModelStateDictionary state = null bool jsonFormat = false)
{
StringBuilder msg = new StringBuilder();
state = state ?? ModelState;
if (state.IsValid)
{
return string.Empty;
}
var validationerrors = state
.Keys
.SelectMany(k => state[k].Errors)
.Select(e => e.ErrorMessage)
.ToArray();
if (jsonFormat)
{
return validationerrors.SerializeToJson();
}
return string.Join(‘\n‘ validationerrors);
}
#region 常用返回信息
protect
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2020-02-17 04:17 xms\
文件 102 2020-02-17 04:17 xms\.gitattributes
文件 530 2020-02-17 04:17 xms\.gitignore
文件 1067 2020-02-17 04:17 xms\LICENSE
目录 0 2020-02-17 04:17 xms\Libraries\
目录 0 2020-02-17 04:17 xms\Libraries\Business\
目录 0 2020-02-17 04:17 xms\Libraries\Business\Xms.Business.DataAnalyse\
文件 353 2020-02-17 04:17 xms\Libraries\Business\Xms.Business.DataAnalyse\ChartContext.cs
文件 1197 2020-02-17 04:17 xms\Libraries\Business\Xms.Business.DataAnalyse\ChartDataDesc
文件 1422 2020-02-17 04:17 xms\Libraries\Business\Xms.Business.DataAnalyse\ChartDesc
目录 0 2020-02-17 04:17 xms\Libraries\Business\Xms.Business.DataAnalyse\Data\
文件 8605 2020-02-17 04:17 xms\Libraries\Business\Xms.Business.DataAnalyse\Data\ChartRepository.cs
文件 575 2020-02-17 04:17 xms\Libraries\Business\Xms.Business.DataAnalyse\Data\IChartRepository.cs
文件 900 2020-02-17 04:17 xms\Libraries\Business\Xms.Business.DataAnalyse\Data\IReportRepository.cs
文件 5673 2020-02-17 04:17 xms\Libraries\Business\Xms.Business.DataAnalyse\Data\ReportRepository.cs
目录 0 2020-02-17 04:17 xms\Libraries\Business\Xms.Business.DataAnalyse\Domain\
文件 1119 2020-02-17 04:17 xms\Libraries\Business\Xms.Business.DataAnalyse\Domain\Chart.cs
文件 1358 2020-02-17 04:17 xms\Libraries\Business\Xms.Business.DataAnalyse\Domain\Report.cs
目录 0 2020-02-17 04:17 xms\Libraries\Business\Xms.Business.DataAnalyse\Report\
文件 1518 2020-02-17 04:17 xms\Libraries\Business\Xms.Business.DataAnalyse\Report\IReportService.cs
文件 859 2020-02-17 04:17 xms\Libraries\Business\Xms.Business.DataAnalyse\Report\ModuleEntry.cs
文件 400 2020-02-17 04:17 xms\Libraries\Business\Xms.Business.DataAnalyse\Report\ReportDefaults.cs
文件 2924 2020-02-17 04:17 xms\Libraries\Business\Xms.Business.DataAnalyse\Report\ReportDesc
文件 1101 2020-02-17 04:17 xms\Libraries\Business\Xms.Business.DataAnalyse\Report\ReportExporter.cs
文件 2167 2020-02-17 04:17 xms\Libraries\Business\Xms.Business.DataAnalyse\Report\ReportImporter.cs
文件 10481 2020-02-17 04:17 xms\Libraries\Business\Xms.Business.DataAnalyse\Report\ReportService.cs
文件 1365 2020-02-17 04:17 xms\Libraries\Business\Xms.Business.DataAnalyse\ServiceRegistrar.cs
目录 0 2020-02-17 04:17 xms\Libraries\Business\Xms.Business.DataAnalyse\Visualization\
文件 7756 2020-02-17 04:17 xms\Libraries\Business\Xms.Business.DataAnalyse\Visualization\ChartBuilder.cs
文件 1676 2020-02-17 04:17 xms\Libraries\Business\Xms.Business.DataAnalyse\Visualization\ChartCreater.cs
文件 148 2020-02-17 04:17 xms\Libraries\Business\Xms.Business.DataAnalyse\Visualization\ChartDefaults.cs
............此处省略3674个文件信息
- 上一篇:C#向Excel写入数据和图表源
- 下一篇:Spire Spire.Doc 去水印
评论
共有 条评论