/// <summary> /// 生成权限控制的对象json字符串 /// </summary> /// <param name="toolbar">权限控制对象</param> /// <returns></returns> private string GetToolbarSlnJsonString(ToolbarExcel toolbar) { var json = "{"; var t = toolbar.GetType(); var props = t.GetProperties(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public); object val = null; foreach (var prop in props) { if (!prop.Name.StartsWith("Office")) { continue; } val = prop.GetValue(toolbar, null); switch (prop.PropertyType.Name) { case "Boolean": json += "\"" + prop.Name + "\":" + val.ToString().ToLower() + ","; break; case "String": json += "\"" + prop.Name + "\":\"" + (val ?? string.Empty) + "\","; break; default: break; } } return(json.TrimEnd(',') + "}"); }
protected void Page_Load(object sender, EventArgs e) { BP.Sys.ToolbarExcel en = new ToolbarExcel(this.FK_MapData); //this.Pub1.AddH2("编辑Excel表单属性."); //this.Pub1.Add("<a href=\"javascript:WinOpen('/WF/Comm/RefFunc/UIEn.aspx?EnName=BP.Sys.ToolbarExcel&No=" + this.FK_MapData + "')\" >Excel配置项</a>"); //确定模板文件 string moduleFile = getModuleFile(new[] { ".xls", ".xlsx" }); this.Pub1.AddEasyUiPanelInfoBegin("Excel表单属性"); this.Pub1.Add("模版文件(必须是*.xls/*.xlsx文件):"); Literal lit = new Literal(); lit.ID = "litInfo"; if (!string.IsNullOrEmpty(moduleFile)) { lit.Text = "[<span style='color:green'>已上传Excel表单模板:<a href='" + moduleFile + "' target='_blank' title='下载或打开模版'>" + moduleFile + "</a></span>]<br /><br />"; this.Pub1.Add(lit); } else { lit.Text = "[<span style='color:red'>还未上传Excel表单模板</span>]<br /><br />"; this.Pub1.Add(lit); } FileUpload fu = new FileUpload(); fu.ID = "FU"; fu.Width = 300; this.Pub1.Add(fu); this.Pub1.AddSpace(2); LinkBtn btn = new LinkBtn(false, NamesOfBtn.Save, "保存"); btn.Click += new EventHandler(btn_SaveExcelFrm_Click); this.Pub1.Add(btn); this.Pub1.AddSpace(2); this.Pub1.Add( string.Format( "<a href=\"javascript:OpenEasyUiDialog('/WF/Comm/RefFunc/UIEn.aspx?EnName=BP.Sys.ToolbarExcel&No={0}','eudlgframe','Excel配置顶',800,495,'icon-config')\" class=\"easyui-linkbutton\" data-options=\"iconCls:'icon-config'\">Excel配置项</a>", this.FK_MapData)); this.Pub1.AddEasyUiPanelInfoEnd(); }
/// <summary> /// 生成各FK_MapData对应的权限控制json字符串,应用于前端JS控制相应的显示 /// </summary> private void GenerateToolbarSlns() { BP.WF.Template.FrmNode fn = null; ToolbarExcelSln toobarsln = null; ToolbarSlns = "["; foreach (var fk_mapdata in fk_mapdatas) { ToolbarSlns += "{\"" + fk_mapdata + "\":"; if (string.IsNullOrEmpty(this.FK_Flow) == false) { /*接受到了流程编号,就要找到他的控制方案.*/ fn = new BP.WF.Template.FrmNode(this.FK_Flow, this.FK_Node, fk_mapdata); if (fn.FrmSln == 1) { /* 如果是自定义方案.*/ toobarsln = new ToolbarExcelSln(this.FK_Flow, this.FK_Node, fk_mapdata); toolbar.Row = toobarsln.Row; } else { //非自定义方案就取默认方案. toolbar = new ToolbarExcel(fk_mapdata); } } else { /*没有找打他的控制方案,就取默认方案.*/ toolbar = new ToolbarExcel(fk_mapdata); } ToolbarSlns += GetToolbarSlnJsonString(toolbar) + "},"; } ToolbarSlns = ToolbarSlns.TrimEnd(',') + "]"; }