/// <summary>查询所有相关记录</summary> /// <param name="query">数据查询参数</param> /// <returns>返回所有实例<see cref="ApplicationMenuInfo"/>的详细信息</returns> public IList <ApplicationMenuInfo> FindAll(DataQuery query) { Dictionary <string, object> args = new Dictionary <string, object>(); StringBuilder whereClause = new StringBuilder(); if (query.Variables["scence"] == "Search") { // query.Where.Add("AppKey", appKey); // query.Where.Add("Code", bankCodes); whereClause.Append(" Status = 5 "); if (query.Where.ContainsKey("AppKey") && query.Where.ContainsKey("Code")) { if (query.Where["Code"].ToString() == "0") { DataQueryBuilder.Equal(query.Where, "AppKey", whereClause); } else { query.Where["Code"] = "'" + query.Where["Code"].ToString().Replace(",", "','") + "'"; DataQueryBuilder.Equal(query.Where, "AppKey", whereClause); DataQueryBuilder.In(query.Where, "Code", whereClause); } } else if (query.Where.ContainsKey("Id")) { if (query.Where["Id"].ToString() == "0") { // =0 返回全库 } else { DataQueryBuilder.In(query.Where, "Id", whereClause); } } args.Add("WhereClause", whereClause); } else { args.Add("WhereClause", query.GetWhereSql(new Dictionary <string, string>() { { "Name", "LIKE" } })); } args.Add("OrderBy", query.GetOrderBySql(" Id DESC ")); args.Add("Length", query.Length); // 普通用户只能看到授权范围内的内容 if (!AppsSecurity.IsAdministrator(KernelContext.Current.User, AppsConfiguration.ApplicationName) && !AppsSecurity.IsReviewer(KernelContext.Current.User, AppsConfiguration.ApplicationName)) { args["WhereClause"] = this.BindAuthorizationScopeSQL((string)args["WhereClause"]); } return(this.ibatisMapper.QueryForList <ApplicationMenuInfo>(StringHelper.ToProcedurePrefix(string.Format("{0}_FindAll", tableName)), args)); }
// ------------------------------------------------------- // 自定义功能 // ------------------------------------------------------- #region 函数:GetPaging(XmlDocument doc) /// <summary>获取分页内容</summary> /// <param name="doc">Xml 文档对象</param> /// <returns>返回操作结果</returns> public string GetPaging(XmlDocument doc) { StringBuilder outString = new StringBuilder(); PagingHelper paging = PagingHelper.Create(XmlHelper.Fetch("paging", doc, "xml"), XmlHelper.Fetch("query", doc, "xml")); // 设置当前用户权限 if (XmlHelper.Fetch("su", doc) == "1" && AppsSecurity.IsAdministrator(KernelContext.Current.User, BugConfiguration.ApplicationName)) { paging.Query.Variables["elevatedPrivileges"] = "1"; } paging.Query.Variables["accountId"] = KernelContext.Current.User.Id; int rowCount = -1; IList <BugCategoryQueryInfo> list = this.service.GetQueryObjectPaging(paging.RowIndex, paging.PageSize, paging.Query, out rowCount); paging.RowCount = rowCount; outString.Append("{\"data\":" + AjaxUtil.Parse <BugCategoryQueryInfo>(list) + ","); outString.Append("\"paging\":" + paging + ","); outString.Append(MessageObject.Stringify("0", I18n.Strings["msg_query_success"], true) + "}"); return(outString.ToString()); }
// ------------------------------------------------------- // 自定义功能 // ------------------------------------------------------- #region 函数:GetPaging(XmlDocument doc) /// <summary>获取分页内容</summary> /// <param name="doc">Xml 文档对象</param> /// <returns>返回操作结果</returns> public string GetPaging(XmlDocument doc) { StringBuilder outString = new StringBuilder(); PagingHelper paging = PagingHelper.Create(XmlHelper.Fetch("paging", doc, "xml"), XmlHelper.Fetch("query", doc, "xml")); // 设置当前用户权限 if (XmlHelper.Fetch("su", doc) == "1" && AppsSecurity.IsAdministrator(KernelContext.Current.User, TasksConfiguration.ApplicationName)) { paging.Query.Variables["elevatedPrivileges"] = "1"; } paging.Query.Variables["accountId"] = KernelContext.Current.User.Id; int rowCount = -1; IList <TaskCategoryInfo> list = this.service.GetPaging(paging.RowIndex, paging.PageSize, paging.Query, out rowCount); paging.RowCount = rowCount; outString.Append("{\"data\":" + AjaxUtil.Parse <TaskCategoryInfo>(list) + ","); outString.Append("\"paging\":" + paging + ","); outString.Append("\"message\":{\"returnCode\":0,\"value\":\"查询成功。\"},"); outString.Append("\"metaData\":{\"root\":\"data\",\"idProperty\":\"id\",\"totalProperty\":\"total\",\"successProperty\":\"success\",\"messageProperty\": \"message\"},"); outString.Append("\"total\":" + paging.RowCount + ","); outString.Append("\"success\":1,"); outString.Append("\"msg\":\"success\"}"); return(outString.ToString()); }
/// <summary>表单内容界面</summary> /// <returns></returns> public ActionResult Form(string options) { // 所属应用信息 ApplicationInfo application = ViewBag.application = AppsContext.Instance.ApplicationService[BugConfiguration.ApplicationName]; // 管理员身份标记 bool isAdminToken = ViewBag.isAdminToken = AppsSecurity.IsAdministrator(this.Account, application.ApplicationName); // ------------------------------------------------------- // 业务数据处理 // ------------------------------------------------------- JsonData request = JsonMapper.ToObject(options == null ? "{}" : options); // 实体数据标识 string id = !request.Keys.Contains("id") ? string.Empty : request["id"].ToString(); // 文档编辑模式 DocEditMode docEditMode = DocEditMode.Unkown; // 实体数据信息 BugInfo param = null; if (string.IsNullOrEmpty(id)) { param = new BugInfo(); param.Id = DigitalNumberContext.Generate("Table_Bug_Key_Id"); // 设置编辑模式【新建】 docEditMode = DocEditMode.New; } else { param = BugContext.Instance.BugService.FindOne(id); if (param == null) { ApplicationError.Write(404); } // 设置编辑模式【编辑】 docEditMode = DocEditMode.Edit; } // ------------------------------------------------------- // 数据加载 // ------------------------------------------------------- ViewBag.Title = string.Format("{0}-{1}-{2}", (string.IsNullOrEmpty(param.Title) ? "新问题" : param.Title), application.ApplicationDisplayName, this.SystemName); // 加载当前业务实体类名称 ViewBag.entityClassName = KernelContext.ParseObjectType(param.GetType()); // 加载当前业务实体数据 ViewBag.param = param; // 加载当前文档编辑模式 ViewBag.docEditMode = docEditMode; return(View("/views/main/bugs/bug-form.cshtml")); }
/// <summary>列表</summary> /// <returns></returns> public ActionResult List() { // 所属应用信息 ApplicationInfo application = ViewBag.application = AppsContext.Instance.ApplicationService[ForumConfiguration.ApplicationName]; bool isAdminToken = ViewBag.isAdminToken = AppsSecurity.IsAdministrator(this.Account, ForumConfiguration.ApplicationName); return(View("/views/main/forum/forum-essential-thread-list.cshtml")); }
public static bool IsHumanResourceOfficer(IAccountInfo account) { if (AppsSecurity.IsAdministrator(KernelContext.Current.User, HumanResourcesConfiguration.ApplicationName)) { return(true); } return(Instance.HumanResourceOfficerService.IsHumanResourceOfficer(account)); }
/// <summary>主页</summary> /// <returns></returns> public ActionResult Index() { // 所属应用信息 ApplicationInfo application = ViewBag.application = AppsContext.Instance.ApplicationService[BugConfiguration.ApplicationName]; // 管理员身份标记 bool isAdminToken = ViewBag.isAdminToken = AppsSecurity.IsAdministrator(this.Account, application.ApplicationName); // 视图 return(View("/views/main/bugs/bug-list.cshtml")); }
/// <summary>主页</summary> /// <returns></returns> public ActionResult Setting() { // 所属应用信息 ApplicationInfo application = ViewBag.application = AppsContext.Instance.ApplicationService[APPLICATION_NAME]; if (!AppsSecurity.IsAdministrator(KernelContext.Current.User, application.ApplicationName)) { ApplicationError.Write(401); } return(View("/views/main/applications/application-feature-setting.cshtml")); }
/// <summary>查询所有相关记录</summary> /// <param name="whereClause">SQL 查询条件</param> /// <param name="length">条数</param> /// <returns>返回所有实例<see cref="ApplicationMenuQueryInfo"/>的详细信息</returns> public IList <ApplicationMenuQueryInfo> FindAllQueryObject(string whereClause, int length) { // 验证管理员身份 if (AppsSecurity.IsAdministrator(KernelContext.Current.User, AppsConfiguration.ApplicationName)) { return(this.provider.FindAllQueryObject(whereClause, length)); } else { return(this.provider.FindAllQueryObject(this.BindAuthorizationScopeSQL(whereClause), length)); } }
/// <summary>分页函数</summary> /// <param name="startIndex">开始行索引数,由0开始统计</param> /// <param name="pageSize">页面大小</param> /// <param name="whereClause">WHERE 查询条件</param> /// <param name="orderBy">ORDER BY 排序条件</param> /// <param name="rowCount">行数</param> /// <returns>返回一个列表实例<see cref="ApplicationMenuQueryInfo"/></returns> public IList <ApplicationMenuQueryInfo> GetQueryObjectPaging(int startIndex, int pageSize, string whereClause, string orderBy, out int rowCount) { // 验证管理员身份 if (AppsSecurity.IsAdministrator(KernelContext.Current.User, AppsConfiguration.ApplicationName)) { return(this.provider.GetQueryObjectPaging(startIndex, pageSize, whereClause, orderBy, out rowCount)); } else { return(this.provider.GetQueryObjectPaging(startIndex, pageSize, this.BindAuthorizationScopeSQL(whereClause), orderBy, out rowCount)); } }
/// <summary>主页</summary> /// <returns></returns> public ActionResult List() { // 所属应用信息 ApplicationInfo application = ViewBag.application = AppsContext.Instance.ApplicationService[APPLICATION_NAME]; if (!AppsSecurity.IsAdministrator(KernelContext.Current.User, application.ApplicationName)) { ApplicationError.Write(401); } ViewBag.searchApplication = AppsContext.Instance.ApplicationService.FindOne("00000000-0000-0000-0000-000000000001"); // 角色 return(View("/views/main/applications/application-feature-list.cshtml")); }
/// <summary>详细内容界面</summary> /// <param name="options"></param> /// <returns></returns> public ActionResult Detail(string options) { // 所属应用信息 ApplicationInfo application = ViewBag.application = AppsContext.Instance.ApplicationService[BugConfiguration.ApplicationName]; // 管理员身份标记 bool isAdminToken = ViewBag.isAdminToken = AppsSecurity.IsAdministrator(this.Account, application.ApplicationName); JsonData request = JsonMapper.ToObject(options == null ? "{}" : options); // 实体数据标识 string id = !request.Keys.Contains("id") ? string.Empty : request["id"].ToString(); // 实体数据编码 string code = !request.Keys.Contains("code") ? string.Empty : request["code"].ToString(); BugInfo param = null; if (!string.IsNullOrEmpty(id)) { param = BugContext.Instance.BugService.FindOne(id); } else if (!string.IsNullOrEmpty(code)) { param = BugContext.Instance.BugService.FindOneByCode(code); } if (param == null) { ApplicationError.Write(404); } // ------------------------------------------------------- // 数据加载 // ------------------------------------------------------- ViewBag.Title = string.Format("{0}-{1}-{2}", param.Title, application.ApplicationDisplayName, this.SystemName); // 加载数据表前缀 ViewBag.dataTablePrefix = BugConfigurationView.Instance.DataTablePrefix; // 加载当前业务实体数据 ViewBag.entityClassName = KernelContext.ParseObjectType(param.GetType()); // 加载当前业务实体数据 ViewBag.param = param; // 加载当前用户详细信息 ViewBag.member = MembershipManagement.Instance.MemberService[this.Account.Id]; return(View("/views/main/bugs/bug-detail.cshtml")); }
/// <summary>主页</summary> /// <returns></returns> public ActionResult List() { // 所属应用信息 ApplicationInfo application = ViewBag.application = AppsContext.Instance.ApplicationService[ForumConfiguration.ApplicationName]; // ------------------------------------------------------- // 身份验证 // ------------------------------------------------------- if (!AppsSecurity.IsAdministrator(KernelContext.Current.User, application.ApplicationName)) { ApplicationError.Write(401); } return(View("/views/main/forum/forum-category-list.cshtml")); }
/// <summary>主页</summary> /// <returns></returns> public ActionResult List() { // 所属应用信息 ApplicationInfo application = ViewBag.application = AppsContext.Instance.ApplicationService[APPLICATION_NAME]; // ------------------------------------------------------- // 身份验证 // ------------------------------------------------------- if (!AppsSecurity.IsAdministrator(KernelContext.Current.User, application.ApplicationName)) { ApplicationError.Write(401); } return(View("/views/main/membership/group-list.cshtml")); }
/// <summary>列表</summary> /// <returns></returns> public ActionResult List() { // 所属应用信息 ApplicationInfo application = ViewBag.application = AppsContext.Instance.ApplicationService[WebConfiguration.APP_NAME_CUSTOMIZES]; // ------------------------------------------------------- // 身份验证 // ------------------------------------------------------- if (!AppsSecurity.IsAdministrator(KernelContext.Current.User, application.ApplicationName)) { ApplicationError.Write(401); } return(View("/views/main/customizes/customize-content-list.cshtml")); }
/// <summary>表单</summary> /// <returns></returns> public ActionResult Form(string options) { // 测试页面 customizes/customize-page/form?id=442049bb-9bb3-49cc-8a30-2454a56c770e // 所属应用信息 ApplicationInfo application = ViewBag.application = AppsContext.Instance.ApplicationService[WebConfiguration.APP_NAME_CUSTOMIZES]; // ------------------------------------------------------- // 身份验证 // ------------------------------------------------------- if (!AppsSecurity.IsAdministrator(KernelContext.Current.User, application.ApplicationName)) { ApplicationError.Write(401); } // ------------------------------------------------------- // 业务数据处理 // ------------------------------------------------------- JsonData request = JsonMapper.ToObject(options == null ? "{}" : options); // 实体数据标识 string id = !request.Keys.Contains("id") ? string.Empty : request["id"].ToString(); CustomizePageInfo param = null; if (string.IsNullOrEmpty(id)) { param = new CustomizePageInfo(); param.Id = param.Name = DigitalNumberContext.Generate("Key_Guid"); param.Html = CustomizeContext.Instance.CustomizeLayoutService.GetHtml("default"); param.CreateDate = param.UpdateDate = DateTime.Now; } else { param = CustomizeContext.Instance.CustomizePageService.FindOne(id); } ViewBag.param = param; return(View("/views/main/customizes/customize-page-form.cshtml")); }
/// <summary>表单</summary> /// <returns></returns> public ActionResult Form(string options) { // 所属应用信息 ApplicationInfo application = ViewBag.application = AppsContext.Instance.ApplicationService[APPLICATION_NAME]; // ------------------------------------------------------- // 身份验证 // ------------------------------------------------------- if (!AppsSecurity.IsAdministrator(KernelContext.Current.User, application.ApplicationName)) { ApplicationError.Write(401); } // ------------------------------------------------------- // 数据加载 // ------------------------------------------------------- JsonData request = JsonMapper.ToObject(options); string id = JsonHelper.GetDataValue(request, "id"); ApplicationMenuInfo param = new ApplicationMenuInfo(); if (string.IsNullOrEmpty(id)) { string applicationId = JsonHelper.GetDataValue(request, "applicationId", "00000000-0000-0000-0000-000000000001"); string menuId = JsonHelper.GetDataValue(request, "menuId", "00000000-0000-0000-0000-000000000000"); string menuType = JsonHelper.GetDataValue(request, "menuType", "00000000-0000-0000-0000-000000000000"); param.Id = DigitalNumberContext.Generate("Key_Guid"); param.ApplicationId = applicationId; param.ParentId = menuId; param.MenuType = menuType; param.Status = 1; } else { param = AppsContext.Instance.ApplicationMenuService.FindOne(id); } ViewBag.param = param; return(View("/views/main/applications/application-menu-form.cshtml")); }
/// <summary>删除记录</summary> /// <param name="id">标识</param> public void Delete(string id) { IAccountInfo account = KernelContext.Current.User; if (AppsSecurity.IsAdministrator(account, AttachmentStorageConfiguration.ApplicationName)) { this.provider.Delete(id); } else { IAttachmentFileInfo file = this.FindOne(id); if (file.CreatedBy == account.Id) { this.provider.Delete(id); } } }
// ------------------------------------------------------- // 权限 // ------------------------------------------------------- #region 私有函数:GetAuthorizationReadObject(ApplicationMenuInfo param) ///<summary>验证对象的权限</summary> ///<param name="param">需验证的对象</param> ///<returns>对象</returns> private ApplicationMenuInfo GetAuthorizationReadObject(ApplicationMenuInfo param) { IAccountInfo account = KernelContext.Current.User; if (AppsSecurity.IsAdministrator(account, AppsConfiguration.ApplicationName)) { return(param); } else { if (MembershipAuthorizationScopeManagement.Authenticate(param.AuthorizationReadScopeObjects, account)) { return(param); } return(null); } }
/// <summary>环境变量</summary> /// <returns></returns> public ActionResult Variables() { // 所属应用信息 ApplicationInfo application = ViewBag.application = AppsContext.Instance.ApplicationService[APPLICATION_NAME]; // ------------------------------------------------------- // 身份验证 // ------------------------------------------------------- if (!AppsSecurity.IsAdministrator(KernelContext.Current.User, application.ApplicationName)) { ApplicationError.Write(401); } ViewBag.options = KernelConfigurationView.Instance.Configuration.Keys; return(View("/views/main/sys/variables.cshtml")); }
/// <summary>查询类别数据以供形成类别下拉框数据源</summary> /// <param name="doc">Xml 文档对象</param> /// <returns>返回操作结果</returns> public string GetComboboxWithDrafter(XmlDocument doc) { StringBuilder outString = new StringBuilder(); string combobox = XmlHelper.Fetch("combobox", doc); string selectedValue = XmlHelper.Fetch("selectedValue", doc); string emptyItemText = XmlHelper.Fetch("emptyItemText", doc); string whereClause = string.Empty; if (AppsSecurity.IsAdministrator(KernelContext.Current.User, BugConfiguration.ApplicationName)) { // 管理员可以编辑所有新闻类别 whereClause = " Status = 1 ORDER BY OrderId "; } else { whereClause = string.Format(@" ( ( Id IN ( SELECT DISTINCT EntityId FROM view_AuthObject_Account View1, tb_Bug_Category_Scope Scope WHERE View1.AccountId = ##{0}## AND View1.AuthorizationObjectId = Scope.AuthorizationObjectId AND View1.AuthorizationObjectType = Scope.AuthorizationObjectType AND AuthorityId = ##00000000-0000-0000-0000-000000000002##)) ) AND Status = 1 ORDER BY OrderId ", KernelContext.Current.User.Id); } IList <ComboboxItem> list = this.service.GetComboboxByWhereClause(whereClause, selectedValue); if (!string.IsNullOrEmpty(emptyItemText)) { list.Insert(0, new ComboboxItem("全部", string.Empty)); } outString.Append("{\"data\":" + FormatCombobox(list) + ","); outString.Append("\"combobox\":\"" + combobox + "\","); outString.Append(MessageObject.Stringify("0", I18n.Strings["msg_query_success"], true) + "}"); return(outString.ToString()); }
/// <summary>会话设置</summary> /// <returns></returns> public ActionResult Sessions() { // 所属应用信息 ApplicationInfo application = ViewBag.application = AppsContext.Instance.ApplicationService[APPLICATION_NAME]; // ------------------------------------------------------- // 身份验证 // ------------------------------------------------------- if (!AppsSecurity.IsAdministrator(KernelContext.Current.User, application.ApplicationName)) { ApplicationError.Write(401); } // ------------------------------------------------------- // 刷新缓存数据 // ------------------------------------------------------- string reset = Request.QueryString["reset"]; if (reset == "1") { KernelContext.Current.AuthenticationManagement.ResetSessions(); } string removeKey = Request.QueryString["removeKey"]; if (!string.IsNullOrEmpty(removeKey)) { KernelContext.Current.AuthenticationManagement.RemoveSession(removeKey); Response.Redirect("/sys/sessions"); Response.End(); } // ------------------------------------------------------- // 加载数据 // ------------------------------------------------------- StringBuilder outString = new StringBuilder(); IDictionary <string, IAccountInfo> dictionary = ViewBag.dictionary = KernelContext.Current.AuthenticationManagement.GetSessions(); return(View("/views/main/sys/sessions.cshtml")); }
public void TestIsAdministrator() { bool result = false; Mock <IAccountInfo> administorMock = this.factory.CreateMock <IAccountInfo>(); //产生一个mock对象 administorMock.Expects.Between(0, 5).GetProperty(m => m.Id, "00000000-0000-0000-0000-000000001001"); administorMock.Expects.Between(0, 5).GetProperty(m => m.LoginName, "admin"); administorMock.Expects.Between(0, 5).GetProperty(m => m.Name, "超级管理员(模拟)"); Mock <IAccountInfo> memberMock = this.factory.CreateMock <IAccountInfo>(); memberMock.Expects.Between(0, 5).GetProperty(m => m.Id, "00000000-0000-0000-0000-000000001000"); memberMock.Expects.Between(0, 5).GetProperty(m => m.LoginName, "guest"); memberMock.Expects.Between(0, 5).GetProperty(m => m.Name, "guest(模拟)"); // // 测试会议管理 // // accountService = new AccountService(mockCurrencyService); //用mock对象初始化accountService // // 模拟mossadmin帐号 // administrator = new TestAccountInfo("00000000-0000-0000-0000-000000001001", "mossadmin", "mossadmin(模拟)"); // member = new TestAccountInfo("00000000-0000-0000-0000-000000001000", "mossguest", "mossguest(模拟)"); IAccountInfo administrator = administorMock.MockObject; IAccountInfo member = memberMock.MockObject; Assert.AreEqual(administrator.Id, "00000000-0000-0000-0000-000000001001"); Assert.AreEqual(administrator.LoginName, "admin"); Assert.AreEqual(administrator.Id, "00000000-0000-0000-0000-000000001001"); Assert.AreEqual(administrator.LoginName, "admin"); ApplicationInfo application = AppsContext.Instance.ApplicationService.FindOne(ConfigurationManager.AppSettings["appKey"]); result = AppsSecurity.IsAdministrator(administrator, application.ApplicationName); Assert.IsTrue(result); result = AppsSecurity.IsAdministrator(member, application.ApplicationName); Assert.IsFalse(result); }
/// <summary>验证码发送日志</summary> /// <returns></returns> public ActionResult VerificationCodeHistory() { // 所属应用信息 ApplicationInfo application = ViewBag.application = AppsContext.Instance.ApplicationService[APPLICATION_NAME]; // ------------------------------------------------------- // 身份验证 // ------------------------------------------------------- if (!AppsSecurity.IsAdministrator(KernelContext.Current.User, application.ApplicationName)) { ApplicationError.Write(401); } // ------------------------------------------------------- // 加载数据 // ------------------------------------------------------- return(View("/views/main/sys/verification-code-history.cshtml")); }
// ------------------------------------------------------- // 权限设置 // ------------------------------------------------------- #region 函数:HasAuthorizationReadObject(BugInfo param) /// <summary>验证对象的权限</summary> /// <param name="param">需验证的对象</param> /// <returns>对象</returns> private bool HasAuthority(BugInfo param) { IAccountInfo account = KernelContext.Current.User; if (AppsSecurity.IsAdministrator(account, "Bug") || param.AccountId == account.Id || param.AssignToAccountId == account.Id) { return(true); } else { if (MembershipAuthorizationScopeManagement.Authenticate(param.AuthorizationReadScopeObjects, account)) { return(true); } return(false); } }
/// <summary>详细内容界面</summary> /// <param name="options"></param> /// <returns></returns> public ActionResult Overview(string options) { JsonData request = JsonMapper.ToObject(options == null ? "{}" : options); string applicationName = JsonHelper.GetDataValue(request, "applicationName", ConnectConfiguration.ApplicationName); // 所属应用信息 ApplicationInfo application = ViewBag.application = AppsContext.Instance.ApplicationService[applicationName]; // 管理员身份标记 bool isAdminToken = ViewBag.isAdminToken = AppsSecurity.IsAdministrator(this.Account, application.ApplicationName); // 实体数据标识 string id = !request.Keys.Contains("id") ? string.Empty : request["id"].ToString(); ConnectInfo param = null; if (!string.IsNullOrEmpty(id)) { param = ConnectContext.Instance.ConnectService.FindOne(id); } if (param == null) { ApplicationError.Write(404); } // ------------------------------------------------------- // 数据加载 // ------------------------------------------------------- ViewBag.Title = string.Format("{0}-{1}-{2}", param.Name, application.ApplicationDisplayName, this.SystemName); // 加载当前业务实体数据 ViewBag.entityClassName = KernelContext.ParseObjectType(param.GetType()); // 加载当前业务实体数据 ViewBag.param = param; return(View("/views/main/connect/connect-overview.cshtml")); }
/// <summary>提交界面</summary> /// <returns></returns> public ActionResult Form(string options) { // 所属应用信息 ApplicationInfo application = ViewBag.application = AppsContext.Instance.ApplicationService[ForumConfiguration.ApplicationName]; // ------------------------------------------------------- // 身份验证 // ------------------------------------------------------- if (!AppsSecurity.IsAdministrator(KernelContext.Current.User, application.ApplicationName)) { ApplicationError.Write(401); } JsonData request = JsonMapper.ToObject(options == null ? "{}" : options); string id = !request.Keys.Contains("id") ? string.Empty : request["id"].ToString(); ForumCategoryInfo param = null; if (string.IsNullOrEmpty(id)) { IAccountInfo account = KernelContext.Current.User; param = new ForumCategoryInfo(); param.Id = DigitalNumberContext.Generate("Key_Guid"); param.AccountId = account.Id; param.CreatedDate = param.ModifiedDate = DateTime.Now; } else { param = ForumContext.Instance.ForumCategoryService.FindOne(id); } ViewBag.param = param; return(View("/views/main/forum/forum-category-form.cshtml")); }
/// <summary>主页</summary> /// <returns></returns> public ActionResult List(string options) { // 所属应用信息 ApplicationInfo application = ViewBag.application = AppsContext.Instance.ApplicationService[APPLICATION_NAME]; // ------------------------------------------------------- // 身份验证 // ------------------------------------------------------- if (!AppsSecurity.IsAdministrator(KernelContext.Current.User, application.ApplicationName)) { ApplicationError.Write(401); } JsonData request = JsonMapper.ToObject(options); string treeViewId = !request.Keys.Contains("treeViewId") ? string.Empty : request["treeViewId"].ToString(); ViewBag.tree = MembershipManagement.Instance.CatalogService.FindOne(treeViewId); // 角色 return(View("/views/main/membership/catalog-item-list.cshtml")); }
// ------------------------------------------------------- // 权限 // ------------------------------------------------------- #region 私有函数:BindAuthorizationScopeSQL(string whereClause) /// <summary>绑定SQL查询条件</summary> /// <param name="whereClause">WHERE 查询条件</param> /// <returns></returns> private string BindAuthorizationScopeSQL(string whereClause) { // 验证管理员身份 if (!AppsSecurity.IsAdministrator(KernelContext.Current.User, ForumConfiguration.ApplicationName)) { IAccountInfo account = KernelContext.Current.User; // string tableName = ForumUtility.ToDataTablePrefix(applicationTag) + "_Category_Scope"; string tableName = "tb_Forum_Category_Scope"; string scope = MembershipManagement.Instance.AuthorizationObjectService.GetAuthorizationScopeEntitySQL( tableName, account.Id, ContactType.Default, "00000000-0000-0000-0000-000000000003,00000000-0000-0000-0000-000000000001"); scope = @"( AccountId = ##" + account.Id + "## OR T.CategoryId IN ( " + scope + " ) ) "; if (whereClause.IndexOf(scope) == -1) { whereClause = string.IsNullOrEmpty(whereClause) ? scope : scope + " AND " + whereClause; } } return(whereClause); }
/// <summary></summary> /// <param name="account"></param> /// <param name="menuName"></param> /// <returns></returns> public string ParseMenu(IAccountInfo account, string menuName) { return(ParseMenu(account, menuName, AppsSecurity.IsAdministrator(account, menuName))); }