优化autofac注入方式,Controller使用属性注入

This commit is contained in:
yubaolee 2017-03-24 15:35:52 +08:00
parent 9122bec093
commit 96a9ee6bd2
20 changed files with 1948 additions and 2029 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,30 +1,30 @@
using System; using System;
namespace OpenAuth.App.SSO namespace OpenAuth.App.SSO
{ {
public class PassportLoginRequest public class PassportLoginRequest
{ {
public string UserName { get; set; } public string UserName { get; set; }
public string Password { get; set; } public string Password { get; set; }
public string AppKey { get; set; } public string AppKey { get; set; }
public void Trim() public void Trim()
{ {
if (string.IsNullOrEmpty(UserName)) if (string.IsNullOrEmpty(UserName))
{ {
throw new Exception("用户名不能为空"); throw new Exception("用户名不能为空");
} }
if (string.IsNullOrEmpty(Password)) if (string.IsNullOrEmpty(Password))
{ {
throw new Exception("密码不能为空"); throw new Exception("密码不能为空");
} }
UserName = UserName.Trim(); UserName = UserName.Trim();
Password = Password.Trim(); Password = Password.Trim();
if(!string.IsNullOrEmpty(AppKey)) AppKey = AppKey.Trim(); if(!string.IsNullOrEmpty(AppKey)) AppKey = AppKey.Trim();
} }
} }
} }

View File

@ -1,78 +1,78 @@
using System; using System;
using System.Web; using System.Web;
using System.Web.Mvc; using System.Web.Mvc;
using Infrastructure; using Infrastructure;
using Infrastructure.Cache; using Infrastructure.Cache;
using OpenAuth.Domain; using OpenAuth.Domain;
namespace OpenAuth.App.SSO namespace OpenAuth.App.SSO
{ {
public class SSOAuthUtil public class SSOAuthUtil
{ {
public static LoginResult Parse(PassportLoginRequest model) public static LoginResult Parse(PassportLoginRequest model)
{ {
var result = new LoginResult(); var result = new LoginResult();
try try
{ {
model.Trim(); model.Trim();
//获取应用信息 //获取应用信息
var appInfo = new AppInfoService().Get(model.AppKey); var appInfo = new AppInfoService().Get(model.AppKey);
if (appInfo == null) if (appInfo == null)
{ {
throw new Exception("应用不存在"); throw new Exception("应用不存在");
} }
//获取用户信息 //获取用户信息
User userInfo = null; User userInfo = null;
if (model.UserName == "System") if (model.UserName == "System")
{ {
userInfo = new User userInfo = new User
{ {
Id = Guid.Empty, Id = Guid.Empty,
Account = "System", Account = "System",
Name ="超级管理员", Name ="超级管理员",
Password = "123456" Password = "123456"
}; };
} }
else else
{ {
var usermanager = (UserManagerApp)DependencyResolver.Current.GetService(typeof(UserManagerApp)); var usermanager = (UserManagerApp)DependencyResolver.Current.GetService(typeof(UserManagerApp));
userInfo = usermanager.Get(model.UserName); userInfo = usermanager.Get(model.UserName);
} }
if (userInfo == null) if (userInfo == null)
{ {
throw new Exception("用户不存在"); throw new Exception("用户不存在");
} }
if (userInfo.Password != model.Password) if (userInfo.Password != model.Password)
{ {
throw new Exception("密码错误"); throw new Exception("密码错误");
} }
var currentSession = new UserAuthSession var currentSession = new UserAuthSession
{ {
UserName = model.UserName, UserName = model.UserName,
Token = Guid.NewGuid().ToString().GetHashCode().ToString("x"), Token = Guid.NewGuid().ToString().GetHashCode().ToString("x"),
AppKey = model.AppKey, AppKey = model.AppKey,
CreateTime = DateTime.Now, CreateTime = DateTime.Now,
IpAddress = HttpContext.Current.Request.UserHostAddress IpAddress = HttpContext.Current.Request.UserHostAddress
}; };
//创建Session //创建Session
new ObjCacheProvider<UserAuthSession>().Create(currentSession.Token, currentSession, DateTime.Now.AddDays(10)); new ObjCacheProvider<UserAuthSession>().Create(currentSession.Token, currentSession, DateTime.Now.AddDays(10));
result.Success = true; result.Success = true;
result.ReturnUrl = appInfo.ReturnUrl; result.ReturnUrl = appInfo.ReturnUrl;
result.Token = currentSession.Token; result.Token = currentSession.Token;
} }
catch (Exception ex) catch (Exception ex)
{ {
result.Success = false; result.Success = false;
result.ErrorMsg = ex.Message; result.ErrorMsg = ex.Message;
} }
return result; return result;
} }
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -21,14 +21,7 @@ namespace OpenAuth.Mvc.Areas.FlowManage.Controllers
/// </summary> /// </summary>
public class FlowDesignController :BaseController public class FlowDesignController :BaseController
{ {
private WFSchemeService wfFlowInfoBLL; public WFSchemeService WfFlowInfoBll { get; set; }
private UserManagerApp userBLL;
public FlowDesignController()
{
wfFlowInfoBLL = AutofacExt.GetFromFac<WFSchemeService>();
userBLL = AutofacExt.GetFromFac<UserManagerApp>();
}
#region #region
/// <summary> /// <summary>
@ -100,8 +93,8 @@ namespace OpenAuth.Mvc.Areas.FlowManage.Controllers
[HttpGet] [HttpGet]
public ActionResult GetFormJson(Guid keyValue) public ActionResult GetFormJson(Guid keyValue)
{ {
var schemeinfo = wfFlowInfoBLL.GetEntity(keyValue); var schemeinfo = WfFlowInfoBll.GetEntity(keyValue);
var schemecontent = wfFlowInfoBLL.GetSchemeEntity(schemeinfo.Id, schemeinfo.SchemeVersion); var schemecontent = WfFlowInfoBll.GetSchemeEntity(schemeinfo.Id, schemeinfo.SchemeVersion);
var JsonData = new var JsonData = new
{ {
schemeinfo = schemeinfo, schemeinfo = schemeinfo,
@ -118,7 +111,7 @@ namespace OpenAuth.Mvc.Areas.FlowManage.Controllers
[HttpGet] [HttpGet]
public ActionResult GetSchemeContentJson(Guid keyValue, string SchemeVersion) public ActionResult GetSchemeContentJson(Guid keyValue, string SchemeVersion)
{ {
var schemecontent = wfFlowInfoBLL.GetSchemeEntity(keyValue, SchemeVersion); var schemecontent = WfFlowInfoBll.GetSchemeEntity(keyValue, SchemeVersion);
return Content(schemecontent.ToJson()); return Content(schemecontent.ToJson());
} }
#endregion #endregion
@ -132,7 +125,7 @@ namespace OpenAuth.Mvc.Areas.FlowManage.Controllers
[HttpPost] [HttpPost]
public string RemoveForm(Guid[] ids) public string RemoveForm(Guid[] ids)
{ {
wfFlowInfoBLL.RemoveForm(ids); WfFlowInfoBll.RemoveForm(ids);
return Result.ToJson(); return Result.ToJson();
} }
/// <summary> /// <summary>
@ -146,7 +139,7 @@ namespace OpenAuth.Mvc.Areas.FlowManage.Controllers
{ {
WFSchemeInfo entyity = InfoEntity.ToObject<WFSchemeInfo>(); WFSchemeInfo entyity = InfoEntity.ToObject<WFSchemeInfo>();
WFSchemeContent contententity = ContentEntity.ToObject<WFSchemeContent>(); WFSchemeContent contententity = ContentEntity.ToObject<WFSchemeContent>();
wfFlowInfoBLL.SaveForm(keyValue, entyity, contententity); WfFlowInfoBll.SaveForm(keyValue, entyity, contententity);
return Result.ToJson(); return Result.ToJson();
} }
/// <summary> /// <summary>
@ -159,13 +152,13 @@ namespace OpenAuth.Mvc.Areas.FlowManage.Controllers
public ActionResult SubmitUpdateState(string keyValue, int State) public ActionResult SubmitUpdateState(string keyValue, int State)
{ {
wfFlowInfoBLL.UpdateState(keyValue, State); WfFlowInfoBll.UpdateState(keyValue, State);
return Content("操作成功。"); return Content("操作成功。");
} }
public string Load(int pageCurrent = 1, int pageSize = 30) public string Load(int pageCurrent = 1, int pageSize = 30)
{ {
return JsonHelper.Instance.Serialize(wfFlowInfoBLL.Load(pageCurrent, pageSize)); return JsonHelper.Instance.Serialize(WfFlowInfoBll.Load(pageCurrent, pageSize));
} }
#endregion #endregion

View File

@ -14,12 +14,7 @@ namespace OpenAuth.Mvc.Areas.FlowManage.Controllers
/// </summary> /// </summary>
public class FlowInstancesController : BaseController public class FlowInstancesController : BaseController
{ {
private WFProcessInstanceService _app; public WFProcessInstanceService App { get; set; }
public FlowInstancesController()
{
_app = AutofacExt.GetFromFac<WFProcessInstanceService>();
}
#region #region
@ -115,7 +110,7 @@ namespace OpenAuth.Mvc.Areas.FlowManage.Controllers
WFProcessInstance wfProcessInstanceEntity = wfProcessInstanceJson.ToObject<WFProcessInstance>(); WFProcessInstance wfProcessInstanceEntity = wfProcessInstanceJson.ToObject<WFProcessInstance>();
wfProcessInstanceEntity.Id = Guid.Empty; wfProcessInstanceEntity.Id = Guid.Empty;
_app.CreateInstance(Guid.NewGuid(), wfSchemeInfoId, wfProcessInstanceEntity, frmData); App.CreateInstance(Guid.NewGuid(), wfSchemeInfoId, wfProcessInstanceEntity, frmData);
return Result.ToJson(); return Result.ToJson();
} }
@ -129,7 +124,7 @@ namespace OpenAuth.Mvc.Areas.FlowManage.Controllers
[HttpPost] [HttpPost]
public string VerificationProcess(Guid processId, string verificationData) public string VerificationProcess(Guid processId, string verificationData)
{ {
_app.VerificationProcess(processId, verificationData); App.VerificationProcess(processId, verificationData);
return Result.ToJson(); return Result.ToJson();
} }
@ -142,7 +137,7 @@ namespace OpenAuth.Mvc.Areas.FlowManage.Controllers
{ {
foreach (var id in ids) foreach (var id in ids)
{ {
_app.DeleteProcess(id); App.DeleteProcess(id);
} }
return Result.ToJson(); return Result.ToJson();
} }
@ -166,7 +161,7 @@ namespace OpenAuth.Mvc.Areas.FlowManage.Controllers
[HttpGet] [HttpGet]
public ActionResult GetProcessSchemeJson(Guid keyValue) public ActionResult GetProcessSchemeJson(Guid keyValue)
{ {
var data = _app.GetProcessSchemeEntity(keyValue); var data = App.GetProcessSchemeEntity(keyValue);
return Content(data.ToJson()); return Content(data.ToJson());
} }
@ -178,7 +173,7 @@ namespace OpenAuth.Mvc.Areas.FlowManage.Controllers
[HttpGet] [HttpGet]
public ActionResult GetProcessSchemeEntityByUserId(Guid keyValue) public ActionResult GetProcessSchemeEntityByUserId(Guid keyValue)
{ {
var data = _app.GetProcessSchemeByUserId(keyValue); var data = App.GetProcessSchemeByUserId(keyValue);
return Content(data.ToJson()); return Content(data.ToJson());
} }
@ -191,7 +186,7 @@ namespace OpenAuth.Mvc.Areas.FlowManage.Controllers
[HttpGet] [HttpGet]
public ActionResult GetProcessSchemeEntityByNodeId(Guid keyValue, string nodeId) public ActionResult GetProcessSchemeEntityByNodeId(Guid keyValue, string nodeId)
{ {
var data = _app.GetProcessSchemeEntityByNodeId(keyValue, nodeId); var data = App.GetProcessSchemeEntityByNodeId(keyValue, nodeId);
return Content(data.ToJson()); return Content(data.ToJson());
} }
@ -203,8 +198,8 @@ namespace OpenAuth.Mvc.Areas.FlowManage.Controllers
[HttpGet] [HttpGet]
public ActionResult GetProcessInfoJson(Guid keyValue) public ActionResult GetProcessInfoJson(Guid keyValue)
{ {
var processInstance = _app.GetProcessInstanceEntity(keyValue); var processInstance = App.GetProcessInstanceEntity(keyValue);
var processScheme = _app.GetProcessSchemeEntity(processInstance.ProcessSchemeId); var processScheme = App.GetProcessSchemeEntity(processInstance.ProcessSchemeId);
var JsonData = new var JsonData = new
{ {
processInstance = processInstance, processInstance = processInstance,
@ -221,13 +216,13 @@ namespace OpenAuth.Mvc.Areas.FlowManage.Controllers
[HttpGet] [HttpGet]
public ActionResult GetProcessInstanceJson(Guid keyValue) public ActionResult GetProcessInstanceJson(Guid keyValue)
{ {
var processInstance = _app.GetProcessInstanceEntity(keyValue); var processInstance = App.GetProcessInstanceEntity(keyValue);
return Content(processInstance.ToJson()); return Content(processInstance.ToJson());
} }
public string Load(string type, int pageCurrent = 1, int pageSize = 30) public string Load(string type, int pageCurrent = 1, int pageSize = 30)
{ {
return JsonHelper.Instance.Serialize(_app.Load(AuthUtil.GetCurrentUser().User.Id.ToString(), type, pageCurrent, pageSize)); return JsonHelper.Instance.Serialize(App.Load(AuthUtil.GetCurrentUser().User.Id.ToString(), type, pageCurrent, pageSize));
} }
#endregion () #endregion ()

View File

@ -13,12 +13,7 @@ namespace OpenAuth.Mvc.Areas.FlowManage.Controllers
public class FormDesignController : BaseController public class FormDesignController : BaseController
{ {
private readonly WFFormService _wfFrmMainBll; public WFFormService WfFrmMainBll { get; set; }
public FormDesignController()
{
_wfFrmMainBll = AutofacExt.GetFromFac<WFFormService>();
}
#region #region
/// <summary> /// <summary>
@ -55,7 +50,7 @@ namespace OpenAuth.Mvc.Areas.FlowManage.Controllers
public string Load(int pageCurrent = 1, int pageSize = 30) public string Load(int pageCurrent = 1, int pageSize = 30)
{ {
return JsonHelper.Instance.Serialize(_wfFrmMainBll.Load(pageCurrent, pageSize)); return JsonHelper.Instance.Serialize(WfFrmMainBll.Load(pageCurrent, pageSize));
} }
/// <summary> /// <summary>
@ -66,7 +61,7 @@ namespace OpenAuth.Mvc.Areas.FlowManage.Controllers
[HttpGet] [HttpGet]
public ActionResult GetTreeJson() public ActionResult GetTreeJson()
{ {
var data = _wfFrmMainBll.GetAllList(); var data = WfFrmMainBll.GetAllList();
var treeList = new List<TreeEntity>(); var treeList = new List<TreeEntity>();
foreach (var item in data) foreach (var item in data)
{ {
@ -95,7 +90,7 @@ namespace OpenAuth.Mvc.Areas.FlowManage.Controllers
[HttpGet] [HttpGet]
public ActionResult GetFormJson(Guid keyValue) public ActionResult GetFormJson(Guid keyValue)
{ {
var data = _wfFrmMainBll.GetForm(keyValue); var data = WfFrmMainBll.GetForm(keyValue);
return Content(data.ToJson()); return Content(data.ToJson());
} }
@ -106,7 +101,7 @@ namespace OpenAuth.Mvc.Areas.FlowManage.Controllers
[HttpGet] [HttpGet]
public ActionResult GetAllListJson() public ActionResult GetAllListJson()
{ {
var data = _wfFrmMainBll.GetAllList(); var data = WfFrmMainBll.GetAllList();
return Content(data.ToJson()); return Content(data.ToJson());
} }
#endregion #endregion
@ -120,7 +115,7 @@ namespace OpenAuth.Mvc.Areas.FlowManage.Controllers
[HttpPost] [HttpPost]
public string RemoveForm(Guid[] ids) public string RemoveForm(Guid[] ids)
{ {
_wfFrmMainBll.RemoveForm(ids); WfFrmMainBll.RemoveForm(ids);
return Result.ToJson(); return Result.ToJson();
} }
///// <summary> ///// <summary>
@ -137,7 +132,7 @@ namespace OpenAuth.Mvc.Areas.FlowManage.Controllers
var user = AuthUtil.GetCurrentUser(); var user = AuthUtil.GetCurrentUser();
userEntity.ModifyUserId = user.User.Account; userEntity.ModifyUserId = user.User.Account;
userEntity.ModifyUserName = user.User.Name; userEntity.ModifyUserName = user.User.Name;
_wfFrmMainBll.SaveForm(keyValue, userEntity); WfFrmMainBll.SaveForm(keyValue, userEntity);
} }
catch (Exception e) catch (Exception e)
{ {

View File

@ -15,12 +15,12 @@
InitControl(); InitControl();
}); });
function initLoadPageData() { function initLoadPageData() {
var _FlowDesignObject = top.FlowSchemeBuider.FlowDesignObject; var _FlowDesignObject = parent.FlowDesignObject;
lineobject = _FlowDesignObject.$lineData[top.FlowSchemeBuider.LineId]; lineobject = _FlowDesignObject.$lineData[parent.LineId];
lineobject.id = top.FlowSchemeBuider.LineId; lineobject.id = parent.LineId;
fromnode = _FlowDesignObject.$nodeData[lineobject.from]; fromnode = _FlowDesignObject.$nodeData[lineobject.from];
frmtype = top.FlowSchemeBuider.postData["FrmType"]; frmtype = parent.postData["FrmType"];
if (frmtype == 0) { if (frmtype == 0) {
frmCotent = JSON.parse(top.FlowSchemeBuider.frmData["FrmContent"]); frmCotent = JSON.parse(top.FlowSchemeBuider.frmData["FrmContent"]);
} }

View File

@ -36,30 +36,31 @@ namespace OpenAuth.Mvc
builder.RegisterGeneric(typeof(BaseRepository<>)).As(typeof(IRepository<>)); builder.RegisterGeneric(typeof(BaseRepository<>)).As(typeof(IRepository<>));
builder.RegisterType(typeof (UnitWork)).As(typeof (IUnitWork)); builder.RegisterType(typeof (UnitWork)).As(typeof (IUnitWork));
//注册WebConfig中的配置
builder.RegisterModule(new ConfigurationSettingsReader("autofac"));
//注册app层 //注册app层
builder.RegisterAssemblyTypes(Assembly.GetAssembly(typeof (UserManagerApp))); builder.RegisterAssemblyTypes(Assembly.GetAssembly(typeof (UserManagerApp)));
//注册领域服务 //注册领域服务
builder.RegisterAssemblyTypes(Assembly.GetAssembly(typeof(AuthoriseService))) builder.RegisterAssemblyTypes(Assembly.GetAssembly(typeof(AuthoriseService)))
.Where(u =>u.Namespace== "OpenAuth.Domain.Service"); .Where(u =>u.Namespace== "OpenAuth.Domain.Service"
|| u.Namespace == "OpenAuth.Domain.Interface");
// Register your MVC controllers. //注册Repository
builder.RegisterControllers(typeof(MvcApplication).Assembly); builder.RegisterAssemblyTypes(Assembly.GetAssembly(typeof(UserRepository)))
.AsImplementedInterfaces();
// OPTIONAL: Register model binders that require DI. // 注册controller使用属性注入
builder.RegisterControllers(Assembly.GetExecutingAssembly()).PropertiesAutowired();
builder.RegisterModelBinders(Assembly.GetExecutingAssembly()); builder.RegisterModelBinders(Assembly.GetExecutingAssembly());
builder.RegisterModelBinderProvider(); builder.RegisterModelBinderProvider();
// OPTIONAL: Register web abstractions like HttpContextBase. // OPTIONAL: Register web abstractions like HttpContextBase.
builder.RegisterModule<AutofacWebTypesModule>(); //builder.RegisterModule<AutofacWebTypesModule>();
// OPTIONAL: Enable property injection in view pages. // OPTIONAL: Enable property injection in view pages.
builder.RegisterSource(new ViewRegistrationSource()); builder.RegisterSource(new ViewRegistrationSource());
// OPTIONAL: Enable property injection into action filters. // 注册所有的Attribute
builder.RegisterFilterProvider(); builder.RegisterFilterProvider();
// Set the dependency resolver to be Autofac. // Set the dependency resolver to be Autofac.

View File

@ -10,12 +10,7 @@ namespace OpenAuth.Mvc.Controllers
{ {
public class CategoryManagerController : BaseController public class CategoryManagerController : BaseController
{ {
private CategoryManagerApp _app; public CategoryManagerApp App { get; set; }
public CategoryManagerController()
{
_app = AutofacExt.GetFromFac<CategoryManagerApp>();
}
// //
// GET: /UserManager/ // GET: /UserManager/
@ -30,12 +25,12 @@ namespace OpenAuth.Mvc.Controllers
/// </summary> /// </summary>
public string Load(Guid parentId, int page = 1, int rows = 30) public string Load(Guid parentId, int page = 1, int rows = 30)
{ {
return JsonHelper.Instance.Serialize(_app.Load(parentId, page, rows)); return JsonHelper.Instance.Serialize(App.Load(parentId, page, rows));
} }
public string LoadForTree() public string LoadForTree()
{ {
return JsonHelper.Instance.Serialize(_app.LoadAll()); return JsonHelper.Instance.Serialize(App.LoadAll());
} }
//添加或修改Category //添加或修改Category
@ -44,7 +39,7 @@ namespace OpenAuth.Mvc.Controllers
{ {
try try
{ {
_app.AddOrUpdate(model); App.AddOrUpdate(model);
} }
catch (Exception ex) catch (Exception ex)
@ -59,7 +54,7 @@ namespace OpenAuth.Mvc.Controllers
{ {
try try
{ {
_app.Delete(ids); App.Delete(ids);
} }
catch (Exception e) catch (Exception e)
{ {

View File

@ -12,13 +12,7 @@ namespace OpenAuth.Mvc.Controllers
{ {
public class HomeController : BaseController public class HomeController : BaseController
{ {
private ModuleManagerApp _app;
public HomeController()
{
_app = AutofacExt.GetFromFac<ModuleManagerApp>();
}
public ActionResult Index() public ActionResult Index()
{ {
ViewBag.NavBar = GetNavBar(); ViewBag.NavBar = GetNavBar();

View File

@ -24,12 +24,8 @@ namespace OpenAuth.Mvc.Controllers
{ {
public class ModuleElementManagerController : BaseController public class ModuleElementManagerController : BaseController
{ {
private ModuleElementManagerApp _app; public ModuleElementManagerApp App { get; set; }
public ModuleElementManagerController()
{
_app = AutofacExt.GetFromFac<ModuleElementManagerApp>();
}
public ActionResult Index(Guid id) public ActionResult Index(Guid id)
{ {
ViewBag.ModuleId = id; ViewBag.ModuleId = id;
@ -37,14 +33,14 @@ namespace OpenAuth.Mvc.Controllers
} }
public ActionResult Get(Guid moduleId) public ActionResult Get(Guid moduleId)
{ {
return Json(_app.LoadByModuleId(moduleId), JsonRequestBehavior.AllowGet); return Json(App.LoadByModuleId(moduleId), JsonRequestBehavior.AllowGet);
} }
[HttpPost] [HttpPost]
public string AddOrEditButton(ModuleElement button) public string AddOrEditButton(ModuleElement button)
{ {
try try
{ {
_app.AddOrUpdate(button); App.AddOrUpdate(button);
} }
catch (DbEntityValidationException e) catch (DbEntityValidationException e)
{ {
@ -58,7 +54,7 @@ namespace OpenAuth.Mvc.Controllers
{ {
try try
{ {
_app.Delete(ids); App.Delete(ids);
} }
catch (Exception e) catch (Exception e)
{ {
@ -83,7 +79,7 @@ namespace OpenAuth.Mvc.Controllers
} }
public string LoadWithAccess(Guid tId, Guid firstId, string key) public string LoadWithAccess(Guid tId, Guid firstId, string key)
{ {
return JsonHelper.Instance.Serialize(_app.LoadWithAccess(key, firstId, tId)); return JsonHelper.Instance.Serialize(App.LoadWithAccess(key, firstId, tId));
} }
} }
} }

View File

@ -14,12 +14,7 @@ namespace OpenAuth.Mvc.Controllers
{ {
public class ModuleManagerController : BaseController public class ModuleManagerController : BaseController
{ {
private ModuleManagerApp _app; public ModuleManagerApp App { get; set; }
public ModuleManagerController()
{
_app = AutofacExt.GetFromFac<ModuleManagerApp>();
}
// GET: /ModuleManager/ // GET: /ModuleManager/
[Authenticate] [Authenticate]
@ -34,7 +29,7 @@ namespace OpenAuth.Mvc.Controllers
ViewBag.ModuleType = key; ViewBag.ModuleType = key;
var moduleWithChildren = AuthUtil.GetCurrentUser().ModuleWithChildren; var moduleWithChildren = AuthUtil.GetCurrentUser().ModuleWithChildren;
var modules = key == "UserModule" ? _app.LoadForUser(firstId) : _app.LoadForRole(firstId); var modules = key == "UserModule" ? App.LoadForUser(firstId) : App.LoadForRole(firstId);
CheckModule(moduleWithChildren, modules); CheckModule(moduleWithChildren, modules);
@ -106,7 +101,7 @@ namespace OpenAuth.Mvc.Controllers
/// </summary> /// </summary>
public string Load(Guid orgId, int page = 1, int rows = 30) public string Load(Guid orgId, int page = 1, int rows = 30)
{ {
return JsonHelper.Instance.Serialize(_app.Load(orgId, page, rows)); return JsonHelper.Instance.Serialize(App.Load(orgId, page, rows));
} }
/// <summary> /// <summary>
@ -116,7 +111,7 @@ namespace OpenAuth.Mvc.Controllers
/// <returns>System.String.</returns> /// <returns>System.String.</returns>
public string LoadForUser(Guid firstId) public string LoadForUser(Guid firstId)
{ {
var orgs = _app.LoadForUser(firstId); var orgs = App.LoadForUser(firstId);
return JsonHelper.Instance.Serialize(orgs); return JsonHelper.Instance.Serialize(orgs);
} }
@ -127,7 +122,7 @@ namespace OpenAuth.Mvc.Controllers
/// <returns>System.String.</returns> /// <returns>System.String.</returns>
public string LoadForRole(Guid firstId) public string LoadForRole(Guid firstId)
{ {
var orgs = _app.LoadForRole(firstId); var orgs = App.LoadForRole(firstId);
return JsonHelper.Instance.Serialize(orgs); return JsonHelper.Instance.Serialize(orgs);
} }
@ -145,7 +140,7 @@ namespace OpenAuth.Mvc.Controllers
{ {
try try
{ {
_app.AddOrUpdate(model); App.AddOrUpdate(model);
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -162,7 +157,7 @@ namespace OpenAuth.Mvc.Controllers
{ {
foreach (var obj in ids) foreach (var obj in ids)
{ {
_app.Delete(obj); App.Delete(obj);
} }
} }
catch (Exception e) catch (Exception e)

View File

@ -10,12 +10,7 @@ namespace OpenAuth.Mvc.Controllers
{ {
public class OrgManagerController : BaseController public class OrgManagerController : BaseController
{ {
private OrgManagerApp _orgApp; public OrgManagerApp OrgApp { get; set; }
public OrgManagerController()
{
_orgApp = AutofacExt.GetFromFac<OrgManagerApp>();
}
// //
// GET: /OrgManager/ // GET: /OrgManager/
@ -38,13 +33,13 @@ namespace OpenAuth.Mvc.Controllers
public string LoadForUser(Guid firstId) public string LoadForUser(Guid firstId)
{ {
var orgs = _orgApp.LoadForUser(firstId); var orgs = OrgApp.LoadForUser(firstId);
return JsonHelper.Instance.Serialize(orgs); return JsonHelper.Instance.Serialize(orgs);
} }
public string LoadForRole(Guid firstId) public string LoadForRole(Guid firstId)
{ {
var orgs = _orgApp.LoadForRole(firstId); var orgs = OrgApp.LoadForRole(firstId);
return JsonHelper.Instance.Serialize(orgs); return JsonHelper.Instance.Serialize(orgs);
} }
@ -55,7 +50,7 @@ namespace OpenAuth.Mvc.Controllers
{ {
try try
{ {
_orgApp.AddOrUpdate(org); OrgApp.AddOrUpdate(org);
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -67,7 +62,7 @@ namespace OpenAuth.Mvc.Controllers
public string LoadChildren(Guid id) public string LoadChildren(Guid id)
{ {
return JsonHelper.Instance.Serialize(_orgApp.LoadAllChildren(id)); return JsonHelper.Instance.Serialize(OrgApp.LoadAllChildren(id));
} }
/// <summary> /// <summary>
@ -80,7 +75,7 @@ namespace OpenAuth.Mvc.Controllers
{ {
try try
{ {
_orgApp.DelOrg(ids); OrgApp.DelOrg(ids);
} }
catch (Exception e) catch (Exception e)
{ {

View File

@ -12,19 +12,14 @@ namespace OpenAuth.Mvc.Controllers
{ {
public class RelevanceManagerController : BaseController public class RelevanceManagerController : BaseController
{ {
private RevelanceManagerApp _app; public RevelanceManagerApp App { get; set; }
public RelevanceManagerController()
{
_app = AutofacExt.GetFromFac<RevelanceManagerApp>();
}
[HttpPost] [HttpPost]
public string Assign(string type, Guid firstId, Guid[] secIds) public string Assign(string type, Guid firstId, Guid[] secIds)
{ {
try try
{ {
_app.Assign(type, firstId, secIds); App.Assign(type, firstId, secIds);
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -38,7 +33,7 @@ namespace OpenAuth.Mvc.Controllers
{ {
try try
{ {
_app.UnAssign(type, firstId, secIds); App.UnAssign(type, firstId, secIds);
} }
catch (Exception ex) catch (Exception ex)
{ {

View File

@ -11,12 +11,7 @@ namespace OpenAuth.Mvc.Controllers
{ {
public class ResourceManagerController : BaseController public class ResourceManagerController : BaseController
{ {
private ResourceManagerApp _app; public ResourceManagerApp App { get; set; }
public ResourceManagerController()
{
_app = AutofacExt.GetFromFac<ResourceManagerApp>();
}
// //
// GET: /UserManager/ // GET: /UserManager/
@ -32,7 +27,7 @@ namespace OpenAuth.Mvc.Controllers
{ {
try try
{ {
_app.AddOrUpdate(model); App.AddOrUpdate(model);
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -47,12 +42,12 @@ namespace OpenAuth.Mvc.Controllers
/// </summary> /// </summary>
public string Load(Guid categoryId, int page = 1, int rows = 30) public string Load(Guid categoryId, int page = 1, int rows = 30)
{ {
return JsonHelper.Instance.Serialize(_app.Load(AuthUtil.GetUserName(), categoryId, page, rows)); return JsonHelper.Instance.Serialize(App.Load(AuthUtil.GetUserName(), categoryId, page, rows));
} }
public string LoadForTree() public string LoadForTree()
{ {
var models = _app.LoadAll(); var models = App.LoadAll();
return JsonHelper.Instance.Serialize(models); return JsonHelper.Instance.Serialize(models);
} }
@ -61,7 +56,7 @@ namespace OpenAuth.Mvc.Controllers
{ {
try try
{ {
_app.Delete(ids); App.Delete(ids);
} }
catch (Exception e) catch (Exception e)
{ {
@ -96,7 +91,7 @@ namespace OpenAuth.Mvc.Controllers
/// <returns>System.String.</returns> /// <returns>System.String.</returns>
public string LoadWithAccess(Guid cId, Guid firstId, string key) public string LoadWithAccess(Guid cId, Guid firstId, string key)
{ {
return JsonHelper.Instance.Serialize(_app.LoadWithAccess(AuthUtil.GetUserName(),key,firstId, cId)); return JsonHelper.Instance.Serialize(App.LoadWithAccess(AuthUtil.GetUserName(),key,firstId, cId));
} }
} }
} }

View File

@ -10,12 +10,7 @@ namespace OpenAuth.Mvc.Controllers
{ {
public class RoleManagerController : BaseController public class RoleManagerController : BaseController
{ {
private RoleManagerApp _app; public RoleManagerApp App { get; set; }
public RoleManagerController()
{
_app = AutofacExt.GetFromFac<RoleManagerApp>();
}
// //
// GET: /RoleManager/ // GET: /RoleManager/
@ -31,7 +26,7 @@ namespace OpenAuth.Mvc.Controllers
{ {
try try
{ {
_app.AddOrUpdate(obj); App.AddOrUpdate(obj);
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -46,7 +41,7 @@ namespace OpenAuth.Mvc.Controllers
/// </summary> /// </summary>
public string Load(Guid orgId, int pageCurrent = 1, int pageSize = 30) public string Load(Guid orgId, int pageCurrent = 1, int pageSize = 30)
{ {
return JsonHelper.Instance.Serialize(_app.Load(orgId, pageCurrent, pageSize)); return JsonHelper.Instance.Serialize(App.Load(orgId, pageCurrent, pageSize));
} }
[System.Web.Mvc.HttpPost] [System.Web.Mvc.HttpPost]
@ -56,7 +51,7 @@ namespace OpenAuth.Mvc.Controllers
{ {
foreach (var obj in ids) foreach (var obj in ids)
{ {
_app.Delete(obj); App.Delete(obj);
} }
} }
catch (Exception e) catch (Exception e)
@ -78,7 +73,7 @@ namespace OpenAuth.Mvc.Controllers
public string LoadForOrgAndUser(Guid orgId, Guid userId) public string LoadForOrgAndUser(Guid orgId, Guid userId)
{ {
return JsonHelper.Instance.Serialize(_app.LoadForOrgAndUser(orgId, userId)); return JsonHelper.Instance.Serialize(App.LoadForOrgAndUser(orgId, userId));
} }
#endregion #endregion

View File

@ -14,12 +14,7 @@ namespace OpenAuth.Mvc.Controllers
/// </summary> /// </summary>
public class StockManagerController : BaseController public class StockManagerController : BaseController
{ {
private StockManagerApp _app; public StockManagerApp App { get; set; }
public StockManagerController()
{
_app = AutofacExt.GetFromFac<StockManagerApp>();
}
// //
// GET: /UserManager/ // GET: /UserManager/
@ -37,7 +32,7 @@ namespace OpenAuth.Mvc.Controllers
{ {
var newmodel = new Stock(); var newmodel = new Stock();
model.CopyTo(newmodel); model.CopyTo(newmodel);
_app.AddOrUpdate(newmodel); App.AddOrUpdate(newmodel);
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -52,14 +47,14 @@ namespace OpenAuth.Mvc.Controllers
/// </summary> /// </summary>
public string Load(Guid parentId, int page = 1, int rows = 30) public string Load(Guid parentId, int page = 1, int rows = 30)
{ {
return JsonHelper.Instance.Serialize(_app.Load(AuthUtil.GetUserName(), parentId, page, rows)); return JsonHelper.Instance.Serialize(App.Load(AuthUtil.GetUserName(), parentId, page, rows));
} }
public string Delete(Guid[] ids) public string Delete(Guid[] ids)
{ {
try try
{ {
_app.Delete(ids); App.Delete(ids);
} }
catch (Exception e) catch (Exception e)
{ {

View File

@ -13,12 +13,7 @@ namespace OpenAuth.Mvc.Controllers
{ {
public class UserManagerController : BaseController public class UserManagerController : BaseController
{ {
private UserManagerApp _app; public UserManagerApp App { get; set; }
public UserManagerController()
{
_app = AutofacExt.GetFromFac<UserManagerApp>();
}
// //
// GET: /UserManager/ // GET: /UserManager/
@ -34,7 +29,7 @@ namespace OpenAuth.Mvc.Controllers
{ {
try try
{ {
_app.AddOrUpdate(view); App.AddOrUpdate(view);
} }
catch (Exception ex) catch (Exception ex)
@ -50,7 +45,7 @@ namespace OpenAuth.Mvc.Controllers
/// </summary> /// </summary>
public string Load(Guid orgId, int page = 1, int rows = 30) public string Load(Guid orgId, int page = 1, int rows = 30)
{ {
return JsonHelper.Instance.Serialize(_app.Load(orgId, page, rows)); return JsonHelper.Instance.Serialize(App.Load(orgId, page, rows));
} }
[HttpPost] [HttpPost]
@ -58,7 +53,7 @@ namespace OpenAuth.Mvc.Controllers
{ {
try try
{ {
_app.Delete(ids); App.Delete(ids);
} }
catch (Exception e) catch (Exception e)
{ {
@ -81,7 +76,7 @@ namespace OpenAuth.Mvc.Controllers
var treeList = new List<TreeEntity>(); var treeList = new List<TreeEntity>();
string companyid = ""; string companyid = "";
string departmentid = ""; string departmentid = "";
foreach (UserView item in _app.Load(Guid.Empty, 1, 10).rows) foreach (UserView item in App.Load(Guid.Empty, 1, 10).rows)
{ {
TreeEntity tree = new TreeEntity(); TreeEntity tree = new TreeEntity();
@ -107,7 +102,7 @@ namespace OpenAuth.Mvc.Controllers
/// </summary> /// </summary>
public string GetAccessedUsers() public string GetAccessedUsers()
{ {
IEnumerable<UserView> users = _app.Load(Guid.Empty, 1, 10).rows; IEnumerable<UserView> users = App.Load(Guid.Empty, 1, 10).rows;
var result = new Dictionary<string , object>(); var result = new Dictionary<string , object>();
foreach (var user in users) foreach (var user in users)
{ {

View File

@ -9,8 +9,6 @@
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" /> <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
<section name="autofac" type="Autofac.Configuration.SectionHandler, Autofac.Configuration" />
</configSections> </configSections>
<connectionStrings> <connectionStrings>
@ -42,19 +40,6 @@
</root> </root>
</log4net> </log4net>
<autofac defaultAssembly=" OpenAuth.Repository">
<components>
<component type=" OpenAuth.Repository.UserRepository" service=" OpenAuth.Domain.Interface.IUserRepository,OpenAuth.Domain" />
<component type=" OpenAuth.Repository.OrgRepository" service="OpenAuth.Domain.Interface.IOrgRepository,OpenAuth.Domain" />
<component type=" OpenAuth.Repository.RoleRepository" service="OpenAuth.Domain.Interface.IRoleRepository,OpenAuth.Domain" />
<component type=" OpenAuth.Repository.ModuleRepository" service="OpenAuth.Domain.Interface.IModuleRepository,OpenAuth.Domain" />
<component type=" OpenAuth.Repository.RelevanceRepository" service="OpenAuth.Domain.Interface.IRelevanceRepository,OpenAuth.Domain" />
<component type=" OpenAuth.Repository.CategoryRepository" service="OpenAuth.Domain.Interface.ICategoryRepository,OpenAuth.Domain" />
<component type=" OpenAuth.Repository.ResourceRepository" service="OpenAuth.Domain.Interface.IResourceRepository,OpenAuth.Domain" />
<component type=" OpenAuth.Repository.StockRepository" service="OpenAuth.Domain.Interface.IStockRepository,OpenAuth.Domain" />
</components>
</autofac>
<appSettings> <appSettings>
<add key="webpages:Version" value="3.0.0.0" /> <add key="webpages:Version" value="3.0.0.0" />
<add key="webpages:Enabled" value="false" /> <add key="webpages:Enabled" value="false" />