Procházet zdrojové kódy

DB Route Table Add

SK.Kang před 6 roky
rodič
revize
ff3cb0c700

+ 1 - 0
.gitignore

@@ -110,3 +110,4 @@ UpgradeLog*.XML
 
 Dev/OHV/.vs/
 Dev/OHV/.cr/
+Dev/Connection/OHVProtocolServer/.vs/

+ 14 - 0
Dev/OHV/OHV.Common/App.config

@@ -0,0 +1,14 @@
+<?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>
+    <providers>
+      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"/>
+    </providers>
+  </entityFramework>
+</configuration>

+ 40 - 0
Dev/OHV/OHV.Common/Model/Route.cs

@@ -0,0 +1,40 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+
+namespace OHV.Common.Model
+{
+    public class Route
+    {
+        public enum eRoadForm
+        {
+            Straight,
+            Curve,
+        }
+
+        public enum ePointType
+        {
+            LoadPort,
+            UnloadPort,
+            Charging,
+            Road, // 일반 길
+        }
+
+        [Key]
+        public int Id { get; set; }
+
+        [Index("Route_Name", IsUnique =true)]
+        public string Name { get; set; }
+        public string PrePoint { get; set; }
+        public string NextPoint { get; set; }
+        public eRoadForm Form { get; set; }
+        public ePointType Type { get; set; }
+        public double ScaleValue { get; set; }
+        public bool UserPIO { get; set; }
+
+    }
+}

+ 20 - 0
Dev/OHV/OHV.Common/OHV.Common.csproj

@@ -1,5 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="..\packages\EntityFramework.6.4.0\build\EntityFramework.props" Condition="Exists('..\packages\EntityFramework.6.4.0\build\EntityFramework.props')" />
   <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
   <PropertyGroup>
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -12,6 +13,8 @@
     <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
     <FileAlignment>512</FileAlignment>
     <Deterministic>true</Deterministic>
+    <NuGetPackageImportStamp>
+    </NuGetPackageImportStamp>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
     <DebugSymbols>true</DebugSymbols>
@@ -31,10 +34,17 @@
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
   <ItemGroup>
+    <Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
+      <HintPath>..\packages\EntityFramework.6.4.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.4.0\lib\net45\EntityFramework.SqlServer.dll</HintPath>
+    </Reference>
     <Reference Include="Prism, Version=7.2.0.1422, Culture=neutral, PublicKeyToken=40ee6c3a2184dc59, processorArchitecture=MSIL">
       <HintPath>..\packages\Prism.Core.7.2.0.1422\lib\net45\Prism.dll</HintPath>
     </Reference>
     <Reference Include="System" />
+    <Reference Include="System.ComponentModel.DataAnnotations" />
     <Reference Include="System.Core" />
     <Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
       <HintPath>..\packages\System.ValueTuple.4.5.0\lib\netstandard1.0\System.ValueTuple.dll</HintPath>
@@ -53,11 +63,21 @@
     <Compile Include="Interfaces\IVehicle.cs" />
     <Compile Include="Model\Command.cs" />
     <Compile Include="Model\Config.cs" />
+    <Compile Include="Model\Route.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="Shareds\SharedEnumType.cs" />
   </ItemGroup>
   <ItemGroup>
+    <None Include="App.config" />
     <None Include="packages.config" />
   </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
+    <PropertyGroup>
+      <ErrorText>이 프로젝트는 이 컴퓨터에 없는 NuGet 패키지를 참조합니다. 해당 패키지를 다운로드하려면 NuGet 패키지 복원을 사용하십시오. 자세한 내용은 http://go.microsoft.com/fwlink/?LinkID=322105를 참조하십시오. 누락된 파일은 {0}입니다.</ErrorText>
+    </PropertyGroup>
+    <Error Condition="!Exists('..\packages\EntityFramework.6.4.0\build\EntityFramework.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\EntityFramework.6.4.0\build\EntityFramework.props'))" />
+    <Error Condition="!Exists('..\packages\EntityFramework.6.4.0\build\EntityFramework.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\EntityFramework.6.4.0\build\EntityFramework.targets'))" />
+  </Target>
+  <Import Project="..\packages\EntityFramework.6.4.0\build\EntityFramework.targets" Condition="Exists('..\packages\EntityFramework.6.4.0\build\EntityFramework.targets')" />
 </Project>

+ 1 - 0
Dev/OHV/OHV.Common/packages.config

@@ -1,5 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <packages>
+  <package id="EntityFramework" version="6.4.0" targetFramework="net45" />
   <package id="Prism.Core" version="7.2.0.1422" targetFramework="net45" />
   <package id="System.ValueTuple" version="4.5.0" targetFramework="net45" />
 </packages>

+ 48 - 0
Dev/OHV/OHV.SqliteDAL/DAL/RouteDAL.cs

@@ -0,0 +1,48 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using OHV.Common.Model;
+
+namespace OHV.SqliteDAL.DAL
+{
+    public class RouteDAL
+    {
+        public RouteDAL()
+        {
+        }
+
+        public void Add(Route route)
+        {
+            using (var db = new OHVDbContext("OHVDb"))
+            {
+                db.Set<Route>().Add(route);
+                db.SaveChanges();
+            }
+        }
+
+        public Route GetConfig(string name)
+        {
+            Route route = null;
+
+            using (var db = new OHVDbContext("OHVDb"))
+            {
+                route = db.Set<Route>().Where(x => x.Name.Equals(name)).SingleOrDefault();
+            }
+
+            return route;
+        }
+
+        public int GetCount()
+        {
+            int count = 0;
+            using (var db = new OHVDbContext("OHVDb"))
+            {
+                count = db.Set<Route>().Count();
+            }
+
+            return count;
+        }
+    }
+}

+ 1 - 0
Dev/OHV/OHV.SqliteDAL/ModelConfiguration.cs

@@ -13,6 +13,7 @@ namespace OHV.SqliteDAL
         public static void Configure(DbModelBuilder modelBuilder )
         {
             modelBuilder.Entity<Config>();
+            modelBuilder.Entity<Route>();
         }
     }
 }

+ 1 - 0
Dev/OHV/OHV.SqliteDAL/OHV.SqliteDAL.csproj

@@ -56,6 +56,7 @@
   <ItemGroup>
     <Compile Include="CustomHistory.cs" />
     <Compile Include="DAL\ConfigDAL.cs" />
+    <Compile Include="DAL\RouteDAL.cs" />
     <Compile Include="ModelConfiguration.cs" />
     <Compile Include="OHVDbContext.cs" />
     <Compile Include="OHVDbInitializer.cs" />

binární
Dev/OHV/OHV.Vehicle/DB/OHVDb.sqlite


+ 4 - 0
Dev/OHV/OHV.Vehicle/MainWindow.xaml.cs

@@ -12,6 +12,7 @@ using System.Windows.Media;
 using System.Windows.Media.Imaging;
 using System.Windows.Navigation;
 using System.Windows.Shapes;
+using GSG.NET.WPF.Extensions;
 
 namespace OHV.Vehicle
 {
@@ -25,6 +26,7 @@ namespace OHV.Vehicle
         public MainWindow()
         {
             InitializeComponent();
+
             this.Loaded += MainWindow_Loaded;
             this.Closing += MainWindow_Closing;
         }
@@ -37,6 +39,8 @@ namespace OHV.Vehicle
         private void MainWindow_Loaded(object sender, RoutedEventArgs e)
         {
             this.ViewModel.InitViewModel();
+
+            this.MaximizeToFirstMonitor();
         }
 
     }

+ 3 - 0
Dev/OHV/OHV.Vehicle/OHV.Vehicle.csproj

@@ -49,6 +49,9 @@
     <Reference Include="GSG.NET">
       <HintPath>..\Assambly\GSG.NET.dll</HintPath>
     </Reference>
+    <Reference Include="GSG.NET.WPF">
+      <HintPath>..\Assambly\GSG.NET.WPF.dll</HintPath>
+    </Reference>
     <Reference Include="log4net">
       <HintPath>..\Assambly\log4net.dll</HintPath>
     </Reference>

+ 2 - 0
Dev/OHV/VehicleControlSystem/Managers/SqlManager.cs

@@ -11,9 +11,11 @@ namespace VehicleControlSystem.Managers
     public class SqlManager : SingletonBase<SqlManager>
     {
         public ConfigDAL ConfigDal { get; set; }
+        public RouteDAL RouteDal { get; set; }
         private SqlManager()
         {
             this.ConfigDal = new ConfigDAL();
+            this.RouteDal = new RouteDAL();
         }
     }
 }

+ 2 - 0
Dev/OHV/VehicleControlSystem/VCSystem.cs

@@ -40,6 +40,8 @@ namespace VehicleControlSystem
 
             this.scheduler = new Scheduler(eventAggregator);
             this.scheduler.Init();
+
+            //SqlManager.Instance.RouteDal.Add(new Route {Id=1, Name="P01", PrePoint="P10", NextPoint="P02", Form=Route.eRoadForm.Straight, Type=Route.ePointType.Charging, ScaleValue=0.005, UserPIO=false });
         }
 
         public void Dispose()