This commit is contained in:
yubaolee
2015-04-15 23:57:36 +08:00
commit 7c42a3fc9f
119 changed files with 18893 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<connectionStrings configSource="DB.config"></connectionStrings>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="mssqllocaldb" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
</configuration>

View File

@@ -0,0 +1,4 @@
<connectionStrings>
<add name="OpenAuthDBContext" connectionString="Data Source=.;Initial Catalog=OpenAuthDB;Persist Security Info=True;User ID=sa;Password=516688;MultipleActiveResultSets=True"
providerName="System.Data.SqlClient" />
</connectionStrings>

View File

@@ -0,0 +1,49 @@
using System.Data.Entity.ModelConfiguration;
using OpenAuth.Domain;
namespace OpenAuth.Infrastructure.Mapping
{
public class ButtonMap : EntityTypeConfiguration<Button>
{
public ButtonMap()
{
// Primary Key
this.HasKey(t => t.ButtonId);
// Properties
this.Property(t => t.ButtonId)
.IsRequired()
.HasMaxLength(50);
this.Property(t => t.FullName)
.HasMaxLength(50);
this.Property(t => t.Img)
.HasMaxLength(50);
this.Property(t => t.Event)
.HasMaxLength(200);
this.Property(t => t.Control_ID)
.HasMaxLength(50);
this.Property(t => t.Category)
.HasMaxLength(50);
this.Property(t => t.Description)
.HasMaxLength(200);
// Table & Column Mappings
this.ToTable("Button");
this.Property(t => t.ButtonId).HasColumnName("ButtonId");
this.Property(t => t.FullName).HasColumnName("FullName");
this.Property(t => t.Img).HasColumnName("Img");
this.Property(t => t.Event).HasColumnName("Event");
this.Property(t => t.Control_ID).HasColumnName("Control_ID");
this.Property(t => t.Category).HasColumnName("Category");
this.Property(t => t.Description).HasColumnName("Description");
this.Property(t => t.Enabled).HasColumnName("Enabled");
this.Property(t => t.SortCode).HasColumnName("SortCode");
}
}
}

View File

@@ -0,0 +1,39 @@
using System.Data.Entity.ModelConfiguration;
using OpenAuth.Domain;
namespace OpenAuth.Infrastructure.Mapping
{
public class DataPermissionMap : EntityTypeConfiguration<DataPermission>
{
public DataPermissionMap()
{
// Primary Key
this.HasKey(t => t.Id);
// Properties
this.Property(t => t.Id)
.IsRequired()
.HasMaxLength(50);
this.Property(t => t.RoleId)
.IsRequired()
.HasMaxLength(50);
this.Property(t => t.ResourceId)
.HasMaxLength(50);
// Table & Column Mappings
this.ToTable("DataPermission");
this.Property(t => t.Id).HasColumnName("Id");
this.Property(t => t.RoleId).HasColumnName("RoleId");
this.Property(t => t.ResourceId).HasColumnName("ResourceId");
this.Property(t => t.ObjectId).HasColumnName("ObjectId");
// Relationships
this.HasRequired(t => t.Role)
.WithMany(t => t.DataPermissions)
.HasForeignKey(d => d.RoleId);
}
}
}

View File

@@ -0,0 +1,51 @@
using System.Data.Entity.ModelConfiguration;
using OpenAuth.Domain;
namespace OpenAuth.Infrastructure.Mapping
{
public class DepartmentMap : EntityTypeConfiguration<Department>
{
public DepartmentMap()
{
// Primary Key
this.HasKey(t => t.DepartmentId);
// Properties
this.Property(t => t.DepartmentId)
.IsRequired()
.HasMaxLength(50);
this.HasMany(d => d.Users)
.WithMany(u => u.Departments)
.Map(
m =>
{
m.MapLeftKey("DepartmentId");
m.MapRightKey("UserId");
m.ToTable("UserDepartment");
});
this.HasMany(d => d.Roles)
.WithRequired(r => r.Department);
this.Property(t => t.ParentId)
.HasMaxLength(50);
this.Property(t => t.FullName)
.HasMaxLength(50);
this.Property(t => t.Description)
.HasMaxLength(50);
// Table & Column Mappings
this.ToTable("Department");
this.Property(t => t.DepartmentId).HasColumnName("DepartmentId");
this.Property(t => t.ParentId).HasColumnName("ParentId");
this.Property(t => t.FullName).HasColumnName("FullName");
this.Property(t => t.Description).HasColumnName("Description");
this.Property(t => t.Enabled).HasColumnName("Enabled");
this.Property(t => t.SortCode).HasColumnName("SortCode");
this.Property(t => t.DeleteMark).HasColumnName("DeleteMark");
}
}
}

View File

@@ -0,0 +1,55 @@
using System.Data.Entity.ModelConfiguration;
using OpenAuth.Domain;
namespace OpenAuth.Infrastructure.Mapping
{
public class MenuMap : EntityTypeConfiguration<Menu>
{
public MenuMap()
{
// Primary Key
this.HasKey(t => t.MenuId);
// Properties
this.Property(t => t.MenuId)
.IsRequired()
.HasMaxLength(50);
this.Property(t => t.ParentId)
.HasMaxLength(50);
this.Property(t => t.FullName)
.HasMaxLength(50);
this.Property(t => t.Description)
.HasMaxLength(200);
this.Property(t => t.Img)
.HasMaxLength(50);
this.Property(t => t.NavigateUrl)
.HasMaxLength(200);
this.Property(t => t.FormName)
.HasMaxLength(200);
this.Property(t => t.Target)
.HasMaxLength(50);
// Table & Column Mappings
this.ToTable("Menu");
this.Property(t => t.MenuId).HasColumnName("MenuId");
this.Property(t => t.ParentId).HasColumnName("ParentId");
this.Property(t => t.FullName).HasColumnName("FullName");
this.Property(t => t.Description).HasColumnName("Description");
this.Property(t => t.Img).HasColumnName("Img");
this.Property(t => t.Category).HasColumnName("Category");
this.Property(t => t.NavigateUrl).HasColumnName("NavigateUrl");
this.Property(t => t.FormName).HasColumnName("FormName");
this.Property(t => t.Target).HasColumnName("Target");
this.Property(t => t.IsUnfold).HasColumnName("IsUnfold");
this.Property(t => t.Enabled).HasColumnName("Enabled");
this.Property(t => t.SortCode).HasColumnName("SortCode");
}
}
}

View File

@@ -0,0 +1,48 @@
using System.Data.Entity.ModelConfiguration;
using OpenAuth.Domain;
namespace OpenAuth.Infrastructure.Mapping
{
public class RoleMap : EntityTypeConfiguration<Role>
{
public RoleMap()
{
// Primary Key
this.HasKey(t => t.RoleId);
// Properties
this.Property(t => t.RoleId)
.IsRequired()
.HasMaxLength(50);
this.Property(t => t.ParentId)
.HasMaxLength(50);
this.Property(t => t.FullName)
.HasMaxLength(50);
this.Property(t => t.Category)
.HasMaxLength(50);
this.Property(t => t.Description)
.HasMaxLength(200);
this.Property(t => t.DepartmentId)
.HasMaxLength(50);
// Table & Column Mappings
this.ToTable("Role");
this.Property(t => t.RoleId).HasColumnName("RoleId");
this.Property(t => t.ParentId).HasColumnName("ParentId");
this.Property(t => t.FullName).HasColumnName("FullName");
this.Property(t => t.Category).HasColumnName("Category");
this.Property(t => t.Description).HasColumnName("Description");
this.Property(t => t.Enabled).HasColumnName("Enabled");
this.Property(t => t.SortCode).HasColumnName("SortCode");
this.Property(t => t.DeleteMark).HasColumnName("DeleteMark");
this.Property(t => t.DepartmentId).HasColumnName("DepartmentId");
}
}
}

View File

@@ -0,0 +1,50 @@
using System.Data.Entity.ModelConfiguration;
using OpenAuth.Domain;
namespace OpenAuth.Infrastructure.Mapping
{
public class RoleMenuButtonMap : EntityTypeConfiguration<RoleMenuButton>
{
public RoleMenuButtonMap()
{
// Primary Key
this.HasKey(t => t.RoleMenuButtonId);
// Properties
this.Property(t => t.RoleMenuButtonId)
.IsRequired()
.HasMaxLength(50);
this.Property(t => t.RoleId)
.IsRequired()
.HasMaxLength(50);
this.Property(t => t.MenuId)
.IsRequired()
.HasMaxLength(50);
this.Property(t => t.ButtonId)
.IsRequired()
.HasMaxLength(50);
// Table & Column Mappings
this.ToTable("RoleMenuButton");
this.Property(t => t.RoleMenuButtonId).HasColumnName("RoleMenuButtonId");
this.Property(t => t.RoleId).HasColumnName("RoleId");
this.Property(t => t.MenuId).HasColumnName("MenuId");
this.Property(t => t.ButtonId).HasColumnName("ButtonId");
// Relationships
this.HasRequired(t => t.Button)
.WithMany(t => t.RoleMenuButtons)
.HasForeignKey(d => d.ButtonId);
this.HasRequired(t => t.Menu)
.WithMany(t => t.RoleMenuButtons)
.HasForeignKey(d => d.MenuId);
this.HasRequired(t => t.Role)
.WithMany(t => t.RoleMenuButtons)
.HasForeignKey(d => d.RoleId);
}
}
}

View File

@@ -0,0 +1,52 @@
using System.Data.Entity.ModelConfiguration;
using OpenAuth.Domain;
namespace OpenAuth.Infrastructure.Mapping
{
public class UserMap : EntityTypeConfiguration<User>
{
public UserMap()
{
// Primary Key
this.HasKey(t => t.UserId);
// Properties
this.Property(t => t.UserId)
.IsRequired()
.HasMaxLength(50);
this.Property(t => t.Account)
.HasMaxLength(50);
this.Property(t => t.Password)
.HasMaxLength(50);
this.Property(t => t.RealName)
.HasMaxLength(50);
this.Property(t => t.RoleId)
.HasMaxLength(50);
this.HasMany(u => u.Departments)
.WithMany(d => d.Users)
.Map(m =>
{
m.MapLeftKey("UserId");
m.MapRightKey("DepartmentId");
m.ToTable("UserDepartment");
});
// Table & Column Mappings
this.ToTable("User");
this.Property(t => t.UserId).HasColumnName("UserId");
this.Property(t => t.Account).HasColumnName("Account");
this.Property(t => t.Password).HasColumnName("Password");
this.Property(t => t.RealName).HasColumnName("RealName");
this.Property(t => t.RoleId).HasColumnName("RoleId");
this.Property(t => t.Enabled).HasColumnName("Enabled");
this.Property(t => t.DeleteMark).HasColumnName("DeleteMark");
}
}
}

View File

@@ -0,0 +1,84 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{ADAE08C0-DE22-41F7-9F94-0E62AE327C25}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>OpenAuth.Infrastructure</RootNamespace>
<AssemblyName>OpenAuth.Infrastructure</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="EntityFramework">
<HintPath>..\packages\EntityFramework.6.1.3\lib\net40\EntityFramework.dll</HintPath>
</Reference>
<Reference Include="EntityFramework.SqlServer">
<HintPath>..\packages\EntityFramework.6.1.3\lib\net40\EntityFramework.SqlServer.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Mapping\ButtonMap.cs" />
<Compile Include="Mapping\DataPermissionMap.cs" />
<Compile Include="Mapping\DepartmentMap.cs" />
<Compile Include="Mapping\MenuMap.cs" />
<Compile Include="Mapping\RoleMap.cs" />
<Compile Include="Mapping\RoleMenuButtonMap.cs" />
<Compile Include="Mapping\UserMap.cs" />
<Compile Include="OpenAuthDBContext.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\OpenAuth.App\OpenAuth.App.csproj">
<Project>{0bbf2d65-fffd-4272-b138-8ea4fb6fec48}</Project>
<Name>OpenAuth.App</Name>
</ProjectReference>
<ProjectReference Include="..\OpenAuth.Domain\OpenAuth.Domain.csproj">
<Project>{6108da8e-92a1-4abe-b9f5-26d64d55ca2c}</Project>
<Name>OpenAuth.Domain</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="DB.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -0,0 +1,38 @@
using System.Data.Entity;
using OpenAuth.Domain;
using OpenAuth.Infrastructure.Mapping;
namespace OpenAuth.Infrastructure
{
public partial class OpenAuthDBContext : DbContext
{
static OpenAuthDBContext()
{
Database.SetInitializer<OpenAuthDBContext>(null);
}
public OpenAuthDBContext()
: base("Name=OpenAuthDBContext")
{
}
public DbSet<Button> Buttons { get; set; }
public DbSet<DataPermission> DataPermissions { get; set; }
public DbSet<Department> Departments { get; set; }
public DbSet<Menu> Menus { get; set; }
public DbSet<Role> Roles { get; set; }
public DbSet<RoleMenuButton> RoleMenuButtons { get; set; }
public DbSet<User> Users { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Configurations.Add(new ButtonMap());
modelBuilder.Configurations.Add(new DataPermissionMap());
modelBuilder.Configurations.Add(new DepartmentMap());
modelBuilder.Configurations.Add(new MenuMap());
modelBuilder.Configurations.Add(new RoleMap());
modelBuilder.Configurations.Add(new RoleMenuButtonMap());
modelBuilder.Configurations.Add(new UserMap());
}
}
}

View File

@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的常规信息通过以下
// 特性集控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("OpenAuth.Infrastructure")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("OpenAuth.Infrastructure")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 使此程序集中的类型
// 对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
// 则将该类型上的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("b387116d-343a-462e-b2ed-b509a6be2c9b")]
// 程序集的版本信息由下面四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
// 方法是按如下所示使用“*”:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="EntityFramework" version="6.1.3" targetFramework="net40" />
</packages>