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 91% rename from CodeSmith/EF/CSharp/Internal/Context.Generated.cst rename to CodeSmith/CSharp/Internal/Context.Generated.cst index e2220fce..df3d3a21 100644 --- a/CodeSmith/EF/CSharp/Internal/Context.Generated.cst +++ b/CodeSmith/CSharp/Internal/Context.Generated.cst @@ -77,14 +77,7 @@ namespace <%= ContextNamespace %> public System.Data.Entity.<%= InterfaceMode ? "I" : "" %>DbSet<<%= p.ClassName.ToSafeName() %>> <%= p.ContextName.ToSafeName() %> { get; set; } <% } // foreach %> - protected override void OnModelCreating(DbModelBuilder modelBuilder) - { -<% foreach(var p in EntityContext.Entities) { %> - modelBuilder.Configurations.Add(new <%= p.MappingName.ToSafeName() %>()); -<% } // foreach %> - - InitializeMapping(modelBuilder); - } + <% if (InterfaceMode) { %> System.Data.Entity.IDbSet IDbContext.Set() 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/CSharp/Web/Index.cshtml.cst b/CodeSmith/CSharp/Web/Index.cshtml.cst new file mode 100644 index 00000000..4705c8e6 --- /dev/null +++ b/CodeSmith/CSharp/Web/Index.cshtml.cst @@ -0,0 +1,105 @@ +<%-- +Name: 列表页面 +Author: yubaolee +Description: 列表页面 +--%> +<%@ 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" %> + +@section header +{ + +} + + +
+
    + + + + + <% foreach (ColumnSchema column in this.SourceTable.Columns) {%> + + <% }%> + + + +
    <%=Tools.GetDescription(column)%>
    +
    + + + + + + + + + diff --git a/CodeSmith/Util.cs b/CodeSmith/CSharp/Web/Util.cs similarity index 100% rename from CodeSmith/Util.cs rename to CodeSmith/CSharp/Web/Util.cs diff --git a/CodeSmith/CSharp/Web/index.js.cst b/CodeSmith/CSharp/Web/index.js.cst new file mode 100644 index 00000000..72e8807a --- /dev/null +++ b/CodeSmith/CSharp/Web/index.js.cst @@ -0,0 +1,166 @@ +<%-- +Name: 主JS界面 +Author: yubaolee +--%> +<%@ CodeTemplate Language="C#" TargetLanguage="C#" Debug="False" Encoding="utf-8" 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" %> + +layui.config({ + base: "/js/" +}).use(['form','vue', 'ztree', 'layer', 'jquery', 'table','droptree','openauth'], function () { + var form = layui.form, + //layer = (parent == undefined || parent.layer === undefined )? layui.layer : parent.layer, + layer = layui.layer, + $ = layui.jquery; + var table = layui.table; + var openauth = layui.openauth; + layui.droptree("/UserSession/GetOrgs", "#Organizations", "#OrganizationIds"); + + //主列表加载,可反复调用进行刷新 + var config= {}; //table的参数,如搜索key,点击tree的id + var mainList = function (options) { + if (options != undefined) { + $.extend(config, options); + } + table.reload('mainList', { + url: '/<%=ModuleName%>Manager/Load', + where: config + }); + } + //左边树状机构列表 + var ztree = function () { + var url = '/UserSession/GetOrgs'; + var zTreeObj; + var setting = { + view: { selectedMulti: false }, + data: { + key: { + name: 'Name', + title: 'Name' + }, + simpleData: { + enable: true, + idKey: 'Id', + pIdKey: 'ParentId', + rootPId: 'null' + } + }, + callback: { + onClick: function (event, treeId, treeNode) { + mainList({ orgId: treeNode.Id }); + } + } + }; + var load = function () { + $.getJSON(url, function (json) { + zTreeObj = $.fn.zTree.init($("#tree"), setting, json); + mainList({ orgId: json[0].Id }); + zTreeObj.expandAll(true); + }); + }; + load(); + return { + reload: load + } + }(); + + //添加(编辑)对话框 + var editDlg = function() { + var vm = new Vue({ + el: "#formEdit" + }); + var update = false; //是否为更新 + var show = function (data) { + var title = update ? "编辑信息" : "添加"; + layer.open({ + title: title, + area: ["500px", "400px"], + type: 1, + content: $('#divEdit'), + success: function() { + vm.$set('$data', data); + }, + end: mainList + }); + var url = "/<%=ModuleName%>Manager/Add"; + if (update) { + url = "/<%=ModuleName%>Manager/Update"; //暂时和添加一个地址 + } + //提交数据 + form.on('submit(formSubmit)', + function(data) { + $.post(url, + data.field, + function(data) { + layer.msg(data.Message); + }, + "json"); + return false; + }); + } + return { + add: function() { //弹出添加 + update = false; + show({ + Id: '' + }); + }, + update: function(data) { //弹出编辑框 + update = true; + show(data); + } + }; + }(); + + //监听表格内部按钮 + table.on('tool(list)', function (obj) { + var data = obj.data; + if (obj.event === 'detail') { //查看 + layer.msg('ID:' + data.Id + ' 的查看操作'); + } + }); + + + //监听页面主按钮操作 + var active = { + btnDel: function () { //批量删除 + var checkStatus = table.checkStatus('mainList') + , data = checkStatus.data; + openauth.del("/<%=ModuleName%>Manager/Delete", + data.map(function (e) { return e.Id; }), + mainList); + } + , btnAdd: function () { //添加 + editDlg.add(); + } + , btnEdit: function () { //编辑 + var checkStatus = table.checkStatus('mainList') + , data = checkStatus.data; + if (data.length != 1) { + layer.msg("请选择编辑的行,且同时只能编辑一行"); + return; + } + editDlg.update(data[0]); + } + + , search: function () { //搜索 + mainList({ key: $('#key').val() }); + } + , btnRefresh: function() { + mainList(); + } + }; + + $('.toolList .layui-btn').on('click', function () { + var type = $(this).data('type'); + active[type] ? active[type].call(this) : ''; + }); + + //监听页面主按钮操作 end +}) \ No newline at end of file diff --git a/CodeSmith/CSharp/WebGenerate.cst b/CodeSmith/CSharp/WebGenerate.cst new file mode 100644 index 00000000..f02fbc9a --- /dev/null +++ b/CodeSmith/CSharp/WebGenerate.cst @@ -0,0 +1,146 @@ +<%@ Template Language="C#" TargetLanguage="Text" Debug="True" OutputType="None" %> + +<%@ Assembly Name="SchemaExplorer" %> +<%@ Assembly Name="CodeSmith.CustomProperties" %> + +<%@ Assembly Name="Mono.Cecil" Path="..\Common" %> +<%@ Assembly Name="ICSharpCode.NRefactory" Path="..\Common" %> +<%@ Assembly Name="ICSharpCode.NRefactory.CSharp" Path="..\Common" %> + +<%@ Assembly Src="Internal\Model.cs" %> +<%@ Assembly Src="Internal\Extensions.cs" %> +<%@ Assembly Src="Internal\Generator.cs" %> +<%@ Assembly Src="Internal\Parser.cs" %> + +<%@ Import Namespace="System.Collections.Generic" %> +<%@ Import Namespace="System.IO" %> +<%@ Import Namespace="System.Linq" %> +<%@ Import Namespace="System.Text" %> +<%@ Import Namespace="System.Text.RegularExpressions" %> + +<%@ Import Namespace="SchemaMapper" %> + +<%@ Property Name="SourceTable" +Type="SchemaExplorer.TableSchema" +Category="Context" +Description="连接的数据库" +OnChanged="OnSourceDatabaseChanged"%> + +<%@ Property Name="ModuleName" + Type="System.String" + Description="模块名称,如:User"%> +<%@ Property Name="directory" + Type="System.String" + Default=".\" + Optional="True" + Description="代码生成路径" + Editor="System.Windows.Forms.Design.FolderNameEditor, System.Design, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" %> + +<%@ Property Name="NeedViewModel" + Type="Boolean" + Default="False" + Optional="True" + Description="是否需要ViewModel" %> + + +<%@ Register Name="ApplicationGenerateClass" + Template="Web\Application.cst" + MergeProperties="False" %> +<%@ Register Name="HtmlGenerateClass" + Template="Web\Index.cshtml.cst" + MergeProperties="False" %> +<%@ Register Name="JSGenerateClass" + Template="Web\index.js.cst" + MergeProperties="False" %> +Generating Entities ... +<% Generate(); %> + + \ No newline at end of file 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/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/Index.cshtml.cst b/CodeSmith/Index.cshtml.cst deleted file mode 100644 index a5b3c345..00000000 --- a/CodeSmith/Index.cshtml.cst +++ /dev/null @@ -1,103 +0,0 @@ -<%-- -Name: 列表页面 -Author: yubaolee -Description: 列表页面 ---%> -<%@ 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" %> -@{ - Layout = "~/Views/Shared/_BjuiLayout.cshtml"; -} - -@{ Html.RenderAction("MenuHeader", "Home");} -
    -
    -
    -
      -
      - -
      -
      -
      -
      -
      - - - - - - \ 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/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