From 533c67339be511fc32e645c450201522ea4d5dfb Mon Sep 17 00:00:00 2001 From: wells.liu <wells.liu@broconcentric.com> Date: 星期三, 24 六月 2020 14:56:42 +0800 Subject: [PATCH] 添加 四个项目 --- src/Bro.Device.GTSCard/Bro.Device.GTSCard.csproj | 48 + src/Bro.M071.Process.DBManager/Properties/AssemblyInfo.cs | 36 src/Bro.M071.Process.Model/BaseModel.cs | 201 ++++ src/Bro.M071.Process.Model/Properties/AssemblyInfo.cs | 36 src/Bro.Process.DBManager/ModelManager.cs | 113 ++ src/Bro.Process.DBManager/App.config | 36 src/Bro.M071.Process.Model/Bro.M071.Process.Model.csproj | 95 ++ src/Bro.M071.Process.Model/packages.config | 10 src/Bro.Process.DBManager/Properties/AssemblyInfo.cs | 36 src/Bro.M071.Process.DBManager/ProductionDetectionRecordsDetailManager.cs | 248 +++++ src/Bro.Device.GTSCard/Properties/AssemblyInfo.cs | 36 src/Bro.M071.Process.DBManager/Bro.M071.Process.DBManager.csproj | 103 ++ src/Bro.M071.Process.Model/Model/ManualDetectionRecords.cs | 58 + src/Bro.M071.Process.Model/Migrations/Configuration.cs | 37 src/Bro.Process.DBManager/Bro.Process.DBManager.csproj | 102 ++ src/Bro.M071.Process.Model/Model/EventTimeRecords.cs | 52 + src/Bro.M071.Process.Model/Model/OperationRecords.cs | 60 + src/Bro.Process.DBManager/packages.config | 10 src/Bro.M071.Process.DBManager/App.config | 36 M071.sln | 56 + src/Bro.Process.DBManager/SQLiteHelper.cs | 614 +++++++++++++ src/Bro.M071.Process.DBManager/ProductionDetectionImageRecordsManager.cs | 303 ++++++ src/Bro.Device.GTSCard/Class1.cs | 12 src/Bro.M071.Process.Model/App.config | 43 src/Bro.M071.Process.DBManager/packages.config | 10 src/Bro.M071.Process.Model/DBModel.cs | 67 + src/Bro.M071.Process.DBManager/ProductionDetectionRecordsManager.cs | 305 ++++++ 27 files changed, 2,763 insertions(+), 0 deletions(-) diff --git a/M071.sln b/M071.sln index e7bed2c..30b6272 100644 --- a/M071.sln +++ b/M071.sln @@ -19,6 +19,14 @@ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bro.UI.Model.Winform", "src\Bro.UI.Model.Winform\Bro.UI.Model.Winform.csproj", "{741F6491-57C7-479A-B391-09BBA9FBA9DC}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bro.Device.GTSCard", "src\Bro.Device.GTSCard\Bro.Device.GTSCard.csproj", "{B536003E-70BA-4701-B8FD-BAFA303AB4E2}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bro.M071.Process.DBManager", "src\Bro.M071.Process.DBManager\Bro.M071.Process.DBManager.csproj", "{230B0FFF-F6AF-45FE-AAF7-B4B66250DD58}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bro.M071.Process.Model", "src\Bro.M071.Process.Model\Bro.M071.Process.Model.csproj", "{AD645C48-5811-4B1E-B81F-D35D5E6B577F}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bro.Process.DBManager", "src\Bro.Process.DBManager\Bro.Process.DBManager.csproj", "{65302D6E-9918-4E4C-92B4-75C8830C6BA7}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -125,6 +133,54 @@ {741F6491-57C7-479A-B391-09BBA9FBA9DC}.Release|x64.Build.0 = Release|Any CPU {741F6491-57C7-479A-B391-09BBA9FBA9DC}.Release|x86.ActiveCfg = Release|Any CPU {741F6491-57C7-479A-B391-09BBA9FBA9DC}.Release|x86.Build.0 = Release|Any CPU + {B536003E-70BA-4701-B8FD-BAFA303AB4E2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B536003E-70BA-4701-B8FD-BAFA303AB4E2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B536003E-70BA-4701-B8FD-BAFA303AB4E2}.Debug|x64.ActiveCfg = Debug|Any CPU + {B536003E-70BA-4701-B8FD-BAFA303AB4E2}.Debug|x64.Build.0 = Debug|Any CPU + {B536003E-70BA-4701-B8FD-BAFA303AB4E2}.Debug|x86.ActiveCfg = Debug|Any CPU + {B536003E-70BA-4701-B8FD-BAFA303AB4E2}.Debug|x86.Build.0 = Debug|Any CPU + {B536003E-70BA-4701-B8FD-BAFA303AB4E2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B536003E-70BA-4701-B8FD-BAFA303AB4E2}.Release|Any CPU.Build.0 = Release|Any CPU + {B536003E-70BA-4701-B8FD-BAFA303AB4E2}.Release|x64.ActiveCfg = Release|Any CPU + {B536003E-70BA-4701-B8FD-BAFA303AB4E2}.Release|x64.Build.0 = Release|Any CPU + {B536003E-70BA-4701-B8FD-BAFA303AB4E2}.Release|x86.ActiveCfg = Release|Any CPU + {B536003E-70BA-4701-B8FD-BAFA303AB4E2}.Release|x86.Build.0 = Release|Any CPU + {230B0FFF-F6AF-45FE-AAF7-B4B66250DD58}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {230B0FFF-F6AF-45FE-AAF7-B4B66250DD58}.Debug|Any CPU.Build.0 = Debug|Any CPU + {230B0FFF-F6AF-45FE-AAF7-B4B66250DD58}.Debug|x64.ActiveCfg = Debug|Any CPU + {230B0FFF-F6AF-45FE-AAF7-B4B66250DD58}.Debug|x64.Build.0 = Debug|Any CPU + {230B0FFF-F6AF-45FE-AAF7-B4B66250DD58}.Debug|x86.ActiveCfg = Debug|Any CPU + {230B0FFF-F6AF-45FE-AAF7-B4B66250DD58}.Debug|x86.Build.0 = Debug|Any CPU + {230B0FFF-F6AF-45FE-AAF7-B4B66250DD58}.Release|Any CPU.ActiveCfg = Release|Any CPU + {230B0FFF-F6AF-45FE-AAF7-B4B66250DD58}.Release|Any CPU.Build.0 = Release|Any CPU + {230B0FFF-F6AF-45FE-AAF7-B4B66250DD58}.Release|x64.ActiveCfg = Release|Any CPU + {230B0FFF-F6AF-45FE-AAF7-B4B66250DD58}.Release|x64.Build.0 = Release|Any CPU + {230B0FFF-F6AF-45FE-AAF7-B4B66250DD58}.Release|x86.ActiveCfg = Release|Any CPU + {230B0FFF-F6AF-45FE-AAF7-B4B66250DD58}.Release|x86.Build.0 = Release|Any CPU + {AD645C48-5811-4B1E-B81F-D35D5E6B577F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AD645C48-5811-4B1E-B81F-D35D5E6B577F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AD645C48-5811-4B1E-B81F-D35D5E6B577F}.Debug|x64.ActiveCfg = Debug|Any CPU + {AD645C48-5811-4B1E-B81F-D35D5E6B577F}.Debug|x64.Build.0 = Debug|Any CPU + {AD645C48-5811-4B1E-B81F-D35D5E6B577F}.Debug|x86.ActiveCfg = Debug|Any CPU + {AD645C48-5811-4B1E-B81F-D35D5E6B577F}.Debug|x86.Build.0 = Debug|Any CPU + {AD645C48-5811-4B1E-B81F-D35D5E6B577F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AD645C48-5811-4B1E-B81F-D35D5E6B577F}.Release|Any CPU.Build.0 = Release|Any CPU + {AD645C48-5811-4B1E-B81F-D35D5E6B577F}.Release|x64.ActiveCfg = Release|Any CPU + {AD645C48-5811-4B1E-B81F-D35D5E6B577F}.Release|x64.Build.0 = Release|Any CPU + {AD645C48-5811-4B1E-B81F-D35D5E6B577F}.Release|x86.ActiveCfg = Release|Any CPU + {AD645C48-5811-4B1E-B81F-D35D5E6B577F}.Release|x86.Build.0 = Release|Any CPU + {65302D6E-9918-4E4C-92B4-75C8830C6BA7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {65302D6E-9918-4E4C-92B4-75C8830C6BA7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {65302D6E-9918-4E4C-92B4-75C8830C6BA7}.Debug|x64.ActiveCfg = Debug|Any CPU + {65302D6E-9918-4E4C-92B4-75C8830C6BA7}.Debug|x64.Build.0 = Debug|Any CPU + {65302D6E-9918-4E4C-92B4-75C8830C6BA7}.Debug|x86.ActiveCfg = Debug|Any CPU + {65302D6E-9918-4E4C-92B4-75C8830C6BA7}.Debug|x86.Build.0 = Debug|Any CPU + {65302D6E-9918-4E4C-92B4-75C8830C6BA7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {65302D6E-9918-4E4C-92B4-75C8830C6BA7}.Release|Any CPU.Build.0 = Release|Any CPU + {65302D6E-9918-4E4C-92B4-75C8830C6BA7}.Release|x64.ActiveCfg = Release|Any CPU + {65302D6E-9918-4E4C-92B4-75C8830C6BA7}.Release|x64.Build.0 = Release|Any CPU + {65302D6E-9918-4E4C-92B4-75C8830C6BA7}.Release|x86.ActiveCfg = Release|Any CPU + {65302D6E-9918-4E4C-92B4-75C8830C6BA7}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/Bro.Device.GTSCard/Bro.Device.GTSCard.csproj b/src/Bro.Device.GTSCard/Bro.Device.GTSCard.csproj new file mode 100644 index 0000000..e68e95c --- /dev/null +++ b/src/Bro.Device.GTSCard/Bro.Device.GTSCard.csproj @@ -0,0 +1,48 @@ +锘�<?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>{B536003E-70BA-4701-B8FD-BAFA303AB4E2}</ProjectGuid> + <OutputType>Library</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>Bro.Device.GTSCard</RootNamespace> + <AssemblyName>Bro.Device.GTSCard</AssemblyName> + <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion> + <FileAlignment>512</FileAlignment> + <Deterministic>true</Deterministic> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>..\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="System" /> + <Reference Include="System.Core" /> + <Reference Include="System.Xml.Linq" /> + <Reference Include="System.Data.DataSetExtensions" /> + <Reference Include="Microsoft.CSharp" /> + <Reference Include="System.Data" /> + <Reference Include="System.Net.Http" /> + <Reference Include="System.Xml" /> + </ItemGroup> + <ItemGroup> + <Compile Include="Class1.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + </ItemGroup> + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> +</Project> \ No newline at end of file diff --git a/src/Bro.Device.GTSCard/Class1.cs b/src/Bro.Device.GTSCard/Class1.cs new file mode 100644 index 0000000..4801fad --- /dev/null +++ b/src/Bro.Device.GTSCard/Class1.cs @@ -0,0 +1,12 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Bro.Device.GTSCard +{ + public class Class1 + { + } +} diff --git a/src/Bro.Device.GTSCard/Properties/AssemblyInfo.cs b/src/Bro.Device.GTSCard/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..507b541 --- /dev/null +++ b/src/Bro.Device.GTSCard/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +锘縰sing System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 鏈夊叧绋嬪簭闆嗙殑涓�鑸俊鎭敱浠ヤ笅 +// 鎺у埗銆傛洿鏀硅繖浜涚壒鎬у�煎彲淇敼 +// 涓庣▼搴忛泦鍏宠仈鐨勪俊鎭�� +[assembly: AssemblyTitle("Bro.Device.GTSCard")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Bro.Device.GTSCard")] +[assembly: AssemblyCopyright("Copyright 漏 2020")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 灏� ComVisible 璁剧疆涓� false 浼氫娇姝ょ▼搴忛泦涓殑绫诲瀷 +//瀵� COM 缁勪欢涓嶅彲瑙併�傚鏋滈渶瑕佷粠 COM 璁块棶姝ょ▼搴忛泦涓殑绫诲瀷 +//璇峰皢姝ょ被鍨嬬殑 ComVisible 鐗规�ц缃负 true銆� +[assembly: ComVisible(false)] + +// 濡傛灉姝ら」鐩悜 COM 鍏紑锛屽垯涓嬪垪 GUID 鐢ㄤ簬绫诲瀷搴撶殑 ID +[assembly: Guid("b536003e-70ba-4701-b8fd-bafa303ab4e2")] + +// 绋嬪簭闆嗙殑鐗堟湰淇℃伅鐢变笅鍒楀洓涓�肩粍鎴�: +// +// 涓荤増鏈� +// 娆$増鏈� +// 鐢熸垚鍙� +// 淇鍙� +// +//鍙互鎸囧畾鎵�鏈夎繖浜涘�硷紝涔熷彲浠ヤ娇鐢ㄢ�滅敓鎴愬彿鈥濆拰鈥滀慨璁㈠彿鈥濈殑榛樿鍊� +//閫氳繃浣跨敤 "*"锛屽涓嬫墍绀�: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/Bro.M071.Process.DBManager/App.config b/src/Bro.M071.Process.DBManager/App.config new file mode 100644 index 0000000..1c8faee --- /dev/null +++ b/src/Bro.M071.Process.DBManager/App.config @@ -0,0 +1,36 @@ +锘�<?xml version="1.0" encoding="utf-8"?> +<configuration> + <configSections> + <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --> + <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --> + <!-- 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> + <system.data> + <DbProviderFactories> + <remove invariant="System.Data.SQLite.EF6" /> + <add name="SQLite Data Provider (Entity Framework 6)" invariant="System.Data.SQLite.EF6" description=".NET Framework Data Provider for SQLite (Entity Framework 6)" type="System.Data.SQLite.EF6.SQLiteProviderFactory, System.Data.SQLite.EF6" /> + <remove invariant="System.Data.SQLite" /> + <add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".NET Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" /> + </DbProviderFactories> + </system.data> + <entityFramework> + <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" /> + <providers> + <provider invariantName="System.Data.SQLite" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" /> + <provider invariantName="System.Data.SQLite.EF6" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" /> + </providers> + </entityFramework> + <runtime> + <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> + <dependentAssembly> + <assemblyIdentity name="System.Data.SQLite" publicKeyToken="db937bc2d44ff139" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-1.0.112.0" newVersion="1.0.112.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Data.SQLite.EF6" publicKeyToken="db937bc2d44ff139" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-1.0.112.0" newVersion="1.0.112.0" /> + </dependentAssembly> + </assemblyBinding> + </runtime> +<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" /></startup></configuration> diff --git a/src/Bro.M071.Process.DBManager/Bro.M071.Process.DBManager.csproj b/src/Bro.M071.Process.DBManager/Bro.M071.Process.DBManager.csproj new file mode 100644 index 0000000..c2cd4ac --- /dev/null +++ b/src/Bro.M071.Process.DBManager/Bro.M071.Process.DBManager.csproj @@ -0,0 +1,103 @@ +锘�<?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> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProjectGuid>{230B0FFF-F6AF-45FE-AAF7-B4B66250DD58}</ProjectGuid> + <OutputType>Library</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>Bro.Process.DBManager</RootNamespace> + <AssemblyName>Bro.Process.DBManager</AssemblyName> + <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion> + <FileAlignment>512</FileAlignment> + <NuGetPackageImportStamp> + </NuGetPackageImportStamp> + <TargetFrameworkProfile /> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>..\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.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="SQLite.CodeFirst, Version=1.5.3.29, Culture=neutral, PublicKeyToken=eb96ba0a78d831a7, processorArchitecture=MSIL"> + <HintPath>..\..\packages\SQLite.CodeFirst.1.5.3.29\lib\net45\SQLite.CodeFirst.dll</HintPath> + </Reference> + <Reference Include="System" /> + <Reference Include="System.ComponentModel.DataAnnotations" /> + <Reference Include="System.Configuration" /> + <Reference Include="System.Core" /> + <Reference Include="System.Data.SQLite, Version=1.0.112.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL"> + <HintPath>..\..\packages\System.Data.SQLite.Core.1.0.112.0\lib\net451\System.Data.SQLite.dll</HintPath> + </Reference> + <Reference Include="System.Data.SQLite.EF6, Version=1.0.112.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL"> + <HintPath>..\..\packages\System.Data.SQLite.EF6.1.0.112.0\lib\net451\System.Data.SQLite.EF6.dll</HintPath> + </Reference> + <Reference Include="System.Data.SQLite.EF6.Migrations, Version=1.0.106.0, Culture=neutral, processorArchitecture=MSIL"> + <HintPath>..\..\packages\System.Data.SQLite.EF6.Migrations.1.0.106\lib\System.Data.SQLite.EF6.Migrations.dll</HintPath> + </Reference> + <Reference Include="System.Data.SQLite.Linq, Version=1.0.112.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL"> + <HintPath>..\..\packages\System.Data.SQLite.Linq.1.0.112.0\lib\net451\System.Data.SQLite.Linq.dll</HintPath> + </Reference> + <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="ProductionDetectionImageRecordsManager.cs" /> + <Compile Include="ProductionDetectionRecordsDetailManager.cs" /> + <Compile Include="ProductionDetectionRecordsManager.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\Bro.Common.Model\Bro.Common.Model.csproj"> + <Project>{1A3CBFE7-3F78-42C3-95C5-10360450DBEA}</Project> + <Name>Bro.Common.Model</Name> + </ProjectReference> + <ProjectReference Include="..\Bro.Common.Device\Bro.Common.Device.csproj"> + <Project>{987308DD-8BAA-463A-94E2-77D62E01A5BF}</Project> + <Name>Bro.Process.Common</Name> + </ProjectReference> + <ProjectReference Include="..\Bro.Process.Model\Bro.Process.Model.csproj"> + <Project>{AD645C48-5811-4B1E-B81F-D35D5E6B577F}</Project> + <Name>Bro.Process.Model</Name> + </ProjectReference> + </ItemGroup> + <ItemGroup> + <None Include="App.config" /> + <None Include="packages.config" /> + </ItemGroup> + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> + <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> + <PropertyGroup> + </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'))" /> + <Error Condition="!Exists('..\..\packages\System.Data.SQLite.Core.1.0.112.0\build\net451\System.Data.SQLite.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\System.Data.SQLite.Core.1.0.112.0\build\net451\System.Data.SQLite.Core.targets'))" /> + </Target> + <Import Project="..\..\packages\EntityFramework.6.4.0\build\EntityFramework.targets" Condition="Exists('..\..\packages\EntityFramework.6.4.0\build\EntityFramework.targets')" /> + <Import Project="..\..\packages\System.Data.SQLite.Core.1.0.112.0\build\net451\System.Data.SQLite.Core.targets" Condition="Exists('..\..\packages\System.Data.SQLite.Core.1.0.112.0\build\net451\System.Data.SQLite.Core.targets')" /> +</Project> \ No newline at end of file diff --git a/src/Bro.M071.Process.DBManager/ProductionDetectionImageRecordsManager.cs b/src/Bro.M071.Process.DBManager/ProductionDetectionImageRecordsManager.cs new file mode 100644 index 0000000..49f5e9d --- /dev/null +++ b/src/Bro.M071.Process.DBManager/ProductionDetectionImageRecordsManager.cs @@ -0,0 +1,303 @@ +锘�////using Bro.Process.Common.Helper; +//using Bro.Common.Helper; +//using Bro.Process.Model; +//using Bro.Process.Model.Model; +//using System; +//using System.Collections; +//using System.Collections.Generic; +//using System.Configuration; +//using System.Data; +//using System.Data.Common; +//using System.Data.SQLite; +//using System.Diagnostics; +//using System.Linq; +//using System.Text; +//using System.Threading.Tasks; + +//namespace Bro.M071.Process.DBManager +//{ +// public class ProductionDetectionImageRecordsManager : ModelManager<ProductionDetectionImageRecords> +// { +// DbProviderFactory Dbfactory = SQLiteFactory.Instance; +// protected override void ActionBeforeNewModel(DBModel context, ProductionDetectionImageRecords config) +// { +// CheckProductionCodeDuplicate(context, config); +// } + +// protected override void ActionBeforeUpdateModel(DBModel context, ProductionDetectionImageRecords config) +// { +// CheckProductionCodeDuplicate(context, config); +// } + +// private void CheckProductionCodeDuplicate(DBModel context, ProductionDetectionImageRecords config) +// { +// //if (context.ProductionDetectionImageRecords.Any(u => u.IS_DELETED == 0 +// // && u.ID != config.ID +// // && u.PRODUCTION_CODE == config.PRODUCTION_CODE)) +// { +// //throw new ProcessException("鏂板鎴栦慨鏀圭殑浜у搧閰嶇疆淇℃伅鐨勪骇鍝佷唬鐮佷笉鑳介噸澶�", null); +// } +// } + +// public List<ProductionDetectionImageRecords> GetProductionDetectionImageRecords(string productionBatchNO, string pid) +// { +// using (DBModel context = new DBModel()) +// { +// var list = context.ProductionDetectionImageRecords.Where(u => u.IS_DELETED == 0); + +// if (!string.IsNullOrWhiteSpace(productionBatchNO)) +// { +// list = list.Where(u => u.ProductionBatchNO.Contains(productionBatchNO)); +// } +// if (!string.IsNullOrWhiteSpace(pid)) +// { +// list = list.Where(u => u.PId.Contains(pid)); +// } + +// var resultList = list.ToList(); +// return resultList; +// } +// } +// //public List<ProductionStatistics_Dto> GetOperationRecordsList(OperationRecordsRequest request) +// //{ +// // using (DBModel context = new DBModel()) +// // { +// // var oList = context.OperationRecords.Where(u => u.IS_DELETED == 0); +// // var pList = context.ProductionDetectionRecords.Where(u => u.IS_DELETED == 0); +// // if (!string.IsNullOrWhiteSpace(request.ProductionBatchNO)) +// // { +// // oList = oList.Where(u => u.ProductionBatchNO.Contains(request.ProductionBatchNO)); +// // } +// // if (!string.IsNullOrWhiteSpace(request.UserNO)) +// // { +// // oList = oList.Where(u => u.UserNO.Contains(request.UserNO)); +// // } +// // if (request.StartTime != null) +// // { +// // oList = oList.Where(u => u.OperationStartTime >= request.StartTime); +// // } +// // if (request.EndTime != null) +// // { +// // oList = oList.Where(u => u.OperationStartTime <= request.EndTime); +// // } + +// // var query = from operationRecords in oList +// // join productionDetectionRecords in pList +// // on operationRecords.ID equals productionDetectionRecords.OperationRecordsId +// // into opList +// // select new ProductionStatistics_Dto +// // { +// // OperationRecordsRowData = operationRecords, +// // BatchProductionTotalCount = opList.Where(u => u.ProductionBatchNO == operationRecords.ProductionBatchNO).Count(), +// // BatchProductionOKCount = opList.Where(u => u.ProductionBatchNO == operationRecords.ProductionBatchNO && u.Result == "OK").Count(), +// // BatchProductionNGCount = opList.Where(u => u.ProductionBatchNO == operationRecords.ProductionBatchNO && u.Result == "NG").Count(), +// // BatchProductionTBDCount = opList.Where(u => u.ProductionBatchNO == operationRecords.ProductionBatchNO && u.Result == "TBD").Count(), +// // IsSelected = false, +// // }; +// // var pageList = query.OrderBy(u => u.OperationRecordsRowData.OperationStartTime).ToPagedList(request); +// // request.TotalNum = oList.Count(); +// // return pageList; +// // } +// //} +// public List<ProductionDetectionImageRecords_Dto> GetProductionDetectionImageRecordsPagedList(ProductionDetectionImageRecordsRequest request) +// { +// using (DBModel context = new DBModel()) +// { +// var imageRecordsList = context.ProductionDetectionImageRecords.Where(u => u.IS_DELETED == 0); +// var detectionRecordsList = context.ProductionDetectionRecordsDetail.Where(u => u.IS_DELETED == 0); +// var manualDetectionRecordsList = context.ManualDetectionRecords.Where(u => u.IS_DELETED == 0); +// if (!string.IsNullOrWhiteSpace(request.ProductionBatchNO)) +// { +// imageRecordsList = imageRecordsList.Where(u => u.ProductionBatchNO.Contains(request.ProductionBatchNO)); +// } +// if (!string.IsNullOrWhiteSpace(request.PId)) +// { +// imageRecordsList = imageRecordsList.Where(u => u.PId.Contains(request.PId)); +// } +// if (!string.IsNullOrWhiteSpace(request.Detection)) +// { +// imageRecordsList = imageRecordsList.Where(u => u.Detection.Contains(request.Detection)); +// } +// if (!string.IsNullOrWhiteSpace(request.DefectName)) +// { +// imageRecordsList = imageRecordsList.Where(u => u.DefectNameList.Contains(request.DefectName)); +// } +// if (!string.IsNullOrWhiteSpace(request.ManualDefectName)) +// { +// imageRecordsList = imageRecordsList.Where(u => u.ManualDefectNameList.Contains(request.ManualDefectName)); +// } +// if (!string.IsNullOrWhiteSpace(request.Result)) +// { +// imageRecordsList = imageRecordsList.Where(u => u.Result == request.Result); +// } +// if (!string.IsNullOrWhiteSpace(request.ManualResult)) +// { +// manualDetectionRecordsList = manualDetectionRecordsList.Where(u => u.ManualResult == request.ManualResult); +// } +// if (request.StartTime != null) +// { +// imageRecordsList = imageRecordsList.Where(u => u.Time >= request.StartTime); +// } +// if (request.EndTime != null) +// { +// imageRecordsList = imageRecordsList.Where(u => u.Time <= request.EndTime); +// } + +// var query = from imageRecord in imageRecordsList +// join manualDetectionRecords in manualDetectionRecordsList on imageRecord.OriginalImgPath equals manualDetectionRecords.OriginalImgPath +// join detectionRecords in detectionRecordsList on imageRecord.ID equals detectionRecords.ImageRecordId +// into imageDetectionRecord + +// select new ProductionDetectionImageRecords_Dto +// { +// ProductionDetectionImageRecordsRowData = imageRecord, +// ManualDetectionRecords = manualDetectionRecords, +// ProductionDetectionRecordsDetailList = detectionRecordsList.Where(u => u.ImageRecordId == imageRecord.ID) +// }; +// var pageList = query.OrderBy(u => u.ProductionDetectionImageRecordsRowData.CREATE_TIME).ToPagedList(request); +// request.TotalNum = imageRecordsList.Count(); + +// return pageList; +// } +// } + +// public ProductionDetectionImageRecords GetConfigByProductionCode(string productionCode) +// { +// using (DBModel context = new DBModel()) +// { +// //ProductionDetectionImageRecords RR= context.ProductionDetectionImageRecords.FirstOrDefault(u => u.IS_DELETED == 0 && u.PRODUCTION_CODE == productionCode); +// //return RR; +// return new ProductionDetectionImageRecords(); +// } +// } +// public void ADOBatchAdd(List<ProductionDetectionImageRecords> records) +// { +// Hashtable SQLStringList = new Hashtable(); +// try +// { +// var idList = records.Select(u => u.ID).ToList(); +// var disIdList = idList.Distinct().ToList(); +// if (idList.Count != disIdList.Count)//鏈夐噸澶峣d +// { +// throw new ProcessException("寮傚父锛氭湁閲嶅id:" + idList.ToString(), null); +// } +// //foreach (var record in records) +// //{ +// // if (IsExistId(record.ID)) +// // { +// // throw new ProcessException("寮傚父锛氭湁閲嶅id:" + record.ID, null); +// // } +// // StringBuilder strSql = new StringBuilder(); +// // strSql.Append("insert into ProductionDetectionImageRecords ("); +// // strSql.Append("ID,ProductionBatchNO,PId,Result,Time,Detection,DefectName,Probability,Uncertainty,DefectX,DefectY,DefectWidth,DefectHeight, RawImgPath,DefectImgPath,ImageTime,PreElapsed,DefectElapsed,AfterElapsed,TotalElapsed,PreTreatedFlag,DetectionType, SpecStandard, SpecActualValue,IS_DISABLED,IS_DELETED,CREATE_USER,CREATE_TIME, UPDATE_USER,UPDATE_TIME"); +// // strSql.Append(")values ("); +// // strSql.Append("@ID,@ProductionBatchNO,@PId,@Result,@Time,@Detection,@DefectName,@Probability,@Uncertainty,@DefectX,@DefectY,@DefectWidth,@DefectHeight,@RawImgPath,@DefectImgPath,@ImageTime,@PreElapsed,@DefectElapsed,@AfterElapsed,@TotalElapsed,@PreTreatedFlag,@DetectionType,@SpecStandard,@SpecActualValue,@IS_DISABLED,@IS_DELETED,@CREATE_USER,@CREATE_TIME,@UPDATE_USER,@UPDATE_TIME)"); +// // List<SQLiteParameter> parameters = new List<SQLiteParameter>(); +// // parameters.Add(new SQLiteParameter("@ID", record.ID)); +// // parameters.Add(new SQLiteParameter("@ProductionBatchNO", record.ProductionBatchNO)); +// // parameters.Add(new SQLiteParameter("@PId", record.PId)); +// // parameters.Add(new SQLiteParameter("@Result", record.Result)); +// // parameters.Add(new SQLiteParameter("@Time", record.Time)); +// // parameters.Add(new SQLiteParameter("@Detection", record.Detection)); +// // parameters.Add(new SQLiteParameter("@DefectName", record.DefectName)); +// // parameters.Add(new SQLiteParameter("@Probability", record.Probability)); +// // parameters.Add(new SQLiteParameter("@Uncertainty", record.Uncertainty)); +// // parameters.Add(new SQLiteParameter("@DefectX", record.DefectX)); +// // parameters.Add(new SQLiteParameter("@DefectY", record.DefectY)); +// // parameters.Add(new SQLiteParameter("@DefectWidth", record.DefectWidth)); +// // parameters.Add(new SQLiteParameter("@DefectHeight", record.DefectHeight)); +// // parameters.Add(new SQLiteParameter("@RawImgPath", record.RawImgPath)); +// // parameters.Add(new SQLiteParameter("@DefectImgPath", record.DefectImgPath)); +// // parameters.Add(new SQLiteParameter("@ImageTime", record.ImageTime)); +// // parameters.Add(new SQLiteParameter("@PreElapsed", record.PreElapsed)); +// // parameters.Add(new SQLiteParameter("@DefectElapsed", record.DefectElapsed)); +// // parameters.Add(new SQLiteParameter("@AfterElapsed", record.AfterElapsed)); +// // parameters.Add(new SQLiteParameter("@TotalElapsed", record.TotalElapsed)); +// // parameters.Add(new SQLiteParameter("@PreTreatedFlag", record.PreTreatedFlag)); +// // parameters.Add(new SQLiteParameter("@DetectionType", record.DetectionType)); +// // parameters.Add(new SQLiteParameter("@SpecStandard", record.SpecStandard)); +// // parameters.Add(new SQLiteParameter("@SpecActualValue", record.SpecActualValue)); +// // parameters.Add(new SQLiteParameter("@IS_DISABLED", record.IS_DISABLED)); +// // parameters.Add(new SQLiteParameter("@IS_DELETED", record.IS_DELETED)); +// // parameters.Add(new SQLiteParameter("@CREATE_USER", record.CREATE_USER)); +// // parameters.Add(new SQLiteParameter("@CREATE_TIME", record.CREATE_TIME)); +// // parameters.Add(new SQLiteParameter("@UPDATE_USER", record.UPDATE_USER)); +// // parameters.Add(new SQLiteParameter("@UPDATE_TIME", record.UPDATE_TIME)); + +// // SQLStringList.Add(strSql, parameters.ToArray()); +// //} +// SQLiteHelper.ExecuteSqlTran(SQLStringList); //浣跨敤鏁版嵁搴撲簨鍔� +// } +// catch (Exception ex) +// { +// throw new ProcessException(SQLStringList.ToString() + ex.Message, null); +// } +// } + +// public void InserPatch(List<ProductionDetectionImageRecords> records) +// { +// try +// { +// using (SQLiteConnection conn = new SQLiteConnection(ConnectionString)) +// { +// using (SQLiteCommand insertRngCmd = (SQLiteCommand)conn.CreateCommand()) +// { +// StringBuilder strSql = new StringBuilder(); +// strSql.Append("insert into ProductionDetectionImageRecords ("); +// strSql.Append("ID,ProductionBatchNO,PId,ManualResult,Result,Time,DetectionSource,Detection,DefectNameList,ManualDefectNameList,RawImgPath,DefectImgPath,ImageTime,PreElapsed,DefectElapsed,AfterElapsed,TotalElapsed,PreTreatedFlag,OriginalImgPath,IS_DISABLED,IS_DELETED,CREATE_USER,CREATE_TIME, UPDATE_USER,UPDATE_TIME"); +// strSql.Append(")values ("); +// strSql.Append("@ID,@ProductionBatchNO,@PId,@ManualResult,@Result,@Time,@DetectionSource,@Detection,@DefectNameList,@ManualDefectNameList,@RawImgPath,@DefectImgPath,@ImageTime,@PreElapsed,@DefectElapsed,@AfterElapsed,@TotalElapsed,@PreTreatedFlag,@OriginalImgPath,@IS_DISABLED,@IS_DELETED,@CREATE_USER,@CREATE_TIME,@UPDATE_USER,@UPDATE_TIME)"); + +// insertRngCmd.CommandText = strSql.ToString(); +// conn.Open(); +// var transaction = conn.BeginTransaction(); + +// foreach (var record in records) +// { +// insertRngCmd.Parameters.AddWithValue("@ID", record.ID); +// insertRngCmd.Parameters.AddWithValue("@ProductionBatchNO", record.ProductionBatchNO); +// insertRngCmd.Parameters.AddWithValue("@PId", record.PId); +// insertRngCmd.Parameters.AddWithValue("@ManualResult", record.ManualResult); +// insertRngCmd.Parameters.AddWithValue("@Result", record.Result); +// insertRngCmd.Parameters.AddWithValue("@Time", record.Time); +// insertRngCmd.Parameters.AddWithValue("@DetectionSource", record.DetectionSource); +// insertRngCmd.Parameters.AddWithValue("@Detection", record.Detection); +// insertRngCmd.Parameters.AddWithValue("@DefectNameList", record.DefectNameList); +// insertRngCmd.Parameters.AddWithValue("@ManualDefectNameList", record.ManualDefectNameList); +// insertRngCmd.Parameters.AddWithValue("@RawImgPath", record.RawImgPath); +// insertRngCmd.Parameters.AddWithValue("@DefectImgPath", record.DefectImgPath); +// insertRngCmd.Parameters.AddWithValue("@ImageTime", record.ImageTime); +// insertRngCmd.Parameters.AddWithValue("@PreElapsed", record.PreElapsed); +// insertRngCmd.Parameters.AddWithValue("@DefectElapsed", record.DefectElapsed); +// insertRngCmd.Parameters.AddWithValue("@AfterElapsed", record.AfterElapsed); +// insertRngCmd.Parameters.AddWithValue("@TotalElapsed", record.TotalElapsed); +// insertRngCmd.Parameters.AddWithValue("@PreTreatedFlag", record.PreTreatedFlag); +// insertRngCmd.Parameters.AddWithValue("@OriginalImgPath", record.OriginalImgPath); +// insertRngCmd.Parameters.AddWithValue("@IS_DISABLED", record.IS_DISABLED); +// insertRngCmd.Parameters.AddWithValue("@IS_DELETED", record.IS_DELETED); +// insertRngCmd.Parameters.AddWithValue("@CREATE_USER", record.CREATE_USER); +// insertRngCmd.Parameters.AddWithValue("@CREATE_TIME", record.CREATE_TIME); +// insertRngCmd.Parameters.AddWithValue("@UPDATE_USER", record.UPDATE_USER); +// insertRngCmd.Parameters.AddWithValue("@UPDATE_TIME", record.UPDATE_TIME); +// insertRngCmd.ExecuteNonQuery(); +// } +// transaction.Commit(); +// } +// } +// } +// catch (Exception ex) +// { +// throw new ProcessException(ex.Message, null); +// } +// } + +// public bool IsExistId(string id) +// { +// using (DBModel context = new DBModel()) +// { +// ProductionDetectionImageRecords RR = context.ProductionDetectionImageRecords.FirstOrDefault(u => u.ID == id); +// return RR != null; +// } +// } +// } +//} diff --git a/src/Bro.M071.Process.DBManager/ProductionDetectionRecordsDetailManager.cs b/src/Bro.M071.Process.DBManager/ProductionDetectionRecordsDetailManager.cs new file mode 100644 index 0000000..d12f104 --- /dev/null +++ b/src/Bro.M071.Process.DBManager/ProductionDetectionRecordsDetailManager.cs @@ -0,0 +1,248 @@ +锘�////using Bro.Process.Common.Helper; +//using Bro.Common.Helper; +//using Bro.Process.Model; +//using Bro.Process.Model.Model; +//using System; +//using System.Collections; +//using System.Collections.Generic; +//using System.Configuration; +//using System.Data; +//using System.Data.Common; +//using System.Data.SQLite; +//using System.Diagnostics; +//using System.Linq; +//using System.Text; +//using System.Threading.Tasks; + +//namespace Bro.M071.Process.DBManager +//{ +// public class ProductionDetectionRecordsDetailManager : ModelManager<ProductionDetectionRecordsDetail> +// { +// DbProviderFactory Dbfactory = SQLiteFactory.Instance; +// protected override void ActionBeforeNewModel(DBModel context, ProductionDetectionRecordsDetail config) +// { +// CheckProductionCodeDuplicate(context, config); +// } + +// protected override void ActionBeforeUpdateModel(DBModel context, ProductionDetectionRecordsDetail config) +// { +// CheckProductionCodeDuplicate(context, config); +// } + +// private void CheckProductionCodeDuplicate(DBModel context, ProductionDetectionRecordsDetail config) +// { +// //if (context.ProductionDetectionRecordsDetail.Any(u => u.IS_DELETED == 0 +// // && u.ID != config.ID +// // && u.PRODUCTION_CODE == config.PRODUCTION_CODE)) +// { +// //throw new ProcessException("鏂板鎴栦慨鏀圭殑浜у搧閰嶇疆淇℃伅鐨勪骇鍝佷唬鐮佷笉鑳介噸澶�", null); +// } +// } + +// public List<ProductionDetectionRecordsDetail> GetProductionDetectionRecordsDetail(string productionBatchNO, string pid) +// { +// using (DBModel context = new DBModel()) +// { +// var list = context.ProductionDetectionRecordsDetail.Where(u => u.IS_DELETED == 0 && u.OfflineDetectionId == null); + +// if (!string.IsNullOrWhiteSpace(productionBatchNO)) +// { +// list = list.Where(u => u.ProductionBatchNO.Contains(productionBatchNO)); +// } +// if (!string.IsNullOrWhiteSpace(pid)) +// { +// list = list.Where(u => u.PId.Contains(pid)); +// } + +// var resultList = list.ToList(); +// return resultList; +// } +// } + +// public List<ProductionDetectionRecordsDetail> GetProductionDetectionRecordsDetailPagedList(ProductionDetectionRecordsDetailRequest request) +// { +// using (DBModel context = new DBModel()) +// { +// var list = context.ProductionDetectionRecordsDetail.Where(u => u.IS_DELETED == 0); + +// if (!string.IsNullOrWhiteSpace(request.ProductionBatchNO)) +// { +// list = list.Where(u => u.ProductionBatchNO.Contains(request.ProductionBatchNO)); +// } +// if (!string.IsNullOrWhiteSpace(request.PId)) +// { +// list = list.Where(u => u.PId.Contains(request.PId)); +// } +// if (!string.IsNullOrWhiteSpace(request.Detection)) +// { +// list = list.Where(u => u.Detection.Contains(request.Detection)); +// } +// if (!string.IsNullOrWhiteSpace(request.DefectName)) +// { +// list = list.Where(u => u.DefectName.Contains(request.DefectName)); +// } +// if (!string.IsNullOrWhiteSpace(request.Result)) +// { +// list = list.Where(u => u.Result == request.Result); +// } +// if (request.StartTime != null) +// { +// list = list.Where(u => u.Time >= request.StartTime); +// } +// if (request.EndTime != null) +// { +// list = list.Where(u => u.Time <= request.EndTime); +// } +// var pageList = list.OrderBy(u => u.Time).ToPagedList(request); +// request.TotalNum = list.Count(); +// return pageList; +// } +// } + +// public ProductionDetectionRecordsDetail GetConfigByProductionCode(string productionCode) +// { +// using (DBModel context = new DBModel()) +// { +// //ProductionDetectionRecordsDetail RR= context.ProductionDetectionRecordsDetail.FirstOrDefault(u => u.IS_DELETED == 0 && u.PRODUCTION_CODE == productionCode); +// //return RR; +// return new ProductionDetectionRecordsDetail(); +// } +// } +// public void ADOBatchAdd(List<ProductionDetectionRecordsDetail> records) +// { +// Hashtable SQLStringList = new Hashtable(); +// try +// { +// var idList = records.Select(u => u.ID).ToList(); +// var disIdList = idList.Distinct().ToList(); +// if (idList.Count != disIdList.Count)//鏈夐噸澶峣d +// { +// throw new ProcessException("寮傚父锛氭湁閲嶅id:" + idList.ToString(), null); +// } +// foreach (var record in records) +// { +// if (IsExistId(record.ID)) +// { +// throw new ProcessException("寮傚父锛氭湁閲嶅id:" + record.ID, null); +// } +// StringBuilder strSql = new StringBuilder(); +// strSql.Append("insert into ProductionDetectionRecordsDetail ("); +// strSql.Append("ID,ProductionBatchNO,PId,Result,Time,Detection,DefectName,Probability,Uncertainty,DefectX,DefectY,DefectWidth,DefectHeight, RawImgPath,DefectImgPath,ImageTime,PreElapsed,DefectElapsed,AfterElapsed,TotalElapsed,PreTreatedFlag,DetectionType, SpecStandard, SpecActualValue,IS_DISABLED,IS_DELETED,CREATE_USER,CREATE_TIME, UPDATE_USER,UPDATE_TIME"); +// strSql.Append(")values ("); +// strSql.Append("@ID,@ProductionBatchNO,@PId,@Result,@Time,@Detection,@DefectName,@Probability,@Uncertainty,@DefectX,@DefectY,@DefectWidth,@DefectHeight,@RawImgPath,@DefectImgPath,@ImageTime,@PreElapsed,@DefectElapsed,@AfterElapsed,@TotalElapsed,@PreTreatedFlag,@DetectionType,@SpecStandard,@SpecActualValue,@IS_DISABLED,@IS_DELETED,@CREATE_USER,@CREATE_TIME,@UPDATE_USER,@UPDATE_TIME)"); +// List<SQLiteParameter> parameters = new List<SQLiteParameter>(); +// parameters.Add(new SQLiteParameter("@ID", record.ID)); +// parameters.Add(new SQLiteParameter("@ProductionBatchNO", record.ProductionBatchNO)); +// parameters.Add(new SQLiteParameter("@PId", record.PId)); +// parameters.Add(new SQLiteParameter("@Result", record.Result)); +// parameters.Add(new SQLiteParameter("@Time", record.Time)); +// parameters.Add(new SQLiteParameter("@Detection", record.Detection)); +// parameters.Add(new SQLiteParameter("@DefectName", record.DefectName)); +// parameters.Add(new SQLiteParameter("@Probability", record.Probability)); +// parameters.Add(new SQLiteParameter("@Uncertainty", record.Uncertainty)); +// parameters.Add(new SQLiteParameter("@DefectX", record.DefectX)); +// parameters.Add(new SQLiteParameter("@DefectY", record.DefectY)); +// parameters.Add(new SQLiteParameter("@DefectWidth", record.DefectWidth)); +// parameters.Add(new SQLiteParameter("@DefectHeight", record.DefectHeight)); +// parameters.Add(new SQLiteParameter("@RawImgPath", record.RawImgPath)); +// parameters.Add(new SQLiteParameter("@DefectImgPath", record.DefectImgPath)); +// parameters.Add(new SQLiteParameter("@ImageTime", record.ImageTime)); +// parameters.Add(new SQLiteParameter("@PreElapsed", record.PreElapsed)); +// parameters.Add(new SQLiteParameter("@DefectElapsed", record.DefectElapsed)); +// parameters.Add(new SQLiteParameter("@AfterElapsed", record.AfterElapsed)); +// parameters.Add(new SQLiteParameter("@TotalElapsed", record.TotalElapsed)); +// parameters.Add(new SQLiteParameter("@PreTreatedFlag", record.PreTreatedFlag)); +// parameters.Add(new SQLiteParameter("@DetectionType", record.DetectionType)); +// parameters.Add(new SQLiteParameter("@SpecStandard", record.SpecStandard)); +// parameters.Add(new SQLiteParameter("@SpecActualValue", record.SpecActualValue)); +// parameters.Add(new SQLiteParameter("@IS_DISABLED", record.IS_DISABLED)); +// parameters.Add(new SQLiteParameter("@IS_DELETED", record.IS_DELETED)); +// parameters.Add(new SQLiteParameter("@CREATE_USER", record.CREATE_USER)); +// parameters.Add(new SQLiteParameter("@CREATE_TIME", record.CREATE_TIME)); +// parameters.Add(new SQLiteParameter("@UPDATE_USER", record.UPDATE_USER)); +// parameters.Add(new SQLiteParameter("@UPDATE_TIME", record.UPDATE_TIME)); + +// SQLStringList.Add(strSql, parameters.ToArray()); +// } +// SQLiteHelper.ExecuteSqlTran(SQLStringList); //浣跨敤鏁版嵁搴撲簨鍔� +// } +// catch (Exception ex) +// { +// throw new ProcessException(SQLStringList.ToString() + ex.Message, null); +// } +// } + +// public void InserPatch(List<ProductionDetectionRecordsDetail> records) +// { +// try +// { +// using (SQLiteConnection conn = new SQLiteConnection(ConnectionString)) +// { +// using (SQLiteCommand insertRngCmd = (SQLiteCommand)conn.CreateCommand()) +// { +// StringBuilder strSql = new StringBuilder(); +// strSql.Append("insert into ProductionDetectionRecordsDetail ("); +// strSql.Append("ID,ProductionBatchNO,PId,Result,Time,DetectionSource,Detection,DefectName,Probability,Uncertainty,DefectX,DefectY,DefectWidth,DefectHeight, RawImgPath,DefectImgPath,ImageTime,PreElapsed,DefectElapsed,AfterElapsed,TotalElapsed,PreTreatedFlag,DetectionType, SpecStandard, SpecActualValue,IS_DISABLED,IS_DELETED,CREATE_USER,CREATE_TIME, UPDATE_USER,UPDATE_TIME,ImageRecordId"); +// strSql.Append(")values ("); +// strSql.Append("@ID,@ProductionBatchNO,@PId,@Result,@Time,@DetectionSource,@Detection,@DefectName,@Probability,@Uncertainty,@DefectX,@DefectY,@DefectWidth,@DefectHeight,@RawImgPath,@DefectImgPath,@ImageTime,@PreElapsed,@DefectElapsed,@AfterElapsed,@TotalElapsed,@PreTreatedFlag,@DetectionType,@SpecStandard,@SpecActualValue,@IS_DISABLED,@IS_DELETED,@CREATE_USER,@CREATE_TIME,@UPDATE_USER,@UPDATE_TIME,@ImageRecordId)"); + +// insertRngCmd.CommandText = strSql.ToString(); +// conn.Open(); +// var transaction = conn.BeginTransaction(); + +// foreach (var record in records) +// { +// insertRngCmd.Parameters.AddWithValue("@ID", record.ID); +// insertRngCmd.Parameters.AddWithValue("@ProductionBatchNO", record.ProductionBatchNO); +// insertRngCmd.Parameters.AddWithValue("@PId", record.PId); +// insertRngCmd.Parameters.AddWithValue("@Result", record.Result); +// insertRngCmd.Parameters.AddWithValue("@Time", record.Time); +// insertRngCmd.Parameters.AddWithValue("@DetectionSource", record.DetectionSource); +// insertRngCmd.Parameters.AddWithValue("@Detection", record.Detection); +// insertRngCmd.Parameters.AddWithValue("@DefectName", record.DefectName); +// insertRngCmd.Parameters.AddWithValue("@Probability", record.Probability); +// insertRngCmd.Parameters.AddWithValue("@Uncertainty", record.Uncertainty); +// insertRngCmd.Parameters.AddWithValue("@DefectX", record.DefectX); +// insertRngCmd.Parameters.AddWithValue("@DefectY", record.DefectY); +// insertRngCmd.Parameters.AddWithValue("@DefectWidth", record.DefectWidth); +// insertRngCmd.Parameters.AddWithValue("@DefectHeight", record.DefectHeight); +// insertRngCmd.Parameters.AddWithValue("@RawImgPath", record.RawImgPath); +// insertRngCmd.Parameters.AddWithValue("@DefectImgPath", record.DefectImgPath); +// insertRngCmd.Parameters.AddWithValue("@ImageTime", record.ImageTime); +// insertRngCmd.Parameters.AddWithValue("@PreElapsed", record.PreElapsed); +// insertRngCmd.Parameters.AddWithValue("@DefectElapsed", record.DefectElapsed); +// insertRngCmd.Parameters.AddWithValue("@AfterElapsed", record.AfterElapsed); +// insertRngCmd.Parameters.AddWithValue("@TotalElapsed", record.TotalElapsed); +// insertRngCmd.Parameters.AddWithValue("@PreTreatedFlag", record.PreTreatedFlag); +// insertRngCmd.Parameters.AddWithValue("@DetectionType", record.DetectionType); +// insertRngCmd.Parameters.AddWithValue("@SpecStandard", record.SpecStandard); +// insertRngCmd.Parameters.AddWithValue("@SpecActualValue", record.SpecActualValue); +// insertRngCmd.Parameters.AddWithValue("@IS_DISABLED", record.IS_DISABLED); +// insertRngCmd.Parameters.AddWithValue("@IS_DELETED", record.IS_DELETED); +// insertRngCmd.Parameters.AddWithValue("@CREATE_USER", record.CREATE_USER); +// insertRngCmd.Parameters.AddWithValue("@CREATE_TIME", record.CREATE_TIME); +// insertRngCmd.Parameters.AddWithValue("@UPDATE_USER", record.UPDATE_USER); +// insertRngCmd.Parameters.AddWithValue("@UPDATE_TIME", record.UPDATE_TIME); +// insertRngCmd.Parameters.AddWithValue("@ImageRecordId", record.ImageRecordId); +// insertRngCmd.ExecuteNonQuery(); +// } +// transaction.Commit(); +// } +// } +// } +// catch (Exception ex) +// { +// throw new ProcessException(ex.Message, null); +// } +// } + +// public bool IsExistId(string id) +// { +// using (DBModel context = new DBModel()) +// { +// ProductionDetectionRecordsDetail RR = context.ProductionDetectionRecordsDetail.FirstOrDefault(u => u.ID == id); +// return RR != null; +// } +// } +// } +//} diff --git a/src/Bro.M071.Process.DBManager/ProductionDetectionRecordsManager.cs b/src/Bro.M071.Process.DBManager/ProductionDetectionRecordsManager.cs new file mode 100644 index 0000000..bd25939 --- /dev/null +++ b/src/Bro.M071.Process.DBManager/ProductionDetectionRecordsManager.cs @@ -0,0 +1,305 @@ +锘�////using Bro.Process.Common.Helper; +//using Bro.Common.Helper; +//using Bro.Process.Model; +//using Bro.Process.Model.Model; +//using System; +//using System.Collections; +//using System.Collections.Generic; +//using System.Data.Common; +//using System.Data.SQLite; +//using System.Diagnostics; +//using System.Linq; +//using System.Text; +//using System.Threading.Tasks; + +//namespace Bro.M071.Process.DBManager +//{ +// public class ProductionDetectionRecordsManager : ModelManager<ProductionDetectionRecords> +// { +// DbProviderFactory Dbfactory = SQLiteFactory.Instance; +// protected override void ActionBeforeNewModel(DBModel context, ProductionDetectionRecords config) +// { +// CheckProductionCodeDuplicate(context, config); +// } + +// protected override void ActionBeforeUpdateModel(DBModel context, ProductionDetectionRecords config) +// { +// CheckProductionCodeDuplicate(context, config); +// } + +// private void CheckProductionCodeDuplicate(DBModel context, ProductionDetectionRecords config) +// { +// //if (context.ProductionDetectionRecords.Any(u => u.IS_DELETED == 0 +// // && u.ID != config.ID +// // && u.PRODUCTION_CODE == config.PRODUCTION_CODE)) +// { +// //throw new ProcessException("鏂板鎴栦慨鏀圭殑浜у搧閰嶇疆淇℃伅鐨勪骇鍝佷唬鐮佷笉鑳介噸澶�", null); +// } +// } + +// //public void ADOBatchAdd(List<ProductionDetectionRecords> records) +// //{ +// // Hashtable SQLStringList = new Hashtable(); +// // try +// // { +// // var idList = records.Select(u => u.ID).ToList(); +// // var disIdList = idList.Distinct().ToList(); +// // if (idList.Count != disIdList.Count)//鏈夐噸澶峣d +// // { +// // throw new ProcessException("寮傚父锛氭湁閲嶅id:" + idList.ToString(), null); +// // } +// // foreach (var record in records) +// // { +// // if (IsExistId(record.ID)) +// // { +// // throw new ProcessException("寮傚父锛氭湁閲嶅id:" + record.ID, null); +// // } +// // StringBuilder strSql = new StringBuilder(); +// // strSql.Append("insert into ProductionDetectionRecords ("); +// // strSql.Append(@"ID, +// // ProductionBatchNO, +// // PId, +// // Time, +// // Result, +// // DetectionTimes, +// // DetectionDetail, +// // X, +// // Y, +// // UploadTime, +// // DequeueTime, +// // UploadResult, +// // TBDList, +// // InsideDiameter, +// // OutsideDiameter, +// // Thickness, +// // IS_DISABLED, +// // IS_DELETED, +// // CREATE_USER, +// // CREATE_TIME, +// // UPDATE_USER, +// // UPDATE_TIME"); +// // strSql.Append(")values ("); +// // strSql.Append(@"@ID, +// // @ProductionBatchNO, +// // @PId, +// // @Time, +// // @Result, +// // @DetectionTimes, +// // @DetectionDetail, +// // @X, +// // @Y, +// // @UploadTime, +// // @DequeueTime, +// // @UploadResult, +// // @TBDList, +// // @InsideDiameter, +// // @OutsideDiameter, +// // @Thickness, +// // @IS_DISABLED, +// // @IS_DELETED, +// // @CREATE_USER, +// // @CREATE_TIME, +// // @UPDATE_USER, +// // @UPDATE_TIME)"); +// // List<SQLiteParameter> parameters = new List<SQLiteParameter>(); + +// // parameters.Add(new SQLiteParameter("@ID", record.ID)); +// // parameters.Add(new SQLiteParameter("@ProductionBatchNO", record.ProductionBatchNO)); +// // parameters.Add(new SQLiteParameter("@PId", record.PId)); +// // parameters.Add(new SQLiteParameter("@Time", record.Time)); +// // parameters.Add(new SQLiteParameter("@Result", record.Result)); +// // parameters.Add(new SQLiteParameter("@DetectionTimes", record.DetectionTimes)); +// // parameters.Add(new SQLiteParameter("@DetectionDetail", record.DetectionDetail)); +// // parameters.Add(new SQLiteParameter("@X", record.X)); +// // parameters.Add(new SQLiteParameter("@Y", record.Y)); +// // parameters.Add(new SQLiteParameter("@UploadTime", record.UploadTime)); +// // parameters.Add(new SQLiteParameter("@DequeueTime", record.DequeueTime)); +// // parameters.Add(new SQLiteParameter("@UploadResult", record.UploadResult)); +// // parameters.Add(new SQLiteParameter("@TBDList", record.TBDList)); +// // parameters.Add(new SQLiteParameter("@InsideDiameter", record.InsideDiameter)); +// // parameters.Add(new SQLiteParameter("@OutsideDiameter", record.OutsideDiameter)); +// // parameters.Add(new SQLiteParameter("@Thickness", record.Thickness)); +// // parameters.Add(new SQLiteParameter("@IS_DISABLED", record.IS_DISABLED)); +// // parameters.Add(new SQLiteParameter("@IS_DELETED", record.IS_DELETED)); +// // parameters.Add(new SQLiteParameter("@CREATE_USER", record.CREATE_USER)); +// // parameters.Add(new SQLiteParameter("@CREATE_TIME", record.CREATE_TIME)); +// // parameters.Add(new SQLiteParameter("@UPDATE_USER", record.UPDATE_USER)); +// // parameters.Add(new SQLiteParameter("@UPDATE_TIME", record.UPDATE_TIME)); + +// // SQLStringList.Add(strSql, parameters.ToArray()); +// // } +// // SQLiteHelper.ExecuteSqlTran(SQLStringList); //浣跨敤鏁版嵁搴撲簨鍔� + +// // } +// // catch (Exception ex) +// // { +// // throw new ProcessException(SQLStringList.ToString() + ex.Message, null); +// // } +// //} + +// public void InserPatch(List<ProductionDetectionRecords> records) +// { +// try +// { +// using (SQLiteConnection conn = new SQLiteConnection(ConnectionString)) +// { +// using (SQLiteCommand insertRngCmd = (SQLiteCommand)conn.CreateCommand()) +// { +// StringBuilder strSql = new StringBuilder(); +// strSql.Append("insert into ProductionDetectionRecords ("); +// strSql.Append(@"ID, +// OperationRecordsId, +// ProductionBatchNO, +// PId, +// Time, +// Source, +// Result, +// DetectionTimes, +// DetectionDetail, +// X, +// Y, +// UploadTime, +// DequeueTime, +// UploadResult, +// TBDList, +// InsideDiameter, +// OutsideDiameter, +// Thickness, +// IS_DISABLED, +// IS_DELETED, +// CREATE_USER, +// CREATE_TIME, +// UPDATE_USER, +// UPDATE_TIME"); +// strSql.Append(")values ("); +// strSql.Append(@"@ID, +// @OperationRecordsId, +// @ProductionBatchNO, +// @PId, +// @Time, +// @Source, +// @Result, +// @DetectionTimes, +// @DetectionDetail, +// @X, +// @Y, +// @UploadTime, +// @DequeueTime, +// @UploadResult, +// @TBDList, +// @InsideDiameter, +// @OutsideDiameter, +// @Thickness, +// @IS_DISABLED, +// @IS_DELETED, +// @CREATE_USER, +// @CREATE_TIME, +// @UPDATE_USER, +// @UPDATE_TIME)"); + +// insertRngCmd.CommandText = strSql.ToString(); +// conn.Open(); +// var transaction = conn.BeginTransaction(); + +// foreach (var record in records) +// { +// insertRngCmd.Parameters.AddWithValue("@ID", record.ID); +// insertRngCmd.Parameters.AddWithValue("@OperationRecordsId", record.OperationRecordsId); +// insertRngCmd.Parameters.AddWithValue("@ProductionBatchNO", record.ProductionBatchNO); +// insertRngCmd.Parameters.AddWithValue("@PId", record.PId); +// insertRngCmd.Parameters.AddWithValue("@Time", record.Time); +// insertRngCmd.Parameters.AddWithValue("@Source", record.Source); +// insertRngCmd.Parameters.AddWithValue("@Result", record.Result); +// insertRngCmd.Parameters.AddWithValue("@DetectionTimes", record.DetectionTimes); +// insertRngCmd.Parameters.AddWithValue("@DetectionDetail", record.DetectionDetail); +// insertRngCmd.Parameters.AddWithValue("@X", record.X); +// insertRngCmd.Parameters.AddWithValue("@Y", record.Y); +// insertRngCmd.Parameters.AddWithValue("@UploadTime", record.UploadTime); +// insertRngCmd.Parameters.AddWithValue("@DequeueTime", record.DequeueTime); +// insertRngCmd.Parameters.AddWithValue("@UploadResult", record.UploadResult); +// insertRngCmd.Parameters.AddWithValue("@TBDList", record.TBDList); +// insertRngCmd.Parameters.AddWithValue("@InsideDiameter", record.InsideDiameter); +// insertRngCmd.Parameters.AddWithValue("@OutsideDiameter", record.OutsideDiameter); +// insertRngCmd.Parameters.AddWithValue("@Thickness", record.Thickness); +// insertRngCmd.Parameters.AddWithValue("@IS_DISABLED", record.IS_DISABLED); +// insertRngCmd.Parameters.AddWithValue("@IS_DELETED", record.IS_DELETED); +// insertRngCmd.Parameters.AddWithValue("@CREATE_USER", record.CREATE_USER); +// insertRngCmd.Parameters.AddWithValue("@CREATE_TIME", record.CREATE_TIME); +// insertRngCmd.Parameters.AddWithValue("@UPDATE_USER", record.UPDATE_USER); +// insertRngCmd.Parameters.AddWithValue("@UPDATE_TIME", record.UPDATE_TIME); +// insertRngCmd.ExecuteNonQuery(); +// } +// transaction.Commit(); +// } +// } +// } +// catch (Exception ex) +// { +// throw new ProcessException(ex.Message, null); +// } +// } + +// public List<ProductionDetectionRecords> GetProductionDetectionRecordsList(ProductionDetectionRecordsRequest request) +// { +// using (DBModel context = new DBModel()) +// { +// var list = context.ProductionDetectionRecords.Where(u => u.IS_DELETED == 0); + +// if (!string.IsNullOrWhiteSpace(request.ProductionBatchNO)) +// { +// list = list.Where(u => u.ProductionBatchNO.Contains(request.ProductionBatchNO)); +// } +// if (!string.IsNullOrWhiteSpace(request.PId)) +// { +// list = list.Where(u => u.PId.Contains(request.PId)); +// } +// if (!string.IsNullOrWhiteSpace(request.Result)) +// { +// list = list.Where(u => u.Result == request.Result); +// } +// if (request.StartTime != null) +// { +// list = list.Where(u => u.Time >= request.StartTime); +// } +// if (request.EndTime != null) +// { +// list = list.Where(u => u.Time <= request.EndTime); +// } +// var pageList = list.OrderBy(u => u.Time).ToPagedList(request); +// request.TotalNum = list.Count(); +// return pageList; +// } +// } + +// public ProductionDetectionRecords GetConfigByProductionCode(string productionCode) +// { +// using (DBModel context = new DBModel()) +// { +// //ProductionDetectionRecords RR= context.ProductionDetectionRecords.FirstOrDefault(u => u.IS_DELETED == 0 && u.PRODUCTION_CODE == productionCode); +// //return RR; +// return new ProductionDetectionRecords(); +// } +// } +// public bool IsExistId(string id) +// { +// using (DBModel context = new DBModel()) +// { +// ProductionDetectionRecords RR = context.ProductionDetectionRecords.FirstOrDefault(u => u.ID == id); +// return RR != null; +// } +// } + +// } + +// //public class ProductionManagerkey : ModelManager<PRODUCTION_SECRETKEY> +// //{ +// // public PRODUCTION_SECRETKEY GetConfig() +// // { +// // using (DBModel context = new DBModel()) +// // { +// // //return context.PRODUCTION_SECRETKEY.FirstOrDefault(u => u.RUNDAYNUMMAX > 0); +// // return new PRODUCTION_SECRETKEY(); +// // } +// // } +// //} +//} diff --git a/src/Bro.M071.Process.DBManager/Properties/AssemblyInfo.cs b/src/Bro.M071.Process.DBManager/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..8895ef9 --- /dev/null +++ b/src/Bro.M071.Process.DBManager/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +锘縰sing System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 鏈夊叧绋嬪簭闆嗙殑涓�鑸俊鎭敱浠ヤ笅 +// 鎺у埗銆傛洿鏀硅繖浜涚壒鎬у�煎彲淇敼 +// 涓庣▼搴忛泦鍏宠仈鐨勪俊鎭�� +[assembly: AssemblyTitle("Bro.Process.DBManager")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Bro.Process.DBManager")] +[assembly: AssemblyCopyright("Copyright 漏 2018")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 灏� ComVisible 璁剧疆涓� false 浼氫娇姝ょ▼搴忛泦涓殑绫诲瀷 +//瀵� COM 缁勪欢涓嶅彲瑙併�傚鏋滈渶瑕佷粠 COM 璁块棶姝ょ▼搴忛泦涓殑绫诲瀷 +//璇峰皢姝ょ被鍨嬬殑 ComVisible 鐗规�ц缃负 true銆� +[assembly: ComVisible(false)] + +// 濡傛灉姝ら」鐩悜 COM 鍏紑锛屽垯涓嬪垪 GUID 鐢ㄤ簬绫诲瀷搴撶殑 ID +[assembly: Guid("230b0fff-f6af-45fe-aaf7-b4b66250dd58")] + +// 绋嬪簭闆嗙殑鐗堟湰淇℃伅鐢变笅鍒楀洓涓�肩粍鎴�: +// +// 涓荤増鏈� +// 娆$増鏈� +// 鐢熸垚鍙� +// 淇鍙� +// +// 鍙互鎸囧畾鎵�鏈夊�硷紝涔熷彲浠ヤ娇鐢ㄤ互涓嬫墍绀虹殑 "*" 棰勭疆鐗堟湰鍙峰拰淇鍙� +//閫氳繃浣跨敤 "*"锛屽涓嬫墍绀�: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/Bro.M071.Process.DBManager/packages.config b/src/Bro.M071.Process.DBManager/packages.config new file mode 100644 index 0000000..455fb3e --- /dev/null +++ b/src/Bro.M071.Process.DBManager/packages.config @@ -0,0 +1,10 @@ +锘�<?xml version="1.0" encoding="utf-8"?> +<packages> + <package id="EntityFramework" version="6.4.0" targetFramework="net452" /> + <package id="SQLite.CodeFirst" version="1.5.3.29" targetFramework="net452" /> + <package id="System.Data.SQLite" version="1.0.112.0" targetFramework="net452" /> + <package id="System.Data.SQLite.Core" version="1.0.112.0" targetFramework="net452" /> + <package id="System.Data.SQLite.EF6" version="1.0.112.0" targetFramework="net452" /> + <package id="System.Data.SQLite.EF6.Migrations" version="1.0.106" targetFramework="net452" /> + <package id="System.Data.SQLite.Linq" version="1.0.112.0" targetFramework="net452" /> +</packages> \ No newline at end of file diff --git a/src/Bro.M071.Process.Model/App.config b/src/Bro.M071.Process.Model/App.config new file mode 100644 index 0000000..06783b1 --- /dev/null +++ b/src/Bro.M071.Process.Model/App.config @@ -0,0 +1,43 @@ +锘�<?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.SqlConnectionFactory, EntityFramework" /> + <providers> + <provider invariantName="System.Data.SQLite" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" /> + <provider invariantName="System.Data.SQLite.EF6" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" /> + <!--<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />--> + </providers> + </entityFramework> + <connectionStrings> + <!--<add name="DBSet" connectionString="data source=(LocalDb)\MSSQLLocalDB;initial catalog=Bro.Process.Model.Model;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework" providerName="System.Data.SqlClient" />--> + <!--<add name="DBModel" connectionString="data source=(LocalDb)\MSSQLLocalDB;initial catalog=Bro.Process.Model.DBModel;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework" providerName="System.Data.SqlClient" />--> + <add name="DBModel" connectionString="data source=D:\PROJECTS\M071\DataBase\M071.db;BinaryGUID=False" providerName="System.Data.SQLite" /> + </connectionStrings> + <system.data> + <DbProviderFactories> + <remove invariant="System.Data.SQLite.EF6" /> + <add name="SQLite Data Provider (Entity Framework 6)" invariant="System.Data.SQLite.EF6" description=".NET Framework Data Provider for SQLite (Entity Framework 6)" type="System.Data.SQLite.EF6.SQLiteProviderFactory, System.Data.SQLite.EF6" /> + <remove invariant="System.Data.SQLite" /> + <add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".NET Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" /> + </DbProviderFactories> + </system.data> + <runtime> + <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> + <dependentAssembly> + <assemblyIdentity name="System.Data.SQLite" publicKeyToken="db937bc2d44ff139" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-1.0.112.0" newVersion="1.0.112.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Data.SQLite.EF6" publicKeyToken="db937bc2d44ff139" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-1.0.112.0" newVersion="1.0.112.0" /> + </dependentAssembly> + </assemblyBinding> + </runtime> + <startup> + <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" /> + </startup> +</configuration> \ No newline at end of file diff --git a/src/Bro.M071.Process.Model/BaseModel.cs b/src/Bro.M071.Process.Model/BaseModel.cs new file mode 100644 index 0000000..8bcf90b --- /dev/null +++ b/src/Bro.M071.Process.Model/BaseModel.cs @@ -0,0 +1,201 @@ +锘�//using System; +//using System.Collections.Generic; +//using System.ComponentModel; +//using System.ComponentModel.DataAnnotations; +//using System.Linq; +//using System.Reflection; +//using System.Text; +//using System.Threading.Tasks; + +//namespace Bro.M071.Process.Model +//{ +// public class BaseModel +// { +// /// <summary> +// /// 缂栧彿锛屽敮涓�鍊�,浣跨敤GUID +// /// </summary> +// [Key] +// [Required(ErrorMessage = "缂栧彿涓嶅彲涓虹┖锛�")] +// [StringLength(50)] +// public string ID { get; set; } = Guid.NewGuid().ToString().ToUpper(); + +// /// <summary> +// /// 绂佺敤鐘舵�� 0 鏈鐢� 1 宸茬鐢� +// /// </summary> +// [Required] +// public int IS_DISABLED { get; set; } = 0; + +// /// <summary> +// /// 鍒犻櫎鐘舵�� 0 鏈垹闄� 1 宸插垹闄� +// /// </summary> +// [Required] +// public int IS_DELETED { get; set; } = 0; + +// /// <summary> +// /// 鍒涘缓浜轰俊鎭� +// /// </summary> +// //[Required] +// [StringLength(50)] +// public string CREATE_USER { get; set; } + +// /// <summary> +// /// 鍒涘缓鏃堕棿 +// /// </summary> +// //[Required] +// public DateTime? CREATE_TIME { get; set; } = DateTime.Now; + +// /// <summary> +// /// 鏇存柊浜轰俊鎭� +// /// </summary> +// [StringLength(50)] +// public string UPDATE_USER { get; set; } + +// /// <summary> +// /// 鏇存柊鏃堕棿 +// /// </summary> +// public DateTime? UPDATE_TIME { get; set; } +// } + +// public static class BaseModelHelper +// { +// public static void SetNew<T>(this T t, string userId) where T : BaseModel +// { +// //t.ID = Guid.NewGuid().ToString().ToUpper(); +// t.CREATE_USER = userId; +// t.CREATE_TIME = DateTime.Now; +// } + +// public static void SetUpdate<T>(this T t, string userId) where T : BaseModel +// { +// t.UPDATE_USER = userId; +// t.UPDATE_TIME = DateTime.Now; +// } + +// static List<string> NoTransferProps = new List<string>() { "ID", "CREATE_USER", "CREATE_TIME", "UPDATE_USER", "UPDATE_TIME", "IS_DELETED" }; +// public static void DataTransfer<T>(this T destT, T sourceT) where T : BaseModel +// { +// destT.DataFrom(sourceT, NoTransferProps); +// } + +// public static void DataFrom<T1, T2>(this T1 destT, T2 sourceT, List<string> exceptionProps = null) where T1 : class where T2 : class +// { +// PropertyInfo[] propDest = destT.GetType().GetProperties().Where(p => !(p.GetMethod.IsVirtual && !p.GetMethod.IsFinal)).ToArray(); +// PropertyInfo[] propSource = sourceT.GetType().GetProperties(); + +// Array.ForEach(propDest, prop => +// { +// if (exceptionProps == null || !exceptionProps.Contains(prop.Name)) +// { +// if (prop.CanWrite) +// { +// PropertyInfo propS = propSource.FirstOrDefault(p => p.Name == prop.Name); +// if (propS != null && propS.CanRead) +// { +// prop.SetValue(destT, propS.GetValue(sourceT)); +// } +// } +// } +// }); +// } + +// public static List<T> ToPagedList<T>(this IQueryable<T> orderQuery, BaseRequest request) where T : class +// { +// return orderQuery.Skip((request.PageNum - 1) * request.PageSize).Take(request.PageSize).ToList(); +// } +// } + +// public class BaseRequest : INotifyPropertyChanged +// { + +// private int pageNum = 1; +// /// <summary> +// /// 鏌ヨ缁撴灉椤垫暟 +// /// </summary> +// public int PageNum +// { +// get => pageNum; +// set +// { +// if (pageNum != value) +// { +// pageNum = value; +// PropertyChanged?.BeginInvoke(this, new PropertyChangedEventArgs("PageNum"), null, null); +// } +// } +// } + +// private int pageSize = 100; +// /// <summary> +// /// 姣忛〉鐨勬煡璇㈢粨鏋滄潯鏁� +// /// </summary> +// public int PageSize +// { +// get => pageSize; +// set +// { +// if (pageSize != value) +// { +// pageSize = value; +// PropertyChanged?.BeginInvoke(this, new PropertyChangedEventArgs("PageSize"), null, null); +// } +// } +// } + +// /// <summary> +// /// 鏌ヨ璧峰鏃堕棿 +// /// </summary> +// public DateTime? StartTime { get; set; } + +// /// <summary> +// /// 鏌ヨ缁撴潫鏃堕棿 +// /// </summary> +// public DateTime? EndTime { get; set; } + +// /// <summary> +// /// 鍚敤鐘舵�佽繃婊ゅ櫒 1锛氫粎鏈惎鐢� 0锛氫粎鍚敤 -1锛氬叏閮� +// /// </summary> +// public int DisableFilter { get; set; } = 0; + +// /// <summary> +// /// 鏌ヨ瀛楃涓� +// /// </summary> +// public string SearchTxt { get; set; } + +// private int totalNum = 0; +// /// <summary> +// /// 鏁版嵁鎬绘暟 +// /// </summary> +// public int TotalNum +// { +// get => totalNum; +// set +// { +// if (totalNum != value) +// { +// totalNum = value; +// PropertyChanged?.BeginInvoke(this, new PropertyChangedEventArgs("TotalNum"), null, null); +// } +// TotalPage = (int)Math.Ceiling((double)TotalNum / PageSize); +// } +// } + +// private int totalPage = 0; +// /// <summary> +// /// 鎬婚〉鏁� +// /// </summary> +// public int TotalPage +// { +// get => totalPage; +// set +// { +// if (totalPage != value) +// { +// totalPage = value; +// PropertyChanged?.BeginInvoke(this, new PropertyChangedEventArgs("TotalPage"), null, null); +// } +// } +// } + +// public event PropertyChangedEventHandler PropertyChanged; +// } +//} diff --git a/src/Bro.M071.Process.Model/Bro.M071.Process.Model.csproj b/src/Bro.M071.Process.Model/Bro.M071.Process.Model.csproj new file mode 100644 index 0000000..335fb1c --- /dev/null +++ b/src/Bro.M071.Process.Model/Bro.M071.Process.Model.csproj @@ -0,0 +1,95 @@ +锘�<?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> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProjectGuid>{AD645C48-5811-4B1E-B81F-D35D5E6B577F}</ProjectGuid> + <OutputType>Library</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>Bro.Process.Model</RootNamespace> + <AssemblyName>Bro.Process.Model</AssemblyName> + <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion> + <FileAlignment>512</FileAlignment> + <NuGetPackageImportStamp> + </NuGetPackageImportStamp> + <TargetFrameworkProfile /> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>..\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <PlatformTarget>AnyCPU</PlatformTarget> + </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.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="System" /> + <Reference Include="System.ComponentModel.DataAnnotations" /> + <Reference Include="System.Core" /> + <Reference Include="System.Data.SQLite, Version=1.0.112.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL"> + <HintPath>..\..\packages\System.Data.SQLite.Core.1.0.112.0\lib\net451\System.Data.SQLite.dll</HintPath> + </Reference> + <Reference Include="System.Data.SQLite.EF6, Version=1.0.112.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL"> + <HintPath>..\..\packages\System.Data.SQLite.EF6.1.0.112.0\lib\net451\System.Data.SQLite.EF6.dll</HintPath> + </Reference> + <Reference Include="System.Data.SQLite.EF6.Migrations, Version=1.0.106.0, Culture=neutral, processorArchitecture=MSIL"> + <HintPath>..\..\packages\System.Data.SQLite.EF6.Migrations.1.0.106\lib\System.Data.SQLite.EF6.Migrations.dll</HintPath> + </Reference> + <Reference Include="System.Data.SQLite.Linq, Version=1.0.112.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL"> + <HintPath>..\..\packages\System.Data.SQLite.Linq.1.0.112.0\lib\net451\System.Data.SQLite.Linq.dll</HintPath> + </Reference> + <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="BaseModel.cs" /> + <Compile Include="DBModel.cs" /> + <Compile Include="Migrations\Configuration.cs" /> + <Compile Include="Model\ManualDetectionRecords.cs" /> + <Compile Include="Model\EventTimeRecords.cs" /> + <Compile Include="Model\OperationRecords.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="App.config"> + <SubType>Designer</SubType> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </None> + <None Include="packages.config" /> + </ItemGroup> + <ItemGroup /> + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> + <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> + <PropertyGroup> + </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'))" /> + <Error Condition="!Exists('..\..\packages\System.Data.SQLite.Core.1.0.112.0\build\net451\System.Data.SQLite.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\System.Data.SQLite.Core.1.0.112.0\build\net451\System.Data.SQLite.Core.targets'))" /> + </Target> + <Import Project="..\..\packages\EntityFramework.6.4.0\build\EntityFramework.targets" Condition="Exists('..\..\packages\EntityFramework.6.4.0\build\EntityFramework.targets')" /> + <Import Project="..\..\packages\System.Data.SQLite.Core.1.0.112.0\build\net451\System.Data.SQLite.Core.targets" Condition="Exists('..\..\packages\System.Data.SQLite.Core.1.0.112.0\build\net451\System.Data.SQLite.Core.targets')" /> +</Project> \ No newline at end of file diff --git a/src/Bro.M071.Process.Model/DBModel.cs b/src/Bro.M071.Process.Model/DBModel.cs new file mode 100644 index 0000000..92ccb4a --- /dev/null +++ b/src/Bro.M071.Process.Model/DBModel.cs @@ -0,0 +1,67 @@ +锘�//using Bro.Process.Model.Migrations; +//using Bro.Process.Model.Model; +//using System; +//using System.Data.Entity; +//using System.Data.Entity.ModelConfiguration.Conventions; +//using System.Linq; + +//namespace Bro.M071.Process.Model +//{ +// public class DBModel : DbContext +// { +// //鎮ㄧ殑涓婁笅鏂囧凡閰嶇疆涓轰粠鎮ㄧ殑搴旂敤绋嬪簭鐨勯厤缃枃浠�(App.config 鎴� Web.config) +// //浣跨敤鈥淒BModel鈥濊繛鎺ュ瓧绗︿覆銆傞粯璁ゆ儏鍐典笅锛屾杩炴帴瀛楃涓查拡瀵规偍鐨� LocalDb 瀹炰緥涓婄殑 +// //鈥淏ro.Process.Model.DBModel鈥濇暟鎹簱銆� +// // +// //濡傛灉鎮ㄦ兂瑕侀拡瀵瑰叾浠栨暟鎹簱鍜�/鎴栨暟鎹簱鎻愪緵绋嬪簭锛岃鍦ㄥ簲鐢ㄧ▼搴忛厤缃枃浠朵腑淇敼鈥淒BModel鈥� +// //杩炴帴瀛楃涓层�� +// public DBModel() +// : base("name=DBModel") +// { +// ////鏁版嵁搴撹縼绉绘鏌ユ殏鏃舵斁鍦ㄦ瀯閫犲嚱鏁颁腑锛屽洖澶翠細鏀惧埌绋嬪簭鍒濆鍖栦腑 +// //Database.SetInitializer(new MigrateDatabaseToLatestVersion<DBModel, Configuration>()); +// } + +// //涓烘偍瑕佸湪妯″瀷涓寘鍚殑姣忕瀹炰綋绫诲瀷閮芥坊鍔� DbSet銆傛湁鍏抽厤缃拰浣跨敤 Code First 妯″瀷 +// //鐨勮缁嗕俊鎭紝璇峰弬闃� http://go.microsoft.com/fwlink/?LinkId=390109銆� + +// // public virtual DbSet<MyEntity> MyEntities { get; set; } +// //public virtual DbSet<PRODUCTION_SECRETKEY> PRODUCTION_SECRETKEY { get; set; } +// //public virtual DbSet<PRODUCTION_CONFIG> PRODUCTION_CONFIG { get; set; } + + +// public virtual DbSet<ProductionDetectionRecords> ProductionDetectionRecords { get; set; } +// public virtual DbSet<ProductionDetectionRecordsDetail> ProductionDetectionRecordsDetail { get; set; } +// public virtual DbSet<OperationRecords> OperationRecords { get; set; } +// public virtual DbSet<ProductionDetectionImageRecords> ProductionDetectionImageRecords { get; set; } +// public virtual DbSet<ManualDetectionRecords> ManualDetectionRecords { get; set; } +// public virtual DbSet<EventTimeRecords> EventTimeRecords { get; set; } + +// protected override void OnModelCreating(DbModelBuilder modelBuilder) +// { +// //base.OnModelCreating(modelBuilder); + +// #region for sqlite db +// modelBuilder.Conventions.Remove<PluralizingTableNameConvention>(); +// modelBuilder.Configurations.AddFromAssembly(typeof(DBModel).Assembly); +// #endregion +// } +// } + +// public static class DatabaseInitialize +// { +// public static void Initialize() +// { +// Database.SetInitializer(new MigrateDatabaseToLatestVersion<DBModel, Configuration>()); +// using (DbContext dbContext = new DBModel()) +// { +// dbContext.Database.Initialize(true); +// } +// } +// } +// //public class MyEntity +// //{ +// // public int Id { get; set; } +// // public string Name { get; set; } +// //} +//} \ No newline at end of file diff --git a/src/Bro.M071.Process.Model/Migrations/Configuration.cs b/src/Bro.M071.Process.Model/Migrations/Configuration.cs new file mode 100644 index 0000000..0f2bb06 --- /dev/null +++ b/src/Bro.M071.Process.Model/Migrations/Configuration.cs @@ -0,0 +1,37 @@ +//namespace Bro.M071.Process.Model.Migrations +//{ +// using System; +// using System.Data.Entity; +// using System.Data.Entity.Migrations; +// using System.Data.SQLite.EF6.Migrations; +// using System.Linq; + +// public sealed class Configuration : DbMigrationsConfiguration<Bro.Process.Model.DBModel> +// { +// public Configuration() +// { +// AutomaticMigrationsEnabled = true; +// AutomaticMigrationDataLossAllowed = true; + +// #region for sqlite db +// SetSqlGenerator("System.Data.SQLite", new SQLiteMigrationSqlGenerator()); +// #endregion +// } + +// protected override void Seed(Bro.Process.Model.DBModel 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. E.g. +// // +// // context.People.AddOrUpdate( +// // p => p.FullName, +// // new Person { FullName = "Andrew Peters" }, +// // new Person { FullName = "Brice Lambson" }, +// // new Person { FullName = "Rowan Miller" } +// // ); +// // +// } +// } +//} diff --git a/src/Bro.M071.Process.Model/Model/EventTimeRecords.cs b/src/Bro.M071.Process.Model/Model/EventTimeRecords.cs new file mode 100644 index 0000000..c5fb1bc --- /dev/null +++ b/src/Bro.M071.Process.Model/Model/EventTimeRecords.cs @@ -0,0 +1,52 @@ +锘� +//using System; +//using System.ComponentModel.DataAnnotations; + +//namespace Bro.M071.Process.Model.Model +//{ +// /// <summary> +// /// 浜嬩欢鏃堕棿璁板綍 +// /// </summary> +// public class EventTimeRecords : BaseModel +// { +// /// <summary> +// /// 鎿嶄綔鍛樼紪鍙� +// /// </summary> +// [StringLength(64)] +// public string UserNO { get; set; } + +// /// <summary> +// /// 鐝 +// /// </summary> +// public int Shift { get; set; } + +// /// <summary> +// /// 浜嬩欢绫诲瀷锛堢┖闂� 鏁呴殰 姝e父杩愯锛� +// /// </summary> +// public int EventType { get; set; } + +// ///// <summary> +// ///// 浜嬩欢寮�濮�/缁撴潫 +// ///// </summary> +// //public int EventStatus { get; set; } + +// /// <summary> +// /// 浜嬩欢鏃堕棿 +// /// </summary> +// public DateTime EventTime { get; set; } + +// /// <summary> +// /// 浜嬩欢澶囨敞 +// /// </summary> +// [StringLength(256)] +// public string Remark { get; set; } +// } + +// public class EventTimeRecordsRequest : BaseRequest +// { +// public string UserNO { get; set; } +// public int Shift { get; set; } +// public int EventType { get; set; } +// } + +//} diff --git a/src/Bro.M071.Process.Model/Model/ManualDetectionRecords.cs b/src/Bro.M071.Process.Model/Model/ManualDetectionRecords.cs new file mode 100644 index 0000000..b0f221a --- /dev/null +++ b/src/Bro.M071.Process.Model/Model/ManualDetectionRecords.cs @@ -0,0 +1,58 @@ +锘�//using System; +//using System.Collections.Generic; +//using System.ComponentModel; +//using System.ComponentModel.DataAnnotations; +//using System.Linq; +//using System.Text; +//using System.Threading.Tasks; + +//namespace Bro.M071.Process.Model.Model +//{ +// public class ManualDetectionRecords : BaseModel, INotifyPropertyChanged +// { +// /// <summary> +// /// 妫�娴嬪浘鐗囩殑璺緞锛堝師濮嬪浘鐗� 棰勫鐞嗗浘鐗囪矾寰勶級 鍏宠仈鍒版娴嬭褰曡〃锛堜竴寮犲浘鐗囧娆℃娴� 鍘熷璺緞涓嶅彉锛� +// /// </summary> +// [StringLength(512)] +// public string OriginalImgPath { get; set; } + + +// private string manualResult = null; +// /// <summary> +// /// 浜哄伐瀵规爣缁撴灉 +// /// </summary> +// [StringLength(64)] +// public string ManualResult +// { +// get => manualResult; +// set +// { +// if (manualResult != value) +// { +// manualResult = value; +// PropertyChanged?.BeginInvoke(this, new PropertyChangedEventArgs("ManualResult"), null, null); +// } +// } +// } + +// private string manualDefectNameList = null; +// /// <summary> +// /// 浜哄伐瀵规爣缂洪櫡鍚嶇О +// /// </summary> +// [StringLength(256)] +// public string ManualDefectNameList +// { +// get => manualDefectNameList; +// set +// { +// if (manualDefectNameList != value) +// { +// manualDefectNameList = value; +// PropertyChanged?.BeginInvoke(this, new PropertyChangedEventArgs("ManualDefectNameList"), null, null); +// } +// } +// } + +// public event PropertyChangedEventHandler PropertyChanged; +// } +//} diff --git a/src/Bro.M071.Process.Model/Model/OperationRecords.cs b/src/Bro.M071.Process.Model/Model/OperationRecords.cs new file mode 100644 index 0000000..aaad5ac --- /dev/null +++ b/src/Bro.M071.Process.Model/Model/OperationRecords.cs @@ -0,0 +1,60 @@ +锘� +//using System; +//using System.ComponentModel.DataAnnotations; + +//namespace Bro.M071.Process.Model.Model +//{ +// public class OperationRecords : BaseModel +// { +// /// <summary> +// /// 鎿嶄綔鍛樼紪鍙� +// /// </summary> +// [StringLength(64)] +// public string UserNO { get; set; } + +// /// <summary> +// /// 鎿嶄綔鍛樼敓浜х殑鎵规鍙� +// /// </summary> +// [StringLength(64)] +// public string ProductionBatchNO { get; set; } + +// /// <summary> +// /// 鎿嶄綔寮�濮嬫椂闂� +// /// </summary> +// public DateTime OperationStartTime { get; set; } + +// /// <summary> +// /// 鎿嶄綔缁撴潫鏃堕棿 +// /// </summary> +// public DateTime? OperationEndTime { get; set; } + + +// } + +// public class OperationRecordsRequest : BaseRequest +// { +// public string UserNO { get; set; } +// public string ProductionBatchNO { get; set; } +// } + +// public class ProductionStatistics_Dto +// { + +// public OperationRecords OperationRecordsRowData { get; set; } + +// public int BatchProductionTotalCount { get; set; } + +// public int BatchProductionOKCount { get; set; } + +// public int BatchProductionNGCount { get; set; } + +// public int BatchProductionTBDCount { get; set; } + +// public bool IsSelected { get; set; } + +// public ProductionStatistics_Dto() +// { + +// } +// } +//} diff --git a/src/Bro.M071.Process.Model/Properties/AssemblyInfo.cs b/src/Bro.M071.Process.Model/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..719162e --- /dev/null +++ b/src/Bro.M071.Process.Model/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +锘縰sing System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 鏈夊叧绋嬪簭闆嗙殑涓�鑸俊鎭敱浠ヤ笅 +// 鎺у埗銆傛洿鏀硅繖浜涚壒鎬у�煎彲淇敼 +// 涓庣▼搴忛泦鍏宠仈鐨勪俊鎭�� +[assembly: AssemblyTitle("Bro.Process.Model")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Bro.Process.Model")] +[assembly: AssemblyCopyright("Copyright 漏 2018")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 灏� ComVisible 璁剧疆涓� false 浼氫娇姝ょ▼搴忛泦涓殑绫诲瀷 +//瀵� COM 缁勪欢涓嶅彲瑙併�傚鏋滈渶瑕佷粠 COM 璁块棶姝ょ▼搴忛泦涓殑绫诲瀷 +//璇峰皢姝ょ被鍨嬬殑 ComVisible 鐗规�ц缃负 true銆� +[assembly: ComVisible(false)] + +// 濡傛灉姝ら」鐩悜 COM 鍏紑锛屽垯涓嬪垪 GUID 鐢ㄤ簬绫诲瀷搴撶殑 ID +[assembly: Guid("ad645c48-5811-4b1e-b81f-d35d5e6b577f")] + +// 绋嬪簭闆嗙殑鐗堟湰淇℃伅鐢变笅鍒楀洓涓�肩粍鎴�: +// +// 涓荤増鏈� +// 娆$増鏈� +// 鐢熸垚鍙� +// 淇鍙� +// +// 鍙互鎸囧畾鎵�鏈夊�硷紝涔熷彲浠ヤ娇鐢ㄤ互涓嬫墍绀虹殑 "*" 棰勭疆鐗堟湰鍙峰拰淇鍙� +//閫氳繃浣跨敤 "*"锛屽涓嬫墍绀�: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/Bro.M071.Process.Model/packages.config b/src/Bro.M071.Process.Model/packages.config new file mode 100644 index 0000000..455fb3e --- /dev/null +++ b/src/Bro.M071.Process.Model/packages.config @@ -0,0 +1,10 @@ +锘�<?xml version="1.0" encoding="utf-8"?> +<packages> + <package id="EntityFramework" version="6.4.0" targetFramework="net452" /> + <package id="SQLite.CodeFirst" version="1.5.3.29" targetFramework="net452" /> + <package id="System.Data.SQLite" version="1.0.112.0" targetFramework="net452" /> + <package id="System.Data.SQLite.Core" version="1.0.112.0" targetFramework="net452" /> + <package id="System.Data.SQLite.EF6" version="1.0.112.0" targetFramework="net452" /> + <package id="System.Data.SQLite.EF6.Migrations" version="1.0.106" targetFramework="net452" /> + <package id="System.Data.SQLite.Linq" version="1.0.112.0" targetFramework="net452" /> +</packages> \ No newline at end of file diff --git a/src/Bro.Process.DBManager/App.config b/src/Bro.Process.DBManager/App.config new file mode 100644 index 0000000..acbf0ea --- /dev/null +++ b/src/Bro.Process.DBManager/App.config @@ -0,0 +1,36 @@ +锘�<?xml version="1.0" encoding="utf-8"?> +<configuration> + <configSections> + <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --> + <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --> + <!-- 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> + <system.data> + <DbProviderFactories> + <remove invariant="System.Data.SQLite.EF6" /> + <add name="SQLite Data Provider (Entity Framework 6)" invariant="System.Data.SQLite.EF6" description=".NET Framework Data Provider for SQLite (Entity Framework 6)" type="System.Data.SQLite.EF6.SQLiteProviderFactory, System.Data.SQLite.EF6" /> + <remove invariant="System.Data.SQLite" /> + <add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".NET Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" /> + </DbProviderFactories> + </system.data> + <entityFramework> + <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" /> + <providers> + <provider invariantName="System.Data.SQLite" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" /> + <provider invariantName="System.Data.SQLite.EF6" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" /> + </providers> + </entityFramework> + <runtime> + <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> + <dependentAssembly> + <assemblyIdentity name="System.Data.SQLite" publicKeyToken="db937bc2d44ff139" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-1.0.112.0" newVersion="1.0.112.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Data.SQLite.EF6" publicKeyToken="db937bc2d44ff139" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-1.0.112.0" newVersion="1.0.112.0" /> + </dependentAssembly> + </assemblyBinding> + </runtime> +<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" /></startup></configuration> diff --git a/src/Bro.Process.DBManager/Bro.Process.DBManager.csproj b/src/Bro.Process.DBManager/Bro.Process.DBManager.csproj new file mode 100644 index 0000000..9ff3b55 --- /dev/null +++ b/src/Bro.Process.DBManager/Bro.Process.DBManager.csproj @@ -0,0 +1,102 @@ +锘�<?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> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProjectGuid>{65302D6E-9918-4E4C-92B4-75C8830C6BA7}</ProjectGuid> + <OutputType>Library</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>Bro.Process.DBManager</RootNamespace> + <AssemblyName>Bro.Process.DBManager</AssemblyName> + <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion> + <FileAlignment>512</FileAlignment> + <NuGetPackageImportStamp> + </NuGetPackageImportStamp> + <TargetFrameworkProfile /> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>..\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.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="SQLite.CodeFirst, Version=1.5.3.29, Culture=neutral, PublicKeyToken=eb96ba0a78d831a7, processorArchitecture=MSIL"> + <HintPath>..\..\packages\SQLite.CodeFirst.1.5.3.29\lib\net45\SQLite.CodeFirst.dll</HintPath> + </Reference> + <Reference Include="System" /> + <Reference Include="System.ComponentModel.DataAnnotations" /> + <Reference Include="System.Configuration" /> + <Reference Include="System.Core" /> + <Reference Include="System.Data.SQLite, Version=1.0.112.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL"> + <HintPath>..\..\packages\System.Data.SQLite.Core.1.0.112.0\lib\net451\System.Data.SQLite.dll</HintPath> + </Reference> + <Reference Include="System.Data.SQLite.EF6, Version=1.0.112.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL"> + <HintPath>..\..\packages\System.Data.SQLite.EF6.1.0.112.0\lib\net451\System.Data.SQLite.EF6.dll</HintPath> + </Reference> + <Reference Include="System.Data.SQLite.EF6.Migrations, Version=1.0.106.0, Culture=neutral, processorArchitecture=MSIL"> + <HintPath>..\..\packages\System.Data.SQLite.EF6.Migrations.1.0.106\lib\System.Data.SQLite.EF6.Migrations.dll</HintPath> + </Reference> + <Reference Include="System.Data.SQLite.Linq, Version=1.0.112.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL"> + <HintPath>..\..\packages\System.Data.SQLite.Linq.1.0.112.0\lib\net451\System.Data.SQLite.Linq.dll</HintPath> + </Reference> + <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="ModelManager.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + <Compile Include="SQLiteHelper.cs" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\Bro.Common.Model\Bro.Common.Model.csproj"> + <Project>{1A3CBFE7-3F78-42C3-95C5-10360450DBEA}</Project> + <Name>Bro.Common.Model</Name> + </ProjectReference> + <ProjectReference Include="..\Bro.Common.Device\Bro.Common.Device.csproj"> + <Project>{987308DD-8BAA-463A-94E2-77D62E01A5BF}</Project> + <Name>Bro.Common.Device</Name> + </ProjectReference> + <ProjectReference Include="..\Bro.M071.Process.Model\Bro.M071.Process.Model.csproj"> + <Project>{AD645C48-5811-4B1E-B81F-D35D5E6B577F}</Project> + <Name>Bro.M071.Process.Model</Name> + </ProjectReference> + </ItemGroup> + <ItemGroup> + <None Include="App.config" /> + <None Include="packages.config" /> + </ItemGroup> + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> + <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> + <PropertyGroup> + </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'))" /> + <Error Condition="!Exists('..\..\packages\System.Data.SQLite.Core.1.0.112.0\build\net451\System.Data.SQLite.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\System.Data.SQLite.Core.1.0.112.0\build\net451\System.Data.SQLite.Core.targets'))" /> + </Target> + <Import Project="..\..\packages\EntityFramework.6.4.0\build\EntityFramework.targets" Condition="Exists('..\..\packages\EntityFramework.6.4.0\build\EntityFramework.targets')" /> + <Import Project="..\..\packages\System.Data.SQLite.Core.1.0.112.0\build\net451\System.Data.SQLite.Core.targets" Condition="Exists('..\..\packages\System.Data.SQLite.Core.1.0.112.0\build\net451\System.Data.SQLite.Core.targets')" /> +</Project> \ No newline at end of file diff --git a/src/Bro.Process.DBManager/ModelManager.cs b/src/Bro.Process.DBManager/ModelManager.cs new file mode 100644 index 0000000..9c26540 --- /dev/null +++ b/src/Bro.Process.DBManager/ModelManager.cs @@ -0,0 +1,113 @@ +锘�//using Bro.Process.Model; +//using System; +//using System.Collections.Generic; +//using System.Configuration; +//using System.Data.Common; +//using System.Data.Entity; +//using System.Data.SQLite; +//using System.Linq; +//using System.Reflection; +//using System.Text; +//using System.Threading.Tasks; + +//namespace Bro.Process.DBManager +//{ +// public class ModelManager<T> where T : BaseModel, new() +// { +// private PropertyInfo TableProperty = null; +// public static string ConnectionString = ConfigurationManager.ConnectionStrings["DBModel"].ConnectionString; +// public ModelManager() +// { +// T t = new T(); +// using (DBModel db = new DBModel()) +// { +// TableProperty = db.GetType().GetProperties().FirstOrDefault(u => u.Name == t.GetType().Name); +// } +// } + +// public void NewModel(T t, string userId = "") +// { +// using (DBModel context = new DBModel()) +// { +// ActionBeforeNewModel(context, t); + +// t.SetNew(userId); +// (TableProperty.GetValue(context) as DbSet<T>).Add(t); + +// context.SaveChanges(); +// } +// } + +// public void BatchAdd(List<T> t, string userId = "") +// { +// using (DBModel context = new DBModel()) +// { +// (TableProperty.GetValue(context) as DbSet<T>).AddRange(t); +// context.SaveChanges(); +// } +// } + +// public void UpdateModel(T t, string userId = "") +// { +// using (DBModel context = new DBModel()) +// { +// ActionBeforeUpdateModel(context, t); + +// DbSet<T> set = TableProperty.GetValue(context) as DbSet<T>; +// T oldT = set.FirstOrDefault(u => u.ID == t.ID); + +// oldT.DataTransfer(t); +// oldT.SetUpdate(userId); +// context.SaveChanges(); +// } +// } + +// public void DeleteModel(string id, bool isDelete = true, string userId = "") +// { +// using (DBModel context = new DBModel()) +// { +// ActionBeforeDeleteModel(context, id); + +// DbSet<T> set = TableProperty.GetValue(context) as DbSet<T>; +// T oldT = set.FirstOrDefault(u => u.ID == id); +// oldT.IS_DELETED = isDelete ? 1 : 0; +// oldT.SetUpdate(userId); + +// context.SaveChanges(); +// } +// } + +// public void DisableModel(string id, bool isDisable = true, string userId = "") +// { +// using (DBModel context = new DBModel()) +// { +// ActionBeforeEnableModel(context, id); + +// DbSet<T> set = TableProperty.GetValue(context) as DbSet<T>; +// T oldT = set.FirstOrDefault(u => u.ID == id); +// oldT.IS_DISABLED = isDisable ? 1 : 0; +// oldT.SetUpdate(userId); + +// context.SaveChanges(); +// } +// } + +// #region "" +// protected virtual void ActionBeforeNewModel(DBModel context, T t) +// { +// } + +// protected virtual void ActionBeforeUpdateModel(DBModel context, T t) +// { +// } + +// protected virtual void ActionBeforeDeleteModel(DBModel context, string id) +// { +// } + +// protected virtual void ActionBeforeEnableModel(DBModel context, string id) +// { +// } +// #endregion +// } +//} diff --git a/src/Bro.Process.DBManager/Properties/AssemblyInfo.cs b/src/Bro.Process.DBManager/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..8895ef9 --- /dev/null +++ b/src/Bro.Process.DBManager/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +锘縰sing System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 鏈夊叧绋嬪簭闆嗙殑涓�鑸俊鎭敱浠ヤ笅 +// 鎺у埗銆傛洿鏀硅繖浜涚壒鎬у�煎彲淇敼 +// 涓庣▼搴忛泦鍏宠仈鐨勪俊鎭�� +[assembly: AssemblyTitle("Bro.Process.DBManager")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Bro.Process.DBManager")] +[assembly: AssemblyCopyright("Copyright 漏 2018")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 灏� ComVisible 璁剧疆涓� false 浼氫娇姝ょ▼搴忛泦涓殑绫诲瀷 +//瀵� COM 缁勪欢涓嶅彲瑙併�傚鏋滈渶瑕佷粠 COM 璁块棶姝ょ▼搴忛泦涓殑绫诲瀷 +//璇峰皢姝ょ被鍨嬬殑 ComVisible 鐗规�ц缃负 true銆� +[assembly: ComVisible(false)] + +// 濡傛灉姝ら」鐩悜 COM 鍏紑锛屽垯涓嬪垪 GUID 鐢ㄤ簬绫诲瀷搴撶殑 ID +[assembly: Guid("230b0fff-f6af-45fe-aaf7-b4b66250dd58")] + +// 绋嬪簭闆嗙殑鐗堟湰淇℃伅鐢变笅鍒楀洓涓�肩粍鎴�: +// +// 涓荤増鏈� +// 娆$増鏈� +// 鐢熸垚鍙� +// 淇鍙� +// +// 鍙互鎸囧畾鎵�鏈夊�硷紝涔熷彲浠ヤ娇鐢ㄤ互涓嬫墍绀虹殑 "*" 棰勭疆鐗堟湰鍙峰拰淇鍙� +//閫氳繃浣跨敤 "*"锛屽涓嬫墍绀�: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/Bro.Process.DBManager/SQLiteHelper.cs b/src/Bro.Process.DBManager/SQLiteHelper.cs new file mode 100644 index 0000000..b439d60 --- /dev/null +++ b/src/Bro.Process.DBManager/SQLiteHelper.cs @@ -0,0 +1,614 @@ + + +using System; +using System.Collections; +using System.Collections.Specialized; +using System.Data; +using System.Data.SQLite; +using System.Configuration; + +namespace Bro.Process.DBManager +{ + public class SQLiteHelper + { + //数据库连接字符串 + public static string connectionString = ConfigurationManager.ConnectionStrings["DBModel"].ConnectionString; + + public SQLiteHelper() { } + + #region 公用方法 + + public static int GetMaxID(string FieldName, string TableName) + { + string strsql = "select max(" + FieldName + ")+1 from " + TableName; + object obj = GetSingle(strsql); + if (obj == null) + { + return 1; + } + else + { + return int.Parse(obj.ToString()); + } + } + + public static bool Exists(string strSql) + { + object obj = GetSingle(strSql); + int cmdresult; + if ((Object.Equals(obj, null)) || (Object.Equals(obj, System.DBNull.Value))) + { + cmdresult = 0; + } + else + { + cmdresult = int.Parse(obj.ToString()); + } + if (cmdresult == 0) + { + return false; + } + else + { + return true; + } + } + + public static bool Exists(string strSql, params SQLiteParameter[] cmdParms) + { + object obj = GetSingle(strSql, cmdParms); + int cmdresult; + if ((Object.Equals(obj, null)) || (Object.Equals(obj, System.DBNull.Value))) + { + cmdresult = 0; + } + else + { + cmdresult = int.Parse(obj.ToString()); + } + if (cmdresult == 0) + { + return false; + } + else + { + return true; + } + } + + #endregion + + #region 执行简单SQL语句 + + /// <summary> + /// 执行SQL语句,返回影响的记录数 + /// </summary> + /// <param name="SQLString">SQL语句</param> + /// <returns>影响的记录数</returns> + public static int ExecuteSql(string SQLString) + { + using (SQLiteConnection connection = new SQLiteConnection(connectionString)) + { + using (SQLiteCommand cmd = new SQLiteCommand(SQLString, connection)) + { + try + { + connection.Open(); + int rows = cmd.ExecuteNonQuery(); + return rows; + } + catch (System.Data.SQLite.SQLiteException E) + { + connection.Close(); + throw new Exception(E.Message); + } + } + } + } + + /// <summary> + /// 执行SQL语句,设置命令的执行等待时间 + /// </summary> + /// <param name="SQLString"></param> + /// <param name="Times"></param> + /// <returns></returns> + public static int ExecuteSqlByTime(string SQLString, int Times) + { + using (SQLiteConnection connection = new SQLiteConnection(connectionString)) + { + using (SQLiteCommand cmd = new SQLiteCommand(SQLString, connection)) + { + try + { + connection.Open(); + cmd.CommandTimeout = Times; + int rows = cmd.ExecuteNonQuery(); + return rows; + } + catch (System.Data.SQLite.SQLiteException E) + { + connection.Close(); + throw new Exception(E.Message); + } + } + } + } + + /// <summary> + /// 执行多条SQL语句,实现数据库事务。 + /// </summary> + /// <param name="SQLStringList">多条SQL语句</param> + public static bool ExecuteSqlTran(ArrayList SQLStringList) + { + bool isSuccess = false; + using (SQLiteConnection conn = new SQLiteConnection(connectionString)) + { + conn.Open(); + SQLiteCommand cmd = new SQLiteCommand(); + cmd.Connection = conn; + cmd.CommandText = "PRAGMA synchronous = OFF;"; + cmd.ExecuteNonQuery(); + SQLiteTransaction tx = conn.BeginTransaction(); + cmd.Transaction = tx; + try + { + for (int n = 0; n < SQLStringList.Count; n++) + { + string strsql = SQLStringList[n].ToString(); + if (strsql.Trim().Length > 1) + { + cmd.CommandText = strsql; + cmd.ExecuteNonQuery(); + } + } + tx.Commit(); + isSuccess = true; + } + catch (System.Data.SQLite.SQLiteException E) + { + tx.Rollback(); + isSuccess = false; + throw new Exception(E.Message); + } + } + return isSuccess; + } + + /// <summary> + /// 执行带一个存储过程参数的的SQL语句。 + /// </summary> + /// <param name="SQLString">SQL语句</param> + /// <param name="content">参数内容,比如一个字段是格式复杂的文章,有特殊符号,可以通过这个方式添加</param> + /// <returns>影响的记录数</returns> + public static int ExecuteSql(string SQLString, string content) + { + using (SQLiteConnection connection = new SQLiteConnection(connectionString)) + { + SQLiteCommand cmd = new SQLiteCommand(SQLString, connection); + SQLiteParameter myParameter = new SQLiteParameter("@content", DbType.String); + myParameter.Value = content; + cmd.Parameters.Add(myParameter); + try + { + connection.Open(); + int rows = cmd.ExecuteNonQuery(); + return rows; + } + catch (System.Data.SQLite.SQLiteException E) + { + throw new Exception(E.Message); + } + finally + { + cmd.Dispose(); + connection.Close(); + } + } + } + + /// <summary> + /// 执行带一个存储过程参数的的SQL语句。 + /// </summary> + /// <param name="SQLString">SQL语句</param> + /// <param name="content">参数内容,比如一个字段是格式复杂的文章,有特殊符号,可以通过这个方式添加</param> + /// <returns>影响的记录数</returns> + public static object ExecuteSqlGet(string SQLString, string content) + { + using (SQLiteConnection connection = new SQLiteConnection(connectionString)) + { + SQLiteCommand cmd = new SQLiteCommand(SQLString, connection); + SQLiteParameter myParameter = new SQLiteParameter("@content", DbType.String); + myParameter.Value = content; + cmd.Parameters.Add(myParameter); + try + { + connection.Open(); + object obj = cmd.ExecuteScalar(); + if ((Object.Equals(obj, null)) || (Object.Equals(obj, System.DBNull.Value))) + { + return null; + } + else + { + return obj; + } + } + catch (System.Data.SQLite.SQLiteException E) + { + throw new Exception(E.Message); + } + finally + { + cmd.Dispose(); + connection.Close(); + } + } + } + + /// <summary> + /// 向数据库里插入图像格式的字段(和上面情况类似的另一种实例) + /// </summary> + /// <param name="strSQL">SQL语句</param> + /// <param name="fs">图像字节,数据库的字段类型为image的情况</param> + /// <returns>影响的记录数</returns> + public static int ExecuteSqlInsertImg(string strSQL, byte[] fs) + { + using (SQLiteConnection connection = new SQLiteConnection(connectionString)) + { + SQLiteCommand cmd = new SQLiteCommand(strSQL, connection); + SQLiteParameter myParameter = new SQLiteParameter("@fs", DbType.Binary); + myParameter.Value = fs; + cmd.Parameters.Add(myParameter); + try + { + connection.Open(); + int rows = cmd.ExecuteNonQuery(); + return rows; + } + catch (System.Data.SQLite.SQLiteException E) + { + throw new Exception(E.Message); + } + finally + { + cmd.Dispose(); + connection.Close(); + } + } + } + + /// <summary> + /// 执行一条计算查询结果语句,返回查询结果(object)。 + /// </summary> + /// <param name="SQLString">计算查询结果语句</param> + /// <returns>查询结果(object)</returns> + public static object GetSingle(string SQLString) + { + using (SQLiteConnection connection = new SQLiteConnection(connectionString)) + { + using (SQLiteCommand cmd = new SQLiteCommand(SQLString, connection)) + { + try + { + connection.Open(); + object obj = cmd.ExecuteScalar(); + if ((Object.Equals(obj, null)) || (Object.Equals(obj, System.DBNull.Value))) + { + return null; + } + else + { + return obj; + } + } + catch (System.Data.SQLite.SQLiteException e) + { + connection.Close(); + throw new Exception(e.Message); + } + } + } + } + + /// <summary> + /// 执行查询语句,返回SQLiteDataReader(使用该方法切记要手工关闭SQLiteDataReader和连接) + /// </summary> + /// <param name="strSQL">查询语句</param> + /// <returns>SQLiteDataReader</returns> + public static SQLiteDataReader ExecuteReader(string strSQL) + { + SQLiteConnection connection = new SQLiteConnection(connectionString); + SQLiteCommand cmd = new SQLiteCommand(strSQL, connection); + try + { + connection.Open(); + SQLiteDataReader myReader = cmd.ExecuteReader(); + return myReader; + } + catch (System.Data.SQLite.SQLiteException e) + { + throw new Exception(e.Message); + } + //finally //不能在此关闭,否则,返回的对象将无法使用 + //{ + // cmd.Dispose(); + // connection.Close(); + //} + } + + /// <summary> + /// 执行查询语句,返回DataSet + /// </summary> + /// <param name="SQLString">查询语句</param> + /// <returns>DataSet</returns> + public static DataSet Query(string SQLString) + { + using (SQLiteConnection connection = new SQLiteConnection(connectionString)) + { + DataSet ds = new DataSet(); + try + { + connection.Open(); + SQLiteDataAdapter command = new SQLiteDataAdapter(SQLString, connection); + command.Fill(ds, "ds"); + } + catch (System.Data.SQLite.SQLiteException ex) + { + throw new Exception(ex.Message); + } + return ds; + } + } + + public static DataSet Query(string SQLString, string TableName) + { + using (SQLiteConnection connection = new SQLiteConnection(connectionString)) + { + DataSet ds = new DataSet(); + try + { + connection.Open(); + SQLiteDataAdapter command = new SQLiteDataAdapter(SQLString, connection); + command.Fill(ds, TableName); + } + catch (System.Data.SQLite.SQLiteException ex) + { + throw new Exception(ex.Message); + } + return ds; + } + } + + /// <summary> + /// 执行查询语句,返回DataSet,设置命令的执行等待时间 + /// </summary> + /// <param name="SQLString"></param> + /// <param name="Times"></param> + /// <returns></returns> + public static DataSet Query(string SQLString, int Times) + { + using (SQLiteConnection connection = new SQLiteConnection(connectionString)) + { + DataSet ds = new DataSet(); + try + { + connection.Open(); + SQLiteDataAdapter command = new SQLiteDataAdapter(SQLString, connection); + command.SelectCommand.CommandTimeout = Times; + command.Fill(ds, "ds"); + } + catch (System.Data.SQLite.SQLiteException ex) + { + throw new Exception(ex.Message); + } + return ds; + } + } + + #endregion + + #region 执行带参数的SQL语句 + + /// <summary> + /// 执行SQL语句,返回影响的记录数 + /// </summary> + /// <param name="SQLString">SQL语句</param> + /// <returns>影响的记录数</returns> + public static int ExecuteSql(string SQLString, params SQLiteParameter[] cmdParms) + { + using (SQLiteConnection connection = new SQLiteConnection(connectionString)) + { + using (SQLiteCommand cmd = new SQLiteCommand()) + { + try + { + PrepareCommand(cmd, connection, null, SQLString, cmdParms); + int rows = cmd.ExecuteNonQuery(); + cmd.Parameters.Clear(); + return rows; + } + catch (System.Data.SQLite.SQLiteException E) + { + throw new Exception(E.Message); + } + } + } + } + + /// <summary> + /// 执行多条SQL语句,实现数据库事务。 + /// </summary> + /// <param name="SQLStringList">SQL语句的哈希表(key为sql语句,value是该语句的SQLiteParameter[])</param> + public static void ExecuteSqlTran(Hashtable SQLStringList) + { + using (SQLiteConnection conn = new SQLiteConnection(connectionString)) + { + conn.Open(); + using (SQLiteTransaction trans = conn.BeginTransaction()) + { + SQLiteCommand cmd = new SQLiteCommand(); + try + { + //循环 + foreach (DictionaryEntry myDE in SQLStringList) + { + string cmdText = myDE.Key.ToString(); + SQLiteParameter[] cmdParms = (SQLiteParameter[])myDE.Value; + PrepareCommand(cmd, conn, trans, cmdText, cmdParms); + int val = cmd.ExecuteNonQuery(); + cmd.Parameters.Clear(); + } + trans.Commit(); + } + catch (System.Data.SQLite.SQLiteException e) + { + trans.Rollback(); + throw new Exception(e.Message); + } + } + } + } + + /// <summary> + /// 执行一条计算查询结果语句,返回查询结果(object)。 + /// </summary> + /// <param name="SQLString">计算查询结果语句</param> + /// <returns>查询结果(object)</returns> + public static object GetSingle(string SQLString, params SQLiteParameter[] cmdParms) + { + using (SQLiteConnection connection = new SQLiteConnection(connectionString)) + { + using (SQLiteCommand cmd = new SQLiteCommand()) + { + try + { + PrepareCommand(cmd, connection, null, SQLString, cmdParms); + object obj = cmd.ExecuteScalar(); + cmd.Parameters.Clear(); + if ((Object.Equals(obj, null)) || (Object.Equals(obj, System.DBNull.Value))) + { + return null; + } + else + { + return obj; + } + } + catch (System.Data.SQLite.SQLiteException e) + { + throw new Exception(e.Message); + } + } + } + } + + /// <summary> + /// 执行查询语句,返回SQLiteDataReader (使用该方法切记要手工关闭SQLiteDataReader和连接) + /// </summary> + /// <param name="strSQL">查询语句</param> + /// <returns>SQLiteDataReader</returns> + public static SQLiteDataReader ExecuteReader(string SQLString, params SQLiteParameter[] cmdParms) + { + SQLiteConnection connection = new SQLiteConnection(connectionString); + SQLiteCommand cmd = new SQLiteCommand(); + try + { + PrepareCommand(cmd, connection, null, SQLString, cmdParms); + SQLiteDataReader myReader = cmd.ExecuteReader(); + cmd.Parameters.Clear(); + return myReader; + } + catch (System.Data.SQLite.SQLiteException e) + { + throw new Exception(e.Message); + } + //finally //不能在此关闭,否则,返回的对象将无法使用 + //{ + // cmd.Dispose(); + // connection.Close(); + //} + + } + + /// <summary> + /// 执行查询语句,返回DataSet + /// </summary> + /// <param name="SQLString">查询语句</param> + /// <returns>DataSet</returns> + public static DataSet Query(string SQLString, params SQLiteParameter[] cmdParms) + { + using (SQLiteConnection connection = new SQLiteConnection(connectionString)) + { + SQLiteCommand cmd = new SQLiteCommand(); + PrepareCommand(cmd, connection, null, SQLString, cmdParms); + using (SQLiteDataAdapter da = new SQLiteDataAdapter(cmd)) + { + DataSet ds = new DataSet(); + try + { + da.Fill(ds, "ds"); + cmd.Parameters.Clear(); + } + catch (System.Data.SQLite.SQLiteException ex) + { + throw new Exception(ex.Message); + } + return ds; + } + } + } + + public static void PrepareCommand(SQLiteCommand cmd, SQLiteConnection conn, + SQLiteTransaction trans, string cmdText, SQLiteParameter[] cmdParms) + { + if (conn.State != ConnectionState.Open) + conn.Open(); + cmd.Connection = conn; + cmd.CommandText = cmdText; + if (trans != null) + cmd.Transaction = trans; + cmd.CommandType = CommandType.Text;//cmdType; + if (cmdParms != null) + { + foreach (SQLiteParameter parameter in cmdParms) + { + if ((parameter.Direction == ParameterDirection.InputOutput + || parameter.Direction == ParameterDirection.Input) && + (parameter.Value == null)) + { + parameter.Value = DBNull.Value; + } + cmd.Parameters.Add(parameter); + } + } + } + + #endregion + + #region 参数转换 + /// <summary> + /// 放回一个SQLiteParameter + /// </summary> + /// <param name="name">参数名字</param> + /// <param name="type">参数类型</param> + /// <param name="size">参数大小</param> + /// <param name="value">参数值</param> + /// <returns>SQLiteParameter的值</returns> + public static SQLiteParameter MakeSQLiteParameter(string name, + DbType type, int size, object value) + { + SQLiteParameter parm = new SQLiteParameter(name, type, size); + parm.Value = value; + return parm; + } + + public static SQLiteParameter MakeSQLiteParameter(string name, DbType type, object value) + { + SQLiteParameter parm = new SQLiteParameter(name, type); + parm.Value = value; + return parm; + } + + #endregion + } +} \ No newline at end of file diff --git a/src/Bro.Process.DBManager/packages.config b/src/Bro.Process.DBManager/packages.config new file mode 100644 index 0000000..455fb3e --- /dev/null +++ b/src/Bro.Process.DBManager/packages.config @@ -0,0 +1,10 @@ +锘�<?xml version="1.0" encoding="utf-8"?> +<packages> + <package id="EntityFramework" version="6.4.0" targetFramework="net452" /> + <package id="SQLite.CodeFirst" version="1.5.3.29" targetFramework="net452" /> + <package id="System.Data.SQLite" version="1.0.112.0" targetFramework="net452" /> + <package id="System.Data.SQLite.Core" version="1.0.112.0" targetFramework="net452" /> + <package id="System.Data.SQLite.EF6" version="1.0.112.0" targetFramework="net452" /> + <package id="System.Data.SQLite.EF6.Migrations" version="1.0.106" targetFramework="net452" /> + <package id="System.Data.SQLite.Linq" version="1.0.112.0" targetFramework="net452" /> +</packages> \ No newline at end of file -- Gitblit v1.8.0