diff --git a/CodeSmith/EF/CSharp/Entity.cst b/CodeSmith/CSharp/Entity.cst
similarity index 100%
rename from CodeSmith/EF/CSharp/Entity.cst
rename to CodeSmith/CSharp/Entity.cst
diff --git a/CodeSmith/EF/CSharp/Internal/Context.Generated.cst b/CodeSmith/CSharp/Internal/Context.Generated.cst
similarity index 100%
rename from CodeSmith/EF/CSharp/Internal/Context.Generated.cst
rename to CodeSmith/CSharp/Internal/Context.Generated.cst
diff --git a/CodeSmith/EF/CSharp/Internal/Entity.Generated.cst b/CodeSmith/CSharp/Internal/Entity.Generated.cst
similarity index 97%
rename from CodeSmith/EF/CSharp/Internal/Entity.Generated.cst
rename to CodeSmith/CSharp/Internal/Entity.Generated.cst
index 632d50d9..d387ffed 100644
--- a/CodeSmith/EF/CSharp/Internal/Entity.Generated.cst
+++ b/CodeSmith/CSharp/Internal/Entity.Generated.cst
@@ -1,72 +1,72 @@
-<%@ Template Language="C#" TargetLanguage="C#" Debug="True" Encoding="UTF-8" %>
-
-<%@ Assembly Src="Model.cs" %>
-<%@ Assembly Src="Extensions.cs" %>
-
-<%@ Import Namespace="System.Collections.Generic" %>
-<%@ Import Namespace="System.Linq" %>
-<%@ Import Namespace="System.Text" %>
-<%@ Import Namespace="System.Text.RegularExpressions" %>
-
-<%@ Import Namespace="SchemaMapper" %>
-
-<%@ Property Name="Entity"
- Type="SchemaMapper.Entity" %>
-
-<%@ Property Name="EntityNamespace"
- Type="System.String" %>
-//------------------------------------------------------------------------------
-//
-// This code was generated by a CodeSmith Template.
-//
-// DO NOT MODIFY contents of this file. Changes to this
-// file will be lost if the code is regenerated.
-// Author:Yubao Li
-//
-//------------------------------------------------------------------------------
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace <%= EntityNamespace %>
-{
- ///
- /// <%= Entity.Description %>
- ///
- public partial class <%= Entity.ClassName.ToSafeName() %> : Entity
- {
- public <%= Entity.ClassName.ToSafeName() %>()
- {
-<% foreach(var p in Entity.Properties) {
- if(p.IsPrimaryKey ==true) continue;
- string type = p.SystemType.ToNullableType(p.IsNullable == true);
- if(type =="int" || type=="decimal")
- Response.WriteLine(" this."+p.PropertyName.ToSafeName()+"= 0;");
- else if(type =="string")
- Response.WriteLine(" this."+p.PropertyName.ToSafeName()+"= string.Empty;");
- else if(type.ToLower().Contains("datetime"))
- Response.WriteLine(" this."+p.PropertyName.ToSafeName()+"= DateTime.Now;");
- } // foreach %>
-<% foreach(var r in Entity.Relationships.Where(e => e.ThisCardinality == Cardinality.Many)) { %>
- <%= r.ThisPropertyName.ToSafeName() %> = new List<<%= r.OtherEntity.ToSafeName() %>>();
-<% } // foreach %>
- }
-
-<% foreach(var p in Entity.Properties) {
- if(p.IsPrimaryKey ==true) continue;
- %>
- ///
- /// <%=p.Description %>
- ///
- public <%= p.SystemType.ToNullableType(p.IsNullable == true) %> <%= p.PropertyName.ToSafeName() %> { get; set; }
-<% } // foreach %>
-
-<% foreach(var r in Entity.Relationships) { %>
-<% if(r.ThisCardinality == Cardinality.Many) { %>
- public virtual ICollection<<%= r.OtherEntity.ToSafeName() %>> <%= r.ThisPropertyName.ToSafeName() %> { get; set; }
-<% } else { %>
- public virtual <%= r.OtherEntity.ToSafeName() %> <%= r.ThisPropertyName.ToSafeName() %> { get; set; }
-<% } %>
-<% } // foreach %>
- }
+<%@ Template Language="C#" TargetLanguage="C#" Debug="True" Encoding="UTF-8" %>
+
+<%@ Assembly Src="Model.cs" %>
+<%@ Assembly Src="Extensions.cs" %>
+
+<%@ Import Namespace="System.Collections.Generic" %>
+<%@ Import Namespace="System.Linq" %>
+<%@ Import Namespace="System.Text" %>
+<%@ Import Namespace="System.Text.RegularExpressions" %>
+
+<%@ Import Namespace="SchemaMapper" %>
+
+<%@ Property Name="Entity"
+ Type="SchemaMapper.Entity" %>
+
+<%@ Property Name="EntityNamespace"
+ Type="System.String" %>
+//------------------------------------------------------------------------------
+//
+// This code was generated by a CodeSmith Template.
+//
+// DO NOT MODIFY contents of this file. Changes to this
+// file will be lost if the code is regenerated.
+// Author:Yubao Li
+//
+//------------------------------------------------------------------------------
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace <%= EntityNamespace %>
+{
+ ///
+ /// <%= Entity.Description %>
+ ///
+ public partial class <%= Entity.ClassName.ToSafeName() %> : Entity
+ {
+ public <%= Entity.ClassName.ToSafeName() %>()
+ {
+<% foreach(var p in Entity.Properties) {
+ if(p.IsPrimaryKey ==true) continue;
+ string type = p.SystemType.ToNullableType(p.IsNullable == true);
+ if(type =="int" || type=="decimal")
+ Response.WriteLine(" this."+p.PropertyName.ToSafeName()+"= 0;");
+ else if(type =="string")
+ Response.WriteLine(" this."+p.PropertyName.ToSafeName()+"= string.Empty;");
+ else if(type.ToLower().Contains("datetime"))
+ Response.WriteLine(" this."+p.PropertyName.ToSafeName()+"= DateTime.Now;");
+ } // foreach %>
+<% foreach(var r in Entity.Relationships.Where(e => e.ThisCardinality == Cardinality.Many)) { %>
+ <%= r.ThisPropertyName.ToSafeName() %> = new List<<%= r.OtherEntity.ToSafeName() %>>();
+<% } // foreach %>
+ }
+
+<% foreach(var p in Entity.Properties) {
+ if(p.IsPrimaryKey ==true) continue;
+ %>
+ ///
+ /// <%=p.Description %>
+ ///
+ public <%= p.SystemType.ToNullableType(p.IsNullable == true) %> <%= p.PropertyName.ToSafeName() %> { get; set; }
+<% } // foreach %>
+
+<% foreach(var r in Entity.Relationships) { %>
+<% if(r.ThisCardinality == Cardinality.Many) { %>
+ public virtual ICollection<<%= r.OtherEntity.ToSafeName() %>> <%= r.ThisPropertyName.ToSafeName() %> { get; set; }
+<% } else { %>
+ public virtual <%= r.OtherEntity.ToSafeName() %> <%= r.ThisPropertyName.ToSafeName() %> { get; set; }
+<% } %>
+<% } // foreach %>
+ }
}
\ No newline at end of file
diff --git a/CodeSmith/EF/CSharp/Internal/Extensions.cs b/CodeSmith/CSharp/Internal/Extensions.cs
similarity index 100%
rename from CodeSmith/EF/CSharp/Internal/Extensions.cs
rename to CodeSmith/CSharp/Internal/Extensions.cs
diff --git a/CodeSmith/EF/CSharp/Internal/Generator.cs b/CodeSmith/CSharp/Internal/Generator.cs
similarity index 100%
rename from CodeSmith/EF/CSharp/Internal/Generator.cs
rename to CodeSmith/CSharp/Internal/Generator.cs
diff --git a/CodeSmith/EF/CSharp/Internal/Mapping.Generated.cst b/CodeSmith/CSharp/Internal/Mapping.Generated.cst
similarity index 100%
rename from CodeSmith/EF/CSharp/Internal/Mapping.Generated.cst
rename to CodeSmith/CSharp/Internal/Mapping.Generated.cst
diff --git a/CodeSmith/EF/CSharp/Internal/Model.cs b/CodeSmith/CSharp/Internal/Model.cs
similarity index 100%
rename from CodeSmith/EF/CSharp/Internal/Model.cs
rename to CodeSmith/CSharp/Internal/Model.cs
diff --git a/CodeSmith/EF/CSharp/Internal/Parser.cs b/CodeSmith/CSharp/Internal/Parser.cs
similarity index 100%
rename from CodeSmith/EF/CSharp/Internal/Parser.cs
rename to CodeSmith/CSharp/Internal/Parser.cs
diff --git a/CodeSmith/Application.cst b/CodeSmith/CSharp/Web/Application.cst
similarity index 100%
rename from CodeSmith/Application.cst
rename to CodeSmith/CSharp/Web/Application.cst
diff --git a/CodeSmith/Controller.cst b/CodeSmith/CSharp/Web/Controller.cst
similarity index 100%
rename from CodeSmith/Controller.cst
rename to CodeSmith/CSharp/Web/Controller.cst
diff --git a/CodeSmith/Index.cshtml.cst b/CodeSmith/CSharp/Web/Index.cshtml.1.cst
similarity index 98%
rename from CodeSmith/Index.cshtml.cst
rename to CodeSmith/CSharp/Web/Index.cshtml.1.cst
index a5b3c345..d2a7c4c2 100644
--- a/CodeSmith/Index.cshtml.cst
+++ b/CodeSmith/CSharp/Web/Index.cshtml.1.cst
@@ -100,4 +100,6 @@ Description="连接的数据库" %>
-
\ No newline at end of file
+
+
+
diff --git a/CodeSmith/EF/CSharp/Web/Index.cshtml.cst b/CodeSmith/CSharp/Web/Index.cshtml.cst
similarity index 100%
rename from CodeSmith/EF/CSharp/Web/Index.cshtml.cst
rename to CodeSmith/CSharp/Web/Index.cshtml.cst
diff --git a/CodeSmith/EF/CSharp/Web/Util.cs b/CodeSmith/CSharp/Web/Util.cs
similarity index 100%
rename from CodeSmith/EF/CSharp/Web/Util.cs
rename to CodeSmith/CSharp/Web/Util.cs
diff --git a/CodeSmith/EF/CSharp/WebGenerate.cst b/CodeSmith/CSharp/WebGenerate.cst
similarity index 100%
rename from CodeSmith/EF/CSharp/WebGenerate.cst
rename to CodeSmith/CSharp/WebGenerate.cst
diff --git a/CodeSmith/EF/Common/ICSharpCode.NRefactory.CSharp.dll b/CodeSmith/Common/ICSharpCode.NRefactory.CSharp.dll
similarity index 100%
rename from CodeSmith/EF/Common/ICSharpCode.NRefactory.CSharp.dll
rename to CodeSmith/Common/ICSharpCode.NRefactory.CSharp.dll
diff --git a/CodeSmith/EF/Common/ICSharpCode.NRefactory.dll b/CodeSmith/Common/ICSharpCode.NRefactory.dll
similarity index 100%
rename from CodeSmith/EF/Common/ICSharpCode.NRefactory.dll
rename to CodeSmith/Common/ICSharpCode.NRefactory.dll
diff --git a/CodeSmith/EF/Common/Mono.Cecil.dll b/CodeSmith/Common/Mono.Cecil.dll
similarity index 100%
rename from CodeSmith/EF/Common/Mono.Cecil.dll
rename to CodeSmith/Common/Mono.Cecil.dll
diff --git a/CodeSmith/EF/CSharp/Web/Application.cst b/CodeSmith/EF/CSharp/Web/Application.cst
deleted file mode 100644
index 8425cd7b..00000000
--- a/CodeSmith/EF/CSharp/Web/Application.cst
+++ /dev/null
@@ -1,138 +0,0 @@
-<%--
-Name: Database Table Properties
-Author: yubaolee
-Description: Create a list of properties from a database table
---%>
-<%@ CodeTemplate Language="C#" Encoding="utf-8" TargetLanguage="C#" Debug="False" Description="应用层" %>
-<%@ Property Name="ModuleName" Type="String" Category="Context" Description="模块名称" %>
-<%@ Property Name="NeedViewModel" Type="Boolean" Category="Context" Default="False" Description="是否需要ViewModel" %>
-<%@ Map Name="CSharpAlias" Src="System-CSharpAlias" Description="System to C# Type Map" %>
-<%@ Assembly Name="SchemaExplorer" %>
-<%@ Import Namespace="SchemaExplorer" %>
-
-
-<%if(NeedViewModel){ %>
-using OpenAuth.App.ViewModel;
-<%} %>
-using OpenAuth.Domain;
-using OpenAuth.Domain.Interface;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-
-namespace OpenAuth.App
-{
- public class <%=ModuleName%>ManagerApp
- {
- private I<%=ModuleName%>Repository _repository;
- private IOrgRepository _orgRepository;
-
- public <%=ModuleName%>ManagerApp(I<%=ModuleName%>Repository repository,
- IOrgRepository orgRepository)
- {
- _repository = repository;
- _orgRepository = orgRepository;
- }
-
- public int Get<%=GetModelName()%>CntInOrg(int orgId)
- {
- if (orgId == 0)
- {
- return _repository.Find(null).Count();
- }
- else
- {
- return _repository.Get<%=GetModelName()%>CntInOrgs(GetSubOrgIds(orgId));
- }
- }
-
- public List<<%=GetModelName()%>> LoadAll()
- {
- return _repository.Find(null).ToList();
- }
-
- ///
- /// 加载一个节点下面的一个或全部<%=GetModelName()%>s
- ///
- public dynamic Load(int orgId, int pageindex, int pagesize)
- {
- IEnumerable<<%=ModuleName%>> <%=ModuleName%>s;
- int total = 0;
- if (orgId == 0)
- {
- <%=ModuleName%>s = _repository.Load<%=ModuleName%>s(pageindex, pagesize);
- total = _repository.GetCount();
- }
- else
- {
- <%=ModuleName%>s = _repository.LoadInOrgs(pageindex, pagesize,GetSubOrgIds(orgId));
- total = _repository.Get<%=ModuleName%>CntInOrgs(orgId);
- }
- <%if(NeedViewModel){ %>
- var <%=ModuleName%>views = new List<<%=ModuleName%>View>();
- foreach (var <%=ModuleName%> in <%=ModuleName%>s)
- {
- <%=ModuleName%>View uv = <%=ModuleName%>;
- uv.Organizations = string.Join(",", _orgRepository.LoadBy<%=ModuleName%>(<%=ModuleName%>.Id).Select(u => u.Name).ToList());
- <%=ModuleName%>views.Add(uv);
- }
- <%} %>
-
- return new
- {
- total = total,
- list = <%=GetModelName()%>s,
- pageCurrent = pageindex
- };
- }
-
- ///
- /// 获取当前节点的所有下级节点
- ///
- private int[] GetSubOrgIds(int orgId)
- {
- var org = _orgRepository.FindSingle(u => u.Id == orgId);
- var orgs = _orgRepository.Find(u => u.CascadeId.Contains(org.CascadeId)).Select(u => u.Id).ToArray();
- return orgs;
- }
-
- public <%=GetModelName()%> Find(int id)
- {
- var <%=ModuleName.ToLower()%> = _repository.FindSingle(u => u.Id == id);
- if (<%=ModuleName.ToLower()%> == null) return new <%=GetModelName()%>();
-
- return <%=ModuleName.ToLower() %>;
- }
-
- public void Delete(int id)
- {
- _repository.Delete(id);
- }
-
- public void AddOrUpdate(<%=GetModelName()%> model)
- {
- <%=ModuleName%> <%=ModuleName.ToLower()%> = new <%=ModuleName%>();
- model.CopyTo(<%=ModuleName.ToLower()%>);
-
- if (<%=ModuleName.ToLower()%>.Id == 0)
- {
- _repository.Add(<%=ModuleName.ToLower()%>);
- }
- else
- {
- _repository.Update(<%=ModuleName.ToLower()%>);
- }
-
- }
-
-
- }
-}
\ No newline at end of file
diff --git a/CodeSmith/EF/CSharp/Web/Controller.cst b/CodeSmith/EF/CSharp/Web/Controller.cst
deleted file mode 100644
index c4352691..00000000
--- a/CodeSmith/EF/CSharp/Web/Controller.cst
+++ /dev/null
@@ -1,110 +0,0 @@
-<%--
-Name: Database Table Properties
-Author: yubaolee
-Description: Create a list of properties from a database table
---%>
-<%@ CodeTemplate Language="C#" Encoding="utf-8" TargetLanguage="C#" Debug="False" Description="控制器" %>
-<%@ Property Name="ModuleName" Type="String" Category="Context" Description="模块名称" %>
-<%@ Property Name="NeedViewModel" Type="Boolean" Category="Context" Default="False" Description="是否需要ViewModel" %>
-<%@ Map Name="CSharpAlias" Src="System-CSharpAlias" Description="System to C# Type Map" %>
-<%@ Assembly Name="SchemaExplorer" %>
-<%@ Import Namespace="SchemaExplorer" %>
-
-
-using System;
-using System.Web.Mvc;
-using Infrastructure;
-using OpenAuth.App;
-<%if(NeedViewModel){ %>
-using OpenAuth.App.ViewModel;
-<%} %>
-using OpenAuth.Domain;
-
-namespace OpenAuth.Mvc.Controllers
-{
- public class <%=ModuleName%>ManagerController : BaseController
- {
- private <%=ModuleName%>ManagerApp _app;
-
- public <%=ModuleName%>ManagerController()
- {
- _app = AutofacExt.GetFromFac<<%=ModuleName%>ManagerApp>();
- }
-
- //
- // GET: /UserManager/
- public ActionResult Index()
- {
- return View();
- }
-
- public ActionResult Add(int id = 0)
- {
- return View(_app.Find(id));
- }
-
- //添加或修改<%=ModuleName %>
- [HttpPost]
- public string Add(<%=GetModelName()%> model)
- {
- try
- {
- _app.AddOrUpdate(model);
-
- }
- catch (Exception ex)
- {
- BjuiResponse.statusCode = "300";
- BjuiResponse.message = ex.Message;
- }
- return JsonHelper.Instance.Serialize(BjuiResponse);
- }
-
- ///
- /// 加载节点下面的所有<%=ModuleName %>s
- ///
- public string Load(int parentId, int pageCurrent = 1, int pageSize = 30)
- {
- return JsonHelper.Instance.Serialize(_app.Load(parentId, pageCurrent, pageSize));
- }
-
- public string LoadForTree()
- {
- var models = _app.LoadAll();
- //添加根节点
- models.Add(new <%=ModuleName %>
- {
- Id = 0,
- ParentId = -1,
- Name = "根结点",
- CascadeId = "0"
- });
- return JsonHelper.Instance.Serialize(models);
- }
-
- public string Delete(int Id)
- {
- try
- {
- _app.Delete(Id);
- }
- catch (Exception e)
- {
- BjuiResponse.statusCode = "300";
- BjuiResponse.message = e.Message;
- }
-
- return JsonHelper.Instance.Serialize(BjuiResponse);
- }
-
-
- }
-}
\ No newline at end of file
diff --git a/CodeSmith/IRepository.cst b/CodeSmith/IRepository.cst
deleted file mode 100644
index e8f31b2d..00000000
--- a/CodeSmith/IRepository.cst
+++ /dev/null
@@ -1,28 +0,0 @@
-<%--
-Name: Database Table Properties
-Author: yubaolee
-Description: Create a list of properties from a database table
---%>
-<%@ CodeTemplate Language="C#" Encoding="utf-8" TargetLanguage="C#" Debug="False" Description="创建包含组织机构的接口" %>
-<%@ Property Name="ModuleName" Type="String" Category="Context" Description="模块名称" %>
-<%@ Map Name="CSharpAlias" Src="System-CSharpAlias" Description="System to C# Type Map" %>
-<%@ Assembly Name="SchemaExplorer" %>
-<%@ Import Namespace="SchemaExplorer" %>
-
-using System.Collections.Generic;
-using System.Linq;
-
-namespace OpenAuth.Domain.Interface
-{
- public interface I<%=ModuleName%>Repository :IRepository<<%=ModuleName%>>
- {
- IEnumerable<<%=ModuleName%>> Load<%=ModuleName%>s(int pageindex, int pagesize);
-
- IEnumerable<<%=ModuleName%>> LoadInOrgs(params int[] orgId);
- int Get<%=ModuleName%>CntInOrgs(params int[] orgIds);
- IEnumerable<<%=ModuleName%>> LoadInOrgs(int pageindex, int pagesize, params int[] orgIds);
-
- void Delete(int id);
-
- }
-}
\ No newline at end of file
diff --git a/CodeSmith/NoCascadeIndex.cshtml.cst b/CodeSmith/NoCascadeIndex.cshtml.cst
deleted file mode 100644
index 96627b47..00000000
--- a/CodeSmith/NoCascadeIndex.cshtml.cst
+++ /dev/null
@@ -1,112 +0,0 @@
-<%--
-Name: Database Table Properties
-Author: yubaolee
-Description: 没有树状导航的datagrid
---%>
-<%@ CodeTemplate Language="C#" Encoding="utf-8" TargetLanguage="C#" Debug="True" Description="Create a list of properties from database table." %>
-<%@ Property Name="SourceTable" Type="SchemaExplorer.TableSchema" Category="Context" Description="Table that the object is based on." %>
-<%@ Property Name="ModuleName" Type="String" Category="Context" Description="模块名称" %>
-<%@ Map Name="CSharpAlias" Src="System-CSharpAlias" Description="System to C# Type Map" %>
-<%@ Assembly Name="SchemaExplorer" %>
-<%@ Import Namespace="SchemaExplorer" %>
-
-@{
- string _prefix = "<%=ModuleName%>";
- var _treeId = _prefix + "Tree";
- var _gridId = _prefix + "Grid";
- var _treeDetail = _prefix + "Detail";
-}
-
-@{ Html.RenderAction("MenuHeader", "Home");}
-
-
-
-
diff --git a/CodeSmith/Repository.cst b/CodeSmith/Repository.cst
deleted file mode 100644
index aeb7ccb9..00000000
--- a/CodeSmith/Repository.cst
+++ /dev/null
@@ -1,49 +0,0 @@
-<%--
-Name: 数据访问
-Author: yubaolee
-Description:
---%>
-<%@ CodeTemplate Language="C#" Encoding="utf-8" TargetLanguage="C#" Debug="False" Description="数据访问" %>
-<%@ Property Name="ModuleName" Type="String" Category="Context" Description="模块名称" %>
-<%@ Map Name="CSharpAlias" Src="System-CSharpAlias" Description="System to C# Type Map" %>
-<%@ Assembly Name="SchemaExplorer" %>
-<%@ Import Namespace="SchemaExplorer" %>
-using System.Collections.Generic;
-using System.Linq;
-using OpenAuth.Domain;
-using OpenAuth.Domain.Interface;
-
-namespace OpenAuth.Repository
-{
- public class <%=ModuleName%>Repository :BaseRepository<<%=ModuleName%>>, I<%=ModuleName%>Repository
- {
-
- public IEnumerable<<%=ModuleName%>> Load<%=ModuleName%>s(int pageindex, int pagesize)
- {
- return Context.<%=ModuleName%>s.OrderBy(u => u.Id).Skip((pageindex - 1) * pagesize).Take(pagesize);
- }
-
- public IEnumerable<<%=ModuleName%>> LoadInOrgs(params int[] orgId)
- {
- var result = from <%=ModuleName.ToLower()%> in Context.<%=ModuleName%>s where orgId.Contains(<%=ModuleName.ToLower()%>.Id)
- select <%=ModuleName.ToLower()%>;
- return result;
-
- }
-
- public int Get<%=ModuleName%>CntInOrgs(params int[] orgIds)
- {
- return LoadInOrgs(orgIds).Count();
- }
-
- public IEnumerable<<%=ModuleName%>> LoadInOrgs(int pageindex, int pagesize, params int[] orgIds)
- {
- return LoadInOrgs(orgIds).OrderBy(u =>u.Id).Skip((pageindex -1)*pagesize).Take(pagesize);
- }
-
- public void Delete(int id)
- {
- Delete(u =>u.Id == id);
- }
- }
-}
diff --git a/CodeSmith/Util.cs b/CodeSmith/Util.cs
deleted file mode 100644
index 0ebb0882..00000000
--- a/CodeSmith/Util.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.IO;
-using System.Linq;
-using System.Text;
-using CodeSmith.Engine;
-using SchemaExplorer;
-
-namespace Util{
- public class Tools{
- public static String GetDescription(ColumnSchema column) { //得到字段的描述
- if(string.IsNullOrEmpty(column.Description))
- return column.Name;
- else
- return column.Description;
- }
-
- public static bool NeedCascade(TableSchema SourceTable){ //判断表中是否需要下拉选择树
- return SourceTable.Columns.Contains("ParentId")
- || SourceTable.Columns.Contains("CascadeId") ;
- }
- }
-}
\ No newline at end of file
diff --git a/CodeSmith/editDlg.js.cst b/CodeSmith/editDlg.js.cst
deleted file mode 100644
index 03a58515..00000000
--- a/CodeSmith/editDlg.js.cst
+++ /dev/null
@@ -1,251 +0,0 @@
-<%--
-Name: 编辑修改JS
-Author: yubaolee
-Description: 编辑修改JS
---%>
-<%@ CodeTemplate Language="C#" TargetLanguage="C#" Debug="False" Encoding="utf-8" Description="添加模块" %>
-<%@ Property Name="SourceTable" Type="SchemaExplorer.TableSchema" Category="Context"
-Description="连接的数据库" %>
-<%@ Property Name="ModuleName" Type="String" Category="Context" Description="模块名称" %>
-<%@ Map Name="CSharpAlias" Src="System-CSharpAlias" Description="System to C# Type Map" %>
-<%@ Assembly Name="SchemaExplorer" %>
-<%@ Import Namespace="SchemaExplorer" %>
-<%@ Assembly Src="Util.cs" %>
-<%@ Import Namespace="Util" %>
-
-
-//grid列表模块
-function MainGrid() {
- var url = '/<%=ModuleName%>/Load?parentId=';
- var selectedId = 0; //ztree选中的模块
- this.maingrid = $('#maingrid').datagrid({
- showToolbar: false,
- filterThead: false,
- target: $(this),
- columns: [
- <% foreach (ColumnSchema column in this.SourceTable.Columns) { %>
- {
- name: '<%=column.Name%>',
- label: '<%=Tools.GetDescription(column)%>',
- width: 100
- <%if(column.IsPrimaryKeyMember){ %>
- , hide: true
- <%} %>
- <%else if(CSharpAlias[column.SystemType.FullName] == "bool") {%>
- ,align: 'center',
- items: [{ 'false': '否' }, { 'true': '是' }],
- <%} %>
- <%else if(CSharpAlias[column.SystemType.FullName] == "int") {%>
- , align: 'center',
- items: [{ '0': '默认' }, { '1': '状态1' }],
- <%} %>
- },
- <% } %>
- ],
- dataUrl: url + selectedId,
- fullGrid: true,
- showLinenumber: true,
- showCheckboxcol: true,
- paging: true,
- filterMult: false,
- showTfoot: false,
- height: '100%'
- });
- this.reload = function (id) {
- if (id != undefined) selectedId = id;
- this.maingrid.datagrid('reload', { dataUrl: url+ selectedId });
- };
-};
-MainGrid.prototype = new Grid();
-var list = new MainGrid();
-
-//左边分类导航树
-var ztree = function () {
- var url = '/<%=ModuleName%>/LoadForTree';
- var setting = {
- view: { selectedMulti: false },
- data: {
- key: {
- name: 'Name',
- title: 'Name'
- },
- simpleData: {
- enable: true,
- idKey: 'Id',
- pIdKey: 'ParentId',
- rootPId: 'null'
- }
- },
- callback: { onClick: zTreeOnClick }
- };
- $.getJSON(url, function (json) {
- $.fn.zTree.init($("#tree"), setting, json).expandAll(true);
- });
- function zTreeOnClick(event, treeId, treeNode) {
- list.reload(treeNode.Id);
- }
-
- return {
- reload:function() {
- $.getJSON(url, function (json) {
- $.fn.zTree.init($("#tree"), setting, json).expandAll(true);
- });
- }
- }
-}();
-
-<%if(Tools.NeedCascade(SourceTable)){ %>
-//编辑时,选择上级弹出的树
-var parentTree = function () {
- var nameDom = "#ParentName";
- var idDom = "#ParentId";
- var zTreeObj;
- var setting = {
- view: {
- selectedMulti: false
- },
- check: {
- enable: true,
- chkStyle: "radio", //单选
- radioType: "all"
- },
- data: {
- key: {
- name: 'Name',
- title: 'Name'
- },
- simpleData: {
- enable: true,
- idKey: 'Id',
- pIdKey: 'ParentId',
- rootPId: 'null'
- }
- },
- callback: {
- onClick: zTreeOnClick,
- onCheck: zTreeCheck
- }
- };
-
- function zTreeCheck(event, treeId, treeNode) {
- var nodes = zTreeObj.getCheckedNodes(true);
- var ids = nodes.map(function (e) { return e.Id; }).join(",");
- var names = nodes.map(function (e) { return e.Name; }).join(",");
-
- $(nameDom).val(names);
- $(idDom).val(ids);
- }
- function zTreeOnClick(event, treeId, treeNode) {
- zTreeObj.checkNode(treeNode, !treeNode.checked, true, true);
- event.preventDefault();
- }
-
- return {
- show:function() {
- $.getJSON('/<%=ModuleName%>/LoadForTree', function (json) {
- zTreeObj = $.fn.zTree.init($('#j_select_tree1'), setting, json);
- var orgstr = $(idDom).val();
- var name = '';
- if (orgstr != '') {
- var nodeIds = orgstr.split(',');
- $.each(nodeIds, function () {
- var node = zTreeObj.getNodeByParam("Id", this, null);
- name += ',' + node.Name;
- zTreeObj.checkNode(node, true, true);
- });
- $(nameDom).val(name.substr(1)); //显示名称
- }
- zTreeObj.expandAll(true);
- });
- }
- };
-}();
-<%} %>
-
-//添加(编辑)对话框
-var editDlg = function () {
- var update = false;
- var show = function () {
- BJUI.dialog({ id: 'editDlg', title: '编辑对话框', target: '#editDlg' });
- $("#btnSave").on("click", function() {
- editDlg.save();
- });
- }
- return {
- add: function () { //弹出添加
- update = false;
- show();
- $.CurrentDialog.find("form")[0].reset(); //reset方法只能通过dom调用
- $("#Id").val(0);
-
- <%if(Tools.NeedCascade(SourceTable)){
- Response.WriteLine("parentTree.show();");
- }%>
- },
- update: function (ret) { //弹出编辑框
- update = true;
- show();
- <% foreach (ColumnSchema column in this.SourceTable.Columns) { %>
- <%if(column.IsPrimaryKeyMember){%>
- $('#<%=column.Name%>').val(ret.<%=column.Name%>);
- <%}else if(CSharpAlias[column.SystemType.FullName] == "bool") {%>
- $('#<%=column.Name%>').selectpicker('val', ret.<%=column.Name%>?"true":"false");
- <%}else if(CSharpAlias[column.SystemType.FullName] == "int") {%>
- $('#<%=column.Name%>').selectpicker('val', ret.<%=column.Name%>);
- <%} else{ %>
- $('#<%=column.Name%>').val(ret.<%=column.Name%>);
- <%} %>
- <% } %>
- <%if(Tools.NeedCascade(SourceTable)){
- Response.WriteLine("parentTree.show();");
- }%>
- },
- save: function() { //编辑-->保存
- $('#editForm').isValid(function (v) {
- if (!v) return; //验证没通过
- $("#editForm").bjuiajax('ajaxForm', {
- reload: false,
- callback:function(json) {
- list.reload();
- ztree.reload();
- }
- });
- });
- }
- };
-}();
-
-//删除
-function del() {
- var selected = list.getSelectedObj();
- if (selected == null) return;
-
- $.getJSON('/<%=ModuleName%>/Delete?Id=' + selected.Id, function (data) {
- if (data.statusCode == "200") {
- list.reload();
- ztree.reload();
- }
- else {
- $(this).alertmsg('warn', data.message);
- }
- });
-}
-
-//自定义的编辑按钮
-function edit() {
- var selected = list.getSelectedObj();
- if (selected == null) {
- return;
- }
- editDlg.update(selected);
-}
-
-function add() {
- editDlg.add();
-}
-
-function refresh() {
- list.reload();
-}
-
-//@@ sourceURL=<%=ModuleName%>.js
\ No newline at end of file