Explorar el Código

Sql Sington 수정, Comamnd List View, Sub Command List View 추가

SK.Kang hace 6 años
padre
commit
2c6bef84f7

+ 1 - 0
Dev/OHV/OHV.Common/Events/MessageEventArgs.cs

@@ -162,4 +162,5 @@ namespace OHV.Common.Events
         public eEventDir EventDir { get; set; }
         public object Args { get; set; }
     }
+
 }

+ 1 - 0
Dev/OHV/OHV.Common/Events/PubSubEvent.cs

@@ -22,5 +22,6 @@ namespace OHV.Common.Events
 
     public class IOControlPubSubEvent : PubSubEvent<IOControlEventArgs> { }
     public class VehicleCommandListChanged : PubSubEvent<string> { }
+    public class VehicleSubCmdListChanged : PubSubEvent<string> { }
 
 }

+ 5 - 0
Dev/OHV/OHV.Common/Model/SubCmd.cs

@@ -35,6 +35,7 @@ namespace OHV.Common.Model
         public SubCmd()
         {
             ID = $"{Guid.NewGuid()}_{DateTime.Now.ToString("HHmmssfff")}";
+            this.CreateTime = DateTime.Now;
         }
 
         public string ID { get; set; }
@@ -45,6 +46,10 @@ namespace OHV.Common.Model
         public eType Type { get; set; }
 
         public eCmdType CmdType { get; set; }
+        public eSubCmdState State { get; set; }
+        public DateTime CreateTime { get; set; }
+
+        public virtual bool IsSelected { get; set; }
 
     }
 }

+ 2 - 0
Dev/OHV/OHV.Common/Shareds/RegionNames.cs

@@ -11,5 +11,7 @@ namespace OHV.Common.Shareds
         public const string MainView = "MainView";
         public const string VehicleCommandList = "VehicleCommandList";
         public const string VehicleCommandListSub = "VehicleCommandListSub";
+
+        public const string VehicleSubCmdList = "VehicleSubCmdList";
     }
 }

+ 2 - 0
Dev/OHV/OHV.Module.ListViews/ListViewController.cs

@@ -18,11 +18,13 @@ namespace OHV.Module.ListViews
         public void OnInitialized(IContainerProvider containerProvider)
         {
             ViewModelLocationProvider.Register<CommandListView, CommandListViewModel>();
+            ViewModelLocationProvider.Register<SubCommandListView, SubCommandListViewModel>();
             //ViewModelLocationProvider.Register<VehicleCommandDeleteView, VehicleCommandDeleteViewModel>();
             //ViewModelLocationProvider.Register<VehicleCommandInsertView, VehicleCommandInsertViewModel>();
 
             var regionManager = containerProvider.Resolve<IRegionManager>();
             regionManager.RegisterViewWithRegion(RegionNames.VehicleCommandList, typeof(CommandListView));
+            regionManager.RegisterViewWithRegion(RegionNames.VehicleSubCmdList, typeof(SubCommandListView));
             //regionManager.RegisterViewWithRegion(RegionNames.VehicleCommandListSub, typeof(VehicleCommandDeleteView));
             //regionManager.RegisterViewWithRegion(RegionNames.VehicleCommandListSub, typeof(VehicleCommandInsertView));
         }

+ 10 - 0
Dev/OHV/OHV.Module.ListViews/OHV.Module.ListViews.csproj

@@ -93,6 +93,12 @@
     <Compile Include="Views\CommandListViewModel.cs">
       <DependentUpon>CommandListView.xaml</DependentUpon>
     </Compile>
+    <Compile Include="Views\SubCommandListView.xaml.cs">
+      <DependentUpon>SubCommandListView.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="Views\SubCommandListViewModel.cs">
+      <DependentUpon>SubCommandListView.xaml</DependentUpon>
+    </Compile>
   </ItemGroup>
   <ItemGroup>
     <None Include="packages.config" />
@@ -110,6 +116,10 @@
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
+    <Page Include="Views\SubCommandListView.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
   </ItemGroup>
   <ItemGroup>
     <ProjectReference Include="..\OHV.Common\OHV.Common.csproj">

+ 7 - 3
Dev/OHV/OHV.Module.ListViews/Views/CommandListView.xaml

@@ -10,7 +10,7 @@
              xmlns:System="clr-namespace:System;assembly=mscorlib"
              xmlns:Shared="clr-namespace:OHV.Common.Shareds;assembly=OHV.Common"
              mc:Ignorable="d" 
-             d:DesignHeight="600" d:DesignWidth="800" Foreground="White">
+             d:DesignHeight="400" d:DesignWidth="800" Foreground="White">
 
     <UserControl.Resources>
         <ResourceDictionary>
@@ -49,7 +49,7 @@
                 <ColumnDefinition Width="*"/>
             </Grid.ColumnDefinitions>
             <DataGrid ItemsSource="{Binding CommandList}" CanUserSortColumns="True" CanUserAddRows="False" AutoGenerateColumns="False" materialDesign:DataGridAssist.CellPadding="13 8 8 8" 
-                                  materialDesign:DataGridAssist.ColumnHeaderPadding="8" Background="{x:Null}" Foreground="White" IsReadOnly="True">
+                                  materialDesign:DataGridAssist.ColumnHeaderPadding="8" Background="{x:Null}" Foreground="White" IsReadOnly="True" >
 
                 <DataGrid.Resources>
                     <Style TargetType="{x:Type DataGridRow}">
@@ -59,10 +59,14 @@
                             </Trigger>
                         </Style.Triggers>
                     </Style>
+                    <!--<Style TargetType="{x:Type DataGridColumnHeader}">
+                        <Setter Property="Foreground" Value="White"/>
+                        <Setter Property="Background" Value="Transparent"/>
+                    </Style>-->
                 </DataGrid.Resources>
 
                 <DataGrid.Columns>
-                    <DataGridTemplateColumn >
+                    <DataGridTemplateColumn>
                         <DataGridTemplateColumn.CellTemplate>
                             <DataTemplate>
                                 <CheckBox IsChecked="{Binding IsSelected, UpdateSourceTrigger=PropertyChanged}"></CheckBox>

+ 15 - 9
Dev/OHV/OHV.Module.ListViews/Views/CommandListViewModel.cs

@@ -4,6 +4,7 @@ using System.Collections.ObjectModel;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using System.Windows;
 using System.Windows.Input;
 using OHV.Common.Events;
 using OHV.Common.Model;
@@ -59,6 +60,7 @@ namespace OHV.Module.ListViews.Views
         {
             this.eventAggregator = ea;
             this.sql = sql;
+            this.sql.CommandDAL.ChangedProperty += this.RefreshCommandLIst;
 
             this.CommandList = new ObservableCollection<Command>(sql.CommandDAL.All);
 
@@ -68,28 +70,28 @@ namespace OHV.Module.ListViews.Views
             this.SaveCommand = new DelegateCommand(ExecuteSaveCommand);
             this.DeleteCommand = new DelegateCommand(ExecuteDeleteCommand);
 
-
             this.eventAggregator.GetEvent<VehicleCommandListChanged>().Unsubscribe(UICallbackCommunication);
-            this.eventAggregator.GetEvent<VehicleCommandListChanged>().Subscribe(UICallbackCommunication);
+            this.eventAggregator.GetEvent<VehicleCommandListChanged>().Subscribe(UICallbackCommunication, ThreadOption.UIThread);
         }
 
         private void UICallbackCommunication(string obj)
         {
-            this.CommandList.Clear();
-            this.CommandList.AddRange(sql.CommandDAL.All);
+            //RefreshCommandLIst(null, null);
         }
 
         private void ExecuteDeleteCommand()
         {
+            List<Command> deleteList = new List<Command>();
             foreach (var item in this.CommandList)
             {
                 if (item.IsSelected)
                 {
-                    this.sql.CommandDAL.Delete(item);
+                    deleteList.Add(item);
                 }
             }
 
-            RefreshCommandLIst();
+            deleteList.ForEach(x => { this.sql.CommandDAL.Delete(x); });
+            //RefreshCommandLIst();
         }
 
         private void ExecuteSaveCommand()
@@ -97,13 +99,17 @@ namespace OHV.Module.ListViews.Views
             Command cmd = new Command() { TargetID = TargetID, Type = SelectedCommandType };
             sql.CommandDAL.Add(cmd);
 
-            this.RefreshCommandLIst();
+            this.TargetID = "None";
+            this.SelectedCommandType = eCommandType.Move;
         }
 
         void RefreshCommandLIst()
         {
-            this.CommandList.Clear();
-            this.CommandList.AddRange(sql.CommandDAL.All);
+            Application.Current.Dispatcher.Invoke(() =>
+            {
+                this.CommandList.Clear();
+                this.CommandList.AddRange(sql.CommandDAL.All);
+            });
         }
 
     }

+ 122 - 0
Dev/OHV/OHV.Module.ListViews/Views/SubCommandListView.xaml

@@ -0,0 +1,122 @@
+<UserControl x:Class="OHV.Module.ListViews.Views.SubCommandListView"
+             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
+             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
+             xmlns:local="clr-namespace:OHV.Module.ListViews.Views"
+             mc:Ignorable="d" 
+             xmlns:prism="http://prismlibrary.com/"
+             prism:ViewModelLocator.AutoWireViewModel="True"
+             xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
+             d:DesignHeight="450" d:DesignWidth="800" Foreground="White">
+
+    <UserControl.Resources>
+        <ResourceDictionary>
+            <!--<ObjectDataProvider x:Key="CommandType" MethodName="GetValues"
+                            ObjectType="{x:Type System:Enum}">
+                <ObjectDataProvider.MethodParameters>
+                    <x:Type TypeName="Shared:eCommandType"/>
+                </ObjectDataProvider.MethodParameters>
+            </ObjectDataProvider>
+            <ObjectDataProvider x:Key="CommandState" MethodName="GetValues"
+                            ObjectType="{x:Type System:Enum}">
+                <ObjectDataProvider.MethodParameters>
+                    <x:Type TypeName="Shared:eCommandState"/>
+                </ObjectDataProvider.MethodParameters>
+            </ObjectDataProvider>-->
+
+            <ResourceDictionary.MergedDictionaries>
+                <ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.DataGrid.xaml" />
+                <ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Light.xaml" />
+                <ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml" />
+                <ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.DeepPurple.xaml" />
+                <ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Accent/MaterialDesignColor.Lime.xaml" />
+            </ResourceDictionary.MergedDictionaries>
+        </ResourceDictionary>
+    </UserControl.Resources>
+
+    <Grid Background="#263238" >
+        <Grid.RowDefinitions>
+            <RowDefinition Height="40"/>
+            <RowDefinition Height="*"/>
+        </Grid.RowDefinitions>
+        <TextBlock VerticalAlignment="Center" FontSize="20" Margin="10,0,0,0">SubCommand List</TextBlock>
+        <Grid Grid.Row="1">
+            <Grid.ColumnDefinitions>
+                <ColumnDefinition Width="2*"/>
+                <ColumnDefinition Width="*"/>
+            </Grid.ColumnDefinitions>
+            <DataGrid ItemsSource="{Binding CommandList}" CanUserSortColumns="True" CanUserAddRows="False" AutoGenerateColumns="False" materialDesign:DataGridAssist.CellPadding="13 8 8 8" 
+                                  materialDesign:DataGridAssist.ColumnHeaderPadding="8" Background="{x:Null}" Foreground="White" IsReadOnly="True" >
+
+                <DataGrid.Resources>
+                    <Style TargetType="{x:Type DataGridRow}">
+                        <Style.Triggers>
+                            <Trigger Property="IsSelected" Value="false">
+                                <Setter Property="Background" Value="{x:Null}"></Setter>
+                            </Trigger>
+                        </Style.Triggers>
+                    </Style>
+                </DataGrid.Resources>
+
+                <DataGrid.Columns>
+                    <DataGridTemplateColumn>
+                        <DataGridTemplateColumn.CellTemplate>
+                            <DataTemplate>
+                                <CheckBox IsChecked="{Binding IsSelected, UpdateSourceTrigger=PropertyChanged}"></CheckBox>
+                            </DataTemplate>
+                        </DataGridTemplateColumn.CellTemplate>
+                    </DataGridTemplateColumn>
+
+                    <materialDesign:DataGridTextColumn Header="ID" Binding="{Binding ID}" EditingElementStyle="{StaticResource MaterialDesignDataGridTextColumnPopupEditingStyle}"></materialDesign:DataGridTextColumn>
+                    <materialDesign:DataGridTextColumn Header="Type" Binding="{Binding Type}" EditingElementStyle="{StaticResource MaterialDesignDataGridTextColumnPopupEditingStyle}"></materialDesign:DataGridTextColumn>
+                    <materialDesign:DataGridTextColumn Header="State" Binding="{Binding State}" EditingElementStyle="{StaticResource MaterialDesignDataGridTextColumnPopupEditingStyle}"></materialDesign:DataGridTextColumn>
+                    <materialDesign:DataGridTextColumn Header="CreateTime" Binding="{Binding CreateTime}" EditingElementStyle="{StaticResource MaterialDesignDataGridTextColumnPopupEditingStyle}"></materialDesign:DataGridTextColumn>
+
+                </DataGrid.Columns>
+            </DataGrid>
+
+            <Grid Background="#263238" Grid.Column="1">
+                <Grid.RowDefinitions>
+                    <RowDefinition Height="30"/>
+                    <RowDefinition Height="Auto"/>
+                    <RowDefinition Height="*"/>
+                </Grid.RowDefinitions>
+                <TextBlock Text="Delete" Style="{DynamicResource MaterialDesignTextBlock}" Foreground="Orange" VerticalAlignment="Center" Margin="10,0"/>
+
+                <Grid Grid.Row="1" Margin="20,10,20,15" VerticalAlignment="Center" Background="#263238">
+                    <Grid.RowDefinitions>
+                        <RowDefinition Height="*"/>
+                        <RowDefinition Height="*"/>
+                    </Grid.RowDefinitions>
+
+                    <Grid Margin="0,10,0,0" Grid.Row="0" Height="25" Background="#263238">
+                        <Grid.ColumnDefinitions>
+                            <ColumnDefinition Width="120"/>
+                            <ColumnDefinition Width="*"/>
+                        </Grid.ColumnDefinitions>
+                        <TextBlock Text="ID" Style="{DynamicResource MaterialDesignTextBlock}" VerticalAlignment="Center"/>
+                        <TextBlock Grid.Column="1" Style="{DynamicResource MaterialDesignTextBlock}" VerticalAlignment="Center" HorizontalAlignment="Center" Text="{Binding SelectedSubCmdID, Mode=OneWay}"/>
+                    </Grid>
+
+                    <Grid Margin="0,10,0,0" Grid.Row="1" Height="25">
+                        <Grid.ColumnDefinitions>
+                            <ColumnDefinition Width="120"/>
+                            <ColumnDefinition Width="*"/>
+                        </Grid.ColumnDefinitions>
+                        <TextBlock Text="Type" Style="{DynamicResource MaterialDesignTextBlock}" VerticalAlignment="Center"/>
+                        <TextBlock Grid.Column="1" Style="{DynamicResource MaterialDesignTextBlock}" VerticalAlignment="Center" HorizontalAlignment="Center" Text="{Binding SelectedSubCmdType, Mode=OneWay}"/>
+                    </Grid>
+
+                </Grid>
+
+                <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Grid.Row="2" VerticalAlignment="Top" Margin="0,15,0,0">
+                    <Button Height="45" Content="Delete" Command="{Binding DeleteCommand}" Width="100"/>
+                </StackPanel>
+            </Grid>
+
+
+        </Grid>
+
+    </Grid>
+</UserControl>

+ 28 - 0
Dev/OHV/OHV.Module.ListViews/Views/SubCommandListView.xaml.cs

@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace OHV.Module.ListViews.Views
+{
+    /// <summary>
+    /// SubCommandListView.xaml에 대한 상호 작용 논리
+    /// </summary>
+    public partial class SubCommandListView : UserControl
+    {
+        public SubCommandListView()
+        {
+            InitializeComponent();
+        }
+    }
+}

+ 80 - 0
Dev/OHV/OHV.Module.ListViews/Views/SubCommandListViewModel.cs

@@ -0,0 +1,80 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Input;
+using OHV.Common.Events;
+using OHV.Common.Model;
+using OHV.SqliteDAL;
+using Prism.Commands;
+using Prism.Events;
+using Prism.Mvvm;
+
+namespace OHV.Module.ListViews.Views
+{
+    public class SubCommandListViewModel : BindableBase
+    {
+        #region Properties
+        private ObservableCollection<SubCmd> _subcmdList;
+        public ObservableCollection<SubCmd> SubCmdList
+        {
+            get { return this._subcmdList; }
+            set { SetProperty(ref this._subcmdList, value); }
+        }
+        #endregion
+
+        public ICommand DeleteCommand { get; set; }
+
+        IEventAggregator eventAggregator;
+        SqliteManager sql;
+
+        public SubCommandListViewModel(IEventAggregator ea, SqliteManager sql)
+        {
+            this.eventAggregator = ea;
+            this.sql = sql;
+            this.sql.SubCmdDAL.ChangedProperty += SubCmdDAL_ChangedProperty;
+
+            this.SubCmdList = new ObservableCollection<SubCmd>(sql.SubCmdDAL.All);
+
+            this.DeleteCommand = new DelegateCommand(ExecuteDeleteCommand);
+
+            this.eventAggregator.GetEvent<VehicleSubCmdListChanged>().Unsubscribe(UICallbackCommunication);
+            this.eventAggregator.GetEvent<VehicleSubCmdListChanged>().Subscribe(UICallbackCommunication);
+        }
+
+        private void SubCmdDAL_ChangedProperty()
+        {
+            RefreshLIst();
+        }
+
+        private void UICallbackCommunication(string obj)
+        {
+            this.RefreshLIst();
+        }
+
+        private void ExecuteDeleteCommand()
+        {
+            List<SubCmd> deleteList = new List<SubCmd>();
+            foreach (var item in this.SubCmdList)
+            {
+                if (item.IsSelected)
+                {
+                    deleteList.Add(item);
+                }
+            }
+            deleteList.ForEach(x => { this.sql.SubCmdDAL.Delete(x); });
+        }
+
+        void RefreshLIst()
+        {
+            Application.Current.Dispatcher.Invoke(() =>
+            {
+                this.SubCmdList.Clear();
+                this.SubCmdList.AddRange(sql.SubCmdDAL.All);
+            });
+        }
+    }
+}

+ 4 - 3
Dev/OHV/OHV.Module.MainViews/Views/AutoView.xaml

@@ -23,9 +23,10 @@
                 <RowDefinition Height="1*" />
             </Grid.RowDefinitions>
 
-            <Grid Grid.Row="0">
-                <ContentControl prism:RegionManager.RegionName="{x:Static OHVCommonShareds:RegionNames.VehicleCommandList}" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Width="auto" Height="auto"/>
-            </Grid>
+            <ContentControl Grid.Row="0" prism:RegionManager.RegionName="{x:Static OHVCommonShareds:RegionNames.VehicleCommandList}" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Width="auto" Height="auto"/>
+            <GridSplitter Height="3" VerticalAlignment="Bottom" HorizontalAlignment="Stretch" Background="Gray"></GridSplitter>
+            <ContentControl Grid.Row="1" prism:RegionManager.RegionName="{x:Static OHVCommonShareds:RegionNames.VehicleSubCmdList}" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Width="auto" Height="auto"/>
+            <GridSplitter Grid.Row="1" Height="3" VerticalAlignment="Bottom" HorizontalAlignment="Stretch" Background="Gray"></GridSplitter>
         </Grid>
 
     </Grid>

+ 12 - 5
Dev/OHV/OHV.SqliteDAL/DAL/AbstractDAL.cs

@@ -19,6 +19,14 @@ namespace OHV.SqliteDAL.DAL
 
     public class GenericDAL<T> where T : class
     {
+        public delegate void DlgChangedProperty();
+        public event DlgChangedProperty ChangedProperty;
+
+        protected virtual void OnChangedPropertiy()
+        {
+            ChangedProperty?.BeginInvoke(null, null);
+        }
+
         public List<T> All
         {
             get
@@ -67,6 +75,7 @@ namespace OHV.SqliteDAL.DAL
                 db.Set<T>().Add(entity);
                 db.SaveChanges();
             }
+            OnChangedPropertiy();
         }
 
         public void Delete(T entity)
@@ -77,6 +86,7 @@ namespace OHV.SqliteDAL.DAL
                 //db.Set<T>().Remove(entity);
                 db.SaveChanges();
             }
+            OnChangedPropertiy();
         }
 
         public virtual void Update(T entity)
@@ -86,13 +96,9 @@ namespace OHV.SqliteDAL.DAL
                 db.Entry(entity).State = EntityState.Modified;
                 db.SaveChanges();
             }
+            OnChangedPropertiy();
         }
 
-        //protected int DeleteN(Expression<Func<T, bool>> where)
-        //{
-
-        //}
-
         public void Clean()
         {
             using (var db = new OHVDbContext("OHVDb"))
@@ -100,6 +106,7 @@ namespace OHV.SqliteDAL.DAL
                 db.Set<T>().RemoveRange(db.Set<T>());
                 db.SaveChanges();
             }
+            OnChangedPropertiy();
         }
     }
 

+ 7 - 7
Dev/OHV/OHV.SqliteDAL/DAL/CommandDAL.cs

@@ -1,5 +1,6 @@
 using System;
 using System.Collections.Generic;
+using System.Data.Entity;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
@@ -8,7 +9,7 @@ using OHV.Common.Shareds;
 
 namespace OHV.SqliteDAL.DAL
 {
-    public class CommandDAL : GenericDAL<Command>
+    public class CommandDAL :GenericDAL<Command>
     {
         public Command GetCmd()
         {
@@ -22,12 +23,10 @@ namespace OHV.SqliteDAL.DAL
 
         public void UpdateState(string id, eCommandState state)
         {
-            using (var db = new OHVDbContext("OHVDb"))
-            {
-                var cmd = db.Set<Command>().Where(c => c.CommandID.Equals(id)).SingleOrDefault();
-                cmd.State = state;
-                db.SaveChanges();
-            }
+            var cmd = GetK(id);
+            cmd.State = state;
+            Update(cmd);
+            base.OnChangedPropertiy();
         }
 
         public void UpdateResult(string id, eCommandResult result)
@@ -38,6 +37,7 @@ namespace OHV.SqliteDAL.DAL
                 cmd.Result = result;
                 db.SaveChanges();
             }
+            base.OnChangedPropertiy();
         }
 
         public int GetCount()

+ 1 - 48
Dev/OHV/OHV.SqliteDAL/DAL/SubCmdDAL.cs

@@ -7,28 +7,8 @@ using OHV.Common.Model;
 
 namespace OHV.SqliteDAL.DAL
 {
-    public class SubCmdDAL
+    public class SubCmdDAL : GenericDAL<SubCmd>
     {
-        public void Add(SubCmd subCmd)
-        {
-            using (var db = new OHVDbContext("OHVDb"))
-            {
-                db.Set<SubCmd>().Add(subCmd);
-                db.SaveChanges();
-            }
-        }
-
-        public int GetCount()
-        {
-            int count = 0;
-            using (var db = new OHVDbContext("OHVDb"))
-            {
-                count = db.Set<SubCmd>().Count();
-            }
-
-            return count;
-        }
-
         public SubCmd GetSubCmd()
         {
             SubCmd sub;
@@ -38,32 +18,5 @@ namespace OHV.SqliteDAL.DAL
             }
             return sub;
         }
-
-        public void Clean()
-        {
-            using (var db = new OHVDbContext("OHVDb"))
-            {
-                db.Set<SubCmd>().RemoveRange(db.Set<SubCmd>());
-                db.SaveChanges();
-            }
-        }
-
-        public void Delete(SubCmd sub)
-        {
-            using (var db = new OHVDbContext("OHVDb"))
-            {
-                db.Set<SubCmd>().Remove(sub);
-                db.SaveChanges();
-            }
-        }
-
-        public void Update(SubCmd sub)
-        {
-            using (var db = new OHVDbContext("OHVDb"))
-            {
-                db.Set<SubCmd>().Remove(sub);
-                db.SaveChanges();
-            }
-        }
     }
 }

+ 16 - 0
Dev/OHV/OHV.SqliteDAL/OHVDbContext.cs

@@ -10,6 +10,9 @@ namespace OHV.SqliteDAL
 {
     public class OHVDbContext : DbContext
     {
+        //public delegate void ChangeEventHandler(object sender);
+        //public event ChangeEventHandler ChangeEvent;
+
         public OHVDbContext( string nameOrConnectionString ) : base( nameOrConnectionString )
         {
             Configure();
@@ -34,5 +37,18 @@ namespace OHV.SqliteDAL
             //base.OnModelCreating( modelBuilder );
         }
 
+        //public override int SaveChanges()
+        //{
+        //    var result = base.SaveChanges();
+
+        //    var entitiesAdded = ChangeTracker.Entries().Where(x => x.State == EntityState.Added);
+        //    var entitiesRemoved = this.ChangeTracker.Entries().Where(x => x.State == EntityState.Deleted);
+        //    var entitiesModified = this.ChangeTracker.Entries().Where(x => x.State == EntityState.Modified);
+
+        //    ChangeEvent(this);
+
+        //    return result;
+        //}
+
     }
 }

+ 3 - 3
Dev/OHV/OHV.SqliteDAL/SqliteManager.cs

@@ -10,7 +10,7 @@ using Prism.Modularity;
 
 namespace OHV.SqliteDAL
 {
-    [Module(ModuleName = "SqlManager")]
+    [Module(ModuleName = "SqliteManager")]
     public class SqliteManager : ISqlManager, IModule
     {
         public ConfigDAL ConfigDal { get; set; }
@@ -38,8 +38,8 @@ namespace OHV.SqliteDAL
 
         public void RegisterTypes(IContainerRegistry containerRegistry)
         {
-            if (!containerRegistry.IsRegistered<ISqlManager>())
-                containerRegistry.RegisterSingleton<ISqlManager, SqliteManager>();
+            if (!containerRegistry.IsRegistered<SqliteManager>())
+                containerRegistry.RegisterSingleton<SqliteManager>();
         }
 
         public void OnInitialized(IContainerProvider containerProvider)

+ 2 - 2
Dev/OHV/OHV.Vehicle/App.xaml.cs

@@ -107,8 +107,8 @@ namespace OHV.Vehicle
             if ( !containerRegistry.IsRegistered<VCSystem>() )
                 containerRegistry.RegisterSingleton<VCSystem>();
 
-            if (!containerRegistry.IsRegistered<ISqlManager>())
-                containerRegistry.RegisterSingleton<ISqlManager, SqliteManager>();
+            if (!containerRegistry.IsRegistered<SqliteManager>())
+                containerRegistry.RegisterSingleton<SqliteManager>();
         }
 
         protected override void ConfigureViewModelLocator()

+ 1 - 1
Dev/OHV/OHV.Vehicle/Concept/D_MainWindow.xaml

@@ -115,7 +115,7 @@
             </Grid.ColumnDefinitions>
 
             <Grid Grid.Column="0" Background="#263238">
-                <ContentControl prism:RegionManager.RegionName="{x:Static OHVCommonShareds:RegionNames.MainView}" VerticalAlignment="Bottom" HorizontalAlignment="Stretch" Width="auto" Height="auto"/>
+                <ContentControl prism:RegionManager.RegionName="{x:Static OHVCommonShareds:RegionNames.MainView}" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Width="auto" Height="auto"/>
             </Grid>
 
             <Grid Grid.Column="1" Background="#263238">

BIN
Dev/OHV/OutRelese/VehicleControlSystem.pdb


+ 1 - 1
Dev/OHV/VehicleControlSystem/Managers/Scheduler.cs

@@ -132,7 +132,7 @@ namespace VehicleControlSystem.Managers
             switch (cmd.State)
             {
                 case OHV.Common.Shareds.eCommandState.Queued:
-                    if (sql.SubCmdDAL.GetCount() <= 0)
+                    if (sql.SubCmdDAL.Count <= 0)
                     {
                         switch (cmd.Type)
                         {