Exemple #1
0
        public ArrayList Reprint(string prodid, int type, string editor, string station, string customer, string reason, string pCode, IList<PrintItem> printItems, out MRPLabelDef MRP)
        {
            ArrayList retrunValue = new ArrayList();
            FisException ex;
            List<string> erpara = new List<string>();           
            try
            {
                logger.Debug("(ShipToCartonLabel)ReprintLabel start, ProdId:" + prodid + " editor:" + editor + " customerId:" + customer + " reason:" + reason);
                         
                string sessionKey = prodid;
                Session Session = SessionManager.GetInstance.GetSession(sessionKey, Session.SessionType.Product);
                IDeliveryRepository iDeliveryRepository = RepositoryFactory.GetInstance().GetRepository<IDeliveryRepository, Delivery>();
                if (Session == null)
                {
                    Session = new Session(sessionKey, Session.SessionType.Product, editor, station, "", customer);
                    Dictionary<string, object> wfArguments = new Dictionary<string, object>();

                    wfArguments.Add("Key", sessionKey);
                    wfArguments.Add("Station", station);
                    wfArguments.Add("CurrentFlowSession", Session);
                    wfArguments.Add("Editor", editor);
                    wfArguments.Add("PdLine", "");
                    wfArguments.Add("Customer", customer);
                    wfArguments.Add("SessionType", Session.SessionType.Product);
                    string wfName, rlName;
                    RouteManagementUtils.GetWorkflow(station, "ReprintShipToCartonLabel.xoml", "ReprintShipToCartonLabel.rules", out wfName, out rlName);
                    WorkflowInstance instance = WorkflowRuntimeManager.getInstance.CreateXomlFisWorkflow(wfName, rlName, wfArguments);

                    Session.AddValue(Session.SessionKeys.CustSN, prodid);
                    Session.AddValue(Session.SessionKeys.PalletNo, prodid);
                    Session.AddValue(Session.SessionKeys.Reason, reason);
                    Session.AddValue(Session.SessionKeys.PrintItems, printItems);
                    Session.AddValue(Session.SessionKeys.PCode, pCode); 
                   
                    Session.AddValue(Session.SessionKeys.PrintLogName, "Shipto Label");
                    Session.AddValue(Session.SessionKeys.PrintLogBegNo, prodid);
                    Session.AddValue(Session.SessionKeys.PrintLogEndNo, prodid);                               
                    Session.AddValue(Session.SessionKeys.PrintLogDescr, prodid);                               
                    Session.AddValue(Session.SessionKeys.Reason, reason);

                    Session.AddValue(Session.SessionKeys.CN, type);

                    Session.SetInstance(instance);

                    if (!SessionManager.GetInstance.AddSession(Session))
                    {
                        Session.WorkflowInstance.Terminate("Session:" + sessionKey + " Exists.");
                        erpara.Add(sessionKey);
                        ex = new FisException("CHK020", erpara);
                        throw ex;
                    }
                    Session.WorkflowInstance.Start();
                    Session.SetHostWaitOne();
                }
                else
                {
                    erpara.Add(sessionKey);
                    ex = new FisException("CHK020", erpara);
                    throw ex;
                }

                //check workflow exception
                if (Session.Exception != null)
                {
                    if (Session.GetValue(Session.SessionKeys.WFTerminated) != null)
                    {
                        Session.ResumeWorkFlow();
                    }
                    throw Session.Exception;
                }
                //ChangeLabel
                int changeLabel = (int)Session.GetValue(Session.SessionKeys.labelBranch);
                string delievery = "";
                if (changeLabel == 1 && type == 0)
                {
                    retrunValue.Add("1");
                    retrunValue.Add(sessionKey);                    
                }
                else
                {
                    IList<PrintItem> returnList = (IList<PrintItem>)Session.GetValue(Session.SessionKeys.PrintItems);                    

                    int printType = (int)Session.GetValue(Session.SessionKeys.InfoValue);
                    string pdfname = "";
                    string templatename = "";
                    if (printType == 0)
                    {
                        pdfname = (string)Session.GetValue("PDFFileName");
                        templatename = (string)Session.GetValue("ShiptoTemplate");
                    }

                    //Mantis 972
                    string returnCustSN = (string)Session.GetValue(Session.SessionKeys.CustSN);
                    Delivery currentDelivery = (Delivery)Session.GetValue(Session.SessionKeys.Delivery);
                    string returnDN = currentDelivery.DeliveryNo;
                    int BTFlag = (int)Session.GetValue(Session.SessionKeys.IsBT);
                    delievery = currentDelivery.DeliveryNo;

                    retrunValue.Add("0");
                    retrunValue.Add(returnList);
                    retrunValue.Add(changeLabel.ToString());
                    retrunValue.Add(printType.ToString());
                    retrunValue.Add(pdfname);

                    //Mantis 972
                    retrunValue.Add(returnCustSN);
                    retrunValue.Add(returnDN);
                    retrunValue.Add(templatename);
                    retrunValue.Add(BTFlag.ToString());
                }
                MRP = iDeliveryRepository.GetMRPLabel(delievery);
                if (MRP == null)
                {
                    MRP = new MRPLabelDef();
                    MRP.IndiaPrice = "";
                    MRP.IndiaPriceDescr = "";
                    MRP.IndiaPriceID = "";
                }

                return retrunValue;
            }
            catch (FisException e)
            {
                throw e;
            }
            catch (Exception e)
            {
                throw new SystemException(e.Message);
            }
            finally
            {
                logger.Debug("(ShipToCartonLabel)ReprintLabel end,:" + "ProdId:" + prodid + " editor:" + editor + " station:" + station + " customerId:" + customer + " reason:" + reason);

            }
        }
Exemple #2
0
        /// <summary>
        /// 根据刷入的Customer S/N,SFC,获得 Product ID,Customer P/N 信息
        /// Product ID: Product.ProductID;
        /// Customer P/N: Product.Model对应的Model.CustPN
        /// </summary>
        ProductModel IPodLabelCheck.InputCustSnOnCooLabel(string custsn, string pdLine, string editor, string station, string customer, out string custpn , out MRPLabelDef MRP,out string BoxID)
        {
            logger.Debug("(PodLabelCheckImpl)InputCustSNOnCooLabel start, custsn:" + custsn + "pdLine:" + pdLine + "editor:" + editor + "station:" + station + "customer:" + customer);

            FisException ex;
            List<string> erpara = new List<string>();

            try
            {
                       
                var currentProduct = CommonImpl.GetProductByInput (custsn, CommonImpl.InputTypeEnum.CustSN);
                string sessionKey = currentProduct.ProId;
                CommonImpl2 cm2 = new CommonImpl2();
                string label = "";
                label = cm2.CheckPodLabel(custsn);
                if (label == "")
                { label = cm2.CheckConfigLabel(custsn); }
                if (string.IsNullOrEmpty(label))
                {
                    throw new FisException("SFC013", new string[] { });
                }

                Session currentSession = SessionManager.GetInstance.GetSession(sessionKey, Session.SessionType.Product);

                if (currentSession == null)
                {
                    currentSession = new Session(sessionKey, Session.SessionType.Product, editor, station, pdLine, 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", pdLine);
                    wfArguments.Add("Customer", customer);
                    wfArguments.Add("SessionType", Session.SessionType.Product);
                    
                    string wfName, rlName;
                    RouteManagementUtils.GetWorkflow(station, "PodLabelCheck.xoml", "PodLabelCheck.rules", out wfName, out rlName);
                    WorkflowInstance instance = WorkflowRuntimeManager.getInstance.CreateXomlFisWorkflow(wfName, rlName, wfArguments);

                    currentSession.AddValue(Session.SessionKeys.CustSN, custsn);
                    currentSession.AddValue(Session.SessionKeys.Product, currentProduct);
                    currentSession.AddValue(Session.SessionKeys.IsComplete, false);
                    currentSession.SetInstance(instance);

                    if (!SessionManager.GetInstance.AddSession(currentSession))
                    {
                        currentSession.WorkflowInstance.Terminate("Session:" + sessionKey + " Exists.");
                        erpara.Add(sessionKey);
                        ex = new FisException("CHK020", erpara);
                        throw ex;
                    }

                    currentSession.WorkflowInstance.Start();
                    currentSession.SetHostWaitOne();
                }
                else
                {
                    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;
                }


                ProductModel currentProductModel = new ProductModel();

                currentProductModel.CustSN = currentProduct.CUSTSN;
                currentProductModel.Model = currentProduct.Model;
                currentProductModel.ProductID = currentProduct.ProId;

                custpn = string.Empty;
                //custpn = currentProduct.ModelObj.CustPN;
                //if (String.IsNullOrEmpty(custpn))
                //{
                //    erpara.Add(custsn);
                //    ex = new FisException("CHK043", erpara);
                //    throw ex;
                //} //UC Revision: 7294: CustPN 修改为Model
                //Revision: 9810:	修改列印Config Label 的条件为非BT
                currentSession.AddValue(Session.SessionKeys.ifElseBranch, ""); 
                IDeliveryRepository iDeliveryRepository = RepositoryFactory.GetInstance().GetRepository<IDeliveryRepository, Delivery>();
                
                string printlabeltype1 = string.Empty; // Config Label
                string printlabeltype2 = string.Empty; // POD Label
                string delievery = string.Empty;    // currentDeliveryNo
                string pno = string.Empty;      // currentModel
                delievery = currentProduct.DeliveryNo;
                if (!currentProduct.IsBT)
                {
                    string BTRegId =(string) iDeliveryRepository.GetDeliveryInfoValue(delievery, "RegId");
                    if (BTRegId != null && BTRegId.Length == 3)
                    { BTRegId = BTRegId.Substring(1, 2); }
                    else
                    { BTRegId = ""; }
                    string BTShipTp = iDeliveryRepository.GetDeliveryInfoValue(delievery, "ShipTp");
                    string BTCountry = iDeliveryRepository.GetDeliveryInfoValue(delievery, "Country");

                    if (!string.IsNullOrEmpty(BTRegId) && !string.IsNullOrEmpty(BTShipTp) && !string.IsNullOrEmpty(BTCountry))
                    {
                        //ITC-1360-1527:RegId 为'SNE'时,未能打印CONFIG LABEL                       
                        //if ((BTRegId == "CN" || BTRegId == "AF" || BTRegId == "NE" || BTRegId == "CE") && (BTShipTp == "CTO") && (BTCountry != "JAPAN"))
                        if ((ActivityCommonImpl.Instance.CheckDomesticDN(BTRegId) || BTRegId == "AF" || BTRegId == "NE" || BTRegId == "CE") && (BTShipTp == "CTO") && (BTCountry != "JAPAN"))
                        {
                            printlabeltype1 = "ConfigLabel";
                            currentSession.AddValue(Session.SessionKeys.ifElseBranch, printlabeltype1);
                            currentProductModel.CustSN = printlabeltype1;
                        }
                    }
                }
               
               
                //  Print =====如果IMES_PAK..PODLabelPart中有维护PartNo等于Model的前几位字符的记录 and (Model的第7位不是数字),则需要列印POD Label====
                pno = currentProduct.Model;
                IList<PODLabelPartDef> podLabelPartLst = new List<PODLabelPartDef>();
                podLabelPartLst = ipartRepository.GetPODLabelPartListByPartNo(pno);
                if (podLabelPartLst.Count > 0)
                {
                    string number = "0123456789";
                    string modelbit = currentProduct.Model.Substring(6, 1);
                    if (!number.Contains(modelbit)) //Model的第7位不是数字
                    {
                        printlabeltype2 = "PODLabel";
                        currentSession.AddValue(Session.SessionKeys.ifElseBranch, printlabeltype2);  //如果列印PodLabel,则需要再记录一次ProductLog (Station = 'PD',Line = 'POD Label Print')
                        currentProductModel.CustSN = printlabeltype2;
                    }
                }
                MRP = new MRPLabelDef();
                MRP = iDeliveryRepository.GetMRPLabel(delievery);
                if (MRP == null)
                {
                    MRP = new MRPLabelDef();
                    MRP.IndiaPrice = "";
                    MRP.IndiaPriceDescr = "";
                    MRP.IndiaPriceID = "";
                }
                BoxID = iProductRepository.GetProductInfoValue(currentProduct.ProId, "BoxId");
                if (BoxID == null)
                {
                    BoxID = "";
                }
                return currentProductModel;
            }
            catch (FisException e)
            {
                //logger.Error(e.mErrmsg, e);
                //throw new Exception(e.mErrmsg);
                logger.Error(e.mErrmsg, e);
                if (e.mErrcode == "CHK020") //序號已被刷入
                {
                    throw e;
                }
                throw new Exception(e.mErrmsg);
            }
            catch (Exception e)
            {
                logger.Error(e.Message, e);
                throw new SystemException(e.Message);
            }
            finally
            {
                logger.Debug("(PodLabelCheckImpl)InputCustSNOnCooLabel end, custsn:" + custsn + "pdLine:" + pdLine + "editor:" + editor + "station:" + station + "customer:" + customer);
            }
        }
Exemple #3
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="data"></param>
        /// <param name="type"></param>
        /// <param name="sessionKey"></param>
        /// <param name="printItemLst"></param>
        /// <param name="pdLine"></param>
        /// <param name="station"></param>
        /// <param name="editor"></param>
        /// <param name="customer"></param>
        /// <returns></returns>
        public ArrayList InputProcess(string data, int type, string sessionKey, IList<PrintItem> printItemLst, string pdLine, string station, string editor, string customer, out MRPLabelDef MRP)
        {
            logger.Debug("ShipToCartonLabel WF start, pdLine:" + pdLine + " ,editor:" + editor + " ,station:" + station + " ,customer:" + customer);
            string currentSessionKey = Guid.NewGuid().ToString();
            ArrayList retValue = new ArrayList();
            MRP = new MRPLabelDef();
            try
            {
                Session currentCommonSession = SessionManager.GetInstance.GetSession(currentSessionKey, Session.SessionType.Common);
                if (currentCommonSession == null)
                {
                    currentCommonSession = new Session(currentSessionKey, Session.SessionType.Common, editor, station, pdLine, customer);

                    Dictionary<string, object> wfArguments = new Dictionary<string, object>();
                    wfArguments.Add("Key", currentSessionKey);
                    wfArguments.Add("Station", station);
                    wfArguments.Add("CurrentFlowSession", currentCommonSession);
                    wfArguments.Add("Editor", editor);
                    wfArguments.Add("PdLine", pdLine);
                    wfArguments.Add("Customer", customer);
                    wfArguments.Add("SessionType", Session.SessionType.Common);
                    WorkflowInstance instance = WorkflowRuntimeManager.getInstance.CreateXomlFisWorkflow("ShipToCartonLabel.xoml", "ShipToCartonLabel.rules", wfArguments);
                    
                    if (data.Length == DEFINE_DN_LEN)
                    {
                        currentCommonSession.AddValue(Session.SessionKeys.MaintainAction, 0);
                        currentCommonSession.AddValue(Session.SessionKeys.DeliveryNo, data);
                    }
                    else if (data.Length == DEFINE_SN_LEN)
                    {
                        currentCommonSession.AddValue(Session.SessionKeys.MaintainAction, 1);
                        currentCommonSession.AddValue(Session.SessionKeys.CustSN, data);

                        currentCommonSession.AddValue(Session.SessionKeys.PrintItems, printItemLst);
                        currentCommonSession.AddValue(Session.SessionKeys.CN, type);
                    }
                    else
                    {
                        FisException ex;
                        List<string> erpara = new List<string>();
                        erpara.Add(data);
                        ex = new FisException("CHK837", erpara);
                        throw ex;
                    }


                    currentCommonSession.SetInstance(instance);

                    if (!SessionManager.GetInstance.AddSession(currentCommonSession))
                    {
                        currentCommonSession.WorkflowInstance.Terminate("Session:" + currentSessionKey + " Exists.");
                        FisException ex;
                        List<string> erpara = new List<string>();
                        erpara.Add(currentSessionKey);
                        ex = new FisException("CHK020", erpara);
                        throw ex;
                    }

                    currentCommonSession.WorkflowInstance.Start();
                    currentCommonSession.SetHostWaitOne();
                }
                else
                {
                    FisException ex;
                    List<string> erpara = new List<string>();
                    erpara.Add(currentSessionKey);
                    ex = new FisException("CHK020", erpara);
                    throw ex;
                }


                if (currentCommonSession.Exception != null)
                {
                    if (currentCommonSession.GetValue(Session.SessionKeys.WFTerminated) != null)
                    {
                        currentCommonSession.ResumeWorkFlow();
                    }

                    throw currentCommonSession.Exception;
                }

                int changeLabel = 0;
                if ((int)currentCommonSession.GetValue(Session.SessionKeys.MaintainAction) == 0)
                {
                    changeLabel = 0;
                }
                else
                {
                    changeLabel = (int)currentCommonSession.GetValue(Session.SessionKeys.labelBranch);
                }

                if (changeLabel == 1 && type == 0)
                {
                    retValue.Add(currentSessionKey);
                }
                else
                {
                    //Delivery Info
                    Delivery currentDelivery = (Delivery)currentCommonSession.GetValue(Session.SessionKeys.Delivery);
                    IDeliveryRepository iDeliveryRepository = RepositoryFactory.GetInstance().GetRepository<IDeliveryRepository, Delivery>();
                    DNForUI item = new DNForUI();
                    item.ModelName = currentDelivery.ModelName;
                    item.PoNo = currentDelivery.PoNo;
                    item.DeliveryNo = currentDelivery.DeliveryNo;
                    item.Qty = currentDelivery.Qty;
                    item.DeliveryInfo = new Dictionary<string, string>();
                    string t = (string)currentDelivery.GetExtendedProperty("PartNo");
                    string delievery = currentDelivery.DeliveryNo;
                    if (!String.IsNullOrEmpty(t) && t.Contains('/'))
                    {
                        string[] tmpPartNo = t.Split(new Char[] {'/'} ,2);
                        item.DeliveryInfo.Add("PartNo", tmpPartNo[1]);
                        retValue.Add(tmpPartNo[1]);
                    }
                    else
                    {
                        item.DeliveryInfo.Add("PartNo", "");
                        retValue.Add("");
                    }
                    //Delivery Info
                    //Location Info And Pallet Info
                    string message = string.Empty;
                    string pallet = string.Empty;
                    if ((int)currentCommonSession.GetValue(Session.SessionKeys.MaintainAction) == 1)
                    {
                        message = (string)currentCommonSession.GetValue("LocationMess");
                        pallet = (string)currentCommonSession.GetValue(Session.SessionKeys.Pallet);
                    }
                    else
                    {
                        message = "";
                        pallet = "";
                    }
                    //Location Info And Pallet Info
                    IList<PrintItem> printParams = new List<PrintItem>();
                    if ((int)currentCommonSession.GetValue(Session.SessionKeys.MaintainAction) == 1)
                    {
                         printParams = (IList<PrintItem>)currentCommonSession.GetValue(Session.SessionKeys.PrintItems);
                    }                    

                    int printType = 0;
                    int actionType = 0;
                    if ((int)currentCommonSession.GetValue(Session.SessionKeys.MaintainAction) == 1)
                    {
                        printType = (int)currentCommonSession.GetValue(Session.SessionKeys.InfoValue);
                        actionType = (int)currentCommonSession.GetValue(Session.SessionKeys.MaintainAction);
                    }
                    else
                    {
                        actionType = (int)currentCommonSession.GetValue(Session.SessionKeys.MaintainAction);
                        printType = 2;
                    }

                    string pdfname = "";
                    if ((int)currentCommonSession.GetValue(Session.SessionKeys.MaintainAction) == 1)
                    {
                        if ((int)currentCommonSession.GetValue(Session.SessionKeys.InfoValue) == 0)
                        {
                            pdfname = (string)currentCommonSession.GetValue("PDFFileName");
                        }
                    }

                    MRP = iDeliveryRepository.GetMRPLabel(delievery);
                    if (MRP == null)
                    {
                        MRP = new MRPLabelDef();
                        MRP.IndiaPrice = "";
                        MRP.IndiaPriceDescr = "";
                        MRP.IndiaPriceID = "";
                    }

                    retValue.Add(item.ModelName);
                    retValue.Add(item.PoNo);
                    retValue.Add(item.DeliveryNo);
                    retValue.Add(item.Qty.ToString());
                    retValue.Add(printType.ToString());
                    retValue.Add(printParams);
                    retValue.Add(message);
                    retValue.Add(pallet);
                    retValue.Add(actionType.ToString());
                    retValue.Add(changeLabel.ToString());
                    retValue.Add(pdfname);
                }

                return retValue;

            }
            catch (FisException e)
            {
                throw e;
            }
            catch (Exception e)
            {
                throw new SystemException(e.Message);
            }
            finally
            {
                logger.Debug("ShipToCartonLabel end, pdLine:" + pdLine + " ,editor:" + editor + " ,station:" + station + " ,customer:" + customer);

            }
         
        }