Przeglądaj źródła

init:初始化提交代码

runming56 2 lat temu
commit
ef7a56c880
17 zmienionych plików z 1129 dodań i 0 usunięć
  1. 39 0
      .gitignore
  2. 29 0
      App.config
  3. 121 0
      CommonStorage.csproj
  4. 385 0
      DBHelper.cs
  5. 39 0
      Model/AppConfig.cs
  6. 52 0
      Model/Device.cs
  7. 60 0
      Model/Log.cs
  8. 88 0
      Model/ReportConfig.cs
  9. 75 0
      Model/TestData.cs
  10. 49 0
      Model/TpsConfig.cs
  11. 83 0
      Model/User.cs
  12. 30 0
      Model/ValueItem.cs
  13. 36 0
      MyDb.cs
  14. 36 0
      Properties/AssemblyInfo.cs
  15. 1 0
      README.md
  16. 5 0
      libman.json
  17. 1 0
      mysql配置参考地址.txt

+ 39 - 0
.gitignore

@@ -0,0 +1,39 @@
+*.swp
+*.*~
+project.lock.json
+.DS_Store
+*.pyc
+nupkg/
+
+# Visual Studio Code
+.vscode
+
+# Rider
+.idea
+
+# User-specific files
+*.suo
+*.user
+*.userosscache
+*.sln.docstates
+
+# Build results
+[Dd]ebug/
+[Dd]ebugPublic/
+[Rr]elease/
+[Rr]eleases/
+x64/
+x86/
+build/
+bld/
+[Bb]in/
+[Oo]bj/
+[Oo]ut/
+msbuild.log
+msbuild.err
+msbuild.wrn
+output
+
+# Visual Studio 2015
+.vs/
+.fake

+ 29 - 0
App.config

@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+  <configSections>
+    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
+    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
+  </configSections>
+  <entityFramework>
+    <providers>
+      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
+    <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.EntityFramework, Version=8.0.31.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d">
+      </provider></providers>
+  </entityFramework>
+  <runtime>
+    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+      <dependentAssembly>
+        <assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+        <bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
+      </dependentAssembly>
+      <dependentAssembly>
+        <assemblyIdentity name="MySql.Data" publicKeyToken="c5687fc88969c44d" culture="neutral" />
+        <bindingRedirect oldVersion="0.0.0.0-8.0.21.0" newVersion="8.0.21.0" />
+      </dependentAssembly>
+      <dependentAssembly>
+        <assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
+        <bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
+      </dependentAssembly>
+    </assemblyBinding>
+  </runtime>
+</configuration>

+ 121 - 0
CommonStorage.csproj

@@ -0,0 +1,121 @@
+<?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>{5FC4388B-CF9F-4846-A441-018C1CE903AC}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>CommonStorage</RootNamespace>
+    <AssemblyName>CommonStorage</AssemblyName>
+    <TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <Deterministic>true</Deterministic>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="BouncyCastle.Crypto">
+      <HintPath>..\libs\BouncyCastle.Crypto.dll</HintPath>
+    </Reference>
+    <Reference Include="EntityFramework">
+      <HintPath>..\libs\EntityFramework.dll</HintPath>
+    </Reference>
+    <Reference Include="EntityFramework.SqlServer">
+      <HintPath>..\libs\EntityFramework.SqlServer.dll</HintPath>
+    </Reference>
+    <Reference Include="Google.Protobuf">
+      <HintPath>..\libs\Google.Protobuf.dll</HintPath>
+    </Reference>
+    <Reference Include="K4os.Compression.LZ4">
+      <HintPath>..\libs\K4os.Compression.LZ4.dll</HintPath>
+    </Reference>
+    <Reference Include="K4os.Compression.LZ4.Streams">
+      <HintPath>..\libs\K4os.Compression.LZ4.Streams.dll</HintPath>
+    </Reference>
+    <Reference Include="K4os.Hash.xxHash">
+      <HintPath>..\libs\K4os.Hash.xxHash.dll</HintPath>
+    </Reference>
+    <Reference Include="MySql.Data">
+      <HintPath>..\libs\MySql.Data.dll</HintPath>
+    </Reference>
+    <Reference Include="MySql.Data.EntityFramework">
+      <HintPath>..\libs\MySql.Data.EntityFramework.dll</HintPath>
+    </Reference>
+    <Reference Include="Newtonsoft.Json">
+      <HintPath>..\libs\Newtonsoft.Json.dll</HintPath>
+    </Reference>
+    <Reference Include="Renci.SshNet">
+      <HintPath>..\libs\Renci.SshNet.dll</HintPath>
+    </Reference>
+    <Reference Include="System" />
+    <Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
+      <HintPath>..\libs\System.Buffers.dll</HintPath>
+    </Reference>
+    <Reference Include="System.ComponentModel" />
+    <Reference Include="System.ComponentModel.DataAnnotations" />
+    <Reference Include="System.Configuration" />
+    <Reference Include="System.Configuration.Install" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Drawing" />
+    <Reference Include="System.Drawing.Design" />
+    <Reference Include="System.Management" />
+    <Reference Include="System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
+      <HintPath>..\libs\System.Memory.dll</HintPath>
+    </Reference>
+    <Reference Include="System.Numerics" />
+    <Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
+      <HintPath>..\libs\System.Numerics.Vectors.dll</HintPath>
+    </Reference>
+    <Reference Include="System.Runtime.CompilerServices.Unsafe, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
+      <HintPath>..\libs\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
+    </Reference>
+    <Reference Include="System.Security" />
+    <Reference Include="System.Transactions" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Net.Http" />
+    <Reference Include="System.Xml" />
+    <Reference Include="ZstdNet">
+      <HintPath>..\libs\ZstdNet.dll</HintPath>
+    </Reference>
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="DBHelper.cs" />
+    <Compile Include="Model\AppConfig.cs" />
+    <Compile Include="Model\ReportConfig.cs" />
+    <Compile Include="Model\ValueItem.cs" />
+    <Compile Include="Model\Device.cs" />
+    <Compile Include="Model\Log.cs" />
+    <Compile Include="Model\TestData.cs" />
+    <Compile Include="Model\TpsConfig.cs" />
+    <Compile Include="Model\User.cs" />
+    <Compile Include="MyDb.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <Content Include="mysql配置参考地址.txt" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="App.config" />
+    <None Include="libman.json" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+</Project>

+ 385 - 0
DBHelper.cs

@@ -0,0 +1,385 @@
+using CommonStorage.Model;
+using MySql.Data.MySqlClient;
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.IO;
+using System.Linq;
+using System.Runtime.ConstrainedExecution;
+using System.Runtime.InteropServices.ComTypes;
+using System.Runtime.Remoting.Metadata.W3cXsd2001;
+using System.Text;
+using static Google.Protobuf.Reflection.FieldOptions.Types;
+
+namespace CommonStorage
+{
+    public class DBHelper
+    {
+        static string connectionString = "server=localhost;port=3306;database=jf200;uid=mysqltest;password=test1234";
+        public static bool InsertIntoLog(string msgType, Model.LevelEnum msgLevel, string msg)
+        {
+            using (MySqlConnection connection = new MySqlConnection(connectionString))
+            {
+                connection.Open();
+                //  MySqlTransaction transaction = connection.BeginTransaction();
+                try
+                {
+                    using (var context = new MyDb(connection, false))
+                    {
+                        // Passing an existing transaction to the context
+                        //         context.Database.UseTransaction(transaction);
+                        context.logs.Add(new Model.Log() { MsgType = msgType, MsgLevel = msgLevel, Message = msg, CreateTime = DateTime.Now });
+                        context.SaveChanges();
+                    }
+                    //    transaction.Commit();
+                }
+                catch(Exception ex)
+                {
+                    throw ex;
+                }
+            }
+
+            return true;
+        }//end InsertIntoLog
+
+        public static User QueryUser(string userName)
+        {
+            using (MySqlConnection connection = new MySqlConnection(connectionString))
+            {
+                connection.Open();
+                try
+                {
+                    using (var context = new MyDb(connection, false))
+                    {
+                        var user = context.users.FirstOrDefault(x => x.UserName == userName);
+                        return user;
+                    }
+                }
+                catch (Exception ex)
+                {
+                    throw ex;
+                }
+            }
+        }
+
+        /// <summary>
+        /// 查询配置的测试项目
+        /// </summary>
+        /// <param name="ProductCode">产品代号</param>
+        /// <returns></returns>
+        public static List<List<ValueItem>> QueryTestPar(string ProductCode)
+        {
+            List<List<ValueItem>> TpsDatas = new List<List<ValueItem>>();
+
+            using (MySqlConnection connection = new MySqlConnection(connectionString))
+            {
+                connection.Open();
+                try
+                {
+                    using (var context = new MyDb(connection, false))
+                    {
+                        var config = context.tpsConfigs.FirstOrDefault(x => x.ProductCode == ProductCode);
+                        if(string.IsNullOrEmpty(config.Values))
+                        {
+                            TpsDatas = JsonConvert.DeserializeObject<List<List<ValueItem>>>(config.Values);
+                        }
+                    }
+                }
+                catch (Exception ex)
+                {
+                    throw ex;
+                }
+            }
+
+            return TpsDatas;
+        }
+
+        /// <summary>
+        /// 新增或者更新产品测试配置数据
+        /// </summary>
+        /// <param name="ProductCode"></param>
+        /// <returns></returns>
+        public static bool AddOrUpdateTestPar(string ProductCode, List<List<ValueItem>> dataItems)
+        {
+            using (MySqlConnection connection = new MySqlConnection(connectionString))
+            {
+                connection.Open();
+                try
+                {
+                    using (var context = new MyDb(connection, false))
+                    {
+                        var config = context.tpsConfigs.FirstOrDefault(x => x.ProductCode == ProductCode);
+                        if(config == null)
+                        {
+                            TpsConfig tpsConfig = new TpsConfig();
+                            tpsConfig.ProductCode = ProductCode;
+                            tpsConfig.TpsName = "JF200测试程序";
+                            tpsConfig.TestItem = "空载-负载-短路";
+                            tpsConfig.TestProject = "常温测试";
+                            if(dataItems != null)
+                            {
+                                tpsConfig.Values = JsonConvert.SerializeObject(dataItems);
+                            }
+                            context.tpsConfigs.Add(tpsConfig);
+                        }
+                        else
+                        {
+                            config.Values = "";
+                            if (dataItems != null)
+                            {
+                                config.Values = JsonConvert.SerializeObject(dataItems);
+                            }
+                        }
+                        context.SaveChanges();
+                    }
+                }
+                catch (Exception ex)
+                {
+                    throw ex;
+                }
+            }
+
+            return true;
+        }
+
+        //删除产品测试配置项
+        public static bool DeleteTestPar(string ProductCode)
+        {
+            using (MySqlConnection connection = new MySqlConnection(connectionString))
+            {
+                connection.Open();
+                try
+                {
+                    using (var context = new MyDb(connection, false))
+                    {
+                        var config = context.tpsConfigs.FirstOrDefault(x => x.ProductCode == ProductCode);
+                        if (config != null)
+                        {
+                            context.tpsConfigs.Remove(config);
+                        }
+                        
+                        context.SaveChanges();
+                    }
+                }
+                catch (Exception ex)
+                {
+                    throw ex;
+                }
+            }
+
+            return true;
+        }
+
+        /// <summary>
+        /// 根据筛选信息查询测试数据,不含Values,Values是表内容,以加快查询返回
+        /// </summary>
+        /// <param name="Serial">产品编号</param>
+        /// <param name="ProductCode">产品代号</param>
+        /// <param name="BarCode">产品批次</param>
+        /// <param name="startTime">开始时间</param>
+        /// <param name="stopTime">结束数据</param>
+        /// <returns></returns>
+        public static List<TestDataBase> QueryTestData(string Serial, string ProductCode, string BarCode, DateTime startTime, DateTime stopTime)
+        {
+            List<TestDataBase> datas = new List<TestDataBase>();
+            using (MySqlConnection connection = new MySqlConnection(connectionString))
+            {
+                connection.Open();
+                try
+                {
+                    using (var context = new MyDb(connection, false))
+                    {
+                        //不含Values,Values是表内容,以加快查询返回
+                        //var query = from x in context.testDatas
+                        //            where ((string.IsNullOrEmpty(Serial) || x.Serial.Contains(Serial)) &&
+                        //                            (string.IsNullOrEmpty(ProductCode) || x.ProductCode.Equals(ProductCode)) &&
+                        //                            (string.IsNullOrEmpty(BarCode) || x.BarCode.Equals(BarCode)) &&
+                        //                            x.TestTime >= startTime &&
+                        //                            x.TestTime <= stopTime)
+                        //            select new TestDataBase
+                        //            {
+                        //                ID = x.ID,
+                        //                BarCode = x.BarCode,
+                        //                DataName = x.DataName,
+                        //                TestTime = x.TestTime,
+                        //                ProductCode = x.ProductCode,
+                        //                ProductName = x.ProductName,
+                        //                ProductNum = x.ProductNum,
+                        //                Serial = x.Serial,
+                        //                IsPass = x.IsPass,
+                        //                Tester = x.Tester,
+                        //                TestProject = x.TestProject
+                        //            };
+
+                        var query = from x in context.testDatas
+                                    where ((string.IsNullOrEmpty(Serial) || x.Serial.Contains(Serial)) &&
+                                                    (x.ProductCode.Equals(ProductCode)) &&
+                                                    (string.IsNullOrEmpty(BarCode) || x.BarCode.Equals(BarCode)) &&
+                                                    x.TestTime >= startTime &&
+                                                    x.TestTime <= stopTime)
+                                    select new TestDataBase
+                                    {
+                                        ID = x.ID,
+                                        BarCode = x.BarCode,
+                                        DataName = x.DataName,
+                                        TestTime = x.TestTime,
+                                        ProductCode = x.ProductCode,
+                                        ProductName = x.ProductName,
+                                        ProductNum = x.ProductNum,
+                                        Serial = x.Serial,
+                                        IsPass = x.IsPass,
+                                        Tester = x.Tester,
+                                        TestProject = x.TestProject
+                                    };
+                        datas = query.ToList();
+                    }
+                }
+                catch (Exception ex)
+                {
+                    throw ex;
+                }
+            }
+
+            return datas;
+        }
+
+        /// <summary>
+        /// 查询测试数据,ID是QueryTestData查出来的数据ID
+        /// 用于数据查询,带Values
+        /// </summary>
+        /// <param name="ID">数据ID</param>
+        /// <returns></returns>
+        public static TestData QueryTestData(long ID)
+        {
+            using (MySqlConnection connection = new MySqlConnection(connectionString))
+            {
+                connection.Open();
+                try
+                {
+                    using (var context = new MyDb(connection, false))
+                    {
+                        var query = context.testDatas.FirstOrDefault(x => x.ID == ID);
+                        return query;
+                    }
+                }
+                catch (Exception ex)
+                {
+                    throw ex;
+                }
+            }
+            return null;
+        }
+
+        /// <summary>
+        /// 根据ID删除指定的测试数据
+        /// </summary>
+        /// <param name="ID"></param>
+        /// <returns></returns>
+        public static bool DeleteTestData(long ID)
+        {
+            List<long> ids = new List<long>();
+            ids.Add(ID);
+            return DeleteTestDatas(ids);
+        }
+
+        /// <summary>
+        /// 根据ID删除指定的测试数据,可以一次删除多条
+        /// </summary>
+        /// <param name="ids"></param>
+        public static bool DeleteTestDatas(List<long> ids)
+        {
+            if(ids == null)
+                return false;
+
+            using (MySqlConnection connection = new MySqlConnection(connectionString))
+            {
+                connection.Open();
+                try
+                {
+                    using (var context = new MyDb(connection, false))
+                    {
+                        foreach (var id in ids)
+                        {
+                            var query = context.testDatas.FirstOrDefault(x => x.ID == id);
+                            if(query != null)
+                            {
+                                context.testDatas.Remove(query);
+                            }
+                        }
+
+                        context.SaveChanges();
+                    }
+
+                    return true;
+                }
+                catch (Exception ex)
+                {
+                    throw ex;
+                }
+            }
+        }
+
+        /// <summary>
+        /// 添加测试项
+        /// </summary>
+        /// <param name="testData"></param>
+        /// <returns></returns>
+        public static bool AddTestData(TestData testData)
+        {
+            using (MySqlConnection connection = new MySqlConnection(connectionString))
+            {
+                connection.Open();
+                try
+                {
+                    using (var context = new MyDb(connection, false))
+                    {
+                        context.testDatas.Add(testData);
+                        context.SaveChanges();
+                        return true;
+                    }
+                }
+                catch (Exception ex)
+                {
+                    throw ex;
+                }
+            }
+            return true;
+        }
+
+        /// <summary>
+        /// 查询日志
+        /// </summary>
+        /// <param name="workstation">工位号</param>
+        /// <param name="startTime">开始时间</param>
+        /// <param name="stopTime">截止时间</param>
+        /// <returns></returns>
+        public static List<Log> QueryLog(string workstation, DateTime startTime, DateTime stopTime)
+        {
+            List<Log> logItems = new List<Log>();
+            using (MySqlConnection connection = new MySqlConnection(connectionString))
+            {
+                connection.Open();
+                try
+                {
+                    using (var context = new MyDb(connection, false))
+                    {
+                        //不含Values,Values是表内容,以加快查询返回
+                        var query = from x in context.logs
+                                    where ((string.IsNullOrEmpty(workstation) || x.Workstation.Equals(workstation)) &&
+                                                    x.CreateTime >= startTime &&
+                                                    x.CreateTime <= stopTime) select x;
+
+                        logItems = query.ToList();
+                    }
+                }
+                catch (Exception ex)
+                {
+                    throw ex;
+                }
+            }
+            return logItems;
+        }
+
+    }//class DBHelper
+}

+ 39 - 0
Model/AppConfig.cs

@@ -0,0 +1,39 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace CommonStorage.Model
+{
+    /// <summary>
+    /// 程序配置项
+    /// </summary>
+    [Table("app_configs")]
+    public class AppConfig
+    {
+        /// <summary>
+        /// ID
+        /// </summary>
+        [Key]
+        public long ID { get; set; }
+        /// <summary>
+        /// 应用名称
+        /// </summary>
+        public string App { get; set; }
+        /// <summary>
+        /// 段
+        /// </summary>
+        public string Session { get; set; }
+        /// <summary>
+        /// 键
+        /// </summary>
+        public string Key { get; set; }
+        /// <summary>
+        /// 值
+        /// </summary>
+        public string Value { get; set; }
+    }
+}

+ 52 - 0
Model/Device.cs

@@ -0,0 +1,52 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace CommonStorage.Model
+{
+    /// <summary>
+    /// 设备
+    /// </summary>
+    [Table("devices")]
+    public class Device
+    {
+        /// <summary>
+        /// ID
+        /// </summary>
+        [Key]
+        public long ID { get; set; }
+        /// <summary>
+        /// 工位
+        /// </summary>
+        public string WorkStation { get; set; }
+        /// <summary>
+        /// 仪器类型
+        /// </summary>
+        public string DeviceType { get; set; }
+        /// <summary>
+        /// 仪器型号
+        /// </summary>
+        public string DeviceModel { get; set; }
+        /// <summary>
+        /// 硬件ID
+        /// </summary>
+        public string HardwareID { get; set; }
+        /// <summary>
+        /// 控制句柄
+        /// </summary>
+        public string DeviceHandle { get; set; }
+        /// <summary>
+        /// 设备编号,一般信息管理上的编号
+        /// </summary>
+        public string DeviceNum { get; set; }
+        /// <summary>
+        /// 在线状态
+        /// </summary>
+        public bool OnlineState { get; set; }
+        public string Remark { get; set; }
+    }
+}

+ 60 - 0
Model/Log.cs

@@ -0,0 +1,60 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Text;
+
+namespace CommonStorage.Model
+{
+    [Table("logs")]
+    public class Log
+    {
+        /**[JsonConverter(typeof(LongToStringConverter))]*/
+        /// <summary>
+        /// ID
+        /// </summary>
+        [Key]
+        public long ID { get; set; }
+        public string Workstation { get; set; }
+        /// <summary>
+        /// Message
+        /// </summary>
+        public string Message { get; set; }
+        /// <summary>
+        /// Level
+        /// </summary>
+        public LevelEnum MsgLevel { get; set; }
+        /// <summary>
+        /// 备注
+        /// </summary>
+        public string MsgType { get; set; }
+        /// <summary>
+        /// 创建时间
+        /// </summary>
+        public DateTime CreateTime { get; set; }
+    }
+
+    public enum LevelEnum : int
+    {
+        /// <summary>
+        /// 警告
+        /// </summary>
+        [Display(Name = "警告")]
+        Warn = 0,
+        /// <summary>
+        /// 正常
+        /// </summary>
+        [Display(Name = "正常")]
+        Normal = 1,
+        /// <summary>
+        /// 错误
+        /// </summary>
+        [Display(Name = "错误")]
+        Error = 2,
+        /// <summary>
+        /// 调试
+        /// </summary>
+        [Display(Name = "调试")]
+        Debug = 3,
+    }
+}

+ 88 - 0
Model/ReportConfig.cs

@@ -0,0 +1,88 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace CommonStorage.Model
+{
+    /// <summary>
+    /// 报表配置
+    /// </summary>
+    [Table("report_configs")]
+    public  class ReportConfig
+    {
+        /**[JsonConverter(typeof(LongToStringConverter))]*/
+        /// <summary>
+        /// ID
+        /// </summary>
+        [Key]
+        public long ID { get; set; }
+
+        /// <summary>
+        /// 产品代号
+        /// </summary>
+        public string ProductCode { get; set; }
+
+        /// <summary>
+        /// 报告名称
+        /// </summary>
+        public string ReportName { get; set; }
+
+        /// <summary>
+        /// 导出报告的软件模块的名称
+        /// </summary>
+        public string AppName { get; set; }
+        /// <summary>
+        /// 报告模板文件,根据文件后缀区别是word或者excel
+        /// </summary>
+        public string TemplateFile { get; set; }
+
+        // public List<ReportValueMap> ValueMaps { get; set; }
+        //值的匹配关系内容,是上面内容的序列号结果,每一个序列号对应一组由{Serial,TestProject,TestItem}三个参数确定的数据
+        public string ValueMaps { get; set; }
+
+    }
+
+    /// <summary>
+    /// 报告和数据的映射关系
+    /// 以Excel的形式,定位报告的坐标点与数据坐标点的关系
+    /// </summary>
+    public class ReportValueMap
+    {
+        //以下两项唯一定位一份产品的测试数据
+        /// <summary>
+        /// 测试项目,比如温循、老练等
+        /// </summary>
+        public string TestProject { get; set; }
+        /// <summary>
+        /// 指标项目,或者称为数据项的名称
+        /// </summary>
+        public string DataName { get; set; }
+
+        List<RowColIndexMap> ColIndexMap { get; set; }
+
+        public ReportValueMap()
+        {
+            ColIndexMap = new List<RowColIndexMap>();
+        }
+    }
+
+    public struct RowColIndexMap
+    {
+        //起个名字,方便记忆,可以不填
+        public string Name { get; set; }
+        /// <summary>
+        /// 报告模板文件中的第几个表格,一般是对word模板起作用
+        /// </summary>
+        public uint TableIndex { get; set; }
+        //报告的行列坐标
+        public uint ReportRowIndex { get; set; }
+        public uint ReportColIndex { get; set; }
+        //数据的行列坐标
+        public uint ValueRowIndex { get; set; }
+        public uint ValueColIndex { get; set; }
+    }
+}

+ 75 - 0
Model/TestData.cs

@@ -0,0 +1,75 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace CommonStorage.Model
+{
+    /// <summary>
+    /// 测试数据
+    /// </summary>
+    /// 
+    [Table("test_datas")]
+    public class TestData : TestDataBase
+    {
+        /// <summary>
+        /// 检测数据的json格式,是List<list<ValueItem>>序列化的字符串
+        /// </summary>
+        public string Values { get; set; }
+    }
+
+    public class TestDataBase
+    {
+        /// <summary>
+        /// ID
+        /// </summary>
+        [Key]
+        public long ID { get; set; }
+        /// <summary>
+        /// 批次号
+        /// </summary>
+        public string BarCode { get; set; }
+
+        /// <summary>
+        /// 产品代号
+        /// </summary>
+        public string ProductCode { get; set; }
+        /// <summary>
+        /// 产品名称
+        /// </summary>
+        public string ProductName { get; set; }
+        /// <summary>
+        /// 产品工号
+        /// </summary>
+        public string ProductNum { get; set; }
+
+        /// <summary>
+        /// 产品编号
+        /// </summary>
+        public string Serial { get; set; }
+        /// <summary>
+        /// 测试人员
+        /// </summary>
+        public string Tester { get; set; }
+
+        /// <summary>
+        /// 测试时间
+        /// </summary>
+        public DateTime TestTime { get; set; }
+        /// <summary>
+        /// 测试项目,比如温循、老练等
+        /// </summary>
+        public string TestProject { get; set; }
+        /// <summary>
+        /// 指标项目,或者称为数据项的名称
+        /// </summary>
+        public string DataName { get; set; }
+        /// <summary>
+        /// 测试结论
+        /// </summary>
+        public bool IsPass { get; set; }
+    }
+}

+ 49 - 0
Model/TpsConfig.cs

@@ -0,0 +1,49 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace CommonStorage.Model
+{
+    /// <summary>
+    /// 测试配置项
+    /// </summary>
+    [Table("tps_configs")]
+    public class TpsConfig
+    {
+        /**[JsonConverter(typeof(LongToStringConverter))]*/
+        /// <summary>
+        /// ID
+        /// </summary>
+        [Key]
+        public long ID { get; set; }
+        /// <summary>
+        /// 产品代号
+        /// </summary>
+        public string ProductCode { get; set; }
+
+        /// <summary>
+        /// 测试程序名称
+        /// </summary>
+        public string TpsName { get; set; }
+
+        /// <summary>
+        /// 试验项目
+        /// </summary>
+        public string TestProject { get; set; }
+
+        /// <summary>
+        /// 指标项目
+        /// </summary>
+        public string TestItem { get; set; }
+
+        /// <summary>
+        /// 配置数据的表格,是List<list<ValueItem>>序列化的字符串
+        /// </summary>
+        public string Values { get; set; }
+
+    }
+}

+ 83 - 0
Model/User.cs

@@ -0,0 +1,83 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace CommonStorage.Model
+{
+    [Table("users")]
+    public class User
+    {
+        /// <summary>
+        /// ID
+        /// </summary>
+        [Key] 
+        public long ID { get; set; }
+        /// <summary>
+        /// 用户名
+        /// </summary>
+        public string UserName { get; set; }
+        /// <summary>
+        /// 用户密码
+        /// </summary>
+        public string PassWord { get; set; }
+        /// <summary>
+        /// 手机号
+        /// </summary>
+        public string Phone { get; set; }
+        /// <summary>
+        /// 最后登录时间
+        /// </summary>
+        public System.DateTime LastLoginTime { get; set; }
+        /// <summary>
+        /// 登录次数
+        /// </summary>
+        public int LoginCount { get; set; }
+        /// <summary>
+        /// 备注
+        /// </summary>
+        public string Remark { get; set; }
+        /// <summary>
+        /// 创建时间
+        /// </summary>
+        public System.DateTime CreateTime { get; set; }
+        /// <summary>
+        /// 修改时间
+        /// </summary>
+        public Nullable<System.DateTime> UpdateTime { get; set; }
+        /// <summary>
+        /// 用户类型
+        /// </summary>
+        public UserTypeEnum UserType { get; set; }
+        /// <summary>
+        /// 是否有效
+        /// </summary>
+        public bool Enable { get; set; }
+    }
+
+    /// <summary>
+    /// 用户类型
+    /// </summary>
+    public enum UserTypeEnum : int
+    {
+        /// <summary>
+        /// 管理员
+        /// </summary>
+        [Display(Name = "管理员")]
+        Administrators = 1,
+        /// <summary>
+        /// 开发人员
+        /// </summary>
+        [Display(Name = "开发人员")]
+        DeveloperUser = 2,
+
+        /// <summary>
+        /// 使用人员
+        /// </summary>
+        [Display(Name = "使用人员")]
+        UseUser = 2,
+    }
+}

+ 30 - 0
Model/ValueItem.cs

@@ -0,0 +1,30 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace CommonStorage.Model
+{
+    public class ValueItem
+    {
+        /// <summary>
+        /// 值
+        /// </summary>
+        public string Value { get; set; }
+        /// <summary>
+        /// 范围
+        /// </summary>
+        public string Range { get; set; }  
+
+        public ValueItem()
+        {
+
+        }
+
+        public override string ToString()
+        {
+            return Value;
+        }
+    }
+}

+ 36 - 0
MyDb.cs

@@ -0,0 +1,36 @@
+using CommonStorage.Model;
+using MySql.Data.MySqlClient;
+using System.Data.Common;
+using System.Data.Entity;
+
+namespace CommonStorage
+{
+    //[DbConfigurationType(typeof(MySqlEFConfiguration))]
+    public class MyDb : DbContext
+    {
+        /// <summary>
+        /// 日志
+        /// </summary>
+        public DbSet<Log> logs { get; set; }
+        public DbSet<User> users { get; set; }
+        public DbSet<AppConfig> appConfigs { get; set; }
+        public DbSet<Device> devices { get; set; }
+        public DbSet<TestData> testDatas { get; set; }
+        public DbSet<ReportConfig> reportConfigs { get; set; }
+        public DbSet<TpsConfig> tpsConfigs { get; set; }
+        
+
+        public MyDb(DbConnection existingConnection, bool contextOwnsConnection)
+      : base(existingConnection, contextOwnsConnection)
+        {
+
+        }
+
+        protected override void OnModelCreating(DbModelBuilder modelBuilder)
+        {
+            base.OnModelCreating(modelBuilder);
+
+        }
+
+    }
+}

+ 36 - 0
Properties/AssemblyInfo.cs

@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// 有关程序集的一般信息由以下
+// 控制。更改这些特性值可修改
+// 与程序集关联的信息。
+[assembly: AssemblyTitle("CommonStorage")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("CommonStorage")]
+[assembly: AssemblyCopyright("Copyright ©  2022")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// 将 ComVisible 设置为 false 会使此程序集中的类型
+//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
+//请将此类型的 ComVisible 特性设置为 true。
+[assembly: ComVisible(false)]
+
+// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
+[assembly: Guid("5fc4388b-cf9f-4846-a441-018c1ce903ac")]
+
+// 程序集的版本信息由下列四个值组成: 
+//
+//      主版本
+//      次版本
+//      生成号
+//      修订号
+//
+//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
+//通过使用 "*",如下所示:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 1 - 0
README.md

@@ -0,0 +1 @@
+无刷电机存储模块

+ 5 - 0
libman.json

@@ -0,0 +1,5 @@
+{
+  "version": "1.0",
+  "defaultProvider": "cdnjs",
+  "libraries": []
+}

+ 1 - 0
mysql配置参考地址.txt

@@ -0,0 +1 @@
+https://dev.mysql.com/doc/connector-net/en/connector-net-entityframework60.html