/// <summary> /// 初始化添加/编辑表单 /// </summary> public void Initialize() { btnAdd.Visible = false; btnEdit.Visible = false; btnDel.Visible = false; try { ZhuJi.Portal.IDAL.IPlugin plugin = ZhuJi.AOP.Operator.WrapInterface(typeof(ZhuJi.Portal.NHibernateDAL.Plugin)) as ZhuJi.Portal.IDAL.IPlugin; IList <ZhuJi.Portal.Domain.Plugin> list = plugin.TreeNodes(); Parent.Items.Clear(); foreach (ZhuJi.Portal.Domain.Plugin domainPlugin in list) { Parent.Items.Add(new ListItem(domainPlugin.Title.PadLeft(domainPlugin.Title.Length + domainPlugin.Depth, SYMBOLS), domainPlugin.Id.ToString())); } Parent.Items.Insert(0, new ListItem("根目录", "0")); } catch (Exception ex) { ShowMessage(ex); } switch (_command) { case "ADD": Add(); break; case "EDIT": Edit(); break; } }
private void PopulateNodes2(TreeNodeCollection nodes, int parent) { ZhuJi.Portal.IDAL.IPlugin plugin = ZhuJi.AOP.Operator.WrapInterface(typeof(ZhuJi.Portal.NHibernateDAL.Plugin)) as ZhuJi.Portal.IDAL.IPlugin; IList <ZhuJi.Portal.Domain.Plugin> list = plugin.GetObjects(); ZhuJi.Portal.Domain.PluginCollection plugins = new ZhuJi.Portal.Domain.PluginCollection(); DataTable dt = plugins.CreateDateTable(list); DataRow[] drs = dt.Select(string.Format("[Parent] = {0}", parent)); if (drs.Length == 0) { return; } else { foreach (DataRow dr in drs) { TreeNode tn = new TreeNode(); tn.Text = dr["Title"].ToString(); tn.Value = dr["Id"].ToString(); if (dt.Select(string.Format("[Parent] = {0}", tn.Value)).Length > 0) { tn.PopulateOnDemand = true; } tn.NavigateUrl = string.Format("AddIn.aspx?PluginId={0}", dr["Id"]); nodes.Add(tn); } } }
private void ShowControl(int id) { ZhuJi.Portal.IDAL.IPlugin plugin = ZhuJi.AOP.Operator.WrapInterface(typeof(ZhuJi.Portal.NHibernateDAL.Plugin)) as ZhuJi.Portal.IDAL.IPlugin; ZhuJi.Portal.Domain.Plugin domainPlugin = plugin.GetObject(id); if (domainPlugin != null) { string configPath = HttpContext.Current.Server.MapPath(domainPlugin.Configure); ZhuJi.Plugins.IAddIn addin = new ZhuJi.Plugins.AddIn(); addin.Init(configPath); Control control = addin.GetControl(domainPlugin.Keyword); phContent.Controls.Add(control); } }
/// <summary> /// 点击删除按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnDel_Click(object sender, EventArgs e) { try { ZhuJi.Portal.Domain.Plugin domainPlugin = new ZhuJi.Portal.Domain.Plugin(); domainPlugin.Id = int.Parse(Id.Text); ZhuJi.Portal.IDAL.IPlugin plugin = ZhuJi.AOP.Operator.WrapInterface(typeof(ZhuJi.Portal.NHibernateDAL.Plugin)) as ZhuJi.Portal.IDAL.IPlugin; plugin.Delete(domainPlugin); } catch (Exception ex) { ShowMessage(ex); } Response.Redirect(Request.Url.ToString(), true); }
/// <summary> /// 点击编辑按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnEdit_Click(object sender, EventArgs e) { if (Page.IsValid) { try { ZhuJi.Portal.Domain.Plugin domainPlugin = new ZhuJi.Portal.Domain.Plugin(); UIMapping.BindControlsToObject(domainPlugin, this); ZhuJi.Portal.IDAL.IPlugin plugin = ZhuJi.AOP.Operator.WrapInterface(typeof(ZhuJi.Portal.NHibernateDAL.Plugin)) as ZhuJi.Portal.IDAL.IPlugin; plugin.Update(int.Parse(rblCurrentNode.SelectedValue), domainPlugin); } catch (Exception ex) { ShowMessage(ex); } } }
/// <summary> /// 初始化编辑表单 /// </summary> private void Edit() { btnAdd.Visible = true; btnAdd.Text = "另存为新记录"; btnEdit.Visible = true; btnDel.Visible = true; try { ZhuJi.Portal.IDAL.IPlugin plugin = ZhuJi.AOP.Operator.WrapInterface(typeof(ZhuJi.Portal.NHibernateDAL.Plugin)) as ZhuJi.Portal.IDAL.IPlugin; ZhuJi.Portal.Domain.Plugin domainPlugin = plugin.GetObject(_identity); UIMapping.BindObjectToControls(domainPlugin, this); if (domainPlugin.IsSystem) { btnEdit.Enabled = false; btnDel.Enabled = false; } } catch (Exception ex) { ShowMessage(ex); } }
private void PopulateNodes(TreeNodeCollection nodes, int parent) { try { ZhuJi.Portal.IDAL.IPlugin plugin = ZhuJi.AOP.Operator.WrapInterface(typeof(ZhuJi.Portal.NHibernateDAL.Plugin)) as ZhuJi.Portal.IDAL.IPlugin; IList <ZhuJi.Portal.Domain.Plugin> list = plugin.GetObjects(); ZhuJi.Portal.Domain.PluginCollection plugins = new ZhuJi.Portal.Domain.PluginCollection(); DataTable dt = plugins.CreateDateTable(list); DataRow[] drs = dt.Select(string.Format("[Parent] = {0}", parent)); if (drs.Length == 0) { return; } else { foreach (DataRow dr in drs) { TreeNode tn = new TreeNode(); tn.Text = string.Format("{0}({1})", dr["Title"].ToString(), dr["Id"].ToString()); tn.Value = dr["Id"].ToString(); if (dt.Select(string.Format("[Parent] = {0}", tn.Value)).Length > 0) { tn.PopulateOnDemand = true; } tn.SelectAction = TreeNodeSelectAction.Expand; nodes.Add(tn); } } } catch (Exception ex) { ShowMessage(ex); } }