public static List <string> RetrieveAllPN(List <string> pndeslist) { var cond = ""; foreach (var pn in pndeslist) { if (!IsDigitsOnly(pn.Trim())) { if (string.IsNullOrEmpty(cond)) { cond = " c.Description like '%" + pn.Trim() + "%' "; } else { cond = cond + " or c.Description like '%" + pn.Trim() + "%' "; } } } if (string.IsNullOrEmpty(cond)) { return(new List <string>()); } else { var ret = new List <string>(); var sql = "select DISTINCT p.ProductName from insite.Product c (nolock) left join insite.ProductBase p on c.ProductBaseId = p.ProductBaseId where " + cond; var dbret = DBUtility.ExeMESSqlWithRes(sql); foreach (var item in dbret) { ret.Add(Convert.ToString(item[0])); } return(ret); } }
public static string RetrieveJOFromMESSN(string SN) { var sql = "SELECT MO.MfgOrderName FROM Insite.MfgOrder MO WITH (NOLOCK) LEFT JOIN Insite.Container C WITH (NOLOCK) ON MO.MfgOrderId = C.MfgOrderId WHERE c.containername = '<SN>'"; sql = sql.Replace("<SN>", SN); var dbret = DBUtility.ExeMESSqlWithRes(sql); var ret = string.Empty; if (dbret.Count > 0) { ret = Convert.ToString(dbret[0][0]); } return(ret); }
public static void UpdateProjectData(ProjectViewModels vm, string starttime, string endtime) { try { if (vm.StationList.Count > 0 && vm.TabList.Count > 0 && vm.PNList.Count > 0) { var failurelist = new List <ProjectTestData>(); var passlist = new List <ProjectTestData>(); bool bondinged = false; if (ProjectTestData.RetrieveLatestTimeOfLocalProject(vm.ProjectKey) != null) { bondinged = true; } var bondingeddatadict = new Dictionary <string, bool>(); if (bondinged) { bondingeddatadict = ProjectTestData.RetrieveAllDataID(vm.ProjectKey); } var sqls = RetrieveSqlFromProjectModel(vm); foreach (var s in sqls) { if (string.IsNullOrEmpty(s.Value)) { continue; } var sndict = new Dictionary <string, bool>(); var sql = s.Value.Replace("<TIMECOND>", "and TestTimeStamp > '" + starttime + "' and TestTimeStamp < '" + endtime + "'"); var dbret = DBUtility.ExeMESSqlWithRes(sql); foreach (var item in dbret) { try { var tempdata = new ProjectTestData(vm.ProjectKey, Convert.ToString(item[0]), Convert.ToString(item[1]) , s.Key, Convert.ToString(item[3]), Convert.ToString(item[4]) , Convert.ToString(item[5]), Convert.ToString(item[6]), Convert.ToString(item[7])); tempdata.JO = Convert.ToString(item[8]); if (!bondinged) { tempdata.StoreProjectTestData(); if (!sndict.ContainsKey(tempdata.ModuleSerialNum)) { sndict.Add(tempdata.ModuleSerialNum, true); if (string.Compare(tempdata.ErrAbbr, "PASS", true) != 0) { var ekey = ProjectErrorViewModels.GetUniqKey(); var pjerror = new ProjectErrorViewModels(vm.ProjectKey, ekey, tempdata.ErrAbbr, "", 1); pjerror.Reporter = "System"; pjerror.Description = ""; pjerror.AddandUpdateProjectError(); failurelist.Add(tempdata); } else { passlist.Add(tempdata); } } } else { if (!bondingeddatadict.ContainsKey(tempdata.DataID)) { bondingeddatadict.Add(tempdata.DataID, true); tempdata.StoreProjectTestData(); if (!sndict.ContainsKey(tempdata.ModuleSerialNum)) { sndict.Add(tempdata.ModuleSerialNum, true); if (string.Compare(tempdata.ErrAbbr, "PASS", true) != 0) { var ekey = ProjectErrorViewModels.GetUniqKey(); var pjerror = new ProjectErrorViewModels(vm.ProjectKey, ekey, tempdata.ErrAbbr, "", 1); pjerror.Reporter = "System"; pjerror.Description = ""; pjerror.AddandUpdateProjectError(); failurelist.Add(tempdata); } else { passlist.Add(tempdata); } } } } } catch (Exception ex) { } } } if (vm.FinishRating < 90 && DateTime.Parse(starttime) != vm.StartDate) { //use latest failure cover previous failure foreach (var item in failurelist) { IssueViewModels.CloseIssueAutomaticllyWithFailedSN(item.ProjectKey, item.ModuleSerialNum, item.WhichTest, item.TestStation, item.TestTimeStamp.ToString("yyyy-MM-dd hh:mm:ss")); } CreateSystemIssues(failurelist); } if (vm.FinishRating < 90 && DateTime.Parse(starttime) != vm.StartDate) { //use pass sn cover previous failure foreach (var item in passlist) { IssueViewModels.CloseIssueAutomaticlly(item.ProjectKey, item.ModuleSerialNum, item.WhichTest, item.TestStation, item.TestTimeStamp.ToString("yyyy-MM-dd hh:mm:ss")); } } } } catch (Exception ex) { } }
public static void StartProjectBonding(ProjectViewModels vm) { try { if (ProjectTestData.UpdatePJLockUsing(vm.ProjectKey)) { return; } if (vm.StationList.Count > 0 && vm.TabList.Count > 0 && vm.PNList.Count > 0) { var failurelist = new List <ProjectTestData>(); bool bondinged = false; if (ProjectTestData.RetrieveLatestTimeOfLocalProject(vm.ProjectKey) != null) { bondinged = true; } var bondingeddatadict = new Dictionary <string, bool>(); if (bondinged) { bondingeddatadict = ProjectTestData.RetrieveAllDataID(vm.ProjectKey); } var sqls = RetrieveSqlFromProjectModel(vm); foreach (var s in sqls) { if (string.IsNullOrEmpty(s.Value)) { continue; } var sndict = new Dictionary <string, bool>(); var sql = s.Value.Replace("<TIMECOND>", "and TestTimeStamp > '" + vm.StartDate.ToString() + "' and TestTimeStamp < '" + DateTime.Now.ToString() + "'"); var dbret = DBUtility.ExeMESSqlWithRes(sql); foreach (var item in dbret) { try { var tempdata = new ProjectTestData(vm.ProjectKey, Convert.ToString(item[0]), Convert.ToString(item[1]) , s.Key, Convert.ToString(item[3]), Convert.ToString(item[4]) , Convert.ToString(item[5]), Convert.ToString(item[6]), Convert.ToString(item[7])); tempdata.JO = Convert.ToString(item[8]); if (!bondinged) { tempdata.StoreProjectTestData(); if (!sndict.ContainsKey(tempdata.ModuleSerialNum)) { sndict.Add(tempdata.ModuleSerialNum, true); if (string.Compare(tempdata.ErrAbbr, "PASS", true) != 0) { var ekey = ProjectErrorViewModels.GetUniqKey(); var pjerror = new ProjectErrorViewModels(vm.ProjectKey, ekey, tempdata.ErrAbbr, "", 1); pjerror.Reporter = "System"; pjerror.Description = ""; pjerror.AddandUpdateProjectError(); failurelist.Add(tempdata); } } } else { if (!bondingeddatadict.ContainsKey(tempdata.DataID)) { bondingeddatadict.Add(tempdata.DataID, true); tempdata.StoreProjectTestData(); if (!sndict.ContainsKey(tempdata.ModuleSerialNum)) { sndict.Add(tempdata.ModuleSerialNum, true); if (string.Compare(tempdata.ErrAbbr, "PASS", true) != 0) { var ekey = ProjectErrorViewModels.GetUniqKey(); var pjerror = new ProjectErrorViewModels(vm.ProjectKey, ekey, tempdata.ErrAbbr, "", 1); pjerror.Reporter = "System"; pjerror.Description = ""; pjerror.AddandUpdateProjectError(); failurelist.Add(tempdata); } } } } } catch (Exception ex) { } } } //if (vm.FinishRating < 90) //{ // CreateSystemIssues(failurelist); //} } ProjectTestData.ResetUpdatePJLock(vm.ProjectKey); } catch (Exception ex) { ProjectTestData.ResetUpdatePJLock(vm.ProjectKey); } }