/// <summary> /// 將新物件加入 tblAlarm EntitySet 的方法已被取代。請考慮改為使用關聯的 ObjectSet<T> 屬性的 .Add 方法。 /// </summary> public void AddTotblAlarm(tblAlarm tblAlarm) { base.AddObject("tblAlarm", tblAlarm); }
public void ExportCommand(string PcName,string cmdType, string xml) { // throw new NotImplementedException(); try { if (!dictClientCallBacks.ContainsKey(PcName+"-TESTER")) RegisterFromRemoting(PcName, "TESTER"); System.IO.MemoryStream ms = new System.IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(xml)); if (cmdType.Contains("VerifyNoteData")) { System.Xml.Serialization.XmlSerializer sr = new System.Xml.Serialization.XmlSerializer(typeof(VerifyNoteData)); VerifyNoteData data = sr.Deserialize(ms) as VerifyNoteData; InsertIntoVerifyNote(data); if (data.TestVerify.ToUpper().Trim() == "TEST" || data.TestVerify.ToUpper().Trim().Contains("VERIFY")) { string lotid = data.WaferID.Split(new char[] { '_' })[0]; double yield = (double)data.Pass / (data.Pass+data.Fail)*100.0; if (!dictClientCallBacks.ContainsKey(data.RCP.ToUpper() + "-TESTER")) return; RegisterData inf = dictClientCallBacks[data.RCP.ToUpper() + "-TESTER"]; if (inf.info.lot_id == null || inf.info.lot_id == "") return; if (inf.info.lot_id!=lotid) return; if (inf.info.Status != "Product" && inf.info.Status != "Verify") return; try { NotifyAllYieldChanged(data.RCP, yield, lotid); } catch (Exception ex1) { Console.WriteLine(ex1.Message); } if( dictClientCallBacks.ContainsKey(data.RCP.ToUpper()+"-TESTER") ) { // RegisterData inf = dictClientCallBacks[data.RCP.ToUpper() + "-TESTER"]; inf.info.yield = yield; // dictClientCallBacks[data.RCP.ToUpper() + "-TESTER"].info.yield = yield; } } // NotifyAllStatusChange(PcName, cmdType); //var q = dictClientCallBacks.Where(n => n.Value.DeviceType == "CONSOLE"); //foreach (KeyValuePair<string, RegisterData> pair in q.ToArray()) //{ // try // { // pair.Value.Callback.NotifyClientExported(PcName, cmdType); // } // catch // { ;} //} } else if (cmdType.Contains("ReportProgress")) { System.Xml.Serialization.XmlSerializer sr = new System.Xml.Serialization.XmlSerializer(typeof(ReportProgressData)); ReportProgressData data = sr.Deserialize(ms) as ReportProgressData; AmidaEntities db = new AmidaEntities(); tblEQ eq = (from n in db.tblEQ where n.eqi_id == data.eq_id select n).FirstOrDefault<tblEQ>(); if (eq == null) return; eq.tested_num_chip = data.tested_num_chip; eq.tested_num_wafer = data.tested_num_wafer; eq.total_num_chip = data.total_num_chip; // eq.total_num_wafer = data.total_num_wafer; if (eq.status == "Product") { if (data.tested_num_chip != 0) eq.expected_remain_time = (int)data.timestamp.Subtract(System.Convert.ToDateTime(eq.start_time)).TotalMinutes * (data.total_num_chip - data.tested_num_chip) / data.tested_num_chip; else eq.expected_remain_time = -1; } else if (eq.status == "Verify") { string maskID = data.current_test_wafer_id.Split(new char[] { '-' })[0]; // int totalVerifyMin = 0; tblVerifyTimeRef timeref = db.tblVerifyTimeRef.Where(n => n.MaskID == maskID).FirstOrDefault(); if (timeref == null) eq.expected_remain_time = -1; else { eq.expected_remain_time = timeref.Minutes * (data.total_num_wafer-data.tested_num_wafer); } } else eq.expected_remain_time = -1; db.SaveChanges(); db.AcceptAllChanges(); if (dictClientCallBacks.ContainsKey(data.eq_id.ToUpper()+"-TESTER")) { RegisterDeviceInfo info = (dictClientCallBacks[data.eq_id.ToUpper() + "-TESTER"] as RegisterData).info; info.tested_num_chip = data.tested_num_chip; info.tested_num_wafer = data.tested_num_wafer; info.total_num_chip = data.total_num_chip; info.total_num_wafer = data.total_num_wafer; info.TimeRemain = (double)eq.expected_remain_time; //min info.Status = data.status; info.CurrentWaferId = data.current_test_wafer_id; if (info.Status.Trim().ToUpper() == "PRODUCT" && info.total_num_chip != 0) { info.Progress = (double)info.tested_num_chip*100 / info.total_num_chip ; } else if (info.Status.Trim().ToUpper() == "VERIFY" && info.total_num_wafer!=0 ) { info.Progress = (double)info.tested_num_wafer*100 / info.total_num_wafer; } else info.Progress = 0; if (info.Progress > 100) info.Progress = 100; Console.WriteLine(info.PcName + ":Remain time " + info.TimeRemain); NotifyAllStatusChange(PcName,info); } } else if (cmdType.Contains("ReportStatusChanged")) { System.Xml.Serialization.XmlSerializer sr = new System.Xml.Serialization.XmlSerializer(typeof(ReportStatusChangedData)); ReportStatusChangedData data = sr.Deserialize(ms) as ReportStatusChangedData; AmidaEntities db = new AmidaEntities(); tblEQ eq = (from n in db.tblEQ where n.eqi_id == data.eq_id select n).FirstOrDefault<tblEQ>(); if (eq == null) return; tblEQHistory eqhist = null; if (eq.current_identify != null) eqhist = (from n in db.tblEQHistory where n.identify == eq.current_identify select n).FirstOrDefault<tblEQHistory>(); if (eqhist != null) { if (data.eq_status != "Idle" && eqhist.status == "Idle" || data.eq_status == "Idle" && (eqhist.status != data.eq_status || eqhist.sub_status!=data.sub_status ) ) //狀態不同才寫 { eqhist.stop_time = data.start_time; eqhist.IsFinish = true; eqhist.wafer_id_out = data.wafer_id; eqhist.over_drive_out = data.over_drive; if (data.eq_status == "Idle") eqhist.tested_num_wafer = data.total_num_wafer; } else { eqhist.stop_time = data.start_time; } } tblEQHistory newHist = new tblEQHistory() { eq_id = data.eq_id, lot_id = data.lot_id, probe_card_id = data.probe_card_id, recipe = data.recipe, start_time = data.start_time, total_num_wafer = data.total_num_wafer, status = data.eq_status, IsFinish = false, @operator = data.eq_operator, sub_status=data.sub_status, over_drive_in=data.over_drive, wafer_id_in=data.wafer_id }; db.tblEQHistory.AddObject(newHist); db.SaveChanges(); eq.lot_id = data.lot_id; eq.current_identify = newHist.identify; eq.probe_card_id = data.probe_card_id; eq.status = data.eq_status; eq.recipe = data.recipe; eq.start_time = data.start_time; eq.total_num_wafer = data.total_num_wafer; eq.@operator = data.eq_operator; eq.sub_status=data.sub_status; eq.over_drive=data.over_drive; eq.wafer_id = data.wafer_id; // data.Wafer_ID=data.Wafer_ID; db.SaveChanges(); db.AcceptAllChanges(); if (dictClientCallBacks.ContainsKey(data.eq_id.ToUpper() +"-TESTER")) { RegisterDeviceInfo info = (dictClientCallBacks[data.eq_id.ToUpper() + "-TESTER"] as RegisterData).info; info.tested_num_chip =0; info.tested_num_wafer =0; info.total_num_chip = 0; info.total_num_wafer = data.total_num_wafer; //if (info.Status == "Verify") //{ // string maskID = eq.lot_id.Split(new char[] { '-' })[0]; // //int totalVerifyMin = 0; // tblVerifyTimeRef timeref = db.tblVerifyTimeRef.Where(n => n.MaskID == maskID).FirstOrDefault(); // if (timeref == null) // eq.expected_remain_time = -1; // else // { // eq.expected_remain_time = timeref.Minutes; // } //} //else info.TimeRemain = -1; //min info.Status = data.eq_status; info.SubStatus = data.sub_status; // if(info.Status // info.lot_id = data.lot_id; info.CurrentWaferId =""; info.lot_id=data.lot_id; info.StatusBeginTime = data.start_time; // info.TimeRemain = -1; if(info.Status !="Product" && info.Status!="Verify") info.yield=0; //if (info.Status == "Product" && info.total_num_chip != 0) //{ // info.Progress = info.tested_num_chip / info.total_num_chip * 100; //} //else info.Progress = 0; info.ProbeCardId = data.probe_card_id; //if(data.eq_status=="Idle") //if idle force warning messgae state finish 2013/1/17 // info.WarningMessage=""; NotifyAllStatusChange(PcName, info); } } else if (cmdType.Contains("WarningMessage")) { System.Xml.Serialization.XmlSerializer sr = new System.Xml.Serialization.XmlSerializer(typeof(ReportWarningData)); ReportWarningData data = sr.Deserialize(ms) as ReportWarningData; AmidaEntities db = new AmidaEntities(); if (!data.isfinished) { tblAlarm alarm = new tblAlarm() { eq_id = data.eq_id, start_time = data.timestamp, warning_message = data.warning_message, warning_type = data.warning_type, eq_operator=data.eq_operator, probe_card_id=data.probe_card_id, WaferID=data.WaferID }; db.tblAlarm.AddObject(alarm); db.SaveChanges(); db.AcceptAllChanges(); tblEQ eq = (from n in db.tblEQ where n.eqi_id == data.eq_id select n).FirstOrDefault(); if (eq != null) { eq.IsWarnig = "Y"; eq.current_warning_identify = alarm.identify; } db.SaveChanges(); db.AcceptAllChanges(); } else { tblEQ eq = (from n in db.tblEQ where n.eqi_id == data.eq_id select n).FirstOrDefault(); if (eq != null) { tblAlarm alarm = db.tblAlarm.Where<tblAlarm>(n => n.identify == eq.current_warning_identify).FirstOrDefault(); if (alarm != null) { eq.IsWarnig = "N"; alarm.end_time = data.timestamp; db.SaveChanges(); db.AcceptAllChanges(); } } } if (dictClientCallBacks.ContainsKey(data.eq_id.ToUpper() + "-TESTER")) { RegisterDeviceInfo info = (dictClientCallBacks[data.eq_id.ToUpper() + "-TESTER"] as RegisterData).info; if (data.isfinished) info.WarningMessage = ""; else { info.WarningMessage = data.warning_message; info.WarningBeginTime =data.timestamp; } info.WarningType = data.warning_type; NotifyAllStatusChange(PcName, info); } } NotifyAllExportedCommand(PcName, cmdType); // } catch (Exception ex) { Console.WriteLine(PcName+":"+ ex.Message + "," + ex.StackTrace+",---"+ex.InnerException.Message); EventLog mylog = new EventLog() { Source = "AmidaService" }; try { mylog.WriteEntry(ex.Message + "," + ex.StackTrace); } catch { ;} throw ex; // throw new FaultException<string>(ex.Message + "," + ex.StackTrace); } }
/// <summary> /// 建立新 tblAlarm 物件。 /// </summary> /// <param name="identify">identify 屬性的初始值。</param> /// <param name="eq_id">eq_id 屬性的初始值。</param> public static tblAlarm CreatetblAlarm(global::System.Int32 identify, global::System.String eq_id) { tblAlarm tblAlarm = new tblAlarm(); tblAlarm.identify = identify; tblAlarm.eq_id = eq_id; return tblAlarm; }