104 lines
5.2 KiB
C#

using Adaptation.Shared;
using Adaptation.Shared.Metrology;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Adaptation.Metrology
{
internal class MET08DDUPSP1TBI
{
internal static Dictionary<int, List<object>> GetPreRunInfo(Logistics logistics, EventName eventName)
{
//2019-12-27 - 001
Dictionary<int, List<object>> results;
StringBuilder sql = new StringBuilder();
sql.Append(" SELECT ").
Append(" wafer_id, [run number], recipe, [part number], date, pocket_number, wafer_lot, [satellite group], ISNULL(( ").
Append(" SELECT max(startstamp) ").
Append(" FROM G4Wafers_01.dbo.ToolTimeInfo ").
Append(" WHERE (lot = @mid OR lot = @midSubstring) ").
Append(" ), date) startstamp ").
Append(" FROM G4Wafers_01.dbo.[prerun info] ").
Append(" WHERE (wafer_id = @mid OR [run number] = @mid) ").
Append(" ORDER by date ");
List<Tuple<string, string>> parameters = new List<Tuple<string, string>>
{
new Tuple<string, string>("@midSubstring", string.Concat("'", logistics.MID.Substring(0, logistics.MID.Length - 2), "'")),
new Tuple<string, string>("@mid", string.Concat("'", logistics.MID, "'"))
};
results = SQLDatabase.ExecuteReader(sql, parameters, columns: 9, isG4Wafers: true, isIrmnSpc: false);
return results;
}
internal static List<PreRunInfo> Verify(EventName eventName, List<PreRunInfo> results)
{
//2019-12-28 - 004
if (results.Any())
{
string partFromRecipe;
Dictionary<int, List<object>> check;
StringBuilder sql = new StringBuilder();
string lastPartFromRecipe = string.Empty;
List<Tuple<string, string>> parameters = new List<Tuple<string, string>>();
for (int i = 0; i < results.Count; i++)
{
partFromRecipe = results[i].Recipe;
if (string.IsNullOrEmpty(lastPartFromRecipe) || partFromRecipe != lastPartFromRecipe)
{
// re-format recipe name by extracting middle part of it
if ((!partFromRecipe.ToUpper().StartsWith("PROD")) &&
(!partFromRecipe.ToUpper().StartsWith("MAMD")) &&
(!partFromRecipe.ToUpper().StartsWith("QUAL")) &&
(!partFromRecipe.ToUpper().StartsWith("ENGR")) &&
(!partFromRecipe.ToUpper().StartsWith("ANKO")) &&
(!partFromRecipe.ToUpper().StartsWith("U")))
partFromRecipe = "ENG";
else if (partFromRecipe.Split('-').Length == 3) // recipe name has 3 parts
partFromRecipe = partFromRecipe.Split('-')[0].Trim() + "-" + partFromRecipe.Split('-')[1].Trim(); // middle part of recipe name
else if (partFromRecipe.Split('-').Length == 2) // recipe name has 2 parts
partFromRecipe = partFromRecipe.Split('-')[0].Trim(); // first part of recipe name
else if (partFromRecipe.Split('_').Length == 3)
partFromRecipe = partFromRecipe.Split('_')[1].Trim(); // middle part of recipe name
else if (partFromRecipe.Split('_').Length == 2) // recipe name has 2 parts
partFromRecipe = partFromRecipe.Split('_')[0].Trim(); // first part of recipe name
if (results[i].PartNumber != partFromRecipe)
results[i].PartNumber = partFromRecipe;
if (partFromRecipe != "ENG")
{
sql.Append(" SELECT ").
Append(" count(*) AS my_count ").
Append(" FROM IRMNSPC.dbo.part_dat ").
Append(" WHERE f_name = @part ");
parameters.Clear();
parameters.Add(new Tuple<string, string>("@part", string.Concat("'", partFromRecipe, "'")));
check = SQLDatabase.ExecuteReader(sql, parameters, columns: 1, isG4Wafers: true, isIrmnSpc: false);
if (check.ElementAt(0).Value[0].ToString() == "0")
{
partFromRecipe = "ENG";
results[i].PartNumber = partFromRecipe;
}
}
}
lastPartFromRecipe = partFromRecipe;
}
}
return results;
}
internal static string GetSid(List<PreRunInfo> preRunInfo, bool isMappedPart, IScopeInfo scopeInfo, List<string> tags)
{
string result = string.Empty;
if (preRunInfo.Any())
{
result = tags[0];
}
return result;
}
}
}