/// <summary> /// /// </summary> /// <param name="executionContext"></param> /// <returns></returns> protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext) { IMiscRepository miscRep = RepositoryFactory.GetInstance().GetRepository<IMiscRepository>(); ActivityCommonImpl utl = ActivityCommonImpl.Instance; Session session = CurrentSession; string status=this.Status; if (string.IsNullOrEmpty(this.Status)) { status = utl.IsNullOrEmpty<string>(session, "Status"); } string comment = (string)session.GetValue("Comment"); IList<DefectComponentInfo> defectComponentInfoList = utl.IsNull< IList<DefectComponentInfo>>(session,"DefectComponentInfo"); DateTime now = DateTime.Now; foreach (DefectComponentInfo item in defectComponentInfoList) { item.Status = status; if (this.IsResetBatchID) { item.BatchID = ""; item.ReturnLine = ""; } item.Comment = comment; item.Editor = this.Editor; item.Udt = now; DefectComponentInfo condition = new DefectComponentInfo(); condition.ID = item.ID; miscRep.UpdateDataByIDDefered<DefectComponent, DefectComponentInfo>(session.UnitOfWork,condition, item); } return base.DoExecute(executionContext); }
/// <summary> /// /// </summary> /// <param name="executionContext"></param> /// <returns></returns> protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext) { IMiscRepository miscRep = RepositoryFactory.GetInstance().GetRepository<IMiscRepository>(); Session session = CurrentSession; ActivityCommonImpl utl = ActivityCommonImpl.Instance; string batchID = utl.IsNullOrEmpty<string>(session, "BatchID"); string returnLine = utl.IsNullOrEmpty<string>(session, "ReturnLine"); IList<DefectComponentInfo> defectComponentInfoList = utl.IsNull<IList<DefectComponentInfo>>(session,"DefectComponentInfo"); DateTime now = DateTime.Now; foreach (DefectComponentInfo item in defectComponentInfoList) { item.BatchID = batchID; item.ReturnLine = returnLine; item.Udt = now; item.Editor = this.Editor; DefectComponentInfo condition = new DefectComponentInfo(); condition.ID = item.ID; miscRep.UpdateDataByIDDefered<DefectComponent, DefectComponentInfo>(session.UnitOfWork, condition, item); } return base.DoExecute(executionContext); }
public IList<DefectComponentPrintGV1> GetDefectComponent_RePrint(string batchID) { string methodName = System.Reflection.MethodBase.GetCurrentMethod().Name; logger.DebugFormat("BEGIN: {0}()", methodName); try { DefectComponentInfo items = new DefectComponentInfo(); items.BatchID = batchID; IList<DefectComponentInfo> defectList = miscRep.GetData<DefectComponent, DefectComponentInfo>(items); IList<DefectComponentPrintGV1> gvList = defectList .GroupBy(item => new { Family = item.Family, IECPn = item.IECPn, PartType = item.PartType, Vendor = item.Vendor, DefectCode = item.DefectCode, DefectDesc = item.DefectDescr }) .Select(group => new DefectComponentPrintGV1 { ReturnType = "Z45", Family = group.Key.Family, IECPn = group.Key.IECPn, PartType = group.Key.PartType, Vendor = group.Key.Vendor, NPQty = group.Count(), DefectCode = group.Key.DefectCode, DefectDesc = group.Key.DefectDesc }) .OrderBy(item => item.Family).ThenBy(item => item.IECPn).ThenBy(item => item.Vendor).ThenBy(item => item.DefectCode).ToList(); return gvList; } catch (FisException e) { logger.Error(e.mErrmsg, e); throw new Exception(e.mErrmsg); } catch (Exception e) { logger.Error(e.Message, e); throw; } finally { logger.DebugFormat("END: {0}()", methodName); } }
void CreateDefectComponentInfo(DefectComponentInfo v, RepairInfo ri, IProduct prod, IProductPart pp, string OldPart, string PartType, string BomNodeType, string IECPn, string CheckItemType) { v.RepairID = int.Parse(ri.repairID); v.BatchID = ""; //remark v.Customer = this.Customer; v.Model = prod.Model; v.Family = prod.Family == null ? "" : prod.Family; v.DefectCode = ri.defectCodeID; v.DefectDescr = ri.defectCodeDesc == null ? "" : ri.defectCodeDesc; v.ReturnLine = ""; v.PartSn = ri.oldPartSno; v.PartNo = OldPart; v.PartType = PartType; v.BomNodeType = BomNodeType; v.IECPn = IECPn; v.CustomerPn = ""; v.Vendor = ""; v.CheckItemType = CheckItemType; v.Comment = ""; v.Status = this.Status; v.Editor = this.Editor; v.Cdt = DateTime.Now; v.Udt = DateTime.Now; }
/// <summary> /// CheckAndLockSelectPallet /// </summary> /// <param name="executionContext"></param> /// <returns></returns> protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext) { Session session = CurrentSession; ActivityCommonImpl utl = ActivityCommonImpl.Instance; IMiscRepository miscRep = RepositoryFactory.GetInstance().GetRepository<IMiscRepository>(); string[] AllowStatuses = AllowStatus.Split('~'); IProduct prod = utl.IsNull<IProduct>(session, Session.SessionKeys.Product); RepairInfo repairInfo = session.GetValue("RepairInfo") as RepairInfo; string OldPartSno = repairInfo.oldPartSno; int repairID = int.Parse(repairInfo.repairID); int defectId = int.Parse((string)session.GetValue("DefectId")); string oldPart = prod.Repairs.Where(x => x.ID == repairID).FirstOrDefault().Defects.Where(y => y.ID == defectId).FirstOrDefault().OldPart; oldPart = (null == oldPart) ? "" : oldPart; string partType = "", bomNodeType = ""; IList<IProductPart> lstProductPart = prod.ProductParts.Where(x => x.PartID == oldPart).ToList(); if (null != lstProductPart && lstProductPart.Count > 0) { partType = (null == lstProductPart[0].PartType) ? "" : lstProductPart[0].PartType; bomNodeType = (null == lstProductPart[0].BomNodeType) ? "" : lstProductPart[0].BomNodeType; } IPartRepository partRep = RepositoryFactory.GetInstance().GetRepository<IPartRepository, IPart>(); string IECPn = partRep.GetPartInfoValue(oldPart, "RDESC"); IECPn = (null == IECPn) ? "" : IECPn; DefectComponentInfo condQuery = new DefectComponentInfo(); condQuery.PartSn = OldPartSno; IList<string> lstPartSN = new List<string>(); lstPartSN.Add(OldPartSno); IList<DefectComponentInfo> lstDefectComponent = miscRep.GetDataByList<IMES.Infrastructure.Repository._Metas.DefectComponent, DefectComponentInfo>(condQuery, "PartSn", lstPartSN); IProductPart pp = null; // 若@OldPartSno與@OldPart 不同(表示有唯一的PartSn): // 才進行以下退料追蹤程序 if (OldPartSno == oldPart) return base.DoExecute(executionContext); if (null != lstDefectComponent) lstDefectComponent = lstDefectComponent.Where(x => x.RepairID == repairID).ToList(); DefectComponentInfo dc = null; if (null == lstDefectComponent || lstDefectComponent.Count == 0) { dc = new DefectComponentInfo(); CreateDefectComponentInfo(dc, repairInfo, prod, pp, oldPart, partType, bomNodeType, IECPn, repairInfo.partType); dc.Cdt = DateTime.Now; miscRep.InsertDefectComponentAndLogDefered(session.UnitOfWork, dc, this.LogActionName, ""); } else { dc = lstDefectComponent[0]; if (AllowStatuses.Contains(dc.Status)) { CreateDefectComponentInfo(dc, repairInfo, prod, pp, oldPart, partType, bomNodeType, IECPn, repairInfo.partType); miscRep.InsertDataWithIDDefered<IMES.Infrastructure.Repository._Metas.DefectComponentLog, DefectComponentLogInfo>(session.UnitOfWork, new DefectComponentLogInfo { ActionName = this.LogActionName, Remark = "", ComponentID = dc.ID, BatchID = "", Customer = this.Customer, Model = prod.Model, Family = prod.Family == null ? "" : prod.Family, DefectCode = repairInfo.defectCodeID, DefectDescr = repairInfo.defectCodeDesc, ReturnLine = "", PartSn = repairInfo.oldPartSno, RepairID = repairID, Comment = "", Status = this.Status, Editor = this.Editor, Cdt = DateTime.Now } ); DefectComponentInfo condUpd = new DefectComponentInfo(); condUpd.ID = dc.ID; miscRep.UpdateDataByIDDefered<IMES.Infrastructure.Repository._Metas.DefectComponent, DefectComponentInfo>(session.UnitOfWork, condUpd, dc); } else { // 此機器:@ProductID換下的舊料:@OldPartSno 已進入退料覆判流程,不可打印! throw new FisException("CQCHK5018", new List<string> { prod.ProId, OldPartSno }); } } return base.DoExecute(executionContext); }
private string GetDefectComponentID(IProduct prod, RepairInfo repairInfo) { IMiscRepository miscRep = RepositoryFactory.GetInstance().GetRepository<IMiscRepository>(); string OldPartSno = repairInfo.oldPartSno; int RepadirID = int.Parse(repairInfo.repairID); IList<string> lstProdPartSN = prod.ProductParts.Select(x => x.PartSn).ToList(); //IProductPart pp = null; DefectComponentInfo condQuery = new DefectComponentInfo(); condQuery.PartSn = OldPartSno; IList<string> lstPartSN = new List<string>(); lstPartSN.Add(OldPartSno); IList<DefectComponentInfo> lstDefectComponent = miscRep.GetDataByList<IMES.Infrastructure.Repository._Metas.DefectComponent, DefectComponentInfo>(condQuery, "PartSn", lstPartSN); DefectComponentInfo dc = null; if (null != lstDefectComponent) lstDefectComponent = lstDefectComponent.Where(x => x.RepairID == RepadirID).ToList(); if (null != lstDefectComponent && lstDefectComponent.Count > 0) { dc = lstDefectComponent[0]; return dc.ID.ToString(); } return ""; }