public ArrayList ReprintLabel(string customerSN, string reason, IList<PrintItem> printItems, string line, string editor, string station, string customer) { logger.Debug("(PDPALabel01)ReprintLabel start, customerSN:" + customerSN + "editor:" + editor + "station:" + station + "customer:" + customer); try { var currentProduct = CommonImpl.GetProductByInput(customerSN, CommonImpl.InputTypeEnum.CustSN); string sessionKey = currentProduct.ProId; var repository = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>(); //IList<ProductLog> logList = repository.GetProductLogs("91", 1, line); IList<ProductLog> logList = repository.GetProductLogs(currentProduct.ProId,"91"); if (logList.Count == 0) { FisException ex; List<string> erpara = new List<string>(); erpara.Add(currentProduct.ProId); ex = new FisException("CHK860", erpara);//此Product没有打印过,无需重印 throw ex; } Session currentSession = SessionManager.GetInstance.GetSession(sessionKey, SessionType); if (currentSession == null) { currentSession = new Session(sessionKey, SessionType, editor, station, line, customer); Dictionary<string, object> wfArguments = new Dictionary<string, object>(); wfArguments.Add("Key", sessionKey); wfArguments.Add("Station", station); wfArguments.Add("CurrentFlowSession", currentSession); wfArguments.Add("Editor", editor); wfArguments.Add("PdLine", line); wfArguments.Add("Customer", customer); wfArguments.Add("SessionType", SessionType); string wfName, rlName; RouteManagementUtils.GetWorkflow(station, "ReprintPDPALabel01.xoml", null, out wfName, out rlName); WorkflowInstance instance = WorkflowRuntimeManager.getInstance.CreateXomlFisWorkflow(wfName, rlName, wfArguments); currentSession.AddValue(Session.SessionKeys.Product, sessionKey); currentSession.AddValue(Session.SessionKeys.IsComplete, false); currentSession.SetInstance(instance); currentSession.AddValue(Session.SessionKeys.PrintItems, printItems); if (!SessionManager.GetInstance.AddSession(currentSession)) { currentSession.WorkflowInstance.Terminate("Session:" + sessionKey + " Exists."); FisException ex; List<string> erpara = new List<string>(); erpara.Add(sessionKey); ex = new FisException("CHK020", erpara); throw ex; } currentSession.WorkflowInstance.Start(); currentSession.SetHostWaitOne(); } else { FisException ex; List<string> erpara = new List<string>(); erpara.Add(sessionKey); ex = new FisException("CHK020", erpara); throw ex; } if (currentSession.Exception != null) { if (currentSession.GetValue(Session.SessionKeys.WFTerminated) != null) { currentSession.ResumeWorkFlow(); } throw currentSession.Exception; } //=============================================================================== //Get infomation ArrayList retList = new ArrayList(); Product curProduct = (Product)currentSession.GetValue(Session.SessionKeys.Product); IList<PrintItem> returnList = (IList<PrintItem>)currentSession.GetValue(Session.SessionKeys.PrintItems); retList.Add(returnList); string wlabel = (string)currentSession.GetValue("WLabel"); string clabel = (string)currentSession.GetValue("LanguageLabel"); string cmessage = (string)currentSession.GetValue("LanguageMessage"); string llabel = (string)currentSession.GetValue("LANOMLabel"); string[] tmpList = {"China label", "Taiwan Label", "ICASA Label L", "GOST Lable", "KC Label", "WWAN ID Label", "Wimax Label", "LA NOM Label"}; IReprintLogRepository printLogRep = RepositoryFactory.GetInstance().GetRepository<IReprintLogRepository, ReprintLog>(); IUnitOfWork uof = new UnitOfWork(); for (var i = 0; i < tmpList.Length; i++) { if (i <= 4) { if (tmpList[i] != clabel) { continue; } } else if (i <= 6) { if (tmpList[i] != wlabel) { continue; } } else { if (tmpList[i] != llabel) { continue; } } var log = new ReprintLog { LabelName = tmpList[i], BegNo = curProduct.CUSTSN, EndNo = curProduct.CUSTSN, Descr = tmpList[i], Reason = reason, Editor = editor }; printLogRep.Add(log, uof); } uof.Commit(); retList.Add(wlabel); retList.Add(clabel); retList.Add(cmessage); retList.Add(llabel); //=============================================================================== return retList; } catch (Exception) { throw; } finally { logger.Debug("(PDPALabel01)ReprintLabel end, customerSN:" + customerSN); } }
public ArrayList ReprintCartonLabel(string inputSN, string reason, string line, string editor, string station, string customer, IList<PrintItem> printItems) { logger.Debug("(CombinPoInCarton)ReprintLabel Start," + " [custSN]:" + inputSN + " [line]:" + line + " [editor]:" + editor + " [station]:" + station + " [customer]:" + customer); ArrayList retList = new ArrayList(); try { //var productRep = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IMES.FisObject.FA.Product.IProduct>(); //IDeliveryRepository deliveryRep = RepositoryFactory.GetInstance().GetRepository<IDeliveryRepository, Delivery>(); IProduct curProduct; curProduct = productRep.FindOneProductWithProductIDOrCustSNOrCarton(inputSN); if (curProduct == null) { if (inputSN.Substring(0, 2) == "CN" || inputSN.Substring(0, 2) == "5C") { List<string> errpara = new List<string>(); errpara.Add(inputSN); throw new FisException("PAK042", errpara); } else if (inputSN.Substring(0, 1) == "C") { List<string> errpara = new List<string>(); errpara.Add(inputSN); throw new FisException("CHK801", errpara); } else { List<string> errpara = new List<string>(); errpara.Add(inputSN); throw new FisException("SFC002", errpara); } } //d. 如果Product 尚未结合的Carton,则报告错误:“该Product 尚未Combine Carton,不能Reprint Carton Label!” if (string.IsNullOrEmpty(curProduct.CartonSN)) { List<string> errpara = new List<string>(); errpara.Add(curProduct.ProId); throw new FisException("PAK138", errpara); } //e. 如果输入的[Carton No] 在数据库(CartonStatus.CartonNo) 中不存在,则报告错误:“此Carton 不存在!” carton.ICartonSSCCRepository cartRep = RepositoryFactory.GetInstance().GetRepository<carton.ICartonSSCCRepository, IMES.FisObject.PAK.CartonSSCC.CartonSSCC>(); CartonStatusInfo carConf = new CartonStatusInfo(); carConf.cartonNo = curProduct.CartonSN; IList<CartonStatusInfo> carList = cartRep.GetCartonStatusInfo(carConf); if (carList.Count == 0) { List<string> errpara = new List<string>(); errpara.Add(curProduct.ProId); throw new FisException("PAK139", errpara);//此Carton 不存在! } //如果Product 非Frame Or TRO Or BaseModel Or SLICE 的话,需要报告错误:“Product is not Frame Or TRO Or BaseModel Or SLICE” //SELECT @PN = Value FROM ModelInfo NOLOCk WHERE Model = @Model AND Name = 'PN' IModelRepository modelRep = RepositoryFactory.GetInstance().GetRepository<IModelRepository, Model>(); string pn = ""; string noCarton = ""; string modelstr = curProduct.Model; Model curModel = modelRep.Find(curProduct.Model); pn = curModel.GetAttribute("PN"); noCarton = curModel.GetAttribute("NoCarton"); bool labelFlag = false; if (!string.IsNullOrEmpty(pn) && pn.Length >= 6) { if (pn.Substring(5, 1) == "U" || pn.Substring(5, 1) == "E" || curProduct.Model.Substring(0, 3) == "156" || curProduct.Model.Substring(0, 3) == "146" || curProduct.Model.Substring(0, 3) == "157" || curProduct.Model.Substring(0, 3) == "158" || curProduct.Model.Substring(0, 2) == "PO" || curProduct.Model.Substring(0, 2) == "2P" || curProduct.Model.Substring(0, 3) == "172" || curProduct.Model.Substring(0, 2) == "BC") { labelFlag = true; } } if (!labelFlag) { FisException fe = new FisException("PAK133", new string[] { }); //Product is not Frame Or TRO Or BaseModel Or SLICE throw fe; } string sessionKey = curProduct.ProId; var repository = RepositoryFactory.GetInstance().GetRepository<IMES.FisObject.FA.Product.IProductRepository, IMES.FisObject.FA.Product.IProduct>(); Session currentSession = SessionManager.GetInstance.GetSession(sessionKey, SessionType); if (currentSession == null) { currentSession = new Session(sessionKey, SessionType, editor, station, line, customer); Dictionary<string, object> wfArguments = new Dictionary<string, object>(); wfArguments.Add("Key", sessionKey); wfArguments.Add("Station", station); wfArguments.Add("CurrentFlowSession", currentSession); wfArguments.Add("Editor", editor); wfArguments.Add("PdLine", line); wfArguments.Add("Customer", customer); wfArguments.Add("SessionType", SessionType); WorkflowInstance instance = WorkflowRuntimeManager.getInstance.CreateXomlFisWorkflow("ReprintCombinPoInCarton.xoml", "", wfArguments); currentSession.AddValue(Session.SessionKeys.PrintLogBegNo, curProduct.ProId); currentSession.AddValue(Session.SessionKeys.PrintLogEndNo, curProduct.ProId); currentSession.AddValue(Session.SessionKeys.PrintLogName, curProduct.ProId); currentSession.AddValue(Session.SessionKeys.PrintLogDescr, "CombinInCarton"); currentSession.AddValue(Session.SessionKeys.Reason, reason); currentSession.AddValue(Session.SessionKeys.PrintItems, printItems); currentSession.SetInstance(instance); if (!SessionManager.GetInstance.AddSession(currentSession)) { currentSession.WorkflowInstance.Terminate("Session:" + sessionKey + " Exists."); FisException ex; List<string> erpara = new List<string>(); erpara.Add(sessionKey); ex = new FisException("CHK020", erpara); throw ex; } currentSession.WorkflowInstance.Start(); currentSession.SetHostWaitOne(); } else { FisException ex; List<string> erpara = new List<string>(); erpara.Add(sessionKey); ex = new FisException("CHK020", erpara); throw ex; } if (currentSession.Exception != null) { if (currentSession.GetValue(Session.SessionKeys.WFTerminated) != null) { currentSession.ResumeWorkFlow(); } throw currentSession.Exception; } IList<PrintItem> printList = (IList<PrintItem>)currentSession.GetValue(Session.SessionKeys.PrintItems); Delivery curDev = deliveryRep.Find(curProduct.DeliveryNo); string cQtyStr = (string)curDev.GetExtendedProperty("CQty"); int cQty = 0; if (string.IsNullOrEmpty(cQtyStr)) { cQty = 5; } else { decimal tmp = Convert.ToDecimal(cQtyStr); cQty = Convert.ToInt32(tmp); } // pdf string flagstr = (string)curDev.GetExtendedProperty("Flag"); string templatename = ""; if (flagstr == "N") { //HP_EDI.dbo.op_TemplateCheck '"&DN&"','Box Ship Label' templatename = cartRep.GetTemplateNameViaCallOpTemplateCheck(curProduct.DeliveryNo, "Box Ship Label"); //Not found template of this DN: "&DN if (templatename == "ERROR") { FisException ex; List<string> erpara = new List<string>(); erpara.Add(curProduct.DeliveryNo); ex = new FisException("PAK132", erpara);//Not found template of this DN: &DN throw ex; } } var log = new ReprintLog { LabelName = currentSession.GetValue(Session.SessionKeys.PrintLogName).ToString(), BegNo = currentSession.GetValue(Session.SessionKeys.PrintLogBegNo).ToString(), EndNo = currentSession.GetValue(Session.SessionKeys.PrintLogEndNo).ToString(), Descr = (string)currentSession.GetValue(Session.SessionKeys.PrintLogDescr), Reason = (string)currentSession.GetValue(Session.SessionKeys.Reason), Editor = editor }; //当Delivery 的CQty 属性=1,但Delivery.Model 的NoCarton 属性(Model.InfoType = ‘NoCarton’)不存在,或者存在但<>’Y’ 时,也需要列印Carton Label string printflag = "N"; if (cQty > 1 || (cQty ==1 && noCarton!="Y")) { printflag = "Y"; IUnitOfWork uof = new UnitOfWork(); var rep = RepositoryFactory.GetInstance().GetRepository<IReprintLogRepository, ReprintLog>(); rep.Add(log, uof); uof.Commit(); } retList.Add(printList); retList.Add(flagstr); retList.Add(0); retList.Add(curProduct.CartonSN); retList.Add(curProduct.DeliveryNo); retList.Add(curProduct.CUSTSN); retList.Add(templatename); retList.Add(cQty); retList.Add(printflag); return retList; } catch (FisException e) { logger.Error(e.mErrmsg); throw e; } catch (Exception e) { logger.Error(e.Message); throw new SystemException(e.Message); } finally { logger.Debug("(CombinPoInCarton)ReprintLabel End," + " [custSN]:" + inputSN + " [line]:" + line + " [editor]:" + editor + " [station]:" + station + " [customer]:" + customer); } }
/// <summary> /// 执行逻辑 /// </summary> /// <param name="executionContext"></param> /// <returns></returns> protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext) { IList<PrintItem> resultPrintItemList = new List<PrintItem>(); Session session =CurrentSession; var printItemList = (IList<PrintItem>)session.GetValue(Session.SessionKeys.PrintItems); ILabelTypeRepository lblTypeRepository = RepositoryFactory.GetInstance().GetRepository<ILabelTypeRepository, LabelType>(); PrintUtility resolvePrintTemplate = null; if (printItemList != null && printItemList.Count > 0) //無LabelType時不做檢查及報錯 { Nullable<bool> hasExceptStation = null; for (int i = 0; i < printItemList.Count; i++) { PrintItem tempPrintItem = printItemList[i]; #region decide template logical if (tempPrintItem.PrintMode == Bat) { PrintTemplate newTemplate = lblTypeRepository.GetPrintTemplate(tempPrintItem.TemplateName); if (newTemplate != null) { //if (IsReprint) //{ // tempPrintItem.Piece = 1; //} //else //{ tempPrintItem.Piece = newTemplate.Piece; //} tempPrintItem.SpName = newTemplate.SpName; resultPrintItemList.Add(tempPrintItem); } else if (NotExistException) { //var logger = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); //FisException ex; //List<string> erpara = new List<string>(); //erpara.Add(tempPrintItem.TemplateName); //ex = new FisException("CHK064", erpara); //logger.Error(ex.mErrmsg, ex); //throw ex; if (!hasExceptStation.HasValue) { hasExceptStation = checkExceptStation(); } if (!hasExceptStation.Value) { throw new FisException("CHK064", new string[] { tempPrintItem.LabelType + "/" + tempPrintItem.TemplateName }); } } } else if (tempPrintItem.PrintMode == Template) { if (resolvePrintTemplate == null) { resolvePrintTemplate = new PrintUtility(session, ModelName(session), MONO(session), Dn(session), PartNo(session), Customer); } PrintTemplate newTemplate = resolvePrintTemplate.GetPrintTemplate(tempPrintItem.LabelType, tempPrintItem.RuleMode, tempPrintItem.PrintMode); //PrintTemplate newTemplate = lblTypeRepository.GetPrintTemplate(tempPrintItem.LabelType, ModelName, MONO, Dn, PartNo, tempPrintItem.RuleMode,Customer); if (newTemplate != null) { //if (IsReprint) //{ // tempPrintItem.Piece = 1; //} //else //{ tempPrintItem.Piece = newTemplate.Piece; //} tempPrintItem.TemplateName = newTemplate.TemplateName; tempPrintItem.Layout = newTemplate.Layout; resultPrintItemList.Add(tempPrintItem); } else if (NotExistException) { //var logger = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); //FisException ex; //List<string> erpara = new List<string>(); //erpara.Add(tempPrintItem.LabelType); //ex = new FisException("CHK065", erpara); //logger.Error(ex.mErrmsg, ex); //throw ex; if (!hasExceptStation.HasValue) { hasExceptStation = checkExceptStation(); } if (!hasExceptStation.Value) { throw new FisException("CHK065", new string[] { tempPrintItem.LabelType }); } } } else if (tempPrintItem.PrintMode == Bartender || tempPrintItem.PrintMode == BartenderSrv) { //PrintTemplate newTemplate = lblTypeRepository.GetPrintTemplate(tempPrintItem.TemplateName); if (resolvePrintTemplate == null) { resolvePrintTemplate = new PrintUtility(session, ModelName(session), MONO(session), Dn(session), PartNo(session), Customer); } PrintTemplate newTemplate = resolvePrintTemplate.GetPrintTemplate(tempPrintItem.LabelType, tempPrintItem.RuleMode, tempPrintItem.PrintMode); if (newTemplate != null) { //if (IsReprint) //{ // tempPrintItem.Piece = 1; //} //else //{ tempPrintItem.Piece = newTemplate.Piece; //} tempPrintItem.TemplateName = newTemplate.TemplateName; tempPrintItem.SpName = newTemplate.SpName; resultPrintItemList.Add(tempPrintItem); } else if (NotExistException) { // var logger = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); //FisException ex; //List<string> erpara = new List<string>(); //erpara.Add(tempPrintItem.TemplateName); //ex = new FisException("CHK064", erpara); ////logger.Error(ex.mErrmsg, ex); //throw ex; if (!hasExceptStation.HasValue) { hasExceptStation = checkExceptStation(); } if (!hasExceptStation.Value) { throw new FisException("CHK065", new string[] { tempPrintItem.LabelType }); } } } #endregion } if (resultPrintItemList.Count == 0 & !NotExistException) { //var logger = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); //FisException ex; //List<string> erpara = new List<string>(); //ex = new FisException("CHK065",new string[]{""}); ////logger.Error(ex.mErrmsg, ex); //throw ex; if (!hasExceptStation.HasValue) { hasExceptStation = checkExceptStation(); } if (!hasExceptStation.Value) { throw new FisException("CHK065", new string[] { string.Join(",", printItemList.Select(x => x.LabelType + "/" + x.TemplateName).ToArray()) }); } } session.AddValue(Session.SessionKeys.PrintItems, resultPrintItemList); #region write print log if (this.IsWritePrintLog && resultPrintItemList != null && resultPrintItemList.Count > 0) { ActivityCommonImpl utl = ActivityCommonImpl.Instance; var rep = RepositoryFactory.GetInstance().GetRepository<IPrintLogRepository, PrintLog>(); var reprintRep = RepositoryFactory.GetInstance().GetRepository<IReprintLogRepository, ReprintLog>(); string descrMsg= "Line:{0} PrintMode:{1} SPName:{2} Pieces:{3}"; string reasonMsg = "Template:{0}"; string begNo = utl.GetPrintLogBegNoValue(session, this.PrintLogBegNo, this.SessionBegNoName); string endNo = utl.GetPrintLogEndNoValue(session,this.SessionEndNoName); begNo = begNo ?? session.Key; endNo = endNo ?? session.Key; foreach (PrintItem item in resultPrintItemList) { if (this.IsReprint) { var log = new ReprintLog { LabelName = item.LabelType, BegNo = begNo, EndNo =endNo, Descr = string.Format(descrMsg, this.Line?? "", item.PrintMode.ToString(), item.SpName, item.Piece.ToString()), Reason = session.GetValue(Session.SessionKeys.Reason) as string , Editor = this.Editor }; if (string.IsNullOrEmpty(log.Reason)) { log.Reason = string.Format(reasonMsg, item.TemplateName); } else { log.Reason = log.Reason +" "+ string.Format(reasonMsg, item.TemplateName); } reprintRep.Add(log, session.UnitOfWork); } else { var log = new PrintLog { LabelTemplate = item.TemplateName, Station = this.Station, Name = item.LabelType, BeginNo = begNo, EndNo = endNo, Descr = string.Format(descrMsg, this.Line ?? "", item.PrintMode.ToString(), item.SpName, item.Piece.ToString()), Editor = this.Editor }; rep.Add(log, session.UnitOfWork); } } } #endregion } //Vincent disable code don't Change printitem object or not //else //{ // // var logger = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); // FisException ex; // List<string> erpara = new List<string>(); // ex = new FisException("CHK066", erpara); // // logger.Error(ex.mErrmsg, ex); // throw ex; //} return base.DoExecute(executionContext); }
/// <summary> /// Write Reprintlog to db /// </summary> /// <param name="executionContext"></param> /// <returns></returns> protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext) { var log = new ReprintLog { LabelName = CurrentSession.GetValue(Session.SessionKeys.PrintLogName) as string, BegNo = CurrentSession.GetValue(Session.SessionKeys.PrintLogBegNo) as string, EndNo = CurrentSession.GetValue(Session.SessionKeys.PrintLogEndNo) as string, Descr = CurrentSession.GetValue(Session.SessionKeys.PrintLogDescr) as string, Reason = CurrentSession.GetValue(Session.SessionKeys.Reason) as string, Editor = this.Editor }; var rep = RepositoryFactory.GetInstance().GetRepository<IReprintLogRepository, ReprintLog>(); rep.Add(log, CurrentSession.UnitOfWork); return base.DoExecute(executionContext); }
public ArrayList RePrintPOD(string sn, string reason, string editor, string station, string customer) { string methodName = System.Reflection.MethodBase.GetCurrentMethod().Name; logger.DebugFormat("BEGIN: {0}()", methodName); try { ArrayList retLst = new ArrayList(); var currentProduct = CommonImpl.GetProductByInput(sn, CommonImpl.InputTypeEnum.ProductIDOrCustSN); if (currentProduct == null) { throw new FisException("PAK084", new string[] { }); } bool needPODLabel = IsNeedPodLabel(currentProduct.Model); if (!needPODLabel) { throw new FisException("This Model need not print POD label!"); } string color = GetCqPodLabelColor(currentProduct.Model); retLst.Add(currentProduct.Model); retLst.Add(color); var log = new ReprintLog { LabelName = "Tablet POD", BegNo = sn, EndNo = sn, Descr = "Reprint "+color +" POD", Reason =reason, Editor = editor }; IMES.Infrastructure.UnitOfWork.IUnitOfWork uof = new IMES.Infrastructure.UnitOfWork.UnitOfWork(); var rep = RepositoryFactory.GetInstance().GetRepository<IReprintLogRepository, ReprintLog>(); rep.Add(log, uof); uof.Commit(); return retLst; } 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); } }