| | |
| | | using System.Text; |
| | | using System.Windows.Forms; |
| | | using System.Drawing; |
| | | using System.Diagnostics; |
| | | using System.Collections.Generic; |
| | | |
| | | namespace M423project |
| | | { |
| | |
| | | private SqlConnection connForUpload; |
| | | private string _standardCheckMode; |
| | | |
| | | int enableUploadMinutes = 10; |
| | | private static readonly object synObj = new object(); |
| | | public DetectionData() |
| | | { |
| | |
| | | catch (Exception) |
| | | { |
| | | CommonUtil.WriteLog(LogType.Err, "DataUpload连接数据库失败!"); |
| | | } |
| | | |
| | | string enableUploadMinutesStr = ConfigurationManager.AppSettings["EnableUploadMinutes"]; |
| | | |
| | | int temp = 0; |
| | | if (int.TryParse(enableUploadMinutesStr, out temp)) |
| | | { |
| | | enableUploadMinutes = temp; |
| | | } |
| | | else |
| | | { |
| | | enableUploadMinutes = 10; |
| | | } |
| | | } |
| | | |
| | |
| | | #region add by Patrick 2018-07-13 |
| | | public void SaveTrayBarcode(int detectID) |
| | | { |
| | | string trayCode = CarrierBarcodeCtrl.GlobalCarrierBarcode; |
| | | string trayCode = ""; |
| | | trayCode = CarrierBarcodeCtrl.GlobalCarrierBarcode; |
| | | |
| | | if (string.IsNullOrEmpty(trayCode)) |
| | | { |
| | |
| | | using (SqlCommand cmd = new SqlCommand(sql, connection)) |
| | | { |
| | | cmd.ExecuteNonQuery(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | public void SaveTrayBarcode(List<int> detectIDList, string carrierCode = null) |
| | | { |
| | | //string trayCode = CarrierBarcodeCtrl.GlobalCarrierBarcode; |
| | | |
| | | if (carrierCode == null) |
| | | { |
| | | carrierCode = CarrierBarcodeCtrl.GlobalCarrierBarcode; |
| | | } |
| | | |
| | | if (detectIDList.Count == 0) |
| | | { |
| | | return; |
| | | } |
| | | lock (synObj) |
| | | { |
| | | string idList = string.Join(",", detectIDList); |
| | | try |
| | | { |
| | | string sql = $"Update ProductDetectionDetail set CarrierBarcode='{carrierCode}' where AutoID in ({idList})"; |
| | | |
| | | using (SqlCommand cmd = new SqlCommand(sql, connection)) |
| | | { |
| | | cmd.ExecuteNonQuery(); |
| | | } |
| | | |
| | | Trace.TraceInformation($"{idList}产品绑定载具码:{carrierCode}"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Trace.TraceError($"{idList}产品绑定载具码:{carrierCode}异常:{ex.Message}"); |
| | | //throw; |
| | | } |
| | | } |
| | | } |
| | |
| | | AND ProductNoStatus = 'OK' |
| | | AND ProductStatus<>'NA' |
| | | AND (ISNULL(CarrierBarcode,'')<>'' OR ProductStatus = 'NG') |
| | | AND DATEDIFF(DAY,'{0}',DetectTime)>=-1 |
| | | ORDER BY DetectTime DESC", DateTime.Now.ToString("yyyy-MM-dd")); |
| | | AND DATEDIFF(MINUTE,DetectTime,'{0}')<={1} |
| | | ORDER BY DetectTime DESC", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), enableUploadMinutes.ToString()); |
| | | |
| | | SqlDataReader dr = null; |
| | | using (SqlCommand cmd = new SqlCommand(sql, connForUpload)) |
| | |
| | | public void SaveToCsv(ProductMeasureResult pmr) |
| | | { |
| | | string fileName = @"E:\DailyReport\detectdata" + DateTime.Now.ToString("yyyyMMdd") + ".csv"; |
| | | bool IsNewFile = !File.Exists(fileName); |
| | | |
| | | CSVDataRecord(pmr, fileName); |
| | | |
| | | } |
| | | |
| | | public void CSVDataRecord(ProductMeasureResult pmr, string fileName) |
| | | { |
| | | bool IsNewFile = !File.Exists(fileName); |
| | | lock (csvLock) |
| | | { |
| | | using (FileStream myStream = new FileStream(fileName, FileMode.OpenOrCreate)) |