// サブプロシージャ:テキストファイル出力 private void outputTbiInfo() { string sn = txtChild.Text.Trim(); string lot = txtParent.Text.Trim() == string.Empty? "null" : txtParent.Text.Trim(); string model = txtModel.Text.Trim(); string date = DateTime.Today.ToString("yyyy/MM/dd"); string time = DateTime.Now.ToString("HH:mm:ss"); string cumRecords = string.Empty; if (sn == string.Empty) { return; } if (sn.IndexOf("+") >= 1) { sn = VBS.Left(sn, 17); } // 複数の部品ロット情報に、単数のCHILD情報を紐付け、部品ロット件数分のレコードを作成する for (int i = 0; i < rowPartsLot; i++) { string lotInf = dgvPartsLot[3, i].Value.ToString().Replace(":", "_") + ":" + string.Empty + ":" + description[i] + ":" + dgvPartsLot[0, i].Value.ToString() + ":" + dgvPartsLot[1, i].Value.ToString() + ":" + dgvPartsLot[2, i].Value.ToString().Replace(":", "_") + ":" + dgvPartsLot[4, i].Value.ToString(); lotInf = lotInf.Replace(" ", "_").Replace(",", "_").Replace("'", "_").Replace(";", "_").Replace("\"", "_"); string newRecord = sn + "," + lot + "," + model + "," + date + "," + time + "," + lotInf; cumRecords += newRecord + System.Environment.NewLine; } // 同日日付のファイルが存在する場合は追記し、存在しない場合はファイルを作成しヘッダーを書き込みの上、追記する try { string outFile = outPath + DateTime.Today.ToString("yyyyMMdd") + ".txt"; if (System.IO.File.Exists(outFile)) { System.IO.File.AppendAllText(outFile, cumRecords, System.Text.Encoding.GetEncoding("UTF-8")); } else { string header = DateTime.Today.ToString("yyyy/MM/dd") + "," + model + Environment.NewLine + "SN,LOT,MODELNAME,DATE,TIME,LOTINFO" + Environment.NewLine; System.IO.File.AppendAllText(outFile, header + cumRecords, System.Text.Encoding.GetEncoding("UTF-8")); } // 登録カウントの表示 cumCount += 1; txtCount.Text = cumCount.ToString(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } // 次のスキャンに備え、 txtChild.Text = string.Empty; txtParent.Text = string.Empty; txtChild.Focus(); }
// サブプロシージャ:テキストファイル出力(TIP&TAIL用) private void outputTbiInfoForTipTail() { string[] sn = { txtChild.Text.Trim(), txtChild2.Text.Trim() }; string lot = txtParent.Text.Trim() == string.Empty? "null" : txtParent.Text.Trim(); string model = txtModel.Text.Trim(); string date = DateTime.Today.ToString("yyyy/MM/dd"); string time = DateTime.Now.ToString("HH:mm:ss"); string cumRecords = string.Empty; // TIP&TAILの場合、それぞれのジグに対応するそれぞれの複数の部品ロット情報を紐付け、2件のレコードを作成する for (int i = 0; i < sn.Length; i++) { string lotInf = (dgvPartsLot[3, i].Value.ToString().Replace(":", "_") + ":" + jigposition[i] + ":" + description[i] + ":" + dgvPartsLot[0, i].Value.ToString() + ":" + dgvPartsLot[1, i].Value.ToString() + ":" + dgvPartsLot[2, i].Value.ToString().Replace(":", "_") + ":" + dgvPartsLot[4, i].Value.ToString()) .Replace(" ", "_").Replace(",", "_").Replace("'", "_").Replace(";", "_").Replace("\"", "_"); // 製品シリアルの部品コンフィグ情報は、切り捨てる(17桁のみ保持する) if (sn[i].IndexOf("+") >= 1) { sn[i] = VBS.Left(sn[i], 17); } string newRecord = sn[i] + "," + lot + "," + model + "," + date + "," + time + "," + lotInf; cumRecords += newRecord + System.Environment.NewLine; } // 同日日付のファイルが存在する場合は追記し、存在しない場合はファイルを作成しヘッダーを書き込みの上、追記する try { string outFile = outPath + DateTime.Today.ToString("yyyyMMdd") + ".txt"; if (System.IO.File.Exists(outFile)) { System.IO.File.AppendAllText(outFile, cumRecords, System.Text.Encoding.GetEncoding("UTF-8")); } else { string header = DateTime.Today.ToString("yyyy/MM/dd") + "," + model + Environment.NewLine + "SN,LOT,MODELNAME,DATE,TIME,LOTINFO" + Environment.NewLine; System.IO.File.AppendAllText(outFile, header + cumRecords, System.Text.Encoding.GetEncoding("UTF-8")); } // 登録カウントの表示 cumCount += 1; txtCount.Text = cumCount.ToString(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } // 次のスキャンに備え、 txtChild.Text = string.Empty; txtChild2.Text = string.Empty; txtParent.Text = string.Empty; txtChild.Focus(); }
// 以下NTRS // NTRSサブプロシージャ: テスター用WHERE句の作成 private string makeSqlWhereClause(string criteria) { string sql = " where ("; foreach (string c in criteria.Split(',')) { sql += "process = " + c + " or "; } sql = VBS.Left(sql, sql.Length - 3) + ") "; System.Diagnostics.Debug.Print(sql); return(sql); }
// サブプロシージャ:TBIテーブルへの登録 private void outPutTbiInfo() { var snArray = dtChild.AsEnumerable() .Select(r => new { child = r.Field <string>("child").IndexOf("+") >= 1 ? VBS.Left(r.Field <string>("child").Trim(), 17) : r.Field <string>("child").Trim() }); string[] jsn = { txtParent.Text.Trim(), txtChild2.Text.Trim() }; string[] lbl = { lblParent.Text.Trim(), lblChild2.Text.Trim() }; string model = txtModel.Text.Trim().ToUpper(); string date = DateTime.Today.ToString("yyyy/MM/dd"); string time = DateTime.Now.ToString("HH:mm:ss"); string cumRecords = string.Empty; int tempCount = 0; // チャイルド1、チャイルド2、ペアレントのマッチングを行う(当機能の設定、ONの場合) if (c1c2prMatching == "ON") { wrongScanOrder = matchScanOrder(txtChild.Text, txtChild2.Text, string.Empty); if (wrongScanOrder) { MessageBox.Show("Case pallet barcode is wrong." + Environment.NewLine + "Please clear and re-scan all.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } string lotInf; string newRecord; // 複数の部品ロット情報に、複数のCHILD情報を紐付け、部品ロット件数×CHILD件数の、レコードを作成する foreach (var sn in snArray) { newRecord = string.Empty; // TIP&TAILの場合、それぞれのジグに対応するそれぞれの複数の部品ロット情報を紐付け、2件のレコードを作成する lotInf = (dgvPartsLot[3, 0].Value.ToString().Replace(":", "_") + ":" + jigposition[0] + ":" + description[0] + ":" + dgvPartsLot[0, 0].Value.ToString() + ":" + dgvPartsLot[1, 0].Value.ToString() + ":" + dgvPartsLot[2, 0].Value.ToString().Replace(":", "_") + ":" + dgvPartsLot[4, 0].Value.ToString()) .Replace(" ", "_").Replace(",", "_").Replace("'", "_").Replace(";", "_").Replace("\"", "_"); newRecord = sn.child + "," + "null" + "," + model + "," + date + "," + time + "," + lotInf; cumRecords += newRecord + System.Environment.NewLine; for (int i = 0; i < jsn.Length; i++) { lotInf = ("null" + ":" + string.Empty + ":" + description[i + 1] + ":" + jsn[i] + ":" + lbl[i].ToUpper() + ":" + "null" + ":" + "2000/01/01") .Replace(" ", "_").Replace(",", "_").Replace("'", "_").Replace(";", "_").Replace("\"", "_"); newRecord = sn.child + "," + "null" + "," + model + "," + date + "," + time + "," + lotInf; cumRecords += newRecord + System.Environment.NewLine; } tempCount += 1; } // 同日日付のファイルが存在する場合は追記し、存在しない場合はファイルを作成しヘッダーを書き込みの上、追記する try { string outFile = outPath + DateTime.Today.ToString("yyyyMMdd") + ".txt"; if (System.IO.File.Exists(outFile)) { System.IO.File.AppendAllText(outFile, cumRecords, System.Text.Encoding.GetEncoding("UTF-8")); } else { string header = DateTime.Today.ToString("yyyy/MM/dd") + "," + model + Environment.NewLine + "SN,LOT,MODELNAME,DATE,TIME,LOTINFO" + Environment.NewLine; System.IO.File.AppendAllText(outFile, header + cumRecords, System.Text.Encoding.GetEncoding("UTF-8")); } // 登録カウントの表示 cumCount += tempCount; txtCount.Text = cumCount.ToString(); // 次のチャイルドスキャンのための準備 clerChildView(); txtParent.Text = string.Empty; txtChild2.Text = string.Empty; txtChild.Focus(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } }
// NTRSの処理を行い、判定結果を返す private bool ntrsScanProcess(string id) { TfSQL tf = new TfSQL(); DataTable dt = new DataTable(); string log = string.Empty; string module = id; string mdlShort = VBS.Left(module, 16); // 一時的に16ケタに設定 string sql1 = "select process, judge, max(inspectdate) as inspectdate from (" + "(select process, case when tjudge = '0' then 'PASS' else 'FAIL' end as judge, inspectdate from " + headTableThisMonth + whereProcessSql + "and serno like '" + mdlShort + "%') union all " + "(select process, case when tjudge = '0' then 'PASS' else 'FAIL' end as judge, inspectdate from " + headTableLastMonth + whereProcessSql + "and serno like '" + mdlShort + "%')" + ") d group by judge, process order by judge desc, process"; System.Diagnostics.Debug.Print(sql1); tf.sqlDataAdapterFillDatatableFromPqmDb(sql1, ref dt); for (int i = 0; i < dt.Rows.Count; i++) { System.Diagnostics.Debug.Print(dt.Rows[i][0].ToString() + " " + dt.Rows[i][1].ToString() + " " + dt.Rows[i][2].ToString()); } var allResults = dt.AsEnumerable().Select(r => new TestResult() { process = r.Field <string>("process"), judge = r.Field <string>("judge"), inspectdate = r.Field <DateTime>("inspectdate").ToString("yyyy/MM/dd HH:mm:ss"), }).ToList(); string scanTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"); // 1.パスのプロセス名を取得 var passResults = allResults.Where(r => r.judge == "PASS").Select(r => new ProcessList() { process = r.process }).OrderBy(r => r.process).ToList(); foreach (var p in passResults) { System.Diagnostics.Debug.Print(p.process); } // 2.1に含まれないフェイルのプロセス名を取得 var failResults = allResults.Where(r => r.judge == "FAIL").Select(r => new ProcessList() { process = r.process }).OrderBy(r => r.process).ToList(); List <string> process = failResults.Select(r => r.process).Except(passResults.Select(r => r.process)).ToList(); failResults = failResults.Where(r => process.Contains(r.process)).ToList(); foreach (var p in failResults) { System.Diagnostics.Debug.Print(p.process); } // 3.1にも2にも含まれない、テスト結果なしプロセスを取得する var skipResults = targetProcess.Replace("'", string.Empty).Split(',').ToList().Select(r => new ProcessList() { process = r.ToString() }).OrderBy(r => r.process).ToList(); process = skipResults.Select(r => r.process).Except(passResults.Select(r => r.process)).ToList().Except(failResults.Select(r => r.process)).ToList(); skipResults = skipResults.Where(r => process.Contains(r.process)).ToList(); foreach (var p in skipResults) { System.Diagnostics.Debug.Print(p.process); } // ディスプレイ用のプロセス名リストを加工する string displayPass = string.Empty; string displayFail = string.Empty; string displayAll = string.Empty; // ログ用 List <TestResult> allLog = new List <TestResult>(); foreach (var p in passResults) { displayPass += p.process + " "; allLog.Add(new TestResult { process = p.process, judge = "PASS", inspectdate = string.Empty }); } displayPass = displayPass.Trim(); foreach (var p in failResults) { displayFail += p.process + " F "; allLog.Add(new TestResult { process = p.process, judge = "FAIL", inspectdate = string.Empty }); } foreach (var p in skipResults) { displayFail += p.process + " S "; allLog.Add(new TestResult { process = p.process, judge = "SKIP", inspectdate = string.Empty }); } displayFail = displayFail.Trim(); allLog = allLog.OrderBy(r => r.process).ToList(); foreach (var p in allLog) { displayAll += (p.process + ":" + p.judge + ","); } displayAll = VBS.Left(displayAll, displayAll.Length - 1); bool result = false; // アプリケーションスクリーンに、テスト結果を表示する if (passResults.Count == targetProcessCount) { string okImagePass = System.Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + @"\JigQuickDesk\JigQuickApp\images\" + okImageFile; pnlResult.BackgroundImageLayout = ImageLayout.Zoom; pnlResult.BackgroundImage = System.Drawing.Image.FromFile(okImagePass); // OKカウントの加算 okCount += 1; txtOkCount.Text = okCount.ToString(); // PASSの場合は、TRUEを返す result = true; // 次のモジュールのスキャンにそなえ、スキャン用テキストボックスのテキストを選択し、上書き可能にする txtChild.SelectAll(); } else { string ngImagePath = System.Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + @"\JigQuickDesk\JigQuickApp\images\" + ngImageFile; pnlResult.BackgroundImageLayout = ImageLayout.Zoom; pnlResult.BackgroundImage = System.Drawing.Image.FromFile(ngImagePath); // NGカウントの加算 ngCount += 1; txtNgCount.Text = ngCount.ToString(); // FAILの場合は、FALSEを返す result = true; // 次のモジュールのスキャンをストップするめた、スキャン用テキストボックスを無効にする txtChild.ReadOnly = true; txtChild.BackColor = Color.Red; // アラームでの警告 soundAlarm(); } // アプリケーションスクリーンとデスクトップフォルダの両方の用途用に、日付とテスト結果詳細文字列を作成 log = Environment.NewLine + scanTime + "," + module + "," + displayAll; // スクリーンへの表示 txtResultDetail.Text = log.Replace(",", ", ").Replace(Environment.NewLine, string.Empty); // ログ書込み:同日日付のファイルが存在する場合は追記し、存在しない場合はファイルを作成追記する(AppendAllText がやってくれる) try { string outFile = outPath2 + DateTime.Today.ToString("yyyyMMdd") + ".txt"; if (System.IO.File.Exists(outFile)) { System.IO.File.AppendAllText(outFile, log, System.Text.Encoding.GetEncoding("UTF-8")); } else { string header = DateTime.Today.ToString("yyyy/MM/dd") + " " + model + " " + subAssyName + Environment.NewLine + "SCAN TIME,PRODUCT SERIAL,TEST DETAIL"; System.IO.File.AppendAllText(outFile, header + log, System.Text.Encoding.GetEncoding("UTF-8")); } return(result); } catch (Exception ex) { MessageBox.Show(ex.Message, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return(result); } }
// サブプロシージャ:TBIテーブルへの登録 private void outPutTbiInfo() { string sn; string lot = txtParent.Text.Trim() == string.Empty? "null" : txtParent.Text.Trim(); string model = txtModel.Text.Trim(); string date = DateTime.Today.ToString("yyyy/MM/dd"); string time = DateTime.Now.ToString("HH:mm:ss"); string cumRecords = string.Empty; int position = 1; int tempCount = 0; // チャイルド1、チャイルド2、ペアレントのマッチングを行う(当機能の設定、ONの場合) if (c1c2prMatching == "ON") { wrongScanOrder = matchScanOrder(string.Empty, string.Empty, txtParent.Text); if (wrongScanOrder) { MessageBox.Show("Case pallet barcode is wrong." + Environment.NewLine + "Please clear and re-scan all.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } // 複数の部品ロット情報に、複数のCHILD情報を紐付け、部品ロット件数×CHILD件数の、レコードを作成する for (int i = 0; i < rowChild; i++) { sn = dgvChild[0, i].Value.ToString(); if (sn == string.Empty) { continue; } if (sn.IndexOf("+") >= 1) { sn = VBS.Left(sn, 17); } string pos = posOutput == "OFF" ? string.Empty : position.ToString("00"); string newRecord = string.Empty; for (int j = 0; j < rowPartsLot; j++) { string lotInf; // ペアレントの使用がない場合(D−4)は、ジグポジション列は空白 if (parentuse == "ON") { lotInf = dgvPartsLot[3, j].Value.ToString().Replace(":", "_") + ":" + jigposition[j] + pos + ":" + description[j] + ":" + dgvPartsLot[0, j].Value.ToString() + ":" + dgvPartsLot[1, j].Value.ToString() + ":" + dgvPartsLot[2, j].Value.ToString().Replace(":", "_") + ":" + dgvPartsLot[4, j].Value.ToString(); } else { lotInf = dgvPartsLot[3, j].Value.ToString().Replace(":", "_") + ":" + string.Empty + ":" + description[j] + ":" + dgvPartsLot[0, j].Value.ToString() + ":" + dgvPartsLot[1, j].Value.ToString() + ":" + dgvPartsLot[2, j].Value.ToString().Replace(":", "_") + ":" + dgvPartsLot[4, j].Value.ToString(); } lotInf = lotInf.Replace(" ", "_").Replace(",", "_").Replace("'", "_").Replace(";", "_").Replace("\"", "_"); // 本来、CHILDを左列SERNO、PARENTを右列LOT、へ出力するが、MAINジグ等は、逆で出力する if (reverseEntry == "ON") { newRecord = lot + "," + sn + "," + model + "," + date + "," + time + "," + lotInf; } else { newRecord = sn + "," + lot + "," + model + "," + date + "," + time + "," + lotInf; } cumRecords += newRecord + System.Environment.NewLine; } position += 1; tempCount += 1; } // 同日日付のファイルが存在する場合は追記し、存在しない場合はファイルを作成しヘッダーを書き込みの上、追記する try { string outFile = outPath + DateTime.Today.ToString("yyyyMMdd") + ".txt"; if (System.IO.File.Exists(outFile)) { System.IO.File.AppendAllText(outFile, cumRecords, System.Text.Encoding.GetEncoding("UTF-8")); } else { string header = DateTime.Today.ToString("yyyy/MM/dd") + "," + model + Environment.NewLine + "SN,LOT,MODELNAME,DATE,TIME,LOTINFO" + Environment.NewLine; System.IO.File.AppendAllText(outFile, header + cumRecords, System.Text.Encoding.GetEncoding("UTF-8")); } // 登録カウントの表示 cumCount += tempCount; txtCount.Text = cumCount.ToString(); // 次のチャイルドスキャンのための準備 clerChildView(); txtParent.Text = string.Empty; txtChild.Focus(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } }
// サブプロシージャ:TBIテーブルへの登録 private void outPutTbiInfo() { string sn; string lot; string model = txtModel.Text.Trim(); string date = DateTime.Today.ToString("yyyy/MM/dd"); string time = DateTime.Now.ToString("HH:mm:ss"); string cumRecords = string.Empty; int tempCount = 0; // チャイルド1、チャイルド2、ペアレントのマッチングを行う(当機能の設定、ONの場合) if (c1c2prMatching == "ON") { wrongScanOrder = matchScanOrder(dgvChild[0, 0].Value.ToString(), txtChild2.Text, dgvParent[0, 0].Value.ToString()); if (wrongScanOrder) { MessageBox.Show("Scan order is wrong." + Environment.NewLine + "Please clear and re-scan all.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } // 複数のメインジグに対し、A.複数の製品+部品ロットを紐付けて、レコードを作成する for (int i = 0; i < rowChildParent; i++) { sn = dgvChild[0, i].Value.ToString(); if (sn.IndexOf("+") >= 1) { sn = VBS.Left(sn, 17); } lot = dgvParent[0, i].Value.ToString(); if (sn == string.Empty || lot == string.Empty) { continue; } string lotInf = (dgvPartsLot[3, 0].Value.ToString().Replace(":", "_") + ":" + jigposition[0] + ":" + description[0] + ":" + dgvPartsLot[0, 0].Value.ToString() + ":" + dgvPartsLot[1, 0].Value.ToString() + ":" + dgvPartsLot[2, 0].Value.ToString().Replace(":", "_") + ":" + dgvPartsLot[4, 0].Value.ToString()) .Replace(" ", "_").Replace(",", "_").Replace("'", "_").Replace(";", "_").Replace("\"", "_"); string newRecord = sn + "," + lot + "," + model + "," + date + "," + time + "," + lotInf; cumRecords += newRecord + System.Environment.NewLine; tempCount += 1; } // 複数のメインジグに対し、B.単数のドッキング下部を紐付けて、レコードを作成する for (int i = 0; i < rowChildParent; i++) { sn = txtChild2.Text; if (sn.IndexOf("+") >= 1) { sn = VBS.Left(sn, 17); } lot = dgvParent[0, i].Value.ToString(); if (lot == string.Empty) { continue; } string lotInf = ("null" + ":" + jigposition[1] + ":" + description[1] + ":" + "null" + ":" + "null" + ":" + "null" + ":" + "2000/01/01") .Replace(" ", "_").Replace(",", "_").Replace("'", "_").Replace(";", "_").Replace("\"", "_"); string newRecord = sn + "," + lot + "," + model + "," + date + "," + time + "," + lotInf; cumRecords += newRecord + System.Environment.NewLine; } // 同日日付のファイルが存在する場合は追記し、存在しない場合はファイルを作成しヘッダーを書き込みの上、追記する try { string outFile = outPath + DateTime.Today.ToString("yyyyMMdd") + ".txt"; if (System.IO.File.Exists(outFile)) { System.IO.File.AppendAllText(outFile, cumRecords, System.Text.Encoding.GetEncoding("UTF-8")); } else { string header = DateTime.Today.ToString("yyyy/MM/dd") + "," + model + Environment.NewLine + "SN,LOT,MODELNAME,DATE,TIME,LOTINFO" + Environment.NewLine; System.IO.File.AppendAllText(outFile, header + cumRecords, System.Text.Encoding.GetEncoding("UTF-8")); } // 登録カウントの表示 cumCount += tempCount; txtCount.Text = cumCount.ToString(); // 次のチャイルドスキャンのための準備 clerChildParentView(); txtParent.Text = string.Empty; txtChild.Text = string.Empty; txtChild2.Text = string.Empty; txtChild.Focus(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } }