From 4cb676856f0c791ffcbef569c0ca8195bf8b0938 Mon Sep 17 00:00:00 2001 From: wells.liu <wells.liu@broconcentric.com> Date: 星期六, 04 七月 2020 18:05:47 +0800 Subject: [PATCH] 数据库操作 --- src/Bro.Device.GTSCard/GTSCardDriver.cs | 8 src/Bro.M071.Process.Model/BaseModel.cs | 338 ++--- src/Bro.M071.Process.DBManager/ProductionMeasurementRecordsManager.cs | 96 + src/Bro.UI.Config/MenuForms/FrmOperation.resx | 4 src/Bro.M071.Process.DBManager/MeasurementAndKeyDataRelationManager.cs | 93 + src/Bro.M071.Process.DBManager/Bro.M071.DBManager.csproj | 9 src/Bro.M071.Process.DBManager/MeasurementUnitResultManager.cs | 96 + src/Bro.M071.Process/M071Process.cs | 10 src/Bro.M071.Process.DBManager/ModelManager.cs | 108 + src/Bro.M071.Process.Model/Bro.M071.Model.csproj | 14 src/Bro.M071.Process.DBManager/SQLiteHelper.cs | 614 ++++++++++ src/Bro.Process.DBManager/BaseModel.cs | 354 +++--- src/Bro.Common.Model/Model/MotionCardRelated.cs | 4 src/Bro.M071.Process.Model/Model/MeasurementUnitResult.cs | 56 src/Bro.M071.Process.Model/Migrations/Configuration.cs | 65 src/Bro.M071.Process.Model/Model/KeyUnitData.cs | 41 src/Bro.M071.Process.DBManager/KeyUnitDataManager.cs | 95 + src/Bro.M071.Process.DBManager/App.config | 3 src/Bro.Common.Model/Helper/EnumHelper.cs | 2 src/Bro.M071.Process/App.config | 43 src/Bro.Process.DBManager/SQLiteHelper.cs | 1160 ++++++++++---------- /dev/null | 60 - src/Bro.M071.Process.Model/Model/ProductionMeasurementRecords.cs | 61 + src/Bro.M071.Process.Model/DBModel.cs | 108 - src/Bro.M071.Process/Bro.M071.Process.csproj | 8 src/Bro.M071.Process/M071Config.cs | 4 src/Bro.M071.Process/M071Models.cs | 4 src/Bro.M071.Process.Model/Model/MeasurementAndKeyDataRelation.cs | 22 28 files changed, 2,363 insertions(+), 1,117 deletions(-) diff --git a/src/Bro.Common.Model/Helper/EnumHelper.cs b/src/Bro.Common.Model/Helper/EnumHelper.cs index 703be4a..a9cf25a 100644 --- a/src/Bro.Common.Model/Helper/EnumHelper.cs +++ b/src/Bro.Common.Model/Helper/EnumHelper.cs @@ -447,7 +447,7 @@ /// <summary> /// 椹揪/杩愬姩鏉垮崱杩愯妯″紡 /// </summary> - public enum MotorMoveMode + public enum MotionMode { /// <summary> /// 鏅�氱偣浣嶈繍鍔� diff --git a/src/Bro.Common.Model/Model/MotionCardRelated.cs b/src/Bro.Common.Model/Model/MotionCardRelated.cs index a285cdc..0e5d746 100644 --- a/src/Bro.Common.Model/Model/MotionCardRelated.cs +++ b/src/Bro.Common.Model/Model/MotionCardRelated.cs @@ -216,11 +216,11 @@ } } - private MotorMoveMode moveMode = MotorMoveMode.Normal; + private MotionMode moveMode = MotionMode.Normal; [Category("杩愬姩閰嶇疆")] [DisplayName("杩愬姩妯″紡")] [Description("MoveMode锛氳繍鍔ㄦā寮�")] - public MotorMoveMode MoveMode + public MotionMode MoveMode { get => moveMode; set diff --git a/src/Bro.Device.GTSCard/GTSCardDriver.cs b/src/Bro.Device.GTSCard/GTSCardDriver.cs index f2c0343..3d06c3f 100644 --- a/src/Bro.Device.GTSCard/GTSCardDriver.cs +++ b/src/Bro.Device.GTSCard/GTSCardDriver.cs @@ -323,13 +323,13 @@ if (IConfig.AxisSettings.FirstOrDefault(a => a.AxisIndex == optionPara.AxisIndex)?.IsAxisEnabled ?? false) { string _position = ""; - string motionType = optionPara.MoveMode == EnumHelper.MotorMoveMode.Normal ? (optionPara.IsAbsolute ? "Abs" : "Rel") : optionPara.MoveMode.ToString(); + string motionType = optionPara.MoveMode == EnumHelper.MotionMode.Normal ? (optionPara.IsAbsolute ? "Abs" : "Rel") : optionPara.MoveMode.ToString(); _position = $"{DateTime.Now:yyyy-MM-dd HH:mm:ss.fff},{optionPara.AxisIndex},{motionType},{GetPosition(optionPara.AxisIndex)},{GetPrfPosition(optionPara.AxisIndex)},{optionPara.Destination},"; switch (optionPara.MoveMode) { - case MotorMoveMode.Normal: + case MotionMode.Normal: { if (_isResetting) { @@ -348,12 +348,12 @@ } break; - case MotorMoveMode.FindOri: + case MotionMode.FindOri: { isSuccessAndStop = GoHome(optionPara); } break; - case MotorMoveMode.Jog: + case MotionMode.Jog: { isSuccessAndStop = JogMove(optionPara); } diff --git a/src/Bro.M071.Process.DBManager/App.config b/src/Bro.M071.Process.DBManager/App.config index 1c8faee..a23edd3 100644 --- a/src/Bro.M071.Process.DBManager/App.config +++ b/src/Bro.M071.Process.DBManager/App.config @@ -1,9 +1,6 @@ 锘�<?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> diff --git a/src/Bro.M071.Process.DBManager/Bro.M071.DBManager.csproj b/src/Bro.M071.Process.DBManager/Bro.M071.DBManager.csproj index 5bb2a9a..92dae28 100644 --- a/src/Bro.M071.Process.DBManager/Bro.M071.DBManager.csproj +++ b/src/Bro.M071.Process.DBManager/Bro.M071.DBManager.csproj @@ -107,10 +107,13 @@ <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup> - <Compile Include="ProductionDetectionImageRecordsManager.cs" /> - <Compile Include="ProductionDetectionRecordsDetailManager.cs" /> - <Compile Include="ProductionDetectionRecordsManager.cs" /> + <Compile Include="KeyUnitDataManager.cs" /> + <Compile Include="MeasurementAndKeyDataRelationManager.cs" /> + <Compile Include="ModelManager.cs" /> + <Compile Include="ProductionMeasurementRecordsManager.cs" /> + <Compile Include="MeasurementUnitResultManager.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> + <Compile Include="SQLiteHelper.cs" /> </ItemGroup> <ItemGroup> <ProjectReference Include="..\Bro.Common.Model\Bro.Common.Model.csproj"> diff --git a/src/Bro.M071.Process.DBManager/KeyUnitDataManager.cs b/src/Bro.M071.Process.DBManager/KeyUnitDataManager.cs new file mode 100644 index 0000000..2b246c7 --- /dev/null +++ b/src/Bro.M071.Process.DBManager/KeyUnitDataManager.cs @@ -0,0 +1,95 @@ +锘縰sing Bro.Common.Helper; +using Bro.M071.Model; +using Bro.M071.Model.Model; +using System; +using System.Collections; +using System.Collections.Generic; +using System.Data; +using System.Data.Common; +using System.Data.SQLite; +using System.Linq; +using System.Text; + +namespace Bro.M071.DBManager +{ + public class KeyUnitDataManager : ModelManager<KeyUnitData> + { + DbProviderFactory Dbfactory = SQLiteFactory.Instance; + protected override void ActionBeforeNewModel(DBModel context, KeyUnitData config) + { + CheckProductionCodeDuplicate(context, config); + } + + protected override void ActionBeforeUpdateModel(DBModel context, KeyUnitData config) + { + CheckProductionCodeDuplicate(context, config); + } + + private void CheckProductionCodeDuplicate(DBModel context, KeyUnitData config) + { + } + + public List<KeyUnitData> GetKeyUnitData() + { + using (DBModel context = new DBModel()) + { + var list = context.KeyUnitData.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 void BatchAddKeyUnitData(List<KeyUnitData> records) + { + try + { + using (SQLiteConnection conn = new SQLiteConnection(ConnectionString)) + { + using (SQLiteCommand insertRngCmd = (SQLiteCommand)conn.CreateCommand()) + { + StringBuilder strSql = new StringBuilder(); + strSql.Append("insert into KeyUnitData ("); + strSql.Append("ID,ProductionMeasurementRecordsId,Key,MeasurementItem,ItemValue,IS_DISABLED,IS_DELETED,CREATE_USER,CREATE_TIME, UPDATE_USER,UPDATE_TIME"); + strSql.Append(")values ("); + strSql.Append("@ID,@ProductionMeasurementRecordsId,@Key,@MeasurementItem,@ItemValue,@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("@ProductionMeasurementRecordsId", record.ProductionMeasurementRecordsId); + insertRngCmd.Parameters.AddWithValue("@Key", record.Key); + insertRngCmd.Parameters.AddWithValue("@MeasurementItem", record.MeasurementItem); + insertRngCmd.Parameters.AddWithValue("@ItemValue", record.ItemValue); + 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); + } + } + } +} diff --git a/src/Bro.M071.Process.DBManager/MeasurementAndKeyDataRelationManager.cs b/src/Bro.M071.Process.DBManager/MeasurementAndKeyDataRelationManager.cs new file mode 100644 index 0000000..8a368a5 --- /dev/null +++ b/src/Bro.M071.Process.DBManager/MeasurementAndKeyDataRelationManager.cs @@ -0,0 +1,93 @@ +锘縰sing Bro.Common.Helper; +using Bro.M071.Model; +using Bro.M071.Model.Model; +using System; +using System.Collections; +using System.Collections.Generic; +using System.Data; +using System.Data.Common; +using System.Data.SQLite; +using System.Linq; +using System.Text; + +namespace Bro.M071.DBManager +{ + public class MeasurementAndKeyDataRelationManager : ModelManager<MeasurementAndKeyDataRelation> + { + DbProviderFactory Dbfactory = SQLiteFactory.Instance; + protected override void ActionBeforeNewModel(DBModel context, MeasurementAndKeyDataRelation config) + { + CheckProductionCodeDuplicate(context, config); + } + + protected override void ActionBeforeUpdateModel(DBModel context, MeasurementAndKeyDataRelation config) + { + CheckProductionCodeDuplicate(context, config); + } + + private void CheckProductionCodeDuplicate(DBModel context, MeasurementAndKeyDataRelation config) + { + } + + public List<MeasurementAndKeyDataRelation> GetMeasurementAndKeyDataRelation() + { + using (DBModel context = new DBModel()) + { + var list = context.MeasurementAndKeyDataRelation.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 void BatchAddMeasurementAndKeyDataRelation(List<MeasurementAndKeyDataRelation> records) + { + try + { + using (SQLiteConnection conn = new SQLiteConnection(ConnectionString)) + { + using (SQLiteCommand insertRngCmd = (SQLiteCommand)conn.CreateCommand()) + { + StringBuilder strSql = new StringBuilder(); + strSql.Append("insert into MeasurementAndKeyDataRelation ("); + strSql.Append("ID,KeyUnitDataId,MeasurementUnitResultId,IS_DISABLED,IS_DELETED,CREATE_USER,CREATE_TIME, UPDATE_USER,UPDATE_TIME"); + strSql.Append(")values ("); + strSql.Append("@ID,@KeyUnitDataId,@MeasurementUnitResultId,@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("@KeyUnitDataId", record.KeyUnitDataId); + insertRngCmd.Parameters.AddWithValue("@MeasurementUnitResultId", record.MeasurementUnitResultId); + 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); + } + } + } +} diff --git a/src/Bro.M071.Process.DBManager/MeasurementUnitResultManager.cs b/src/Bro.M071.Process.DBManager/MeasurementUnitResultManager.cs new file mode 100644 index 0000000..6e7a08e --- /dev/null +++ b/src/Bro.M071.Process.DBManager/MeasurementUnitResultManager.cs @@ -0,0 +1,96 @@ +锘縰sing Bro.Common.Helper; +using Bro.M071.Model; +using Bro.M071.Model.Model; +using System; +using System.Collections; +using System.Collections.Generic; +using System.Data; +using System.Data.Common; +using System.Data.SQLite; +using System.Linq; +using System.Text; + +namespace Bro.M071.DBManager +{ + public class MeasurementUnitResultManager : ModelManager<MeasurementUnitResult> + { + DbProviderFactory Dbfactory = SQLiteFactory.Instance; + protected override void ActionBeforeNewModel(DBModel context, MeasurementUnitResult config) + { + CheckProductionCodeDuplicate(context, config); + } + + protected override void ActionBeforeUpdateModel(DBModel context, MeasurementUnitResult config) + { + CheckProductionCodeDuplicate(context, config); + } + + private void CheckProductionCodeDuplicate(DBModel context, MeasurementUnitResult config) + { + } + + public List<MeasurementUnitResult> GetMeasurementUnitResult() + { + using (DBModel context = new DBModel()) + { + var list = context.MeasurementUnitResult.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 void BatchAddMeasurementUnitResult(List<MeasurementUnitResult> records) + { + try + { + using (SQLiteConnection conn = new SQLiteConnection(ConnectionString)) + { + using (SQLiteCommand insertRngCmd = (SQLiteCommand)conn.CreateCommand()) + { + StringBuilder strSql = new StringBuilder(); + strSql.Append("insert into MeasurementUnitResult ("); + strSql.Append("ID,ProductionMeasurementRecordsId,MeasurementName,MeasurementType,MeasurementValue,MeasurementResult,IS_DISABLED,IS_DELETED,CREATE_USER,CREATE_TIME, UPDATE_USER,UPDATE_TIME"); + strSql.Append(")values ("); + strSql.Append("@ID,@ProductionMeasurementRecordsId,@MeasurementName,@MeasurementType,@MeasurementValue,@MeasurementResult,@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("@ProductionMeasurementRecordsId", record.ProductionMeasurementRecordsId); + insertRngCmd.Parameters.AddWithValue("@MeasurementName", record.MeasurementName); + insertRngCmd.Parameters.AddWithValue("@MeasurementType", record.MeasurementType); + insertRngCmd.Parameters.AddWithValue("@MeasurementValue", record.MeasurementValue); + insertRngCmd.Parameters.AddWithValue("@MeasurementResult", record.MeasurementResult); + 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); + } + } + } +} diff --git a/src/Bro.M071.Process.DBManager/ModelManager.cs b/src/Bro.M071.Process.DBManager/ModelManager.cs new file mode 100644 index 0000000..91aa2be --- /dev/null +++ b/src/Bro.M071.Process.DBManager/ModelManager.cs @@ -0,0 +1,108 @@ +锘縰sing Bro.M071.Model; +using System.Collections.Generic; +using System.Configuration; +using System.Data.Entity; +using System.Linq; +using System.Reflection; + +namespace Bro.M071.DBManager +{ + public class ModelManager<T> where T : BaseModel, new() + { + private PropertyInfo TableProperty = null; + public static string ConnectionString = ConfigurationManager.ConnectionStrings["DataBase"].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 CreateModel(T t, string userId = "") + { + using (DBModel context = new DBModel()) + { + ActionBeforeNewModel(context, t); + + t.Create(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.Update(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.Update(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.Update(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.M071.Process.DBManager/ProductionDetectionImageRecordsManager.cs b/src/Bro.M071.Process.DBManager/ProductionDetectionImageRecordsManager.cs deleted file mode 100644 index 65e6fa5..0000000 --- a/src/Bro.M071.Process.DBManager/ProductionDetectionImageRecordsManager.cs +++ /dev/null @@ -1,303 +0,0 @@ -锘�////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.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 deleted file mode 100644 index bd40c8a..0000000 --- a/src/Bro.M071.Process.DBManager/ProductionDetectionRecordsDetailManager.cs +++ /dev/null @@ -1,248 +0,0 @@ -锘�////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.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 deleted file mode 100644 index 9e2876e..0000000 --- a/src/Bro.M071.Process.DBManager/ProductionDetectionRecordsManager.cs +++ /dev/null @@ -1,305 +0,0 @@ -锘�////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.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/ProductionMeasurementRecordsManager.cs b/src/Bro.M071.Process.DBManager/ProductionMeasurementRecordsManager.cs new file mode 100644 index 0000000..0551fda --- /dev/null +++ b/src/Bro.M071.Process.DBManager/ProductionMeasurementRecordsManager.cs @@ -0,0 +1,96 @@ +锘縰sing Bro.Common.Helper; +using Bro.M071.Model; +using Bro.M071.Model.Model; +using System; +using System.Collections; +using System.Collections.Generic; +using System.Data; +using System.Data.Common; +using System.Data.SQLite; +using System.Linq; +using System.Text; + +namespace Bro.M071.DBManager +{ + public class ProductionMeasurementRecordsManager : ModelManager<ProductionMeasurementRecords> + { + DbProviderFactory Dbfactory = SQLiteFactory.Instance; + protected override void ActionBeforeNewModel(DBModel context, ProductionMeasurementRecords config) + { + CheckProductionCodeDuplicate(context, config); + } + + protected override void ActionBeforeUpdateModel(DBModel context, ProductionMeasurementRecords config) + { + CheckProductionCodeDuplicate(context, config); + } + + private void CheckProductionCodeDuplicate(DBModel context, ProductionMeasurementRecords config) + { + } + + public List<ProductionMeasurementRecords> GetProductionMeasurementRecords() + { + using (DBModel context = new DBModel()) + { + var list = context.ProductionMeasurementRecords.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 void BatchAddProductionMeasurementRecords(List<ProductionMeasurementRecords> records) + { + try + { + using (SQLiteConnection conn = new SQLiteConnection(ConnectionString)) + { + using (SQLiteCommand insertRngCmd = (SQLiteCommand)conn.CreateCommand()) + { + StringBuilder strSql = new StringBuilder(); + strSql.Append("insert into ProductionMeasurementRecords ("); + strSql.Append("ID,ProductionCode,ProductionBarcode,ProductionResult,OperationStartTime,OperationEndTime,IS_DISABLED,IS_DELETED,CREATE_USER,CREATE_TIME, UPDATE_USER,UPDATE_TIME"); + strSql.Append(")values ("); + strSql.Append("@ID,@ProductionCode,@ProductionBarcode,@ProductionResult,@OperationStartTime,@OperationEndTime,@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("@ProductionCode", record.ProductionCode); + insertRngCmd.Parameters.AddWithValue("@ProductionBarcode", record.ProductionBarcode); + insertRngCmd.Parameters.AddWithValue("@ProductionResult", record.ProductionResult); + insertRngCmd.Parameters.AddWithValue("@OperationStartTime", record.OperationStartTime); + insertRngCmd.Parameters.AddWithValue("@OperationEndTime", record.OperationEndTime); + 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); + } + } + } +} diff --git a/src/Bro.M071.Process.DBManager/SQLiteHelper.cs b/src/Bro.M071.Process.DBManager/SQLiteHelper.cs new file mode 100644 index 0000000..6da6230 --- /dev/null +++ b/src/Bro.M071.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.DataBase +{ + public class SQLiteHelper + { + //数据库连接字符串 + public static string connectionString = ConfigurationManager.ConnectionStrings["DataBase"].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.M071.Process.Model/BaseModel.cs b/src/Bro.M071.Process.Model/BaseModel.cs index 8fee642..559cbf4 100644 --- a/src/Bro.M071.Process.Model/BaseModel.cs +++ b/src/Bro.M071.Process.Model/BaseModel.cs @@ -1,201 +1,179 @@ -锘�//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; +锘縰sing Bro.Common.Helper; +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.Model -//{ -// public class BaseModel -// { -// /// <summary> -// /// 缂栧彿锛屽敮涓�鍊�,浣跨敤GUID -// /// </summary> -// [Key] -// [Required(ErrorMessage = "缂栧彿涓嶅彲涓虹┖锛�")] -// [StringLength(50)] -// public string ID { get; set; } = Guid.NewGuid().ToString().ToUpper(); +namespace Bro.M071.Model +{ + public class BaseModel + { + /// <summary> + /// 缂栧彿锛屽敮涓�鍊�,浣跨敤GUID + /// </summary> + [Key] + [Required(ErrorMessage = "缂栧彿涓嶅彲涓虹┖锛�")] + [StringLength(64)] + 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_DISABLED { get; set; } = 0; -// /// <summary> -// /// 鍒犻櫎鐘舵�� 0 鏈垹闄� 1 宸插垹闄� -// /// </summary> -// [Required] -// public int IS_DELETED { 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] + [StringLength(64)] + public string CREATE_USER { get; set; } -// /// <summary> -// /// 鍒涘缓鏃堕棿 -// /// </summary> -// //[Required] -// public DateTime? CREATE_TIME { get; set; } = DateTime.Now; + /// <summary> + /// 鍒涘缓鏃堕棿 + /// </summary> + public DateTime CREATE_TIME { get; set; } = DateTime.Now; -// /// <summary> -// /// 鏇存柊浜轰俊鎭� -// /// </summary> -// [StringLength(50)] -// public string UPDATE_USER { get; set; } + /// <summary> + /// 鏇存柊浜轰俊鎭� + /// </summary> + [StringLength(64)] + public string UPDATE_USER { get; set; } -// /// <summary> -// /// 鏇存柊鏃堕棿 -// /// </summary> -// public DateTime? UPDATE_TIME { 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 class BaseModelHelper + { + public static void Create<T>(this T t, string userId) where T : BaseModel + { + 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; -// } + public static void Update<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); -// } + 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(); + 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(); + } + } -// 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 class BaseRequest : INotifyPropertyChanged + { -// 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(); -// } -// } + 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); + } + } + } -// public class BaseRequest : INotifyPropertyChanged -// { + 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); + } + } + } -// 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); -// } -// } -// } + /// <summary> + /// 鏌ヨ璧峰鏃堕棿 + /// </summary> + public DateTime? StartTime { get; set; } -// 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? EndTime { get; set; } -// /// <summary> -// /// 鏌ヨ璧峰鏃堕棿 -// /// </summary> -// public DateTime? StartTime { get; set; } + /// <summary> + /// 鍚敤鐘舵�佽繃婊ゅ櫒 1锛氫粎鏈惎鐢� 0锛氫粎鍚敤 -1锛氬叏閮� + /// </summary> + public int DisableFilter { get; set; } = 0; -// /// <summary> -// /// 鏌ヨ缁撴潫鏃堕棿 -// /// </summary> -// public DateTime? EndTime { get; set; } + /// <summary> + /// 鏌ヨ瀛楃涓� + /// </summary> + public string SearchTxt { get; set; } -// /// <summary> -// /// 鍚敤鐘舵�佽繃婊ゅ櫒 1锛氫粎鏈惎鐢� 0锛氫粎鍚敤 -1锛氬叏閮� -// /// </summary> -// public int DisableFilter { get; set; } = 0; + 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); + } + } -// /// <summary> -// /// 鏌ヨ瀛楃涓� -// /// </summary> -// public string SearchTxt { get; set; } + 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); + } + } + } -// 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; -// } -//} + public event PropertyChangedEventHandler PropertyChanged; + } +} diff --git a/src/Bro.M071.Process.Model/Bro.M071.Model.csproj b/src/Bro.M071.Process.Model/Bro.M071.Model.csproj index 6b7c29c..f867809 100644 --- a/src/Bro.M071.Process.Model/Bro.M071.Model.csproj +++ b/src/Bro.M071.Process.Model/Bro.M071.Model.csproj @@ -109,9 +109,10 @@ <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="Model\KeyUnitData.cs" /> + <Compile Include="Model\MeasurementUnitResult.cs" /> + <Compile Include="Model\ProductionMeasurementRecords.cs" /> + <Compile Include="Model\MeasurementAndKeyDataRelation.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> </ItemGroup> <ItemGroup> @@ -121,7 +122,12 @@ </None> <None Include="packages.config" /> </ItemGroup> - <ItemGroup /> + <ItemGroup> + <ProjectReference Include="..\Bro.Common.Model\Bro.Common.Model.csproj"> + <Project>{1A3CBFE7-3F78-42C3-95C5-10360450DBEA}</Project> + <Name>Bro.Common.Model</Name> + </ProjectReference> + </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> <PropertyGroup> diff --git a/src/Bro.M071.Process.Model/DBModel.cs b/src/Bro.M071.Process.Model/DBModel.cs index d660664..bdf5f07 100644 --- a/src/Bro.M071.Process.Model/DBModel.cs +++ b/src/Bro.M071.Process.Model/DBModel.cs @@ -1,67 +1,53 @@ -锘�//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; +锘縰sing Bro.M071.Model.Migrations; +using Bro.M071.Model.Model; +using System.Data.Entity; +using System.Data.Entity.ModelConfiguration.Conventions; -//namespace Bro.M071.Model -//{ -// public class DBModel : DbContext -// { -// //鎮ㄧ殑涓婁笅鏂囧凡閰嶇疆涓轰粠鎮ㄧ殑搴旂敤绋嬪簭鐨勯厤缃枃浠�(App.config 鎴� Web.config) -// //浣跨敤鈥淒BModel鈥濊繛鎺ュ瓧绗︿覆銆傞粯璁ゆ儏鍐典笅锛屾杩炴帴瀛楃涓查拡瀵规偍鐨� LocalDb 瀹炰緥涓婄殑 -// //鈥淏ro.Process.Model.DBModel鈥濇暟鎹簱銆� -// // -// //濡傛灉鎮ㄦ兂瑕侀拡瀵瑰叾浠栨暟鎹簱鍜�/鎴栨暟鎹簱鎻愪緵绋嬪簭锛岃鍦ㄥ簲鐢ㄧ▼搴忛厤缃枃浠朵腑淇敼鈥淒BModel鈥� -// //杩炴帴瀛楃涓层�� -// public DBModel() -// : base("name=DataBase") -// { -// ////鏁版嵁搴撹縼绉绘鏌ユ殏鏃舵斁鍦ㄦ瀯閫犲嚱鏁颁腑锛屽洖澶翠細鏀惧埌绋嬪簭鍒濆鍖栦腑 -// //Database.SetInitializer(new MigrateDatabaseToLatestVersion<DBModel, Configuration>()); -// } +namespace Bro.M071.Model +{ + public class DBModel : DbContext + { + //鎮ㄧ殑涓婁笅鏂囧凡閰嶇疆涓轰粠鎮ㄧ殑搴旂敤绋嬪簭鐨勯厤缃枃浠�(App.config 鎴� Web.config) + //浣跨敤鈥淒BModel鈥濊繛鎺ュ瓧绗︿覆銆傞粯璁ゆ儏鍐典笅锛屾杩炴帴瀛楃涓查拡瀵规偍鐨� LocalDb 瀹炰緥涓婄殑 + //鈥淏ro.Process.Model.DBModel鈥濇暟鎹簱銆� + // + //濡傛灉鎮ㄦ兂瑕侀拡瀵瑰叾浠栨暟鎹簱鍜�/鎴栨暟鎹簱鎻愪緵绋嬪簭锛岃鍦ㄥ簲鐢ㄧ▼搴忛厤缃枃浠朵腑淇敼鈥淒BModel鈥� + //杩炴帴瀛楃涓层�� + public DBModel() + : base("name=DataBase") + { + ////鏁版嵁搴撹縼绉绘鏌ユ殏鏃舵斁鍦ㄦ瀯閫犲嚱鏁颁腑锛屽洖澶翠細鏀惧埌绋嬪簭鍒濆鍖栦腑 + //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; } + //涓烘偍瑕佸湪妯″瀷涓寘鍚殑姣忕瀹炰綋绫诲瀷閮芥坊鍔� DbSet銆傛湁鍏抽厤缃拰浣跨敤 Code First 妯″瀷 + //鐨勮缁嗕俊鎭紝璇峰弬闃� http://go.microsoft.com/fwlink/?LinkId=390109銆� -// 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; } + public virtual DbSet<KeyUnitData> KeyUnitData { get; set; } + public virtual DbSet<MeasurementAndKeyDataRelation> MeasurementAndKeyDataRelation { get; set; } + public virtual DbSet<MeasurementUnitResult> MeasurementUnitResult { get; set; } + public virtual DbSet<ProductionMeasurementRecords> ProductionMeasurementRecords { get; set; } -// protected override void OnModelCreating(DbModelBuilder modelBuilder) -// { -// //base.OnModelCreating(modelBuilder); + protected override void OnModelCreating(DbModelBuilder modelBuilder) + { + //base.OnModelCreating(modelBuilder); + #region for sqlite db + modelBuilder.Conventions.Remove<PluralizingTableNameConvention>(); + modelBuilder.Configurations.AddFromAssembly(typeof(DBModel).Assembly); + #endregion + } + } -// #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 + public static class DatabaseInitialize + { + public static void Initialize() + { + Database.SetInitializer(new MigrateDatabaseToLatestVersion<DBModel, Configuration>()); + using (DbContext dbContext = new DBModel()) + { + dbContext.Database.Initialize(true); + } + } + } +} \ 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 index 7fbf72b..90bcb83 100644 --- a/src/Bro.M071.Process.Model/Migrations/Configuration.cs +++ b/src/Bro.M071.Process.Model/Migrations/Configuration.cs @@ -1,37 +1,36 @@ -//namespace Bro.M071.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; +using System.Data.Entity.Migrations; +using System.Data.SQLite.EF6.Migrations; -// #region for sqlite db -// SetSqlGenerator("System.Data.SQLite", new SQLiteMigrationSqlGenerator()); -// #endregion -// } +namespace Bro.M071.Model.Migrations +{ -// protected override void Seed(Bro.Process.Model.DBModel context) -// { -// // This method will be called after migrating to the latest version. + public sealed class Configuration : DbMigrationsConfiguration<DBModel> + { + public Configuration() + { + AutomaticMigrationsEnabled = true; + AutomaticMigrationDataLossAllowed = true; -// // 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" } -// // ); -// // -// } -// } -//} + #region for sqlite db + SetSqlGenerator("System.Data.SQLite", new SQLiteMigrationSqlGenerator()); + #endregion + } + + protected override void Seed(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 deleted file mode 100644 index 4592699..0000000 --- a/src/Bro.M071.Process.Model/Model/EventTimeRecords.cs +++ /dev/null @@ -1,52 +0,0 @@ -锘� -//using System; -//using System.ComponentModel.DataAnnotations; - -//namespace Bro.M071.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/KeyUnitData.cs b/src/Bro.M071.Process.Model/Model/KeyUnitData.cs new file mode 100644 index 0000000..ccea504 --- /dev/null +++ b/src/Bro.M071.Process.Model/Model/KeyUnitData.cs @@ -0,0 +1,41 @@ +锘� +using System; +using System.ComponentModel.DataAnnotations; + +namespace Bro.M071.Model.Model +{ + /// <summary> + /// 閿崟鍏� 鐨勬娴嬬粨鏋� + /// </summary> + public class KeyUnitData : BaseModel + { + /// <summary> + /// 浜у搧娴嬮噺璁板綍Id + /// </summary> + [StringLength(64)] + public string ProductionMeasurementRecordsId { get; set; } + + /// <summary> + /// 閿崟鍏� + /// </summary> + [StringLength(64)] + public string Key { get; set; } + + /// <summary> + /// 妫�娴嬮」 + /// </summary> + [StringLength(64)] + public string MeasurementItem { get; set; } + + /// <summary> + /// 璇ラ敭 妫�娴嬮」 鐨勫�� + /// </summary> + [StringLength(64)] + public string ItemValue { get; set; } + } + + public class KeyUnitDataRequest : BaseRequest + { + } + +} diff --git a/src/Bro.M071.Process.Model/Model/ManualDetectionRecords.cs b/src/Bro.M071.Process.Model/Model/ManualDetectionRecords.cs deleted file mode 100644 index 2cc54a7..0000000 --- a/src/Bro.M071.Process.Model/Model/ManualDetectionRecords.cs +++ /dev/null @@ -1,58 +0,0 @@ -锘�//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.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/MeasurementAndKeyDataRelation.cs b/src/Bro.M071.Process.Model/Model/MeasurementAndKeyDataRelation.cs new file mode 100644 index 0000000..345be66 --- /dev/null +++ b/src/Bro.M071.Process.Model/Model/MeasurementAndKeyDataRelation.cs @@ -0,0 +1,22 @@ +锘� +using System; +using System.ComponentModel.DataAnnotations; + +namespace Bro.M071.Model.Model +{ + public class MeasurementAndKeyDataRelation : BaseModel + { + /// <summary> + /// 閿崟鍏� 鐨勬娴嬬粨鏋� id + /// </summary> + [StringLength(64)] + public string KeyUnitDataId { get; set; } + + /// <summary> + /// 妫�娴嬬粨鏋� id + /// </summary> + [StringLength(64)] + public string MeasurementUnitResultId { get; set; } + } + +} diff --git a/src/Bro.M071.Process.Model/Model/MeasurementUnitResult.cs b/src/Bro.M071.Process.Model/Model/MeasurementUnitResult.cs new file mode 100644 index 0000000..955f8a0 --- /dev/null +++ b/src/Bro.M071.Process.Model/Model/MeasurementUnitResult.cs @@ -0,0 +1,56 @@ +锘� +using System; +using System.ComponentModel.DataAnnotations; + +namespace Bro.M071.Model.Model +{ + /// <summary> + /// 妫�娴嬬粨鏋� + /// </summary> + public class MeasurementUnitResult : BaseModel + { + /// <summary> + /// 浜у搧娴嬮噺璁板綍Id + /// </summary> + [StringLength(64)] + public string ProductionMeasurementRecordsId { get; set; } + + /// <summary> + /// 妫�娴嬪悕绉� + /// </summary> + [StringLength(64)] + public string MeasurementName { get; set; } + + /// <summary> + /// 妫�娴嬬粨鏋滅被鍨� (Slant Alignment... ) + /// </summary> + [StringLength(64)] + public string MeasurementType { get; set; } + + /// <summary> + /// 妫�娴嬬粨鏋滃�� + /// </summary> + [StringLength(64)] + public string MeasurementValue { get; set; } + + /// <summary> + /// 妫�娴嬬粨鏋� ok ng + /// </summary> + [StringLength(64)] + public string MeasurementResult { get; set; } + } + + public class MeasurementUnitResultRequest : BaseRequest + { + /// <summary> + /// 妫�娴嬪悕绉� + /// </summary> + public string MeasurementName { get; set; } + + /// <summary> + /// 妫�娴嬪拰鏍囧噯绫诲瀷 + /// </summary> + public string MeasureType { get; set; } + } + +} diff --git a/src/Bro.M071.Process.Model/Model/OperationRecords.cs b/src/Bro.M071.Process.Model/Model/OperationRecords.cs deleted file mode 100644 index ce07827..0000000 --- a/src/Bro.M071.Process.Model/Model/OperationRecords.cs +++ /dev/null @@ -1,60 +0,0 @@ -锘� -//using System; -//using System.ComponentModel.DataAnnotations; - -//namespace Bro.M071.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/Model/ProductionMeasurementRecords.cs b/src/Bro.M071.Process.Model/Model/ProductionMeasurementRecords.cs new file mode 100644 index 0000000..ab65e8b --- /dev/null +++ b/src/Bro.M071.Process.Model/Model/ProductionMeasurementRecords.cs @@ -0,0 +1,61 @@ +锘� +using System; +using System.ComponentModel.DataAnnotations; +using static Bro.Common.Helper.EnumHelper; + +namespace Bro.M071.Model.Model +{ + /// <summary> + /// 浜у搧娴嬮噺璁板綍 + /// </summary> + public class ProductionMeasurementRecords : BaseModel + { + /// <summary> + /// 浜у搧缂栫爜 + /// </summary> + [StringLength(64)] + public string ProductionCode { get; set; } + + /// <summary> + /// 浜у搧鏉$爜 + /// </summary> + [StringLength(64)] + public string ProductionBarcode { get; set; } + + /// <summary> + /// 浜у搧缁撴灉 ok ng + /// </summary> + [StringLength(64)] + public string ProductionResult { get; set; } + + /// <summary> + /// 鎿嶄綔寮�濮嬫椂闂� + /// </summary> + public DateTime OperationStartTime { get; set; } + + /// <summary> + /// 鎿嶄綔缁撴潫鏃堕棿 + /// </summary> + public DateTime OperationEndTime { get; set; } + + } + + public class ProductionMeasurementRecordsRequest : BaseRequest + { + /// <summary> + /// 浜у搧缂栫爜 + /// </summary> + public string ProductionCode { get; set; } + + /// <summary> + /// 浜у搧鏉$爜 + /// </summary> + public string ProductionBarcode { get; set; } + + /// <summary> + /// 浜у搧缁撴灉 + /// </summary> + public OutputResult ProductionResult { get; set; } + } + +} diff --git a/src/Bro.M071.Process/App.config b/src/Bro.M071.Process/App.config new file mode 100644 index 0000000..274ca45 --- /dev/null +++ b/src/Bro.M071.Process/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="DataBase" connectionString="data source=(LocalDb)\MSSQLLocalDB;initial catalog=Bro.Process.Model.DBModel;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework" providerName="System.Data.SqlClient" />--> + <add name="DataBase" 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/Bro.M071.Process.csproj b/src/Bro.M071.Process/Bro.M071.Process.csproj index e251945..df07580 100644 --- a/src/Bro.M071.Process/Bro.M071.Process.csproj +++ b/src/Bro.M071.Process/Bro.M071.Process.csproj @@ -138,6 +138,10 @@ <EmbeddedResource Include="UI\M071_MainForm.resx"> <DependentUpon>M071_MainForm.cs</DependentUpon> </EmbeddedResource> + <None Include="App.config"> + <SubType>Designer</SubType> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </None> <None Include="packages.config" /> <None Include="Properties\Settings.settings"> <Generator>SettingsSingleFileGenerator</Generator> @@ -158,6 +162,10 @@ <Project>{1A3CBFE7-3F78-42C3-95C5-10360450DBEA}</Project> <Name>Bro.Common.Model</Name> </ProjectReference> + <ProjectReference Include="..\Bro.M071.Process.Model\Bro.M071.Model.csproj"> + <Project>{AD645C48-5811-4B1E-B81F-D35D5E6B577F}</Project> + <Name>Bro.M071.Model</Name> + </ProjectReference> <ProjectReference Include="..\Bro.Process\Bro.Process.csproj"> <Project>{197C5AA8-9609-4D1C-B1E3-5879006EAAF4}</Project> <Name>Bro.Process</Name> diff --git a/src/Bro.M071.Process/M071Config.cs b/src/Bro.M071.Process/M071Config.cs index aa06147..cdee3bc 100644 --- a/src/Bro.M071.Process/M071Config.cs +++ b/src/Bro.M071.Process/M071Config.cs @@ -64,8 +64,8 @@ [Category("妫�娴嬭缃�")] [Description("妫�娴嬮厤缃泦鍚�")] [TypeConverter(typeof(CollectionCountConvert))] - [Editor(typeof(ComplexCollectionEditor<MeasurementUint>), typeof(UITypeEditor))] - public List<MeasurementUint> MeasurementUnitCollection { get; set; } = new List<MeasurementUint>(); + [Editor(typeof(ComplexCollectionEditor<MeasurementUnit>), typeof(UITypeEditor))] + public List<MeasurementUnit> MeasurementUnitCollection { get; set; } = new List<MeasurementUnit>(); [Category("鍥剧墖淇濆瓨閰嶇疆")] [Description("鍗曢敭鍥剧墖淇濆瓨閰嶇疆")] diff --git a/src/Bro.M071.Process/M071Models.cs b/src/Bro.M071.Process/M071Models.cs index a5c4137..b00d4d8 100644 --- a/src/Bro.M071.Process/M071Models.cs +++ b/src/Bro.M071.Process/M071Models.cs @@ -205,7 +205,7 @@ { public string Barcode; - public List<MeasurementUint> Measurements = new List<MeasurementUint>(); + public List<MeasurementUnit> Measurements = new List<MeasurementUnit>(); public List<IShapeElement> ElementList = new List<IShapeElement>(); @@ -235,7 +235,7 @@ } } - public class MeasurementUint : IComplexDisplay, INotifyPropertyChanged, IDisposable + public class MeasurementUnit : IComplexDisplay, INotifyPropertyChanged, IDisposable { public string Id = Guid.NewGuid().ToString(); diff --git a/src/Bro.M071.Process/M071Process.cs b/src/Bro.M071.Process/M071Process.cs index 65f74a9..f76d19a 100644 --- a/src/Bro.M071.Process/M071Process.cs +++ b/src/Bro.M071.Process/M071Process.cs @@ -2,6 +2,7 @@ using Bro.Common.Helper; using Bro.Common.Interface; using Bro.Common.Model; +using Bro.M071.Model; using Bro.Process; using HalconDotNet; using System; @@ -56,6 +57,9 @@ private void InitialSetting() { + //鏁版嵁搴撹縼绉绘鏌� + DatabaseInitialize.Initialize(); + Config.SnapshotPointCollection.ForEach(u => { u.GetHalconToolPathList().ForEach(path => @@ -335,7 +339,7 @@ } } - private void SaveKeyImages(string barCode, MeasurementUint measureUnit) + private void SaveKeyImages(string barCode, MeasurementUnit measureUnit) { string measureName = measureUnit.GetDisplayText(); if (Config.ImageSaveOption.IsSaveOriginImage) @@ -366,7 +370,7 @@ } } - private async void SaveKeyImages(MeasurementUint measureUnit, string measureName, string dir) + private async void SaveKeyImages(MeasurementUnit measureUnit, string measureName, string dir) { await Task.Run(() => { @@ -386,7 +390,7 @@ } #endregion - private async void RunImageHandle(CameraBase camera, IOperationConfig opConfig, HImage hImage, string snapshotId, string snapshotName, List<MeasurementUint> measureList) + private async void RunImageHandle(CameraBase camera, IOperationConfig opConfig, HImage hImage, string snapshotId, string snapshotName, List<MeasurementUnit> measureList) { await Task.Run(() => { diff --git a/src/Bro.Process.DBManager/BaseModel.cs b/src/Bro.Process.DBManager/BaseModel.cs index f827c7c..cc6e86b 100644 --- a/src/Bro.Process.DBManager/BaseModel.cs +++ b/src/Bro.Process.DBManager/BaseModel.cs @@ -1,200 +1,200 @@ -锘縰sing 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; +锘�//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.Process.DataBase -{ - public class BaseModel - { - /// <summary> - /// 缂栧彿锛屽敮涓�鍊�,浣跨敤GUID - /// </summary> - [Key] - [Required(ErrorMessage = "缂栧彿涓嶅彲涓虹┖锛�")] - [StringLength(64)] - public string ID { get; set; } = Guid.NewGuid().ToString().ToUpper(); +//namespace Bro.Process.DataBase +//{ +// public class BaseModel +// { +// /// <summary> +// /// 缂栧彿锛屽敮涓�鍊�,浣跨敤GUID +// /// </summary> +// [Key] +// [Required(ErrorMessage = "缂栧彿涓嶅彲涓虹┖锛�")] +// [StringLength(64)] +// 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_DISABLED { get; set; } = 0; - /// <summary> - /// 鍒犻櫎鐘舵�� 0 鏈垹闄� 1 宸插垹闄� - /// </summary> - [Required] - public int IS_DELETED { get; set; } = 0; +// /// <summary> +// /// 鍒犻櫎鐘舵�� 0 鏈垹闄� 1 宸插垹闄� +// /// </summary> +// [Required] +// public int IS_DELETED { get; set; } = 0; - /// <summary> - /// 鍒涘缓浜轰俊鎭� - /// </summary> - //[Required] - [StringLength(64)] - public string CREATE_USER { get; set; } +// /// <summary> +// /// 鍒涘缓浜轰俊鎭� +// /// </summary> +// //[Required] +// [StringLength(64)] +// public string CREATE_USER { get; set; } - /// <summary> - /// 鍒涘缓鏃堕棿 - /// </summary> - //[Required] - public DateTime? CREATE_TIME { get; set; } = DateTime.Now; +// /// <summary> +// /// 鍒涘缓鏃堕棿 +// /// </summary> +// //[Required] +// public DateTime? CREATE_TIME { get; set; } = DateTime.Now; - /// <summary> - /// 鏇存柊浜轰俊鎭� - /// </summary> - [StringLength(64)] - public string UPDATE_USER { get; set; } +// /// <summary> +// /// 鏇存柊浜轰俊鎭� +// /// </summary> +// [StringLength(64)] +// public string UPDATE_USER { get; set; } - /// <summary> - /// 鏇存柊鏃堕棿 - /// </summary> - public DateTime? UPDATE_TIME { 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.CREATE_USER = userId; - t.CREATE_TIME = DateTime.Now; - } +// public static class BaseModelHelper +// { +// public static void SetNew<T>(this T t, string userId) where T : BaseModel +// { +// 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; - } +// 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); - } +// 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(); +// 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)); - } - } - } - }); - } +// 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 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 - { +// 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 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); - } - } - } +// 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? StartTime { get; set; } - /// <summary> - /// 鏌ヨ缁撴潫鏃堕棿 - /// </summary> - public DateTime? EndTime { get; set; } +// /// <summary> +// /// 鏌ヨ缁撴潫鏃堕棿 +// /// </summary> +// public DateTime? EndTime { get; set; } - /// <summary> - /// 鍚敤鐘舵�佽繃婊ゅ櫒 1锛氫粎鏈惎鐢� 0锛氫粎鍚敤 -1锛氬叏閮� - /// </summary> - public int DisableFilter { get; set; } = 0; +// /// <summary> +// /// 鍚敤鐘舵�佽繃婊ゅ櫒 1锛氫粎鏈惎鐢� 0锛氫粎鍚敤 -1锛氬叏閮� +// /// </summary> +// public int DisableFilter { get; set; } = 0; - /// <summary> - /// 鏌ヨ瀛楃涓� - /// </summary> - public string SearchTxt { get; set; } +// /// <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 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); - } - } - } +// 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; - } -} +// public event PropertyChangedEventHandler PropertyChanged; +// } +//} diff --git a/src/Bro.Process.DBManager/SQLiteHelper.cs b/src/Bro.Process.DBManager/SQLiteHelper.cs index 6da6230..dfb07e1 100644 --- a/src/Bro.Process.DBManager/SQLiteHelper.cs +++ b/src/Bro.Process.DBManager/SQLiteHelper.cs @@ -1,614 +1,614 @@ -using System; -using System.Collections; -using System.Collections.Specialized; -using System.Data; -using System.Data.SQLite; -using System.Configuration; +//using System; +//using System.Collections; +//using System.Collections.Specialized; +//using System.Data; +//using System.Data.SQLite; +//using System.Configuration; -namespace Bro.Process.DataBase -{ - public class SQLiteHelper - { - //数据库连接字符串 - public static string connectionString = ConfigurationManager.ConnectionStrings["DataBase"].ConnectionString; +//namespace Bro.Process.DataBase +//{ +// public class SQLiteHelper +// { +// //数据库连接字符串 +// public static string connectionString = ConfigurationManager.ConnectionStrings["DataBase"].ConnectionString; - public SQLiteHelper() { } +// public SQLiteHelper() { } - #region 公用方法 +// #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 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) +// { +// 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; - } - } +// 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 +// #endregion - #region 执行简单SQL语句 +// #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">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="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="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 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> +// /// 执行带一个存储过程参数的的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> +// /// 向数据库里插入图像格式的字段(和上面情况类似的另一种实例) +// /// </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> +// /// 执行一条计算查询结果语句,返回查询结果(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> +// /// 执行查询语句,返回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; - } - } +// /// <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; - } - } +// 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; - } - } +// /// <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 +// #endregion - #region 执行带参数的SQL语句 +// #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="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> +// /// 执行多条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> +// /// 执行一条计算查询结果语句,返回查询结果(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> +// /// 执行查询语句,返回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; - } - } - } +// /// <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); - } - } - } +// 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 +// #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; - } +// #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; - } +// 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 +// #endregion +// } +//} \ No newline at end of file diff --git a/src/Bro.UI.Config/MenuForms/FrmOperation.resx b/src/Bro.UI.Config/MenuForms/FrmOperation.resx index b406f47..821dd26 100644 --- a/src/Bro.UI.Config/MenuForms/FrmOperation.resx +++ b/src/Bro.UI.Config/MenuForms/FrmOperation.resx @@ -125,7 +125,7 @@ AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAADm - CgAAAk1TRnQBSQFMAgEBAgEAAeABAAHgAQABGAEAARgBAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo + CgAAAk1TRnQBSQFMAgEBAgEAAegBAAHoAQABGAEAARgBAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo AwABYAMAARgDAAEBAQABCAYAAQkYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5 AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA @@ -182,7 +182,7 @@ AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAD4 - CAAAAk1TRnQBSQFMAwEBAAHgAQAB4AEAARgBAAEYAQAE/wEJAQAI/wFCAU0BNgEEBgABNgEEAgABKAMA + CAAAAk1TRnQBSQFMAwEBAAHoAQAB6AEAARgBAAEYAQAE/wEJAQAI/wFCAU0BNgEEBgABNgEEAgABKAMA AWADAAEYAwABAQEAAQgGAAEJGAABgAIAAYADAAKAAQABgAMAAYABAAGAAQACgAIAA8ABAAHAAdwBwAEA AfABygGmAQABMwUAATMBAAEzAQABMwEAAjMCAAMWAQADHAEAAyIBAAMpAQADVQEAA00BAANCAQADOQEA AYABfAH/AQACUAH/AQABkwEAAdYBAAH/AewBzAEAAcYB1gHvAQAB1gLnAQABkAGpAa0CAAH/ATMDAAFm -- Gitblit v1.8.0