📄 desktopmodules.ascx.cs
字号:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using DNNLite.Entites.Modules;
using DNNLite.Comm;
using NHibernate.Expression;
using System.IO;
using Castle.ActiveRecord;
public partial class admin_Portal_ModuleDefinitions_desktopmodules : DNNLite.Entites.Modules.PortalModuleBase
{
protected void Page_Load(object sender, EventArgs e)
{
//Comm.RegActiveSession();
if (!IsPostBack)
{
BindDesktopModules();
BindControls();
}
Page.MaintainScrollPositionOnPostBack = true;
}
private void BindDesktopModules()
{
DesktopModuleInfo[] dskmodule =
DesktopModuleInfo.FindAll(
new Order[]{
new Order("IsAdmin",false),
new Order("DeskTopModuleId",true )
}
);
repDesktopModules.DataSource = dskmodule;
repDesktopModules.DataBind();
}
private void BindControls()
{
dplControls.Items.Clear();
string[] ctl = Directory.GetFiles(Server.MapPath("~/DeskTopModules"), "*.ascx", SearchOption.AllDirectories);
dplControls.Items.Add("<没有选择>");
for (int i = 0; i < ctl.Length; i++)
{
dplControls.Items.Add(ctl[i].Replace(Server.MapPath("~/"), "/").Replace("\\", "/"));
}
}
#region "从控件引入模块"
protected void lnkBtnImportDef_Click(object sender, EventArgs e)
{
MultiView1.ActiveViewIndex = 1;
}
protected void btnImportControl_Click(object sender, EventArgs e)
{
if (dplControls.SelectedIndex == 0)
return;
try
{
string d = dplControls.SelectedItem.Text;
d = d.Split('/')[2];
using (TransactionScope t1 = new TransactionScope(OnDispose.Rollback))
{
DesktopModuleInfo m = new DesktopModuleInfo();
m.FolderName = d;
m.FriendlyName = d;
m.IsAdmin = false;
m.ModuleName = d;
m.Version = "1.00";
if (!m.IsValid())
{
lblerr.Text = m.ValidationErrorMessages[0];
return;
}
m.Create();
ModuleDefinitionInfo md = new ModuleDefinitionInfo();
md.DefaultCacheTime = 3600;
md.DeskTopModule = m;
md.FriendlyName = d;
md.Create();
ModuleControlInfo mdc = new ModuleControlInfo();
mdc.ControlKey = "";
mdc.ControlSrc = "~" + dplControls.SelectedItem.Text;
mdc.ControlTitle = "View" + d;
mdc.ControlType = DNNLite.Security.SecurityAccessLevel.View;
mdc.ModuleDefinition = md;
mdc.ViewOrder = 0;
mdc.Create();
t1.VoteCommit();
}
BindDesktopModules();
dplControls.SelectedIndex = 0;
MultiView1.ActiveViewIndex = 0;
DNNLite.Service.Cache.CacheFactory.CacheService("system").Refresh();
}
catch (Exception ex)
{
lblerr.Text = ex.Message;
}
}
protected void btnBack_Click(object sender, EventArgs e)
{
MultiView1.ActiveViewIndex = 0;
}
#endregion
//*******点击编辑模块按钮**********
protected void repDesktopModules_ItemCommand(object source, RepeaterCommandEventArgs e)
{
try
{
ctlEditModule1.Mode = admin_Portal_ModuleDefinitions_ctlEditModule.modulectlmode.Edit;
ctlEditModule1.DeskTopModuleId = e.CommandArgument.ToString();
ctlEditModule1.BindData();
MultiView1.ActiveViewIndex = 2;
}
catch (Exception ex)
{
ProcessModuleLoadException(ex);
}
}
protected void ctlEditMoudle_Back()
{
Response.Redirect(Comm.NavigateURL(TabModuleInfo.Tab.TabId));
}
protected void ctlEditMoudle_Delete()
{
Response.Redirect(Comm.NavigateURL( TabModuleInfo.Tab.TabId ));
}
protected void linkBtnAddDef_Click(object sender, EventArgs e)
{
ctlEditModule1.Mode = admin_Portal_ModuleDefinitions_ctlEditModule.modulectlmode.Add;
ctlEditModule1.BindData();
MultiView1.ActiveViewIndex = 2;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -