Esempio n. 1
0
 /// <summary>
 /// 生成一个隐藏的Input,并根据权限Id把值设置为相对应的Action链接地址
 /// <para>
 /// 基本原型:&lt;input type="hidden" id="{ TagId }" value="[ 权限所对应的Action ]" /&gt;
 /// </para>
 /// </summary>
 /// <param name="tagParams">必须参数:TagId</param>
 /// <returns></returns>
 public static MvcHtmlString TagHiddenActionUrl(
     this HtmlHelper helper,
     TagParams tagParams
     )
 {
     if (tagParams.VerifyPermission())
     {
         Permission permission = AuthorizationManager.GetInstance().GetPermission(tagParams.PermissionId);
         Object     attrs      = new { value = permission.Action, type = "hidden" };
         return(HtmlBuilder(TagType.input, tagParams.TagId, attrs, null, null));
     }
     return(null);
 }
Esempio n. 2
0
 /// <summary>
 /// 基本原型:&lt;a href="[ 权限所对应的菜单链接 ]"&gt;[ 权限所对应的菜单名称 | { InnerHtml } ]&lt;/a&gt;
 /// </summary>
 /// <param name="tagparams">可选参数:TagId/Attributes/ClassName/InnerHtml</param>
 /// <returns>a标签</returns>
 public static MvcHtmlString TagMenuLink(
     this HtmlHelper helper,
     TagParams tagParams
     )
 {
     if (tagParams.VerifyPermission())
     {
         Permission permission = AuthorizationManager.GetInstance().GetPermission(tagParams.PermissionId);
         var        attrs      = new RouteValueDictionary(tagParams.Attributes);
         attrs.Add("href", permission.Menu.Url + tagParams.Params);
         return(HtmlBuilder(TagType.a, tagParams.TagId, attrs, tagParams.ClassName, string.IsNullOrWhiteSpace(tagParams.InnerHtml) ? permission.Menu.Name : tagParams.InnerHtml));
     }
     return(null);
 }
Esempio n. 3
0
 /// <summary>
 /// 生成一个模板链接,然后使用$("#tagId").html().replace("[params]", "参数列表").replace("[text]", "显示文本")生成可替换的链接;
 /// </summary>
 /// <param name="tagParams">必须值:TagId,可选值:Attributes</param>
 /// <returns></returns>
 public static MvcHtmlString TagPlaceholderLink(
     this HtmlHelper helper,
     TagParams tagParams
     )
 {
     if (tagParams.VerifyPermission())
     {
         Permission permission = AuthorizationManager.GetInstance().GetPermission(tagParams.PermissionId);
         var        attrs      = new RouteValueDictionary(tagParams.Attributes);
         attrs.Add("href", permission.Action + "[params]");
         string innerHtml = HtmlBuilder(TagType.a, null, attrs, string.Empty, "[text]").ToHtmlString();
         return(HtmlBuilder(TagType.div, tagParams.TagId, new { style = "display: none;" }, null, innerHtml));
     }
     return(null);
 }
Esempio n. 4
0
 /// <summary>
 /// 判断用户是否具有指定权限,当不具体该权限时,则把用className作为标识的标签元素所包含Html内容清空,
 /// 否则,将生成一个隐藏的Input,并根据权限Id把值设置为相对应的Action链接地址
 /// 注:建议把生成的内容包含在指定标签元素内部
 /// </summary>
 /// <param name="tagParams">必须参数:TagId/ClassName</param>
 /// <returns></returns>
 public static MvcHtmlString TagProtectArea(
     this HtmlHelper helper,
     TagParams tagParams
     )
 {
     if (tagParams.VerifyPermission())
     {
         Permission permission = AuthorizationManager.GetInstance().GetPermission(tagParams.PermissionId);
         return(HtmlBuilder(TagType.input, tagParams.TagId, new { value = permission.Action, type = "hidden" }, null, null));
     }
     else
     {
         string script = "$(function() { $('." + tagParams.ClassName + "').html('');});";
         return(HtmlBuilder(TagType.script, null, new { type = "text/javascript" }, null, script));
     }
 }
Esempio n. 5
0
 /// <summary>
 /// <para> 基本原型:&lt;a id="{ TagId }" actionUrl="[ 权限所对应的Action ]" href="javascript:{ Script }"&gt;"</para>
 /// <para> [ 权限名称 | { InnerHtml } ] &lt;/a&gt;</para>
 /// </summary>
 /// <param name="helper"></param>
 /// <param name="tagParams">必须参数:TagId/Script,可选参数:Attributes/ClassName/InnerHtml</param>
 /// <returns>a标签</returns>
 public static MvcHtmlString TagScriptLink(
     this HtmlHelper helper,
     TagParams tagParams
     )
 {
     if (tagParams.VerifyPermission())
     {
         Permission permission = AuthorizationManager.GetInstance().GetPermission(tagParams.PermissionId);
         var        attrs      = new RouteValueDictionary(tagParams.Attributes)
         {
             { "actionUrl", permission.ActionUrl },
             { "href", "javascript:" + tagParams.Script }
         };
         return(HtmlBuilder(TagType.a, tagParams.TagId, attrs, tagParams.ClassName, string.IsNullOrWhiteSpace(tagParams.InnerHtml) ? permission.Name : tagParams.InnerHtml));
     }
     return(null);
 }