领胜LDS 键盘AOI检测项目
wells.liu
2020-06-28 91293cac4b05319e6ed796ce34cb0640311b553b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
////using Bro.Process.Common.Helper;
//using Bro.Common.Helper;
//using Bro.Process.Model;
//using Bro.Process.Model.Model;
//using System;
//using System.Collections;
//using System.Collections.Generic;
//using System.Data.Common;
//using System.Data.SQLite;
//using System.Diagnostics;
//using System.Linq;
//using System.Text;
//using System.Threading.Tasks;
 
//namespace Bro.M071.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)//有重复id
//        //        {
//        //            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();
//    //        }
//    //    }
//    //}
//}