public override void Process(TagHelperContext context, TagHelperOutput output) { output.TagName = ""; output.Content.Clear(); string content = _multiLangService.GetOrAndMultiLangValue(MultiLanguageOriginEnum.MultiLangTag, LangKey, DefaultContent); output.Content.Append(content); }
public override void Process(TagHelperContext context, TagHelperOutput output) { if (MultiPlaceholder.IsPresent()) { string id = output.Attributes["id"].Value?.ToString() ?? (output.Attributes["name"].Value?.ToString() ?? ""); string langkey = _rbacService.GetCurrentMenu().Fid + "_" + id; string placeholder = _multiLangService.GetOrAndMultiLangValue(MultiLanguageOriginEnum.MultiLangTag, langkey, MultiPlaceholder); output.Attributes.Add("data-placeholder", placeholder); } base.Process(context, output); }
public string GetMenuButtonAuthority(string roleUid, FapMenuButton menuButton) { bool isAdministrator = _applicationContext.IsAdministrator; var menu = GetCurrentMenu(); //注册多语 string multilangKey = $"{menu?.Fid}_{menuButton.ButtonID}"; menuButton.Description = _multiLangService.GetOrAndMultiLangValue(MultiLanguageOriginEnum.ButtonTag, multilangKey, menuButton.Description); if (menu != null) { if (_platformDomain.MenuButtonSet.TryGetValue(menu.Fid, out IEnumerable <FapMenuButton> list)) { if (list.Any() && list.ToList().Exists(m => m.ButtonID == menuButton.ButtonID)) { //检查授权 if (!isAdministrator && _platformDomain.RoleButtonSet.TryGetValue(roleUid, out IEnumerable <FapRoleButton> roleButtons)) { return(roleButtons.FirstOrDefault(b => b.ButtonId == menuButton.ButtonID)?.ButtonValue); } } else { //注册按钮 menuButton.MenuUid = menu.Fid; _dbContext.Insert(menuButton); _platformDomain.MenuButtonSet.Refresh(); } } else { //注册按钮 menuButton.MenuUid = menu.Fid; _dbContext.Insert(menuButton); _platformDomain.MenuButtonSet.Refresh(); } if (isAdministrator) { if (menuButton.ButtonType == FapMenuButtonType.Grid) { return(string.Join(',', typeof(OperEnum).EnumItems().Select(c => c.Key))); } else if (menuButton.ButtonType == FapMenuButtonType.Tree) { return("2,4,8,16");//增删改刷 } else { return("1"); } } } return(string.Empty); }
public static string Description(this Enum value, IMultiLangService multiLangService = null) { FieldInfo field = value.GetType().GetField(value.ToString()); DescriptionAttribute attribute = Attribute.GetCustomAttribute(field, typeof(DescriptionAttribute)) as DescriptionAttribute; string desc = attribute == null?value.ToString() : attribute.Description; if (multiLangService != null) { desc = multiLangService.GetOrAndMultiLangValue(MultiLanguageOriginEnum.Enum, $"enum_{value.ToString()}", desc); } return(desc); }
public override void Process(TagHelperContext context, TagHelperOutput output) { if (MultiPlaceholder.IsPresent()) { string id = output.Attributes["id"].Value?.ToString() ?? (output.Attributes["name"].Value?.ToString() ?? ""); string langkey = _rbacService.GetCurrentMenu()?.Fid ?? "" + "_" + id; string placeholder = _multiLangService.GetOrAndMultiLangValue(MultiLanguageOriginEnum.MultiLangTag, langkey, MultiPlaceholder); output.Attributes.Add("placeholder", placeholder); } if (FapChecked && (output.Attributes["type"].Value?.ToString() ?? "").EqualsWithIgnoreCase("checkbox")) { output.Attributes.Add("checked", "checked"); } base.Process(context, output); }
public IEnumerable <TreeDataView> GetModuleTree() { List <TreeDataView> moList = _platformDomain.ModuleSet.Select(t => new TreeDataView { Id = t.Fid.ToString(), Pid = t.Pid, Text = _multiLangService.GetMultiLangValue(MultiLanguageOriginEnum.Module, t.Fid), Icon = (t.Icon.IsMissing() ? "icon-folder green ace-icon fa fa-leaf" : "icon-folder green ace-icon " + t.Icon) }).ToList <TreeDataView>(); List <TreeDataView> tree = new List <TreeDataView>(); TreeDataView treeRoot = new TreeDataView() { Id = "0", Text = _multiLangService.GetOrAndMultiLangValue(MultiLanguageOriginEnum.Page, "page_module_rootname", "系统模块"), State = new NodeState { Opened = true }, Icon = "icon-folder purple ace-icon fa fa-home bigger-160", }; tree.Add(treeRoot); TreeViewHelper.MakeTree(treeRoot.Children, moList, treeRoot.Id); return(tree); }
private ResponseViewModel SaveChange(FormModel formModel) { ResponseViewModel rvm = new ResponseViewModel(); var mainData = formModel.MainData; var childDataList = formModel.ChildDataList; if (formModel.Oper == FormOperEnum.add) { _dbContext.InsertDynamicData(mainData); SaveChildData(mainData, childDataList); return(ResponseViewModelUtils.Sueecss(mainData, _multiLangService.GetOrAndMultiLangValue(MultiLanguageOriginEnum.Page, "insert_success", "创建成功"))); } else if (formModel.Oper == FormOperEnum.edit) { //返回原因 bool rv = _dbContext.UpdateDynamicData(mainData); SaveChildData(mainData, childDataList); rvm.data = mainData; rvm.success = rv; rvm.msg = rv ? _multiLangService.GetOrAndMultiLangValue(MultiLanguageOriginEnum.Page, "update_success", "更新成功") : _multiLangService.GetOrAndMultiLangValue(MultiLanguageOriginEnum.Page, "update_failure", "更新失败,请重试"); return(rvm); } else if (formModel.Oper == FormOperEnum.del) { bool rv = false; if (formModel.LogicDelete) { //删除可能存在批量 rv = _dbContext.DeleteDynamicData(mainData); } else { rv = _dbContext.DeleteNoLogicDynamicData(mainData); } DeleteChildData(mainData); rvm.success = rv; rvm.msg = rv ? _multiLangService.GetOrAndMultiLangValue(MultiLanguageOriginEnum.Page, "delete_success", "删除成功") : _multiLangService.GetOrAndMultiLangValue(MultiLanguageOriginEnum.Page, "delete_failure", "删除失败,请重试"); return(rvm); } else if (formModel.Oper == FormOperEnum.batch_edit) { var ids = formModel.Ids.SplitComma(); foreach (var id in ids) { mainData.SetValue("Id", id); _dbContext.UpdateDynamicData(mainData); } rvm.success = true; rvm.msg = _multiLangService.GetOrAndMultiLangValue(MultiLanguageOriginEnum.Page, "batch_update_success", "批量更新成功!"); return(rvm); } return(ResponseViewModelUtils.Sueecss()); void SaveChildData(FapDynamicObject mainData, IDictionary <string, IEnumerable <FapDynamicObject> > childDataList) { if (childDataList.Any()) { foreach (var item in childDataList) { //获取外键字段 var childColumnList = _dbContext.Columns(item.Key); string foreignKey = childColumnList.First(f => f.RefTable == mainData.TableName).ColName; IList <long> ids = new List <long>(); foreach (var data in item.Value) { if (data.Get("Id").ToString().IsMissing()) { //赋值外键 data.SetValue(foreignKey, mainData.Get("Fid").ToString()); long id = _dbContext.InsertDynamicData(data); ids.Add(id); } else { ids.Add(data.Get("Id").ToLong()); _dbContext.UpdateDynamicData(data); } } if (ids.Count > 0) { //先删除后增加 _dbContext.DeleteExec(item.Key, $"{foreignKey}='{mainData.Get("Fid")}' and Id not in @Ids", new DynamicParameters(new { Ids = ids })); } } } } void DeleteChildData(FapDynamicObject mainData) { string tableName = mainData.TableName; if (tableName.IsMissing()) { return; } //检查子表,删除子表数据 var childtableList = _dbContext.Tables(t => t.MainTable == mainData.TableName); foreach (var childTable in childtableList) { var childColumnList = _dbContext.Columns(childTable.TableName); string foreignKey = childColumnList.First(f => f.RefTable == mainData.TableName).ColName; _dbContext.DeleteExec(childTable.TableName, $"{foreignKey} = @Fid", new DynamicParameters(new { Fid = mainData.Get(FapDbConstants.FAPCOLUMN_FIELD_Fid) })); } } }