/// <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; DateTime now = DateTime.Now; IList<DefectComponentInfo> defectComponentInfoList =utl.IsNull< IList<DefectComponentInfo>>(session,"DefectComponentInfo"); DefectComponentBatchStatusInfo item = new DefectComponentBatchStatusInfo(); switch (TypeFrom) { case TypeFromEnum.Insert: string batchID = (string)session.GetValue("BatchID") ?? ""; string returnLine = (string)session.GetValue("ReturnLine") ?? ""; int totalQty = (int)(session.GetValue("TotalQty") ?? "0"); IList<string> vendorList = defectComponentInfoList.Select(x => x.Vendor).Distinct().ToList(); item.BatchID = batchID; item.Status = this.Status; item.PrintDate = now; item.Vendor = vendorList[0]; item.ReturnLine = returnLine; item.TotalQty = totalQty; item.Editor = this.Editor; item.Cdt = now; item.Udt = now; miscRep.InsertDataDefered<DefectComponentBatchStatus, DefectComponentBatchStatusInfo>(session.UnitOfWork,item); break; case TypeFromEnum.Update: item = utl.IsNull<DefectComponentBatchStatusInfo>(session, "DefectComponentBatchStatusInfo"); DefectComponentBatchStatusInfo condition = new DefectComponentBatchStatusInfo(); condition.BatchID = item.BatchID; item.Status = this.Status; item.Udt = now; miscRep.UpdateDataDefered<DefectComponentBatchStatus, DefectComponentBatchStatusInfo>(session.UnitOfWork, condition, item); break; } return base.DoExecute(executionContext); }
public IList<DefectComponentPrintGV_Batch> GetDefectComponentBatch(string vendor, string printDate) { string methodName = System.Reflection.MethodBase.GetCurrentMethod().Name; logger.DebugFormat("BEGIN: {0}()", methodName); IList<DefectComponentPrintGV_Batch> ret = new List<DefectComponentPrintGV_Batch>(); try { DefectComponentBatchStatusInfo item = new DefectComponentBatchStatusInfo(); item.Vendor = vendor; DateTime startDate,endDate; IList<DefectComponentBatchStatusInfo> defectBatchList = miscRep.GetData<DefectComponentBatchStatus, DefectComponentBatchStatusInfo>(item); if (!string.IsNullOrEmpty(printDate)) { startDate = DateTime.Parse(printDate); endDate = DateTime.Parse(printDate + " 23:59:59"); defectBatchList = defectBatchList.Where(m => m.PrintDate >= startDate && m.PrintDate <= endDate).ToList(); } IList<ConstValueInfo> constValueList = miscRep.GetData<ConstValue, ConstValueInfo>(new ConstValueInfo { type = "DCBatchStatus" }); ret = (from a in defectBatchList join b in constValueList on a.Status equals b.name select new DefectComponentPrintGV_Batch { BatchID = a.BatchID, PrintDate = a.PrintDate, Status = a.Status + "-" + b.value, ReturnLine = a.ReturnLine, TotalQty = a.TotalQty }).ToList(); return ret; } 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); } }