public static void StartProjectBonding(ProjectViewModels vm) { try { if (ProjectTestData.UpdatePJLockUsing(vm.ProjectKey)) { return; } if (vm.MDIDList.Count > 0 && vm.SumDatasetList.Count > 0) { var dsdict = new Dictionary <string, bool>(); foreach (var item in vm.SumDatasetList) { dsdict.Add(item.Station, true); } var failurelist = new List <ProjectTestData>(); //(c.MODEL_ID like 'FTLX6871%' or c.MODEL_ID like 'FTLX6872%' or c.MODEL_ID like 'FTLX6672%') var mdcond = "("; foreach (var w in vm.MDIDList) { mdcond = mdcond + "c.MODEL_ID like '" + w.Pn.Trim() + "%' or "; } mdcond = mdcond.Substring(0, mdcond.Length - 4) + ")"; var s = "SELECT a.MFR_SN,d.DATASET_NAME,c.FAMILY,d.STATUS,d.END_TIME,d.STATION,a.MFR_PN,d.ROUTE_ID FROM PARTS a INNER JOIN ROUTES b ON a.OPT_INDEX = b.PART_INDEX INNER JOIN BOM_CONTEXT_ID c ON c.BOM_CONTEXT_ID = b.BOM_CONTEXT_ID INNER JOIN DATASETS d ON b.ROUTE_ID = d.ROUTE_ID WHERE <mdcond> and d.END_TIME > '<TIMECOND>' ORDER BY d.ROUTE_ID,d.END_TIME DESC"; var sndict = new Dictionary <string, bool>(); var sql = s.Replace("<TIMECOND>", vm.StartDate.ToString("yyyyMMddhhmmss")).Replace("<mdcond>", mdcond); var currentroutid = ""; var currentroutedsnames = new List <ProjectStation>(); var pjdatalist = new List <ProjectTestData>(); var dbret = DBUtility.ExeATESqlWithRes(sql); foreach (var item in dbret) { try { var status = Convert.ToString(item[3]); var ds = Convert.ToString(item[1]); var temprouteid = Convert.ToString(item[7]); if (string.Compare(currentroutid, temprouteid) != 0) { currentroutid = temprouteid; if (pjdatalist.Count > 0) { FindErrAbbr(pjdatalist, currentroutedsnames, dsdict); foreach (var pjdata in pjdatalist) { pjdata.StoreProjectTestData(); } if (string.Compare(pjdatalist[0].ErrAbbr, "PASS", true) != 0) { if (!sndict.ContainsKey(pjdatalist[0].ModuleSerialNum)) { sndict.Add(pjdatalist[0].ModuleSerialNum, true); failurelist.Add(pjdatalist[0]); var ekey = ProjectErrorViewModels.GetUniqKey(); var pjerror = new ProjectErrorViewModels(vm.ProjectKey, ekey, pjdatalist[0].ErrAbbr, "", 1); pjerror.Reporter = "System"; pjerror.Description = ""; pjerror.AddandUpdateProjectError(); } } else { if (!sndict.ContainsKey(pjdatalist[0].ModuleSerialNum)) { sndict.Add(pjdatalist[0].ModuleSerialNum, true); } } }//end if (tempdata != null) pjdatalist.Clear(); currentroutedsnames.Clear(); currentroutedsnames.Add(new ProjectStation(ds, status)); } else //if (tempdata != null) { currentroutedsnames.Add(new ProjectStation(ds, status)); } if (dsdict.ContainsKey(ds)) { var spdatetime = Convert.ToString(item[4]); var stdtime = spdatetime.Substring(0, 4) + "-" + spdatetime.Substring(4, 2) + "-" + spdatetime.Substring(6, 2) + " " + spdatetime.Substring(8, 2) + ":" + spdatetime.Substring(10, 2) + ":" + spdatetime.Substring(12, 2); //(string pk, string did, string sn, string wtest, string mt, string err, string testtime, string station, string p) var tempdata = new ProjectTestData(vm.ProjectKey, GetUniqKey(), Convert.ToString(item[0]) , Convert.ToString(item[1]), Convert.ToString(item[2]), Convert.ToString(item[3]).ToUpper() , stdtime, Convert.ToString(item[5]), Convert.ToString(item[6])); pjdatalist.Add(tempdata); } } catch (Exception ex) { } } //end for each if (pjdatalist.Count > 0) { FindErrAbbr(pjdatalist, currentroutedsnames, dsdict); foreach (var pjdata in pjdatalist) { pjdata.StoreProjectTestData(); } if (string.Compare(pjdatalist[0].ErrAbbr, "PASS", true) != 0) { if (!sndict.ContainsKey(pjdatalist[0].ModuleSerialNum)) { sndict.Add(pjdatalist[0].ModuleSerialNum, true); failurelist.Add(pjdatalist[0]); var ekey = ProjectErrorViewModels.GetUniqKey(); var pjerror = new ProjectErrorViewModels(vm.ProjectKey, ekey, pjdatalist[0].ErrAbbr, "", 1); pjerror.Reporter = "System"; pjerror.Description = ""; pjerror.AddandUpdateProjectError(); } } else { if (!sndict.ContainsKey(pjdatalist[0].ModuleSerialNum)) { sndict.Add(pjdatalist[0].ModuleSerialNum, true); } } } //end if (tempdata != null) } // if model list > 0 ProjectTestData.ResetUpdatePJLock(vm.ProjectKey); } catch (Exception ex) { ProjectTestData.ResetUpdatePJLock(vm.ProjectKey); } }
public static void retrieveATEData() { var sql = "SELECT d.ROUTE_ID,a.MFR_SN,d.DATASET_NAME,c.FAMILY,d.STATUS,d.END_TIME,d.STATION,a.MFR_PN FROM PARTS a INNER JOIN ROUTES b ON a.OPT_INDEX = b.PART_INDEX INNER JOIN BOM_CONTEXT_ID c ON c.BOM_CONTEXT_ID = b.BOM_CONTEXT_ID INNER JOIN DATASETS d ON b.ROUTE_ID = d.ROUTE_ID WHERE(c.MODEL_ID like 'FTLX6871%' or c.MODEL_ID like 'FTLX6872%' or c.MODEL_ID like 'FTLX6672%') and d.END_TIME > '20161119080000' and d.DATASET_NAME IN('final', 'assembly', 'tune_rf', 'tune', 'temp_test_7up') ORDER BY d.END_TIME DESC"; DBUtility.ExeATESqlWithRes(sql); }