コード例 #1
0
    /// <summary>
    /// 权限分配时,生成每个资源对应的权限
    /// </summary>
    public static MvcHtmlString DistributeOptions(this HtmlHelper helper, int moduleId)
    {
        //string label = "<form class=\"js-form-permission\" name=\"setPermission\"><input type=\"checkbox\" class=\"js-checkall-permission\" style=\"margin-top:-2px\" data-toggle=\"tooltip\" data-placement=\"top\" data-original-title=\"全选\" /><label class=\"inline mr40 pl20\">{0}</label>";
        string label    = "<form class=\"js-form-permission\" name=\"setPermission\"><input type=\"checkbox\" class=\"js-checkall-permission\" style=\"margin-top:-2px\" title=\"全选\" /><label class=\"inline mr40 pl20\">{0}</label>";
        string checkbox = "<input type=\"checkbox\" name=\"{0}-{1}\" style=\"margin:-2px 8px 0 8px\" />{2}";

        StringBuilder          opBuilder     = new StringBuilder();
        ModuleService          moduleService = new ModuleService();
        IEnumerable <T_Module> modules       = moduleService.GetEntities(m => m.ParentId == moduleId);

        string[]         operations       = null;
        int              actionId         = 0;
        T_Operation      operation        = null;
        OperationService operationService = new OperationService();

        foreach (T_Module module in modules)
        {
            if (!string.IsNullOrWhiteSpace(module.Operations))
            {
                opBuilder.AppendFormat(label, module.Name);
                operations = module.Operations.Split(',');
                foreach (string op in operations)
                {
                    actionId  = Convert.ToInt32(op);
                    operation = operationService.GetEntity(o => o.Id == actionId);
                    opBuilder.AppendFormat(checkbox, module.Id, operation.Id, operation.Name);
                }

                opBuilder.Append("</form><p></p>");
            }
        }

        return(MvcHtmlString.Create(opBuilder.ToString()));
    }
コード例 #2
0
    /// <summary>
    /// 权限分配时,生成每个资源对应的权限
    /// </summary>
    public static MvcHtmlString DistributeOptions(this HtmlHelper helper, int moduleId)
    {
        //string label = "<form class=\"js-form-permission\" name=\"setPermission\"><input type=\"checkbox\" class=\"js-checkall-permission\" style=\"margin-top:-2px\" data-toggle=\"tooltip\" data-placement=\"top\" data-original-title=\"全选\" /><label class=\"inline mr40 pl20\">{0}</label>";
        string label = "<form class=\"js-form-permission\" name=\"setPermission\"><input type=\"checkbox\" class=\"js-checkall-permission\" style=\"margin-top:-2px\" title=\"全选\" /><label class=\"inline mr40 pl20\">{0}</label>";
        string checkbox = "<input type=\"checkbox\" name=\"{0}-{1}\" style=\"margin:-2px 8px 0 8px\" />{2}";

        StringBuilder opBuilder = new StringBuilder();
        ModuleService moduleService = new ModuleService();
        IEnumerable<T_Module> modules = moduleService.GetEntities(m => m.ParentId == moduleId);

        string[] operations = null;
        int actionId = 0;
        T_Operation operation = null;
        OperationService operationService = new OperationService();
        foreach (T_Module module in modules)
        {
            if (!string.IsNullOrWhiteSpace(module.Operations))
            {
                opBuilder.AppendFormat(label, module.Name);
                operations = module.Operations.Split(',');
                foreach (string op in operations)
                {
                    actionId = Convert.ToInt32(op);
                    operation = operationService.GetEntity(o => o.Id == actionId);
                    opBuilder.AppendFormat(checkbox, module.Id, operation.Id, operation.Name);
                }

                opBuilder.Append("</form><p></p>");
            }
        }

        return MvcHtmlString.Create(opBuilder.ToString());
    }