Przeglądaj źródła

加入專案檔案。

Jessica.Tseng 5 lat temu
rodzic
commit
77757ccb0a
41 zmienionych plików z 2772 dodań i 0 usunięć
  1. 25 0
      EVCB_OCPP.Common.sln
  2. 22 0
      EVCB_OCPP.Domain/App.config
  3. 29 0
      EVCB_OCPP.Domain/ConnectionLogContextMigrations/201907150816214_Init.Designer.cs
  4. 32 0
      EVCB_OCPP.Domain/ConnectionLogContextMigrations/201907150816214_Init.cs
  5. 126 0
      EVCB_OCPP.Domain/ConnectionLogContextMigrations/201907150816214_Init.resx
  6. 24 0
      EVCB_OCPP.Domain/ConnectionLogContextMigrations/Configuration.cs
  7. 45 0
      EVCB_OCPP.Domain/ConnectionLogDBContext.cs
  8. 12 0
      EVCB_OCPP.Domain/Doc/ReadMe.txt
  9. 115 0
      EVCB_OCPP.Domain/EVCB_OCPP.Domain.csproj
  10. 103 0
      EVCB_OCPP.Domain/MainDBContext.cs
  11. 29 0
      EVCB_OCPP.Domain/MainDBContextMigrations/201907150818448_Init.Designer.cs
  12. 400 0
      EVCB_OCPP.Domain/MainDBContextMigrations/201907150818448_Init.cs
  13. 120 0
      EVCB_OCPP.Domain/MainDBContextMigrations/201907150818448_Init.resx
  14. 24 0
      EVCB_OCPP.Domain/MainDBContextMigrations/Configuration.cs
  15. 44 0
      EVCB_OCPP.Domain/MeterValueDBContext.cs
  16. 29 0
      EVCB_OCPP.Domain/MeterValueDBContextMigrations/201907150814558_Init.Designer.cs
  17. 35 0
      EVCB_OCPP.Domain/MeterValueDBContextMigrations/201907150814558_Init.cs
  18. 126 0
      EVCB_OCPP.Domain/MeterValueDBContextMigrations/201907150814558_Init.resx
  19. 24 0
      EVCB_OCPP.Domain/MeterValueDBContextMigrations/Configuration.cs
  20. 121 0
      EVCB_OCPP.Domain/Models/Database/ApiLogEntry.cs
  21. 46 0
      EVCB_OCPP.Domain/Models/Database/ConnectorMeterValueRecord.cs
  22. 50 0
      EVCB_OCPP.Domain/Models/Database/ConnectorStatus.cs
  23. 90 0
      EVCB_OCPP.Domain/Models/Database/Customer.cs
  24. 40 0
      EVCB_OCPP.Domain/Models/Database/CustomerMachineComponent.cs
  25. 197 0
      EVCB_OCPP.Domain/Models/Database/Machine.cs
  26. 47 0
      EVCB_OCPP.Domain/Models/Database/MachineComponent.cs
  27. 26 0
      EVCB_OCPP.Domain/Models/Database/MachineConfigure.cs
  28. 54 0
      EVCB_OCPP.Domain/Models/Database/MachineConnectionLog.cs
  29. 69 0
      EVCB_OCPP.Domain/Models/Database/MachineError.cs
  30. 25 0
      EVCB_OCPP.Domain/Models/Database/MachineModel.cs
  31. 72 0
      EVCB_OCPP.Domain/Models/Database/MachineOperateRecord.cs
  32. 29 0
      EVCB_OCPP.Domain/Models/Database/MachinePart.cs
  33. 58 0
      EVCB_OCPP.Domain/Models/Database/MachineVersion.cs
  34. 50 0
      EVCB_OCPP.Domain/Models/Database/MachineVersionFile.cs
  35. 48 0
      EVCB_OCPP.Domain/Models/Database/PublishVersion.cs
  36. 37 0
      EVCB_OCPP.Domain/Models/Database/PublishVersionFile.cs
  37. 62 0
      EVCB_OCPP.Domain/Models/Database/ServerCommand.cs
  38. 155 0
      EVCB_OCPP.Domain/Models/Database/TransactionRecord.cs
  39. 91 0
      EVCB_OCPP.Domain/Models/Database/UploadFile.cs
  40. 36 0
      EVCB_OCPP.Domain/Properties/AssemblyInfo.cs
  41. 5 0
      EVCB_OCPP.Domain/packages.config

+ 25 - 0
EVCB_OCPP.Common.sln

@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 15
+VisualStudioVersion = 15.0.28307.705
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EVCB_OCPP.Domain", "EVCB_OCPP.Domain\EVCB_OCPP.Domain.csproj", "{FAFB8754-9A6E-4931-88EC-376F0326D315}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Any CPU = Debug|Any CPU
+		Release|Any CPU = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{FAFB8754-9A6E-4931-88EC-376F0326D315}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{FAFB8754-9A6E-4931-88EC-376F0326D315}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{FAFB8754-9A6E-4931-88EC-376F0326D315}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{FAFB8754-9A6E-4931-88EC-376F0326D315}.Release|Any CPU.Build.0 = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+	GlobalSection(ExtensibilityGlobals) = postSolution
+		SolutionGuid = {2CB536A6-5724-4838-AC9A-E1BE907C21A3}
+	EndGlobalSection
+EndGlobal

+ 22 - 0
EVCB_OCPP.Domain/App.config

@@ -0,0 +1,22 @@
+<?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>
+  <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>
+  <connectionStrings>
+    <add name="ConnectionLogDBContext" connectionString="data source=172.1.0.142\SQLEXPRESS;initial catalog=OCPP_ConnectionLogDBContext;persist security info=True;user id=sa;password=Ph0930118811;MultipleActiveResultSets=True;App=EntityFramework" providerName="System.Data.SqlClient" />
+    <add name="MainDBContext" connectionString="data source=172.1.0.142\SQLEXPRESS;initial catalog=OCPP_MainDBContext;;persist security info=True;user id=sa;password=Ph0930118811;MultipleActiveResultSets=True;App=EntityFramework" providerName="System.Data.SqlClient" />
+    <add name="MeterValueDBContext" connectionString="data source=172.1.0.142\SQLEXPRESS;initial catalog=OCPP_MeterValueDBContext;;persist security info=True;user id=sa;password=Ph0930118811;MultipleActiveResultSets=True;App=EntityFramework" providerName="System.Data.SqlClient" />
+  </connectionStrings>
+</configuration>

+ 29 - 0
EVCB_OCPP.Domain/ConnectionLogContextMigrations/201907150816214_Init.Designer.cs

@@ -0,0 +1,29 @@
+// <auto-generated />
+namespace EVCB_OCPP.Domain.ConnectionLogContextMigrations
+{
+    using System.CodeDom.Compiler;
+    using System.Data.Entity.Migrations;
+    using System.Data.Entity.Migrations.Infrastructure;
+    using System.Resources;
+    
+    [GeneratedCode("EntityFramework.Migrations", "6.2.0-61023")]
+    public sealed partial class Init : IMigrationMetadata
+    {
+        private readonly ResourceManager Resources = new ResourceManager(typeof(Init));
+        
+        string IMigrationMetadata.Id
+        {
+            get { return "201907150816214_Init"; }
+        }
+        
+        string IMigrationMetadata.Source
+        {
+            get { return null; }
+        }
+        
+        string IMigrationMetadata.Target
+        {
+            get { return Resources.GetString("Target"); }
+        }
+    }
+}

+ 32 - 0
EVCB_OCPP.Domain/ConnectionLogContextMigrations/201907150816214_Init.cs

@@ -0,0 +1,32 @@
+namespace EVCB_OCPP.Domain.ConnectionLogContextMigrations
+{
+    using System;
+    using System.Data.Entity.Migrations;
+    
+    public partial class Init : DbMigration
+    {
+        public override void Up()
+        {
+            CreateTable(
+                "dbo.MachineConnectionLog",
+                c => new
+                    {
+                        Id = c.Long(nullable: false, identity: true),
+                        ChargePointSerialNumber = c.String(maxLength: 25),
+                        IpPort = c.String(maxLength: 30),
+                        ClientIpPort = c.String(maxLength: 30),
+                        MessageType = c.String(maxLength: 50),
+                        Data = c.String(maxLength: 4000),
+                        Msg = c.String(),
+                        CreatedOn = c.DateTime(nullable: false),
+                    })
+                .PrimaryKey(t => t.Id);
+            
+        }
+        
+        public override void Down()
+        {
+            DropTable("dbo.MachineConnectionLog");
+        }
+    }
+}

+ 126 - 0
EVCB_OCPP.Domain/ConnectionLogContextMigrations/201907150816214_Init.resx

@@ -0,0 +1,126 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+  <!-- 
+    Microsoft ResX Schema 
+    
+    Version 2.0
+    
+    The primary goals of this format is to allow a simple XML format 
+    that is mostly human readable. The generation and parsing of the 
+    various data types are done through the TypeConverter classes 
+    associated with the data types.
+    
+    Example:
+    
+    ... ado.net/XML headers & schema ...
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
+    <resheader name="version">2.0</resheader>
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
+    </data>
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+        <comment>This is a comment</comment>
+    </data>
+                
+    There are any number of "resheader" rows that contain simple 
+    name/value pairs.
+    
+    Each data row contains a name, and value. The row also contains a 
+    type or mimetype. Type corresponds to a .NET class that support 
+    text/value conversion through the TypeConverter architecture. 
+    Classes that don't support this are serialized and stored with the 
+    mimetype set.
+    
+    The mimetype is used for serialized objects, and tells the 
+    ResXResourceReader how to depersist the object. This is currently not 
+    extensible. For a given mimetype the value must be set accordingly:
+    
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
+    that the ResXResourceWriter will generate, however the reader can 
+    read any of the formats listed below.
+    
+    mimetype: application/x-microsoft.net.object.binary.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+            : and then encoded with base64 encoding.
+    
+    mimetype: application/x-microsoft.net.object.soap.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+            : and then encoded with base64 encoding.
+
+    mimetype: application/x-microsoft.net.object.bytearray.base64
+    value   : The object must be serialized into a byte array 
+            : using a System.ComponentModel.TypeConverter
+            : and then encoded with base64 encoding.
+    -->
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+    <xsd:element name="root" msdata:IsDataSet="true">
+      <xsd:complexType>
+        <xsd:choice maxOccurs="unbounded">
+          <xsd:element name="metadata">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
+              </xsd:sequence>
+              <xsd:attribute name="name" use="required" type="xsd:string" />
+              <xsd:attribute name="type" type="xsd:string" />
+              <xsd:attribute name="mimetype" type="xsd:string" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="assembly">
+            <xsd:complexType>
+              <xsd:attribute name="alias" type="xsd:string" />
+              <xsd:attribute name="name" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="data">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="resheader">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" />
+            </xsd:complexType>
+          </xsd:element>
+        </xsd:choice>
+      </xsd:complexType>
+    </xsd:element>
+  </xsd:schema>
+  <resheader name="resmimetype">
+    <value>text/microsoft-resx</value>
+  </resheader>
+  <resheader name="version">
+    <value>2.0</value>
+  </resheader>
+  <resheader name="reader">
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <resheader name="writer">
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <data name="Target" xml:space="preserve">
+    <value>H4sIAAAAAAAEAM1Yy27jNhTdF+g/CFq1QMZykknRBvIMEjspjMaxMcpkW9DStUKUIlWSCuxv66Kf1F/opfV+WLECd1B4Y5G85z54eXikf/762/28jZj1ClJRwSf2+WhsW8B9EVAeTuxEbz78bH/+9P137l0Qba3nfN2lWYeWXE3sF63ja8dR/gtERI0i6kuhxEaPfBE5JBDOxXj8i3N+7gBC2IhlWe6XhGsawf4BH6eC+xDrhLCFCICpbBxnvD2q9UgiUDHxYWLfPU9vf19OV6vRTESEctu6YZRgHB6wjW0RzoUmGqO8/qrA01Lw0ItxgLCnXQy4bkOYgiz663L5sYmML0wiTmmYQ/mJ0hjRMMDzy6wyTtP8XfW1i8ph7e6wxnpnst7Xb2IviP9COWC1OfjGx4MIbavp+HrKpDFql3qU7s5oRjRZEwWjLsAzq2l2VvQNtpf5nVnThOlEwoRDoiVhZ9YqWTPq/wa7J/EH8AlPGKvmgtngXG0Ah1ZSxCD17gtssgzngW05dTunaViYVWzSfOdc//TRth7ROVkzKFqlUhtPCwm/AgdJNAQrojVIbjBgX+yW94av6QuRIawE5doDiT35mERrkHkA2K547mxrQbYPwEP9MrEvrmzrnm4hyAeymL5yiqcUbbRM4C2383glpO7xcjk+gZcpo1iFb+NrAUqREIyTHldXp3Blur3Hx8fx+CQJqbDHCf49xQZJMF275LknTA2ekIc7er6K5DollbQJBk+/xlMOMvdSZYPZrZmGre7gGeTnjGpUFn89+hTeA91LX2Vo6RXQSUrd+RSRl/eNk144+cXkHLiZ3AWJY9ykyk2VjVheek1NP3jDGTxKMRxfdRB5EW3hCbkIz0Bj1mxAAPdUKp3ztG1Ng6hjWec+HdiD3GnPVjTpudyZ3Nj8TwHaV8sRiGWV7zHxCMlmXwMogjwusD2Q5xNGZMdVMBUsifih66TP+iC5VyEPLjreT86wtUizsQHR1ti6FmJt5njEGidXAWsTx+OlxFsFSkcGRGRItRaJCgfVqCTMWoHK4TaW6zR6tHksnNa5aAiW5pnrY67mksJ7wWANpnIz1nhbaLdoJF1iW1ikVxoYCvF2SkO014Mj70+WNk65YEE43YDSqaazUe1eNNT6/0c5O0oF7B3y+ZuL1DUNqSnym0q090ofLE35K5E+LmmJ09LNcCXaCWr04TDQLuF5IugOndmJfDUYuSorOyFTYTkw3FJF5pg/RGT74+CKNpVigI/69EqxKVT+QwGYshdmshaYVJrBSaVim1hdp/qdw52BomEJ4ZZuS9B8zZxvRL4nWIBqRPmSVqdqgrtEbqSmG+JrnPaxefdvEs+EJUZ04YEO5nyZ6DjRN0pBtGa1V1bX6fe/18P1mN1lbJ7UKVLAMKlptCW/TSgLirjvOxrtAIRpqYwUMSp8k0K4cFcgPQp+JFBWvhnEwA2lPkEUMwRTS+6RV3hPbPi+8wAh8Xf5/XgY5O2NqJfdnVESShKpDKO0N9/uHPPx7tO/2neygu4TAAA=</value>
+  </data>
+  <data name="DefaultSchema" xml:space="preserve">
+    <value>dbo</value>
+  </data>
+</root>

+ 24 - 0
EVCB_OCPP.Domain/ConnectionLogContextMigrations/Configuration.cs

@@ -0,0 +1,24 @@
+namespace EVCB_OCPP.Domain.ConnectionLogContextMigrations
+{
+    using System;
+    using System.Data.Entity;
+    using System.Data.Entity.Migrations;
+    using System.Linq;
+
+    internal sealed class ConnectionLogConfiguration : DbMigrationsConfiguration<EVCB_OCPP.Domain.ConnectionLogDBContext>
+    {
+        public ConnectionLogConfiguration()
+        {
+            AutomaticMigrationsEnabled = false;
+            MigrationsDirectory = @"ConnectionLogContextMigrations";
+        }
+
+        protected override void Seed(EVCB_OCPP.Domain.ConnectionLogDBContext context)
+        {
+            //  This method will be called after migrating to the latest version.
+
+            //  You can use the DbSet<T>.AddOrUpdate() helper extension method 
+            //  to avoid creating duplicate seed data.
+        }
+    }
+}

+ 45 - 0
EVCB_OCPP.Domain/ConnectionLogDBContext.cs

@@ -0,0 +1,45 @@
+namespace EVCB_OCPP.Domain
+{
+    using EVCB_OCPP.Domain.Models.Database;
+    using System;
+    using System.Data.Entity;
+    using System.Linq;
+
+    public class ConnectionLogDBContext : DbContext
+    {
+        // 您的內容已設定為使用應用程式組態檔 (App.config 或 Web.config)
+        // 中的 'ConnectionLogDBContext' 連接字串。根據預設,這個連接字串的目標是
+        // 您的 LocalDb 執行個體上的 'EVCB_OCPP.Domain.ConnectionLogDBContext' 資料庫。
+        // 
+        // 如果您的目標是其他資料庫和 (或) 提供者,請修改
+        // 應用程式組態檔中的 'ConnectionLogDBContext' 連接字串。
+        public ConnectionLogDBContext()
+            : base("name=ConnectionLogDBContext")
+        {
+           
+            this.Configuration.LazyLoadingEnabled = false;
+            this.Database.CommandTimeout = 180;
+        }
+
+        /// <summary>
+        /// DB coneection set
+        /// </summary>
+        public ConnectionLogDBContext(string conn)
+        {
+            this.Database.Connection.ConnectionString = conn;
+            this.Configuration.LazyLoadingEnabled = false;
+            this.Database.CommandTimeout = 180;
+        }
+
+        // 針對您要包含在模型中的每種實體類型新增 DbSet。如需有關設定和使用
+        // Code First 模型的詳細資訊,請參閱 http://go.microsoft.com/fwlink/?LinkId=390109。
+
+        public virtual DbSet<MachineConnectionLog> MachineConnectionLog { get; set; }
+    }
+
+    //public class MyEntity
+    //{
+    //    public int Id { get; set; }
+    //    public string Name { get; set; }
+    //}
+}

+ 12 - 0
EVCB_OCPP.Domain/Doc/ReadMe.txt

@@ -0,0 +1,12 @@
+專案中有多個資料庫Context
+Enable-Migration 方法 
+Enable-Migrations -ContextTypeName EVCB_OCPP.Domain.MainDBContext -MigrationsDirectory MainDBContextMigrations
+
+解釋:
+-MigrationsDirectory 後面接著的是資料夾名稱 ,創建完畢後裡面會有一個 Configuration.cs,
+打開檔案把ClassName重新命名 MainDBConfiguration,後面 Add-Migrations 的時候就可以使用了
+
+Add-Migrations 方法: Add-Migration XXXX  -ConfigurationTypeName MainDBConfiguration
+
+
+update-database -script  方法 : update-database -ConfigurationTypeName MainDBConfiguration

+ 115 - 0
EVCB_OCPP.Domain/EVCB_OCPP.Domain.csproj

@@ -0,0 +1,115 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" 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>{FAFB8754-9A6E-4931-88EC-376F0326D315}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>EVCB_OCPP.Domain</RootNamespace>
+    <AssemblyName>EVCB_OCPP.Domain</AssemblyName>
+    <TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <Deterministic>true</Deterministic>
+  </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, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
+      <HintPath>..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll</HintPath>
+    </Reference>
+    <Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
+      <HintPath>..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll</HintPath>
+    </Reference>
+    <Reference Include="System" />
+    <Reference Include="System.ComponentModel.DataAnnotations" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Runtime.Serialization" />
+    <Reference Include="System.Security" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Net.Http" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="ConnectionLogContextMigrations\201907150816214_Init.cs" />
+    <Compile Include="ConnectionLogContextMigrations\201907150816214_Init.Designer.cs">
+      <DependentUpon>201907150816214_Init.cs</DependentUpon>
+    </Compile>
+    <Compile Include="ConnectionLogContextMigrations\Configuration.cs" />
+    <Compile Include="ConnectionLogDBContext.cs" />
+    <Compile Include="MainDBContext.cs" />
+    <Compile Include="MainDBContextMigrations\201907150818448_Init.cs" />
+    <Compile Include="MainDBContextMigrations\201907150818448_Init.Designer.cs">
+      <DependentUpon>201907150818448_Init.cs</DependentUpon>
+    </Compile>
+    <Compile Include="MainDBContextMigrations\Configuration.cs" />
+    <Compile Include="MeterValueDBContext.cs" />
+    <Compile Include="MeterValueDBContextMigrations\201907150814558_Init.cs" />
+    <Compile Include="MeterValueDBContextMigrations\201907150814558_Init.Designer.cs">
+      <DependentUpon>201907150814558_Init.cs</DependentUpon>
+    </Compile>
+    <Compile Include="MeterValueDBContextMigrations\Configuration.cs" />
+    <Compile Include="Models\Database\ApiLogEntry.cs" />
+    <Compile Include="Models\Database\ConnectorMeterValueRecord.cs" />
+    <Compile Include="Models\Database\ConnectorStatus.cs" />
+    <Compile Include="Models\Database\Customer.cs" />
+    <Compile Include="Models\Database\CustomerMachineComponent.cs" />
+    <Compile Include="Models\Database\Machine.cs" />
+    <Compile Include="Models\Database\MachineComponent.cs" />
+    <Compile Include="Models\Database\MachineConfigure.cs" />
+    <Compile Include="Models\Database\MachineConnectionLog.cs" />
+    <Compile Include="Models\Database\MachineError.cs" />
+    <Compile Include="Models\Database\MachineModel.cs" />
+    <Compile Include="Models\Database\MachineOperateRecord.cs" />
+    <Compile Include="Models\Database\MachinePart.cs" />
+    <Compile Include="Models\Database\MachineVersion.cs" />
+    <Compile Include="Models\Database\MachineVersionFile.cs" />
+    <Compile Include="Models\Database\PublishVersion.cs" />
+    <Compile Include="Models\Database\PublishVersionFile.cs" />
+    <Compile Include="Models\Database\ServerCommand.cs" />
+    <Compile Include="Models\Database\TransactionRecord.cs" />
+    <Compile Include="Models\Database\UploadFile.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="App.config">
+      <SubType>Designer</SubType>
+    </None>
+    <None Include="packages.config" />
+  </ItemGroup>
+  <ItemGroup>
+    <EmbeddedResource Include="ConnectionLogContextMigrations\201907150816214_Init.resx">
+      <DependentUpon>201907150816214_Init.cs</DependentUpon>
+    </EmbeddedResource>
+    <EmbeddedResource Include="MainDBContextMigrations\201907150818448_Init.resx">
+      <DependentUpon>201907150818448_Init.cs</DependentUpon>
+    </EmbeddedResource>
+    <EmbeddedResource Include="MeterValueDBContextMigrations\201907150814558_Init.resx">
+      <DependentUpon>201907150814558_Init.cs</DependentUpon>
+    </EmbeddedResource>
+  </ItemGroup>
+  <ItemGroup />
+  <ItemGroup>
+    <Content Include="Doc\ReadMe.txt" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+</Project>

+ 103 - 0
EVCB_OCPP.Domain/MainDBContext.cs

@@ -0,0 +1,103 @@
+namespace EVCB_OCPP.Domain
+{
+    using EVCB_OCPP.Domain.Models.Database;
+    using System;
+    using System.Data.Entity;
+    using System.Linq;
+
+    public class MainDBContext : DbContext
+    {
+        // 您的內容已設定為使用應用程式組態檔 (App.config 或 Web.config)
+        // 中的 'MainDBContext' 連接字串。根據預設,這個連接字串的目標是
+        // 您的 LocalDb 執行個體上的 'EVCB_OCPP.Domain.MainDBContext' 資料庫。
+        // 
+        // 如果您的目標是其他資料庫和 (或) 提供者,請修改
+        // 應用程式組態檔中的 'MainDBContext' 連接字串。
+        public MainDBContext()
+            : base("name=MainDBContext")
+        {
+            this.Configuration.LazyLoadingEnabled = false;
+            this.Database.CommandTimeout = 180;
+        }
+
+        /// <summary>
+        /// DB coneection set
+        /// </summary>
+        public MainDBContext(string conn)
+        {
+            this.Database.Connection.ConnectionString = conn;
+            this.Configuration.LazyLoadingEnabled = false;
+            this.Database.CommandTimeout = 180;
+        }
+
+        // 針對您要包含在模型中的每種實體類型新增 DbSet。如需有關設定和使用
+        // Code First 模型的詳細資訊,請參閱 http://go.microsoft.com/fwlink/?LinkId=390109。
+
+        public virtual DbSet<ApiLogEntry> ApiLogEntry { get; set; }
+
+        public virtual DbSet<ConnectorStatus> ConnectorStatus { get; set; }
+
+        public virtual DbSet<Customer> Customer { get; set; }
+
+        public virtual DbSet<CustomerMachineComponent> CustomerMachineComponent { get; set; }
+
+        public virtual DbSet<Machine> Machine { get; set; }
+
+        public virtual DbSet<MachineComponent> MachineComponent { get; set; }
+
+        public virtual DbSet<MachineConfigure> MachineConfigure { get; set; }
+
+        public virtual DbSet<MachineError> MachineError { get; set; }
+
+        public virtual DbSet<MachineModel> MachineModel { get; set; }
+
+        public virtual DbSet<MachineOperateRecord> MachineOperateRecord { get; set; }
+
+        public virtual DbSet<MachineVersion> MachineVersion { get; set; }
+
+        public virtual DbSet<MachinePart> MachinePart { get; set; }
+
+        public virtual DbSet<MachineVersionFile> MachineVersionFile { get; set; }
+
+        public virtual DbSet<PublishVersion> PublishVersion { get; set; }
+
+        public virtual DbSet<PublishVersionFile> PublishVersionFile { get; set; }
+
+        public virtual DbSet<ServerCommand> ServerCommand { get; set; }
+
+        public virtual DbSet<TransactionRecord> TransactionRecord { get; set; }
+
+        public virtual DbSet<UploadFile> UploadFile { get; set; }
+
+        protected override void OnModelCreating(DbModelBuilder modelBuilder)
+        {
+            modelBuilder.Entity<MachineVersion>()
+                .HasRequired(a => a.Machine)
+                .WithMany()
+                .HasForeignKey(a => a.MachineId);
+
+
+            modelBuilder.Entity<Machine>()
+                .HasOptional(m => m.FW_MachineVersion)
+                .WithMany()
+                .HasForeignKey(m => m.FW_AssignedMachineVersionId);
+
+
+            modelBuilder.Entity<PublishVersion>()
+                .HasRequired(a => a.CustomerMachineComponent)
+                .WithMany()
+                .HasForeignKey(a => a.CustomerMachineComponentId)
+                .WillCascadeOnDelete(false);
+
+
+
+
+            base.OnModelCreating(modelBuilder);
+
+        }
+    }
+
+
+
+
+}

+ 29 - 0
EVCB_OCPP.Domain/MainDBContextMigrations/201907150818448_Init.Designer.cs

@@ -0,0 +1,29 @@
+// <auto-generated />
+namespace EVCB_OCPP.Domain.MainDBContextMigrations
+{
+    using System.CodeDom.Compiler;
+    using System.Data.Entity.Migrations;
+    using System.Data.Entity.Migrations.Infrastructure;
+    using System.Resources;
+    
+    [GeneratedCode("EntityFramework.Migrations", "6.2.0-61023")]
+    public sealed partial class Init : IMigrationMetadata
+    {
+        private readonly ResourceManager Resources = new ResourceManager(typeof(Init));
+        
+        string IMigrationMetadata.Id
+        {
+            get { return "201907150818448_Init"; }
+        }
+        
+        string IMigrationMetadata.Source
+        {
+            get { return null; }
+        }
+        
+        string IMigrationMetadata.Target
+        {
+            get { return Resources.GetString("Target"); }
+        }
+    }
+}

+ 400 - 0
EVCB_OCPP.Domain/MainDBContextMigrations/201907150818448_Init.cs

@@ -0,0 +1,400 @@
+namespace EVCB_OCPP.Domain.MainDBContextMigrations
+{
+    using System;
+    using System.Data.Entity.Migrations;
+    
+    public partial class Init : DbMigration
+    {
+        public override void Up()
+        {
+            CreateTable(
+                "dbo.ApiLogEntry",
+                c => new
+                    {
+                        ApiLogEntryId = c.Long(nullable: false, identity: true),
+                        Application = c.String(),
+                        User = c.String(),
+                        Machine = c.String(),
+                        RequestIpAddress = c.String(),
+                        RequestContentType = c.String(),
+                        RequestContentBody = c.String(),
+                        RequestUri = c.String(),
+                        RequestMethod = c.String(),
+                        RequestRouteTemplate = c.String(),
+                        RequestRouteData = c.String(),
+                        RequestHeaders = c.String(),
+                        RequestTimestamp = c.DateTime(),
+                        ResponseContentType = c.String(),
+                        ResponseContentBody = c.String(),
+                        ResponseStatusCode = c.Int(),
+                        ResponseHeaders = c.String(),
+                        ResponseTimestamp = c.DateTime(),
+                        IsOutData = c.Boolean(nullable: false),
+                        ErrorMsg = c.String(),
+                        ErrorOn = c.DateTime(),
+                    })
+                .PrimaryKey(t => t.ApiLogEntryId)
+                .Index(t => t.RequestTimestamp);
+            
+            CreateTable(
+                "dbo.ConnectorStatus",
+                c => new
+                    {
+                        Id = c.String(nullable: false, maxLength: 36),
+                        ChargePointSerialNumber = c.String(maxLength: 25),
+                        ConnectorId = c.Byte(nullable: false),
+                        Status = c.Int(nullable: false),
+                        ChargePointErrorCodeNo = c.Int(nullable: false),
+                        ErrorInfo = c.String(maxLength: 50),
+                        VendorId = c.String(maxLength: 255),
+                        VendorErrorCodeNo = c.Int(nullable: false),
+                        CreatedOn = c.DateTime(nullable: false),
+                    })
+                .PrimaryKey(t => t.Id);
+            
+            CreateTable(
+                "dbo.Customer",
+                c => new
+                    {
+                        Id = c.Guid(nullable: false),
+                        Name = c.String(maxLength: 50),
+                        CreatedOn = c.DateTime(nullable: false),
+                        CreatedBy = c.String(maxLength: 50),
+                        Deadline = c.DateTime(),
+                        UpdatedOn = c.DateTime(),
+                        UpdatedBy = c.String(maxLength: 50),
+                        ApiUrl = c.String(maxLength: 256),
+                        ApiKey = c.String(maxLength: 128),
+                        ApiKeyUpdatedOn = c.DateTime(),
+                        PartnerId = c.String(maxLength: 36),
+                        ApiCustomerId = c.String(maxLength: 36),
+                        CallPartnerApiOnSchedule = c.Boolean(nullable: false),
+                        IsShow = c.Boolean(nullable: false),
+                    })
+                .PrimaryKey(t => t.Id);
+            
+            CreateTable(
+                "dbo.CustomerMachineComponent",
+                c => new
+                    {
+                        Id = c.Int(nullable: false, identity: true),
+                        CustomerId = c.Guid(nullable: false),
+                        MachineComponentId = c.Int(nullable: false),
+                        CreatedOn = c.DateTime(nullable: false),
+                        CreatedBy = c.String(maxLength: 50),
+                    })
+                .PrimaryKey(t => t.Id)
+                .ForeignKey("dbo.Customer", t => t.CustomerId, cascadeDelete: true)
+                .ForeignKey("dbo.MachineComponent", t => t.MachineComponentId, cascadeDelete: true)
+                .Index(t => t.CustomerId)
+                .Index(t => t.MachineComponentId);
+            
+            CreateTable(
+                "dbo.MachineComponent",
+                c => new
+                    {
+                        Id = c.Int(nullable: false, identity: true),
+                        MachineModelId = c.Int(nullable: false),
+                        GunAmt = c.Int(),
+                        MachinePartId = c.Int(nullable: false),
+                        ModelName = c.String(),
+                    })
+                .PrimaryKey(t => t.Id)
+                .ForeignKey("dbo.MachineModel", t => t.MachineModelId, cascadeDelete: true)
+                .ForeignKey("dbo.MachinePart", t => t.MachinePartId, cascadeDelete: true)
+                .Index(t => t.MachineModelId)
+                .Index(t => t.MachinePartId);
+            
+            CreateTable(
+                "dbo.MachineModel",
+                c => new
+                    {
+                        Id = c.Int(nullable: false, identity: true),
+                        Name = c.String(maxLength: 36),
+                    })
+                .PrimaryKey(t => t.Id);
+            
+            CreateTable(
+                "dbo.MachinePart",
+                c => new
+                    {
+                        Id = c.Int(nullable: false),
+                        Desc = c.String(maxLength: 36),
+                    })
+                .PrimaryKey(t => t.Id);
+            
+            CreateTable(
+                "dbo.Machine",
+                c => new
+                    {
+                        Id = c.String(nullable: false, maxLength: 36),
+                        ChargePointSerialNumber = c.String(maxLength: 25),
+                        ChargeBoxSerialNumber = c.String(maxLength: 25),
+                        ChargePointModel = c.String(maxLength: 20),
+                        ChargePointVendor = c.String(maxLength: 20),
+                        Iccid = c.String(maxLength: 20),
+                        Imsi = c.String(maxLength: 20),
+                        MeterType = c.String(maxLength: 25),
+                        MeterSerialNumber = c.String(maxLength: 25),
+                        CreatedOn = c.DateTime(nullable: false),
+                        CreatedBy = c.String(maxLength: 50),
+                        Comment = c.String(maxLength: 100),
+                        CustomerId = c.Guid(nullable: false),
+                        AC = c.Boolean(nullable: false),
+                        GunAmt = c.Int(nullable: false),
+                        HeartbeatUpdatedOn = c.DateTime(),
+                        FW_VersionReport = c.Int(),
+                        FW_AssignedVersion = c.Int(),
+                        FW_AssignedMachineVersionId = c.Int(),
+                        Online = c.Boolean(nullable: false),
+                        WattId = c.Int(nullable: false),
+                        MachineModelId = c.Int(nullable: false),
+                        MachinePartId = c.Int(nullable: false),
+                        OfflineOn = c.DateTime(),
+                        FW_CurrentVersion = c.String(maxLength: 50),
+                    })
+                .PrimaryKey(t => t.Id)
+                .ForeignKey("dbo.Customer", t => t.CustomerId, cascadeDelete: true)
+                .ForeignKey("dbo.MachineVersion", t => t.FW_AssignedMachineVersionId)
+                .ForeignKey("dbo.MachineModel", t => t.MachineModelId, cascadeDelete: true)
+                .ForeignKey("dbo.MachinePart", t => t.MachinePartId, cascadeDelete: true)
+                .Index(t => t.ChargePointSerialNumber, unique: true)
+                .Index(t => t.CustomerId)
+                .Index(t => t.FW_AssignedMachineVersionId)
+                .Index(t => t.MachineModelId)
+                .Index(t => t.MachinePartId);
+            
+            CreateTable(
+                "dbo.MachineVersion",
+                c => new
+                    {
+                        Id = c.Int(nullable: false, identity: true),
+                        CreatedOn = c.DateTime(nullable: false),
+                        PublishVersionId = c.Int(nullable: false),
+                        MachineId = c.String(nullable: false, maxLength: 36),
+                        UpdatedOn = c.DateTime(),
+                    })
+                .PrimaryKey(t => t.Id)
+                .ForeignKey("dbo.Machine", t => t.MachineId, cascadeDelete: true)
+                .ForeignKey("dbo.PublishVersion", t => t.PublishVersionId, cascadeDelete: true)
+                .Index(t => t.PublishVersionId)
+                .Index(t => t.MachineId);
+            
+            CreateTable(
+                "dbo.MachineVersionFile",
+                c => new
+                    {
+                        Id = c.Int(nullable: false, identity: true),
+                        CreatedOn = c.DateTime(nullable: false),
+                        UpdatedOn = c.DateTime(),
+                        MachineVersionId = c.Int(nullable: false),
+                        UploadFileId = c.Guid(nullable: false),
+                        DownloadedOn = c.DateTime(),
+                        Seq = c.Int(nullable: false),
+                    })
+                .PrimaryKey(t => t.Id)
+                .ForeignKey("dbo.MachineVersion", t => t.MachineVersionId, cascadeDelete: true)
+                .ForeignKey("dbo.UploadFile", t => t.UploadFileId, cascadeDelete: true)
+                .Index(t => t.MachineVersionId)
+                .Index(t => t.UploadFileId);
+            
+            CreateTable(
+                "dbo.UploadFile",
+                c => new
+                    {
+                        Id = c.Guid(nullable: false),
+                        FileName = c.String(nullable: false, maxLength: 500),
+                        OriginName = c.String(nullable: false, maxLength: 500),
+                        FileSize = c.Int(nullable: false),
+                        FileType = c.String(maxLength: 200),
+                        FileExtensionName = c.String(maxLength: 50),
+                        FilePath = c.String(nullable: false, maxLength: 500),
+                        CreatedOn = c.DateTime(nullable: false),
+                        CreatedBy = c.String(maxLength: 50),
+                        IsOnline = c.Boolean(nullable: false),
+                        CustomerId = c.Guid(nullable: false),
+                        FileMD5 = c.String(maxLength: 50),
+                        FileUrl = c.String(maxLength: 512),
+                    })
+                .PrimaryKey(t => t.Id);
+            
+            CreateTable(
+                "dbo.PublishVersion",
+                c => new
+                    {
+                        Id = c.Int(nullable: false, identity: true),
+                        CreatedOn = c.DateTime(nullable: false),
+                        Version = c.Int(nullable: false),
+                        CustomerMachineComponentId = c.Int(nullable: false),
+                    })
+                .PrimaryKey(t => t.Id)
+                .ForeignKey("dbo.CustomerMachineComponent", t => t.CustomerMachineComponentId)
+                .Index(t => t.CustomerMachineComponentId);
+            
+            CreateTable(
+                "dbo.PublishVersionFile",
+                c => new
+                    {
+                        Id = c.Int(nullable: false, identity: true),
+                        PublishVersionId = c.Int(nullable: false),
+                        UploadFileId = c.Guid(nullable: false),
+                        Seq = c.Int(nullable: false),
+                    })
+                .PrimaryKey(t => t.Id)
+                .ForeignKey("dbo.PublishVersion", t => t.PublishVersionId, cascadeDelete: true)
+                .ForeignKey("dbo.UploadFile", t => t.UploadFileId, cascadeDelete: true)
+                .Index(t => t.PublishVersionId)
+                .Index(t => t.UploadFileId);
+            
+            CreateTable(
+                "dbo.MachineConfigures",
+                c => new
+                    {
+                        Id = c.Int(nullable: false, identity: true),
+                        ChargePointSerialNumber = c.String(maxLength: 25),
+                        ConfigureName = c.String(maxLength: 50),
+                        ConfigureSetting = c.String(maxLength: 500),
+                    })
+                .PrimaryKey(t => t.Id);
+            
+            CreateTable(
+                "dbo.MachineError",
+                c => new
+                    {
+                        Id = c.Int(nullable: false, identity: true),
+                        ChargePointSerialNumber = c.String(maxLength: 25),
+                        ConnectorId = c.Byte(nullable: false),
+                        PreStatus = c.Int(nullable: false),
+                        Status = c.Int(nullable: false),
+                        ErrorCode = c.Int(nullable: false),
+                        ErrorInfo = c.String(maxLength: 50),
+                        VendorId = c.String(maxLength: 255),
+                        VendorErrorCodeNum = c.Int(nullable: false),
+                        CreatedOn = c.DateTime(nullable: false),
+                    })
+                .PrimaryKey(t => t.Id);
+            
+            CreateTable(
+                "dbo.MachineOperateRecord",
+                c => new
+                    {
+                        Id = c.Int(nullable: false, identity: true),
+                        ChargePointSerialNumber = c.String(maxLength: 25),
+                        SerialNo = c.String(maxLength: 36),
+                        RequestType = c.Int(nullable: false),
+                        RequestContent = c.String(maxLength: 36),
+                        Status = c.Int(nullable: false),
+                        CreatedOn = c.DateTime(nullable: false),
+                        FinishedOn = c.DateTime(nullable: false),
+                    })
+                .PrimaryKey(t => t.Id);
+            
+            CreateTable(
+                "dbo.ServerCommand",
+                c => new
+                    {
+                        Id = c.Int(nullable: false, identity: true),
+                        ChargePointSerialNumber = c.String(maxLength: 25),
+                        SerialNo = c.String(maxLength: 36),
+                        OutMessage = c.String(),
+                        InMessage = c.String(),
+                        CreatedOn = c.DateTime(nullable: false),
+                        CreatedBy = c.String(),
+                        ReceivedOn = c.DateTime(),
+                    })
+                .PrimaryKey(t => t.Id);
+            
+            CreateTable(
+                "dbo.TransactionRecord",
+                c => new
+                    {
+                        Id = c.Long(nullable: false, identity: true),
+                        CustomerId = c.Guid(nullable: false),
+                        MachineId = c.String(nullable: false, maxLength: 36),
+                        ConnectorId = c.Byte(nullable: false),
+                        TransactionId = c.Int(nullable: false),
+                        chargePointSerialNumber = c.String(maxLength: 25),
+                        IdTag = c.String(maxLength: 20),
+                        StartTime = c.DateTime(nullable: false),
+                        StopTime = c.DateTime(nullable: false),
+                        StopTransactionReasonId = c.Int(nullable: false),
+                        MeterStart = c.Decimal(nullable: false, precision: 18, scale: 2),
+                        MeterStop = c.Decimal(nullable: false, precision: 18, scale: 2),
+                        SOCStart = c.Decimal(nullable: false, precision: 18, scale: 2),
+                        SOCStop = c.Decimal(nullable: false, precision: 18, scale: 2),
+                        ReportedOn = c.DateTime(),
+                        CreatedOn = c.DateTime(nullable: false),
+                        UpdatedOn = c.DateTime(),
+                        StartTransactionReportedOn = c.DateTime(nullable: false),
+                        RetryStartTransactionTimes = c.Int(nullable: false),
+                        StopTransactionReportedOn = c.DateTime(nullable: false),
+                        RtryStopTransactionTimes = c.Int(nullable: false),
+                        ErrorMsg = c.String(),
+                    })
+                .PrimaryKey(t => t.Id)
+                .ForeignKey("dbo.Machine", t => t.MachineId, cascadeDelete: true)
+                .Index(t => new { t.MachineId, t.ConnectorId, t.TransactionId, t.StartTime }, unique: true, name: "IX_1202_Issue_Report")
+                .Index(t => t.MachineId)
+                .Index(t => t.TransactionId);
+            
+        }
+        
+        public override void Down()
+        {
+            DropForeignKey("dbo.TransactionRecord", "MachineId", "dbo.Machine");
+            DropForeignKey("dbo.Machine", "MachinePartId", "dbo.MachinePart");
+            DropForeignKey("dbo.Machine", "MachineModelId", "dbo.MachineModel");
+            DropForeignKey("dbo.Machine", "FW_AssignedMachineVersionId", "dbo.MachineVersion");
+            DropForeignKey("dbo.MachineVersion", "PublishVersionId", "dbo.PublishVersion");
+            DropForeignKey("dbo.PublishVersionFile", "UploadFileId", "dbo.UploadFile");
+            DropForeignKey("dbo.PublishVersionFile", "PublishVersionId", "dbo.PublishVersion");
+            DropForeignKey("dbo.PublishVersion", "CustomerMachineComponentId", "dbo.CustomerMachineComponent");
+            DropForeignKey("dbo.MachineVersionFile", "UploadFileId", "dbo.UploadFile");
+            DropForeignKey("dbo.MachineVersionFile", "MachineVersionId", "dbo.MachineVersion");
+            DropForeignKey("dbo.MachineVersion", "MachineId", "dbo.Machine");
+            DropForeignKey("dbo.Machine", "CustomerId", "dbo.Customer");
+            DropForeignKey("dbo.CustomerMachineComponent", "MachineComponentId", "dbo.MachineComponent");
+            DropForeignKey("dbo.MachineComponent", "MachinePartId", "dbo.MachinePart");
+            DropForeignKey("dbo.MachineComponent", "MachineModelId", "dbo.MachineModel");
+            DropForeignKey("dbo.CustomerMachineComponent", "CustomerId", "dbo.Customer");
+            DropIndex("dbo.TransactionRecord", new[] { "TransactionId" });
+            DropIndex("dbo.TransactionRecord", new[] { "MachineId" });
+            DropIndex("dbo.TransactionRecord", "IX_1202_Issue_Report");
+            DropIndex("dbo.PublishVersionFile", new[] { "UploadFileId" });
+            DropIndex("dbo.PublishVersionFile", new[] { "PublishVersionId" });
+            DropIndex("dbo.PublishVersion", new[] { "CustomerMachineComponentId" });
+            DropIndex("dbo.MachineVersionFile", new[] { "UploadFileId" });
+            DropIndex("dbo.MachineVersionFile", new[] { "MachineVersionId" });
+            DropIndex("dbo.MachineVersion", new[] { "MachineId" });
+            DropIndex("dbo.MachineVersion", new[] { "PublishVersionId" });
+            DropIndex("dbo.Machine", new[] { "MachinePartId" });
+            DropIndex("dbo.Machine", new[] { "MachineModelId" });
+            DropIndex("dbo.Machine", new[] { "FW_AssignedMachineVersionId" });
+            DropIndex("dbo.Machine", new[] { "CustomerId" });
+            DropIndex("dbo.Machine", new[] { "ChargePointSerialNumber" });
+            DropIndex("dbo.MachineComponent", new[] { "MachinePartId" });
+            DropIndex("dbo.MachineComponent", new[] { "MachineModelId" });
+            DropIndex("dbo.CustomerMachineComponent", new[] { "MachineComponentId" });
+            DropIndex("dbo.CustomerMachineComponent", new[] { "CustomerId" });
+            DropIndex("dbo.ApiLogEntry", new[] { "RequestTimestamp" });
+            DropTable("dbo.TransactionRecord");
+            DropTable("dbo.ServerCommand");
+            DropTable("dbo.MachineOperateRecord");
+            DropTable("dbo.MachineError");
+            DropTable("dbo.MachineConfigures");
+            DropTable("dbo.PublishVersionFile");
+            DropTable("dbo.PublishVersion");
+            DropTable("dbo.UploadFile");
+            DropTable("dbo.MachineVersionFile");
+            DropTable("dbo.MachineVersion");
+            DropTable("dbo.Machine");
+            DropTable("dbo.MachinePart");
+            DropTable("dbo.MachineModel");
+            DropTable("dbo.MachineComponent");
+            DropTable("dbo.CustomerMachineComponent");
+            DropTable("dbo.Customer");
+            DropTable("dbo.ConnectorStatus");
+            DropTable("dbo.ApiLogEntry");
+        }
+    }
+}

Plik diff jest za duży
+ 120 - 0
EVCB_OCPP.Domain/MainDBContextMigrations/201907150818448_Init.resx


+ 24 - 0
EVCB_OCPP.Domain/MainDBContextMigrations/Configuration.cs

@@ -0,0 +1,24 @@
+namespace EVCB_OCPP.Domain.MainDBContextMigrations
+{
+    using System;
+    using System.Data.Entity;
+    using System.Data.Entity.Migrations;
+    using System.Linq;
+
+    internal sealed class MainDBConfiguration : DbMigrationsConfiguration<EVCB_OCPP.Domain.MainDBContext>
+    {
+        public MainDBConfiguration()
+        {
+            AutomaticMigrationsEnabled = false;
+            MigrationsDirectory = @"MainDBContextMigrations";
+        }
+
+        protected override void Seed(EVCB_OCPP.Domain.MainDBContext context)
+        {
+            //  This method will be called after migrating to the latest version.
+
+            //  You can use the DbSet<T>.AddOrUpdate() helper extension method 
+            //  to avoid creating duplicate seed data.
+        }
+    }
+}

+ 44 - 0
EVCB_OCPP.Domain/MeterValueDBContext.cs

@@ -0,0 +1,44 @@
+namespace EVCB_OCPP.Domain
+{
+    using EVCB_OCPP.Domain.Models.Database;
+    using System;
+    using System.Data.Entity;
+    using System.Linq;
+
+    public class MeterValueDBContext : DbContext
+    {
+        // 您的內容已設定為使用應用程式組態檔 (App.config 或 Web.config)
+        // 中的 'MeterValueDBContext' 連接字串。根據預設,這個連接字串的目標是
+        // 您的 LocalDb 執行個體上的 'EVCB_OCPP.Domain.MeterValueDBContext' 資料庫。
+        // 
+        // 如果您的目標是其他資料庫和 (或) 提供者,請修改
+        // 應用程式組態檔中的 'MeterValueDBContext' 連接字串。
+        public MeterValueDBContext()
+            : base("name=MeterValueDBContext")
+        {
+            this.Configuration.LazyLoadingEnabled = false;
+            this.Database.CommandTimeout = 180;
+        }
+
+        /// <summary>
+        /// DB coneection set
+        /// </summary>
+        public MeterValueDBContext(string conn)
+        {
+            this.Database.Connection.ConnectionString = conn;
+            this.Configuration.LazyLoadingEnabled = false;
+            this.Database.CommandTimeout = 180;
+        }
+
+        // 針對您要包含在模型中的每種實體類型新增 DbSet。如需有關設定和使用
+        // Code First 模型的詳細資訊,請參閱 http://go.microsoft.com/fwlink/?LinkId=390109。
+
+        public virtual DbSet<ConnectorMeterValueRecord> ConnectorMeterValueRecord { get; set; }
+    }
+
+    //public class MyEntity
+    //{
+    //    public int Id { get; set; }
+    //    public string Name { get; set; }
+    //}
+}

+ 29 - 0
EVCB_OCPP.Domain/MeterValueDBContextMigrations/201907150814558_Init.Designer.cs

@@ -0,0 +1,29 @@
+// <auto-generated />
+namespace EVCB_OCPP.Domain.MeterValueDBContextMigrations
+{
+    using System.CodeDom.Compiler;
+    using System.Data.Entity.Migrations;
+    using System.Data.Entity.Migrations.Infrastructure;
+    using System.Resources;
+    
+    [GeneratedCode("EntityFramework.Migrations", "6.2.0-61023")]
+    public sealed partial class Init : IMigrationMetadata
+    {
+        private readonly ResourceManager Resources = new ResourceManager(typeof(Init));
+        
+        string IMigrationMetadata.Id
+        {
+            get { return "201907150814558_Init"; }
+        }
+        
+        string IMigrationMetadata.Source
+        {
+            get { return null; }
+        }
+        
+        string IMigrationMetadata.Target
+        {
+            get { return Resources.GetString("Target"); }
+        }
+    }
+}

+ 35 - 0
EVCB_OCPP.Domain/MeterValueDBContextMigrations/201907150814558_Init.cs

@@ -0,0 +1,35 @@
+namespace EVCB_OCPP.Domain.MeterValueDBContextMigrations
+{
+    using System;
+    using System.Data.Entity.Migrations;
+    
+    public partial class Init : DbMigration
+    {
+        public override void Up()
+        {
+            CreateTable(
+                "dbo.ConnectorMeterValueRecord",
+                c => new
+                    {
+                        Id = c.Long(nullable: false, identity: true),
+                        ChargePointSerialNumber = c.String(maxLength: 25),
+                        ConnectorId = c.Byte(nullable: false),
+                        Context = c.String(maxLength: 25),
+                        Format = c.String(maxLength: 10),
+                        Measurand = c.String(maxLength: 25),
+                        Phase = c.String(maxLength: 25),
+                        Location = c.String(maxLength: 10),
+                        Value = c.String(maxLength: 10),
+                        Unit = c.String(maxLength: 10),
+                        CreatedOn = c.DateTime(nullable: false),
+                    })
+                .PrimaryKey(t => t.Id);
+            
+        }
+        
+        public override void Down()
+        {
+            DropTable("dbo.ConnectorMeterValueRecord");
+        }
+    }
+}

+ 126 - 0
EVCB_OCPP.Domain/MeterValueDBContextMigrations/201907150814558_Init.resx

@@ -0,0 +1,126 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+  <!-- 
+    Microsoft ResX Schema 
+    
+    Version 2.0
+    
+    The primary goals of this format is to allow a simple XML format 
+    that is mostly human readable. The generation and parsing of the 
+    various data types are done through the TypeConverter classes 
+    associated with the data types.
+    
+    Example:
+    
+    ... ado.net/XML headers & schema ...
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
+    <resheader name="version">2.0</resheader>
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
+    </data>
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+        <comment>This is a comment</comment>
+    </data>
+                
+    There are any number of "resheader" rows that contain simple 
+    name/value pairs.
+    
+    Each data row contains a name, and value. The row also contains a 
+    type or mimetype. Type corresponds to a .NET class that support 
+    text/value conversion through the TypeConverter architecture. 
+    Classes that don't support this are serialized and stored with the 
+    mimetype set.
+    
+    The mimetype is used for serialized objects, and tells the 
+    ResXResourceReader how to depersist the object. This is currently not 
+    extensible. For a given mimetype the value must be set accordingly:
+    
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
+    that the ResXResourceWriter will generate, however the reader can 
+    read any of the formats listed below.
+    
+    mimetype: application/x-microsoft.net.object.binary.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+            : and then encoded with base64 encoding.
+    
+    mimetype: application/x-microsoft.net.object.soap.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+            : and then encoded with base64 encoding.
+
+    mimetype: application/x-microsoft.net.object.bytearray.base64
+    value   : The object must be serialized into a byte array 
+            : using a System.ComponentModel.TypeConverter
+            : and then encoded with base64 encoding.
+    -->
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+    <xsd:element name="root" msdata:IsDataSet="true">
+      <xsd:complexType>
+        <xsd:choice maxOccurs="unbounded">
+          <xsd:element name="metadata">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
+              </xsd:sequence>
+              <xsd:attribute name="name" use="required" type="xsd:string" />
+              <xsd:attribute name="type" type="xsd:string" />
+              <xsd:attribute name="mimetype" type="xsd:string" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="assembly">
+            <xsd:complexType>
+              <xsd:attribute name="alias" type="xsd:string" />
+              <xsd:attribute name="name" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="data">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="resheader">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" />
+            </xsd:complexType>
+          </xsd:element>
+        </xsd:choice>
+      </xsd:complexType>
+    </xsd:element>
+  </xsd:schema>
+  <resheader name="resmimetype">
+    <value>text/microsoft-resx</value>
+  </resheader>
+  <resheader name="version">
+    <value>2.0</value>
+  </resheader>
+  <resheader name="reader">
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <resheader name="writer">
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <data name="Target" xml:space="preserve">
+    <value>H4sIAAAAAAAEAM1Y227jNhB9L9B/EPSctexsW7SBvItEjougcWxE2bwuaGksE6VIlaQC+9v60E/qL3R0v/malReFX6zR8MyNnMPRv3//Y3/ehMx4A6mo4GNzNBiaBnBP+JQHYzPWqw+/mp8//fiDfe+HG+O10PuY6OFKrsbmWuvoxrKUt4aQqEFIPSmUWOmBJ0KL+MK6Hg5/s0YjCxDCRCzDsJ9jrmkI6QM+OoJ7EOmYsJnwgalcjm/cFNV4IiGoiHgwNu9fnbuvc2exGExESCg3jVtGCfrhAluZBuFcaKLRy5svClwtBQ/cCAWEvWwjQL0VYQpy728q9VMDGV4ngVjVwgLKi5VGj84DHH3MM2O1l78rv2aZOczdPeZYb5Oo0/yNTUwzB08LOQMN8pWwGJ7BE9I3jbb1G4fJZGU334OsRIMJ0WRJFAz2ol4Z7bVX5Q7CjZb8rgwnZjqWMOYQa0nYlbGIl4x6f8D2RfwJfMxjxupRYVz4riFA0UKKCKTePsMqj/UBg7Ka66z2wnJZbU0W9APXv/xkGk9onCwZlJumliAXI4bfgYMkGvwF0Rg8TzAgTXvHesuWsyYygIWgXLsgcXc+xeESZOEAblw8gaYxI5tH4IFej83rn01jSjfgF4Lcpy+c4nnFNVrGcNRsUawq1ruthh2hHsXRsNGXdncqZEgOWRkNe7AyA6JiSbh/6XAWa5KsuayRR+HlDeSyWUtP+qWNoPLFy+9ISI7wvMwYtjZ4QXo6cipsq+qw3b6bnBBseSDLTVZ0x8ldeXo6bRc5K++8Kne+6XqG7YI+3tIr5zJu3N+od4dVBlCxsZXRcUHb1h7etmckirBUNR7PJYabkbjzwT2f38IMw/LUDporvS0tYaAkgNbbJGM+TKlUuiAw03D8sKO2q1x7SlFYPFaRNmlVBSoQkv8ZSod1T4atkj3F+ENkozQVULp7hospmusRRuQOqnQEi0O+j24Prd5LfnXIvUpn2KmzXQO7/uIsvOzctrAy4ek4Ba3VYQrZ6Sg12qoD1cSnY+XMVMfJRadjVMRTh6mkpyPl1FKHyUWnY2TMUYfIJGdUu+KFRr0rcRfLtlqHr33orc6pb11S223lUGduq5TWyw7d6sR23hWPj1mdNpmpmAYm6Y36SYt0t0pDmA4CA/cv5jCK8VYKM8LpCpTO7vEmzjrXrVnt/zM3WUr57L3D03efTpY0oEmmj44g517qD88k/I1ID1U6V9bKzDtHEE35No3o26aQnhxsDh07QZN753mgnRmjJ2cbI0VPmO0JoqcUNAaGnjDr80FPkJ1xwMdH3fc40L2GfpeLftbFMaalwPCyWPqfC7osY1v1T372BBQNKgg7dwH3XAVa6DzwlShKhPmoe1SodM6aJlg0cis1XRFP42sPlEqHxzQ8vF9jY/Mf+DzWUaxvlYJwyRrfbGzrsP10+Gn6bM+j5En1EQK6SZN9N+d3MWV+6fd0x77bA5HssJwc0CscnhEu2JZIT4KfCJSnbwIR8IRaXiCMGIKpOXfJG7zHNxxzHyEg3ra4LOwHOV6IZtrtCSWBJKHKMar1yWdsK/mO/ek/RQyLCvkWAAA=</value>
+  </data>
+  <data name="DefaultSchema" xml:space="preserve">
+    <value>dbo</value>
+  </data>
+</root>

+ 24 - 0
EVCB_OCPP.Domain/MeterValueDBContextMigrations/Configuration.cs

@@ -0,0 +1,24 @@
+namespace EVCB_OCPP.Domain.MeterValueDBContextMigrations
+{
+    using System;
+    using System.Data.Entity;
+    using System.Data.Entity.Migrations;
+    using System.Linq;
+
+    internal sealed class MeterValueDBConfiguration : DbMigrationsConfiguration<EVCB_OCPP.Domain.MeterValueDBContext>
+    {
+        public MeterValueDBConfiguration()
+        {
+            AutomaticMigrationsEnabled = false;
+            MigrationsDirectory = @"MeterValueDBContextMigrations";
+        }
+
+        protected override void Seed(EVCB_OCPP.Domain.MeterValueDBContext context)
+        {
+            //  This method will be called after migrating to the latest version.
+
+            //  You can use the DbSet<T>.AddOrUpdate() helper extension method 
+            //  to avoid creating duplicate seed data.
+        }
+    }
+}

+ 121 - 0
EVCB_OCPP.Domain/Models/Database/ApiLogEntry.cs

@@ -0,0 +1,121 @@
+namespace EVCB_OCPP.Domain.Models.Database
+{
+    using System;
+    using System.Collections.Generic;
+    using System.ComponentModel;
+    using System.ComponentModel.DataAnnotations;
+    using System.ComponentModel.DataAnnotations.Schema;
+    using System.Data.Entity.Spatial;
+
+    [Table("ApiLogEntry")]
+    public class ApiLogEntry
+    {
+        /// <summary>
+        /// // The (database) ID for the API log entry.
+        /// </summary>
+        [Key]
+        public long ApiLogEntryId { get; set; }
+
+        /// <summary>
+        /// The application that made the request.
+        /// </summary>
+        public string Application { get; set; }
+
+        /// <summary>
+        /// The user that made the request.
+        /// </summary>
+        public string User { get; set; }
+
+        /// <summary>
+        /// The machine that made the request.
+        /// </summary>
+        public string Machine { get; set; }
+
+        /// <summary>
+        /// The IP address that made the request.
+        /// </summary>
+        public string RequestIpAddress { get; set; }
+
+        /// <summary>
+        /// The request content type.
+        /// </summary>
+        public string RequestContentType { get; set; }
+
+        /// <summary>
+        /// The request content body.
+        /// </summary>
+        public string RequestContentBody { get; set; }
+
+        /// <summary>
+        /// The request URI.
+        /// </summary>
+        public string RequestUri { get; set; }
+
+        /// <summary>
+        /// The request method (GET, POST, etc).
+        /// </summary>
+
+        public string RequestMethod { get; set; }
+
+        /// <summary>
+        /// // The request route template.
+        /// </summary>
+        public string RequestRouteTemplate { get; set; }
+
+        /// <summary>
+        /// // The request route data.
+        /// </summary>
+        public string RequestRouteData { get; set; }
+
+        /// <summary>
+        /// The request headers.
+        /// </summary>
+        public string RequestHeaders { get; set; }
+
+        /// <summary>
+        /// // The request timestamp.
+        /// </summary>
+        [Index("IX_RequestTimestamp", IsUnique = false)]
+        public DateTime? RequestTimestamp { get; set; }
+
+        /// <summary>
+        /// The response content type.
+        /// </summary>
+        public string ResponseContentType { get; set; }
+
+        /// <summary>
+        /// The response content body.
+        /// </summary>
+        public string ResponseContentBody { get; set; }
+
+        /// <summary>
+        /// The response status code.
+        /// </summary>
+        public int? ResponseStatusCode { get; set; }
+
+        /// <summary>
+        /// The response headers.
+        /// </summary>
+        public string ResponseHeaders { get; set; }
+
+        /// <summary>
+        /// The response timestamp.
+        /// </summary>
+        public DateTime? ResponseTimestamp { get; set; }
+
+        /// <summary>
+        /// 從server丟出去的請求
+        /// </summary>
+        public bool IsOutData { get; set; }
+
+        /// <summary>
+        /// 錯誤訊息
+        /// </summary>
+        public string ErrorMsg { get; set; }
+
+        /// <summary>
+        /// 錯誤時間
+        /// </summary>
+        public DateTime? ErrorOn { get; set; }
+    }
+}

+ 46 - 0
EVCB_OCPP.Domain/Models/Database/ConnectorMeterValueRecord.cs

@@ -0,0 +1,46 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EVCB_OCPP.Domain.Models.Database
+{
+    [Table("ConnectorMeterValueRecord")]
+    public class ConnectorMeterValueRecord
+    {
+        public Int64 Id { set; get; }
+
+        [StringLength(25)]
+        public string ChargePointSerialNumber { get; set; }
+
+        public byte ConnectorId { set; get; }
+
+        [StringLength(25)]
+        public string Context { set; get; }
+
+        [StringLength(10)]
+        public string Format { set; get; }
+
+        [StringLength(25)]
+        public string Measurand { set; get; }
+
+        [StringLength(25)]
+        public string Phase { set; get; }
+
+        [StringLength(10)]
+        public string Location { set; get; }
+
+        [StringLength(10)]
+        public string Value { set; get; }
+
+        [StringLength(10)]
+        public string Unit { set; get; }
+
+        public DateTime CreatedOn { set; get; }
+
+
+    }
+}

+ 50 - 0
EVCB_OCPP.Domain/Models/Database/ConnectorStatus.cs

@@ -0,0 +1,50 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EVCB_OCPP.Domain.Models.Database
+{
+    [Table("ConnectorStatus")]
+    public class ConnectorStatus
+    {
+        [Key]
+        [StringLength(36)]
+        public string Id { get; set; }
+
+        [StringLength(25)]
+        public string ChargePointSerialNumber { get; set; }
+
+        public byte ConnectorId { set; get; }
+
+        public int Status { set; get; }
+
+        /// <summary>
+        /// errorCode
+        /// </summary>
+        public int ChargePointErrorCodeNo { set; get; }
+
+        /// <summary>
+        ///ErrorInfo
+        /// </summary>
+        [StringLength(50)]
+        public string ErrorInfo { set; get; }
+
+        /// <summary>
+        /// vendorId
+        /// </summary>
+        [StringLength(255)]
+        public string VendorId { set; get; }
+
+        /// <summary>
+        /// vendorErrorCode
+        /// </summary>
+        public int VendorErrorCodeNo { set; get; }
+
+        public DateTime CreatedOn { set; get; }
+
+    }
+}

+ 90 - 0
EVCB_OCPP.Domain/Models/Database/Customer.cs

@@ -0,0 +1,90 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EVCB_OCPP.Domain.Models.Database
+{
+    /// <summary>
+    /// 未來會以充電站規模使用管理後台
+    /// </summary>
+    [Table("Customer")]
+    public class Customer
+    {
+        [Key]
+        public Guid Id { get; set; }
+
+        [StringLength(50)]
+        public string Name { get; set; }
+
+        public DateTime CreatedOn { get; set; }
+
+        [StringLength(50)]       
+        public string CreatedBy { get; set; }            
+
+          
+        public DateTime? Deadline { get; set; }
+
+      
+        public DateTime? UpdatedOn { get; set; }
+
+        [StringLength(50)]       
+        public string UpdatedBy { get; set; }        
+
+        /// <summary>
+        /// 對方的api Url
+        /// </summary>
+        [StringLength(256)]
+        public string ApiUrl { get; set; }
+
+        /// <summary>
+        /// 對方的 api Key
+        /// </summary>
+        [StringLength(128)]
+        public string ApiKey { get; set; }
+
+        /// <summary>
+        /// api Key的更新日期
+        /// </summary>
+        public DateTime? ApiKeyUpdatedOn { get; set; }
+
+        /// <summary>
+        /// 呼叫對方 api的客戶代碼
+        /// </summary>
+        [StringLength(36)]
+        public string PartnerId { get; set; }
+
+        /// <summary>
+        /// 對方的 api Id
+        /// </summary>
+        [StringLength(36)]
+        public string ApiCustomerId { get; set; }
+
+     
+
+        /// <summary>
+        /// 排程呼掉對方的services
+        /// </summary>
+        public bool CallPartnerApiOnSchedule { get; set; }
+
+       
+
+        /// <summary>
+        /// 是否顯示
+        /// </summary>
+        public bool IsShow { get; set; }
+
+        public Customer()
+        {
+            Id = Guid.NewGuid();
+        }
+
+        
+        public virtual ICollection<CustomerMachineComponent> CustomerMachineComponents { get; set; }
+       
+
+    }
+}

+ 40 - 0
EVCB_OCPP.Domain/Models/Database/CustomerMachineComponent.cs

@@ -0,0 +1,40 @@
+namespace EVCB_OCPP.Domain.Models.Database
+{
+    using System;
+    using System.Collections.Generic;
+    using System.ComponentModel;
+    using System.ComponentModel.DataAnnotations;
+    using System.ComponentModel.DataAnnotations.Schema;
+    using System.Data.Entity.Spatial;
+
+    /// <summary>
+    /// 客戶所使用的機器元件
+    /// </summary>
+    [Table("CustomerMachineComponent")]
+    public partial class CustomerMachineComponent
+    {
+        [Key]
+        public int Id { get; set; }
+
+        /// <summary>
+        /// 客戶ID
+        /// </summary>
+        public Guid CustomerId { get; set; }
+
+        [ForeignKey("CustomerId")]
+        public virtual Customer Customer { get; set; }
+        /// <summary>
+        /// 設定好的機器元件Id
+        /// </summary>
+        public int MachineComponentId { get; set; }
+
+        [ForeignKey("MachineComponentId")]
+        public virtual MachineComponent MachineComponent { get; set; }
+
+      
+        public DateTime CreatedOn { get; set; }
+
+        [StringLength(50)]     
+        public string CreatedBy { get; set; }
+    }
+}

+ 197 - 0
EVCB_OCPP.Domain/Models/Database/Machine.cs

@@ -0,0 +1,197 @@
+namespace EVCB_OCPP.Domain.Models.Database
+{
+
+    using System;
+    using System.Collections.Generic;
+    using System.ComponentModel.DataAnnotations;
+    using System.ComponentModel.DataAnnotations.Schema;
+
+    /// <summary>
+    /// 樁的基本檔
+    /// </summary>
+    [Table("Machine")]
+    public partial class Machine
+    {
+        public Machine()
+        {            
+            Id = Guid.NewGuid().ToString();
+        }
+
+        [Key]
+        [StringLength(36)]
+        public string Id { get; set; }
+
+        /// <summary>
+        /// chargePointSerialNumber
+        /// </summary>
+        [Index("IX_ChargePointSerialNumber", IsUnique = true)]
+        [StringLength(25)]
+        public string ChargePointSerialNumber { get; set; }
+
+        /// <summary>
+        /// chargeBoxSerialNumber
+        /// </summary>    
+        [StringLength(25)]
+        public string ChargeBoxSerialNumber { get; set; }     
+
+       
+
+        /// <summary>
+        /// chargePointModel
+        /// </summary>      
+        [StringLength(20)]
+        public string ChargePointModel { get; set; }
+
+        /// <summary>
+        /// chargePointVendor
+        /// </summary>
+        [StringLength(20)]
+        public string ChargePointVendor { get; set; }
+
+        /// <summary>
+        /// iccid
+        /// </summary>
+        [StringLength(20)]
+        public string Iccid { get; set; }
+
+
+        /// <summary>
+        /// imsi
+        /// </summary>
+        [StringLength(20)]
+        public string Imsi { get; set; }
+
+        /// <summary>
+        /// MeterType
+        /// </summary>
+        [StringLength(25)]
+        public string MeterType { get; set; }
+
+        /// <summary>
+        /// meterSerialNumber
+        /// </summary>
+        [StringLength(25)]
+        public string MeterSerialNumber { get; set; }
+
+
+        /// <summary>
+        /// 建立時間
+        /// </summary>       
+        public DateTime CreatedOn { get; set; }
+
+        /// <summary>
+        /// 建立者
+        /// </summary>
+        [StringLength(50)]      
+        public string CreatedBy { get; set; }
+
+        /// <summary>
+        /// 描述
+        /// </summary>
+        [StringLength(100)]     
+        public string Comment { get; set; }
+
+        /// <summary>
+        /// 客戶id
+        /// </summary>      
+        public Guid CustomerId { get; set; }
+
+        /// <summary>
+        /// 是否為AC電源 true為ac,false為dc
+        /// </summary>
+        public bool AC { get; set; }
+      
+
+        /// <summary>
+        /// 充電槍個數
+        /// </summary>
+        public int GunAmt { get; set; }
+
+        
+
+        /// <summary>
+        /// 心跳包更新時間
+        /// </summary>
+        public DateTime? HeartbeatUpdatedOn { get; set; }
+
+
+     
+
+
+
+        /// <summary>
+        /// 機器回報的韌體版本編號
+        /// </summary>
+        public int? FW_VersionReport { get; set; }
+
+       
+
+      
+
+        /// <summary>
+        /// 機器被指派的韌體版本編號
+        /// </summary>
+        public int? FW_AssignedVersion { get; set; }
+      
+
+        /// <summary>
+        /// 目前被指派更新的韌體 MachineVersion號碼
+        /// </summary>
+        public int? FW_AssignedMachineVersionId { get; set; }      
+
+        /// <summary>
+        /// 是否在線
+        /// </summary>
+        public bool Online { get; set; }
+
+        /// <summary>
+        /// 機器的K瓦數,Ref Watt
+        /// </summary>
+        public int WattId { get; set; }
+
+    
+
+        /// <summary>
+        /// 機器的模組 Ref MachineModel
+        /// </summary>
+        public int MachineModelId { get; set; }
+
+        [ForeignKey("MachineModelId")]
+        public virtual MachineModel MachineModel { get; set; }
+
+        /// <summary>
+        /// 客戶自訂樁號
+        /// </summary>
+        public int MachinePartId { get; set; }
+
+        [ForeignKey("MachinePartId")]
+        public virtual MachinePart MachinePart { get; set; }
+
+      
+
+        [ForeignKey("CustomerId")]
+        public virtual Customer Customer { get; set; }
+
+      
+
+        public virtual MachineVersion FW_MachineVersion { get; set; }
+      
+
+             
+
+     
+
+        /// <summary>
+        /// 斷網時間
+        /// </summary>
+        public DateTime? OfflineOn { get; set; }
+
+        /// <summary>
+        /// firmwareVersion
+        /// </summary>
+        [StringLength(50)]
+        public string FW_CurrentVersion { get; set; }
+
+      
+    }
+}

+ 47 - 0
EVCB_OCPP.Domain/Models/Database/MachineComponent.cs

@@ -0,0 +1,47 @@
+namespace EVCB_OCPP.Domain.Models.Database
+{
+    using System;
+    using System.Collections.Generic;
+    using System.ComponentModel;
+    using System.ComponentModel.DataAnnotations;
+    using System.ComponentModel.DataAnnotations.Schema;
+    using System.Data.Entity.Spatial;
+
+    /// <summary>
+    /// 機器的組成項目
+    /// </summary>
+    [Table("MachineComponent")]
+    public partial class MachineComponent
+    {
+        [Key]
+        public int Id { get; set; }
+
+        /// <summary>
+        /// 機器的MachineModelId
+        /// </summary>
+        public int MachineModelId { get; set; }
+
+        [ForeignKey("MachineModelId")]
+        public virtual MachineModel MachineModel { get; set; }
+
+        /// <summary>
+        /// 槍數
+        /// </summary>
+        public int? GunAmt { get; set; }
+
+        /// <summary>
+        /// 機器零件ID
+        /// </summary>
+        public int MachinePartId { get; set; }
+
+        [ForeignKey("MachinePartId")]
+        public virtual MachinePart MachinePart { get; set; }
+
+        /// <summary>
+        /// 機器 Model Name
+        /// </summary>
+        public String ModelName { get; set; }
+
+     
+    }
+}

+ 26 - 0
EVCB_OCPP.Domain/Models/Database/MachineConfigure.cs

@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EVCB_OCPP.Domain.Models.Database
+{
+    public class MachineConfigure
+    {
+        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
+        [Key]
+        public Int32 Id { set; get; }
+
+        [StringLength(25)]
+        public string ChargePointSerialNumber { get; set; }
+
+        [StringLength(50)]
+        public string ConfigureName { set; get; }
+
+        [StringLength(500)]
+        public string ConfigureSetting { set; get; }
+    }
+}

+ 54 - 0
EVCB_OCPP.Domain/Models/Database/MachineConnectionLog.cs

@@ -0,0 +1,54 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EVCB_OCPP.Domain.Models.Database
+{
+    [Table("MachineConnectionLog")]
+    public class MachineConnectionLog
+    {
+        public Int64 Id { set; get; }
+
+        [StringLength(25)]
+        public string ChargePointSerialNumber { get; set; }
+         
+
+        /// <summary>
+        /// 連線電腦、IP
+        /// </summary>
+        [StringLength(30)]    
+        public string IpPort { get; set; }
+
+        /// <summary>
+        /// 連線電腦、IP
+        /// </summary>
+        [StringLength(30)]       
+        public string ClientIpPort { get; set; }
+
+        /// <summary>
+        /// 訊息種類
+        /// </summary>
+        [StringLength(50)]
+        public string MessageType { get; set; }
+
+        /// <summary>
+        /// 封包訊息
+        /// </summary>
+        [StringLength(4000)]      
+        public string Data { get; set; }     
+
+        /// <summary>
+        /// 訊息,可放錯誤訊息
+        /// </summary>
+        public string Msg { get; set; }
+
+        /// <summary>
+        /// 產生時間
+        /// </summary>       
+        public DateTime CreatedOn { get; set; }
+    }
+}

+ 69 - 0
EVCB_OCPP.Domain/Models/Database/MachineError.cs

@@ -0,0 +1,69 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EVCB_OCPP.Domain.Models.Database
+{
+    [Table("MachineError")]
+    public partial class MachineError
+    {
+        public MachineError()
+        {
+        }
+
+        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
+        [Key]       
+        public int Id { get; set; }
+
+    
+
+        [StringLength(25)]
+        public string ChargePointSerialNumber { get; set; }
+
+        /// <summary>
+        /// 槍號
+        /// </summary>
+        public byte ConnectorId { get; set; }
+
+        /// <summary>
+        /// 先前的狀態
+        /// </summary>
+        public int PreStatus { get; set; }
+
+        /// <summary>
+        /// 錯誤的狀態
+        /// </summary>
+        public int Status { get; set; }
+
+        /// <summary>
+        /// 錯誤代碼
+        /// </summary>
+        public int ErrorCode { get; set; }
+
+        /// <summary>
+        ///ErrorInfo
+        /// </summary>
+        [StringLength(50)]
+        public string ErrorInfo { set; get; }
+
+        /// <summary>
+        /// vendorId
+        /// </summary>
+        [StringLength(255)]
+        public string VendorId { set; get; }
+
+        /// <summary>
+        /// vendorErrorCode
+        /// </summary>
+        public int VendorErrorCodeNum { set; get; }
+
+
+
+        [Required]
+        public DateTime? CreatedOn { get; set; }
+    }
+}

+ 25 - 0
EVCB_OCPP.Domain/Models/Database/MachineModel.cs

@@ -0,0 +1,25 @@
+namespace EVCB_OCPP.Domain.Models.Database
+{
+    using System;
+    using System.Collections.Generic;
+    using System.ComponentModel;
+    using System.ComponentModel.DataAnnotations;
+    using System.ComponentModel.DataAnnotations.Schema;
+    using System.Data.Entity.Spatial;
+
+    /// <summary>
+    /// 機器的模組
+    /// { Id = 0, Name = "Beaglebone" },
+    /// { Id = 1, Name = "IPC" },
+    /// { Id = 2, Name = "HMI" }
+    /// </summary>
+    [Table("MachineModel")]
+    public partial class MachineModel
+    {
+        [Key]
+        public int Id { get; set; }
+
+        [StringLength(36)]       
+        public string Name { get; set; }
+    }
+}

+ 72 - 0
EVCB_OCPP.Domain/Models/Database/MachineOperateRecord.cs

@@ -0,0 +1,72 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EVCB_OCPP.Domain.Models.Database
+{
+    /// <summary>
+    /// 電樁操作紀錄
+    /// </summary>
+    [Table("MachineOperateRecord")]
+    public class MachineOperateRecord
+    {
+
+        public MachineOperateRecord()
+        {
+        }
+
+        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
+        [Key]
+        public int Id { get; set; }
+
+
+        /// <summary>
+        /// 機器的客戶自訂ID
+        /// </summary>
+        [StringLength(25)]
+        public string ChargePointSerialNumber { get; set; }
+
+
+
+        /// <summary>
+        /// 隨機序號 和ServerCommand是同一個組序號
+        /// </summary>
+        [StringLength(36)]
+        public string SerialNo { get; set; }
+
+        /// <summary>
+        /// 請求類型
+        /// </summary>     
+        public int RequestType { get; set; }
+
+
+        /// <summary>
+        /// 請求內容
+        /// </summary>
+        [StringLength(36)]
+        public string RequestContent { get; set; }
+
+
+        /// <summary>
+        /// 狀態
+        /// </summary>     
+        public int Status { get; set; }
+
+       /// <summary>
+       /// 建立時間
+       /// </summary>
+        public DateTime CreatedOn { set; get; }
+
+
+        /// <summary>
+        /// 結束時間
+        /// </summary>
+        public DateTime FinishedOn { set; get; }
+
+
+    }
+}

+ 29 - 0
EVCB_OCPP.Domain/Models/Database/MachinePart.cs

@@ -0,0 +1,29 @@
+namespace EVCB_OCPP.Domain.Models.Database
+{
+    using System;
+    using System.Collections.Generic;
+    using System.ComponentModel;
+    using System.ComponentModel.DataAnnotations;
+    using System.ComponentModel.DataAnnotations.Schema;
+
+    /// <summary>
+    /// 充電樁零件
+    /// </summary>
+    [Table("MachinePart")]
+    public partial class MachinePart
+    {
+        public MachinePart()
+        {
+        }
+
+        [DatabaseGenerated(DatabaseGeneratedOption.None)]
+        [Key]
+        public int Id { get; set; }
+
+        /// <summary>
+        /// 描述
+        /// </summary>
+        [StringLength(36)]
+        public string Desc { get; set; }
+    }
+}

+ 58 - 0
EVCB_OCPP.Domain/Models/Database/MachineVersion.cs

@@ -0,0 +1,58 @@
+namespace EVCB_OCPP.Domain.Models.Database
+{
+    using System;
+    using System.Collections.Generic;
+    using System.ComponentModel;
+    using System.ComponentModel.DataAnnotations;
+    using System.ComponentModel.DataAnnotations.Schema;
+    using System.Data.Entity.Spatial;
+
+    /// <summary>
+    /// 機器的版本發佈
+    /// </summary>
+    [Table("MachineVersion")]
+    public partial class MachineVersion
+    {
+        public MachineVersion()
+        {
+            MachineVersionFiles = new List<MachineVersionFile>();
+        }
+
+        [Key]
+        public int Id { get; set; }
+
+      
+        [Required]
+        public DateTime CreatedOn { get; set; }
+
+        /// <summary>
+        /// 發佈版本ID
+        /// </summary>
+        [DisplayName("Version")]
+        [Required]
+        public int PublishVersionId { get; set; }
+
+
+        [Required]
+        [StringLength(36)]
+        public string MachineId { get; set; }
+
+        /// <summary>
+        /// 更新日期
+        /// </summary>
+       
+        public DateTime? UpdatedOn { get; set; }
+
+        //[ForeignKey("MachineId")]
+        public virtual Machine Machine { get; set; }
+
+        [ForeignKey("PublishVersionId")]        
+        public virtual PublishVersion PublishVersion { get; set; }
+
+        public virtual ICollection<MachineVersionFile> MachineVersionFiles { get; set; }
+
+        //[InverseProperty("MachineId")]
+        //public virtual ICollection<Machine> Machines { get; set; }
+
+    }
+}

+ 50 - 0
EVCB_OCPP.Domain/Models/Database/MachineVersionFile.cs

@@ -0,0 +1,50 @@
+namespace EVCB_OCPP.Domain.Models.Database
+{
+    using System;
+    using System.Collections.Generic;
+    using System.ComponentModel;
+    using System.ComponentModel.DataAnnotations;
+    using System.ComponentModel.DataAnnotations.Schema;
+    using System.Data.Entity.Spatial;
+
+    /// <summary>
+    /// 機器的版本發佈的檔案關連
+    /// </summary>
+    [Table("MachineVersionFile")]
+    public partial class MachineVersionFile
+    {
+        [Key]
+        public int Id { get; set; }
+
+      
+        [Required]
+        public DateTime CreatedOn { get; set; }
+
+        /// <summary>
+        /// 更新日期
+        /// </summary>     
+        public DateTime? UpdatedOn { get; set; }
+
+        [Required]
+        public int MachineVersionId { get; set; }
+
+        [Required]
+        public Guid UploadFileId { get; set; }
+
+        /// <summary>
+        /// 下載日期
+        /// </summary>
+        public DateTime? DownloadedOn { get; set; }
+
+        /// <summary>
+        /// 排序
+        /// </summary>
+        public int Seq { get; set; }
+
+        [ForeignKey("MachineVersionId")]
+        public virtual MachineVersion MachineVersion { get; set; }
+
+        [ForeignKey("UploadFileId")]
+        public virtual UploadFile UploadFile { get; set; }
+    }
+}

+ 48 - 0
EVCB_OCPP.Domain/Models/Database/PublishVersion.cs

@@ -0,0 +1,48 @@
+namespace EVCB_OCPP.Domain.Models.Database
+{
+ 
+    using System;
+    using System.Collections.Generic;
+    using System.ComponentModel;
+    using System.ComponentModel.DataAnnotations;
+    using System.ComponentModel.DataAnnotations.Schema;
+    using System.Data.Entity.Spatial;
+
+    /// <summary>
+    /// 版本發佈
+    /// </summary>
+    [Table("PublishVersion")]
+    public partial class PublishVersion
+    {
+        public PublishVersion()
+        {
+            PublishVersionFiles = new List<PublishVersionFile>();
+        }
+
+        [Key]
+        public int Id { get; set; }
+
+      
+        [Required]
+        public DateTime CreatedOn { get; set; }
+
+        /// <summary>
+        /// 自動遞增的版號
+        /// </summary>
+        [DisplayName("Version")]
+        [Required]
+        public int Version { get; set; }
+      
+
+        /// <summary>
+        /// 客戶所使用的機器元件
+        /// </summary>
+        [Required]
+        public int CustomerMachineComponentId { get; set; }
+      
+
+        public virtual ICollection<PublishVersionFile> PublishVersionFiles { get; set; }
+
+        public virtual CustomerMachineComponent CustomerMachineComponent { get; set; }
+    }
+}

+ 37 - 0
EVCB_OCPP.Domain/Models/Database/PublishVersionFile.cs

@@ -0,0 +1,37 @@
+namespace EVCB_OCPP.Domain.Models.Database
+{
+    using EVCB_OCPP.Domain.Models.Database;
+    using System;
+    using System.Collections.Generic;
+    using System.ComponentModel;
+    using System.ComponentModel.DataAnnotations;
+    using System.ComponentModel.DataAnnotations.Schema;
+    using System.Data.Entity.Spatial;
+
+    /// <summary>
+    /// 版本發佈的檔案關連
+    /// </summary>
+    [Table("PublishVersionFile")]
+    public partial class PublishVersionFile
+    {
+        [Key]
+        public int Id { get; set; }
+
+        [Required]
+        public int PublishVersionId { get; set; }
+
+        [Required]
+        public Guid UploadFileId { get; set; }
+
+        /// <summary>
+        /// 排序
+        /// </summary>
+        public int Seq { get; set; }
+
+        [ForeignKey("PublishVersionId")]
+        public virtual PublishVersion PublishVersion { get; set; }
+
+        [ForeignKey("UploadFileId")]
+        public virtual UploadFile UploadFile { get; set; }
+    }
+}

+ 62 - 0
EVCB_OCPP.Domain/Models/Database/ServerCommand.cs

@@ -0,0 +1,62 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EVCB_OCPP.Domain.Models.Database
+{
+    /// <summary>
+    /// 需確認的指令發送檔
+    /// </summary>
+    [Table("ServerCommand")]
+    public partial class ServerCommand
+    {
+        public ServerCommand()
+        {
+        }
+
+        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
+        [Key]
+        public int Id { get; set; }
+        
+
+        /// <summary>
+        /// 機器的客戶自訂ID
+        /// </summary>
+        [StringLength(25)]
+        public string ChargePointSerialNumber { get; set; }
+
+        /// <summary>
+        /// 隨機序號
+        /// </summary>
+        [StringLength(36)]
+        public string SerialNo { get; set; }
+       
+
+        /// <summary>
+        /// 送出傳送資料
+        /// </summary>
+        public string OutMessage { get; set; }
+        
+
+        /// <summary>
+        /// 輸入傳送資料
+        /// </summary>
+        public string InMessage { get; set; }
+
+      
+        public DateTime CreatedOn { get; set; }
+
+      
+        public string CreatedBy { get; set; }      
+      
+
+        /// <summary>
+        /// 收到輸入指令
+        /// </summary>
+        public DateTime? ReceivedOn { get; set; }
+    }
+}

+ 155 - 0
EVCB_OCPP.Domain/Models/Database/TransactionRecord.cs

@@ -0,0 +1,155 @@
+namespace EVCB_OCPP.Domain.Models.Database
+{
+    using System;
+    using System.Collections.Generic;
+    using System.ComponentModel;
+    using System.ComponentModel.DataAnnotations;
+    using System.ComponentModel.DataAnnotations.Schema;
+    using System.Data.Entity.Spatial;
+
+    /// <summary>
+    /// 交易紀錄
+    /// </summary>
+    [Table("TransactionRecord")]
+    public partial class TransactionRecord
+    {
+        public TransactionRecord()
+        {
+        }
+
+        [Key]
+        public Int64 Id { get; set; }
+
+        /// <summary>
+        /// 客戶代碼
+        /// </summary>
+        [Required]
+        public Guid CustomerId { get; set; }
+
+        [Required]
+        [Index("IX_MachineId")]
+        [Index("IX_1202_Issue_Report", Order = 1, IsUnique = true)]
+        [StringLength(36)]
+        public string MachineId { get; set; }
+
+        [ForeignKey("MachineId")]
+        public virtual Machine Machine { get; set; }
+
+
+        /// <summary>
+        /// 槍號  1 byte string、本來是 string、改為byte
+        /// </summary>
+        [Required]
+        [Index("IX_1202_Issue_Report", Order = 2, IsUnique = true)]
+        public byte ConnectorId { get; set; }
+
+
+        /// <summary>
+        /// TransactionId
+        /// </summary>
+        [Index("IX_TransactionId")]
+        [Index("IX_1202_Issue_Report", Order = 3, IsUnique = true)]
+        [Required]
+        public int TransactionId { get; set; }
+
+        
+
+        /// <summary>
+        /// chargePointSerialNumber
+        /// </summary>
+        [StringLength(25)]
+        public string chargePointSerialNumber { get; set; }
+
+        /// <summary>
+        /// IdTag
+        /// </summary>
+        [StringLength(20)]
+        public string IdTag { get; set; }
+
+        /// <summary>
+        /// 開始充電開始時間
+        /// </summary>
+        [Index("IX_1202_Issue_Report", Order = 4, IsUnique = true)]
+        public DateTime StartTime { get; set; }
+
+        /// <summary>
+        /// 充電結束時間
+        /// </summary>
+        public DateTime StopTime { get; set; }
+
+        /// <summary>
+        /// 充電停止原因代號
+        /// </summary>
+        public int StopTransactionReasonId { get; set; }
+
+        /// <summary>
+        /// 開始meter
+        /// </summary>
+        [DataType("decimal(16 ,2")]
+        public decimal MeterStart { get; set; }
+
+        /// <summary>
+        /// 結束meter
+        /// </summary>
+        [DataType("decimal(16 ,2")]
+        public decimal MeterStop { get; set; }
+
+        /// <summary>
+        /// 開始SOC
+        /// </summary>      
+        [DataType("decimal(16 ,2")]
+        public decimal SOCStart { get; set; }
+
+        /// <summary>
+        /// 結束SOC
+        /// </summary>   
+        [DataType("decimal(16 ,2")]
+        public decimal SOCStop { get; set; }
+
+      
+
+        /// <summary>
+        /// 回報時間
+        /// </summary>
+        public DateTime? ReportedOn { get; set; }
+
+        /// <summary>
+        /// 產生時間
+        /// </summary>
+        public DateTime CreatedOn { get; set; }
+
+        /// <summary>
+        /// 更新時間
+        /// </summary>
+        public DateTime? UpdatedOn { get; set; }
+      
+
+        /// <summary>
+        /// 開始充電的回報時間
+        /// </summary>
+        public DateTime StartTransactionReportedOn { get; set; }
+
+        /// <summary>
+        /// 開始充電回報的次數
+        /// </summary>
+        public int RetryStartTransactionTimes { get; set; }
+
+        /// <summary>
+        /// 結束充電的回報時間
+        /// </summary>
+        public DateTime StopTransactionReportedOn { get; set; }
+
+        /// <summary>
+        /// 結束充電回報的次數
+        /// </summary>
+        public int RtryStopTransactionTimes { get; set; }
+
+        /// <summary>
+        /// 回調客戶API,問題紀錄
+        /// </summary>
+        public string ErrorMsg { set; get; }
+
+
+
+    }
+}

+ 91 - 0
EVCB_OCPP.Domain/Models/Database/UploadFile.cs

@@ -0,0 +1,91 @@
+namespace EVCB_OCPP.Domain.Models.Database
+{
+    using System;
+    using System.Collections.Generic;
+    using System.ComponentModel.DataAnnotations;
+    using System.ComponentModel.DataAnnotations.Schema;
+
+    /// <summary>
+    /// 上傳檔案
+    /// </summary>
+    [Table("UploadFile")]
+    public partial class UploadFile
+    {
+        public UploadFile()
+        {
+            Id = Guid.NewGuid();
+        }
+
+        //[Index(IsClustered = false)]
+        [Key]
+        public Guid Id { get; set; }
+
+        /// <summary>
+        /// 檔名
+        /// </summary>
+        [Required]
+        [StringLength(500)]    
+        public string FileName { get; set; }
+
+        /// <summary>
+        /// 原始檔名
+        /// </summary>
+        [Required]
+        [StringLength(500)]
+       
+        public string OriginName { get; set; }
+
+       
+        public int FileSize { get; set; }
+
+        /// <summary>
+        /// 檔案類型
+        /// </summary>
+        [StringLength(200)]
+     
+        public string FileType { get; set; }
+
+        /// <summary>
+        /// 副檔名
+        /// </summary>
+        [StringLength(50)]    
+        public string FileExtensionName { get; set; }
+
+        /// <summary>
+        /// 檔案路徑
+        /// </summary>
+        [Required]
+        [StringLength(500)]       
+        public string FilePath { get; set; }
+
+        
+        public DateTime CreatedOn { get; set; }
+
+        [StringLength(50)]      
+        public string CreatedBy { get; set; }
+
+        /// <summary>
+        /// 是否有效
+        /// </summary>       
+        public bool IsOnline { get; set; }       
+
+    
+        public Guid CustomerId { get; set; }
+
+      
+
+        /// <summary>
+        /// MD5
+        /// </summary>
+        [StringLength(50)]
+        public string FileMD5 { get; set; }
+
+        /// <summary>
+        /// 網頁路徑
+        /// </summary>
+        [StringLength(512)]
+        public string FileUrl { get; set; }
+
+       
+    }
+}

+ 36 - 0
EVCB_OCPP.Domain/Properties/AssemblyInfo.cs

@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// 組件的一般資訊是由下列的屬性集控制。
+// 變更這些屬性的值即可修改組件的相關
+// 資訊。
+[assembly: AssemblyTitle("EVCB_OCPP.Domain")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("EVCB_OCPP.Domain")]
+[assembly: AssemblyCopyright("Copyright ©  2019")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// 將 ComVisible 設為 false 可對 COM 元件隱藏
+// 組件中的類型。若必須從 COM 存取此組件中的類型,
+// 的類型,請在該類型上將 ComVisible 屬性設定為 true。
+[assembly: ComVisible(false)]
+
+// 下列 GUID 為專案公開 (Expose) 至 COM 時所要使用的 typelib ID
+[assembly: Guid("fafb8754-9a6e-4931-88ec-376f0326d315")]
+
+// 組件的版本資訊由下列四個值所組成: 
+//
+//      主要版本
+//      次要版本
+//      組建編號
+//      修訂編號
+//
+// 您可以指定所有的值,或將組建編號或修訂編號設為預設值
+//方法是使用 '*',如下所示:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 5 - 0
EVCB_OCPP.Domain/packages.config

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="EntityFramework" version="6.2.0" targetFramework="net471" />
+  <package id="EntityFramework.zh-Hant" version="6.2.0" targetFramework="net471" />
+</packages>

Niektóre pliki nie zostały wyświetlone z powodu dużej ilości zmienionych plików