增加演示版本支持,在web.config中配置即可;

增加自定义出差处理,参考ErrorController
This commit is contained in:
yubaolee
2016-04-25 11:53:21 +08:00
parent 3037c3b1f6
commit 6181f9dd47
22 changed files with 182 additions and 33 deletions

View File

@@ -16,13 +16,12 @@
// </summary>
// ***********************************************************************
using Infrastructure.Helper;
using OpenAuth.App.ViewModel;
using OpenAuth.Mvc.Models;
using System;
using System.Diagnostics;
using System.Configuration;
using System.Linq;
using System.Reflection;
using System.Web;
using System.Web.Mvc;
using OpenAuth.App;
@@ -60,6 +59,16 @@ namespace OpenAuth.Mvc.Controllers
ViewBag.Module = module; //为View显示服务主要是为了显示按钮
}
var version = ConfigurationManager.AppSettings["version"];
if (version == "demo")
{
HttpPostAttribute hobbyAttr = (HttpPostAttribute)Attribute.GetCustomAttribute(function, typeof(HttpPostAttribute));
if (actionname.Contains("del") || hobbyAttr != null) //客户端提交数据
{
throw new HttpException(400, "演示版本,不能进行该操作,当前模块:" + controllername +"/" +actionname);
}
}
base.OnActionExecuting(filterContext);
}
}

View File

@@ -45,11 +45,6 @@ namespace OpenAuth.Mvc.Controllers
return JsonHelper.Instance.Serialize(models);
}
public ActionResult Add(int id = 0)
{
return View(_app.Find(id));
}
//添加或修改Category
[HttpPost]
public string Add(Category model)

View File

@@ -1,17 +1,54 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Web;
using System.Web.Mvc;
using Infrastructure;
using OpenAuth.Mvc.Models;
namespace OpenAuth.Mvc.Controllers
{
public class ErrorController : Controller
{
// GET: Error
public ActionResult NoAccess()
public ActionResult Http404()
{
return View();
return Content("貌似URL不在~~", "text/plain");
}
/// <summary>
/// 演示版本禁止提交
/// </summary>
public string DemoError()
{
Response.Charset = "utf-8";
var response = new BjuiResponse
{
statusCode = "400",
message = "演示版本,不能进行此操作"
};
return JsonHelper.Instance.Serialize(response);
}
/// <summary>
/// 没有登录
/// </summary>
/// <returns>ActionResult.</returns>
public ActionResult Http401()
{
return RedirectToAction("Index", "Login");
}
public string Http500()
{
Response.Charset = "utf-8";
var response = new BjuiResponse
{
statusCode = "500",
message = "服务器内部错误,请联系管理员"
};
return JsonHelper.Instance.Serialize(response);
}
}
}

View File

@@ -22,7 +22,7 @@ using System.Web.Mvc;
namespace OpenAuth.Mvc.Controllers
{
public class ModuleElementManagerController : Controller
public class ModuleElementManagerController : BaseController
{
private readonly BjuiResponse _bjuiResponse = new BjuiResponse();
private ModuleElementManagerApp _app;
@@ -31,18 +31,18 @@ namespace OpenAuth.Mvc.Controllers
{
_app = AutofacExt.GetFromFac<ModuleElementManagerApp>();
}
[Anonymous]
public ActionResult Index(int id)
{
ViewBag.ModuleId = id;
return View();
}
[Anonymous]
public ActionResult Get(int moduleId = 0)
{
return Json(_app.LoadByModuleId(moduleId));
}
[Anonymous]
[HttpPost]
public string AddOrEditButton(ModuleElement button)
{
@@ -57,7 +57,7 @@ namespace OpenAuth.Mvc.Controllers
}
return JsonHelper.Instance.Serialize(_bjuiResponse);
}
[Anonymous]
public string Del(string moduleElements)
{
try
@@ -80,13 +80,14 @@ namespace OpenAuth.Mvc.Controllers
/// <param name="firstId">The first identifier.</param>
/// <param name="key">The key.</param>
/// <returns>ActionResult.</returns>
[Anonymous]
public ActionResult AssignModuleElement(int firstId, string key)
{
ViewBag.FirstId = firstId;
ViewBag.ModuleType = key;
return View();
}
[Anonymous]
public string LoadWithAccess(int tId, int firstId, string key)
{
return JsonHelper.Instance.Serialize(_app.LoadWithAccess(key, firstId, tId));

View File

@@ -23,11 +23,6 @@ namespace OpenAuth.Mvc.Controllers
return View();
}
public ActionResult Add(int id = 0)
{
return View(_app.Find(id));
}
//添加或修改角色
[HttpPost]
public string Add(Role role)