Example #1
0
        /// <summary>
        /// To every one in a COANoList, delete bound to Product and COA No, set status to current product.
		/// set status to COA, and insert COA log.
        /// </summary>
        /// <param name="executionContext"></param>
        /// <returns></returns>
        protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext)
        {
            string editor = this.Editor;
            string pdLine = this.Line;
            string scrap = (string)CurrentSession.GetValue("scrap");
            string cause = (string)CurrentSession.GetValue("cause");

            List<string> list = (List<string>)CurrentSession.GetValue(Session.SessionKeys.COASNList);
            List<string> Actionlist = (List<string>)CurrentSession.GetValue("ActionList");
            List<string> Causelist = (List<string>)CurrentSession.GetValue("CauseList");
            int listcount = list.Count;
            int i = 0;
            IProductRepository productRep = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>();
            ICOAStatusRepository coaStatusRep = RepositoryFactory.GetInstance().GetRepository<ICOAStatusRepository, COAStatus>();

            IPizzaRepository repPizza = RepositoryFactory.GetInstance().GetRepository<IPizzaRepository, Pizza>();
          
            try
            {
                foreach (string coaNo in list)
                {
                    bool found = false;
                    string productID = "";
                    string CUSTSN = "";
                    string CustPartNo = "";

                    string pizzaID = "";

                    bool first_in = true;
                    string partSn = coaNo;
                    IMES.FisObject.FA.Product.ProductStatus newStatus = new IMES.FisObject.FA.Product.ProductStatus();
                    IList<string> product_list = new List<string>();
                    IList<ProductAndCustInfo> product_and_cust_info_list = productRep.GetProductAndCustInfoListByPartSn(partSn);
                    foreach (ProductAndCustInfo node in product_and_cust_info_list)
                    {
                        if (first_in)
                        {
                            productID = node.productId;
                            IProduct _product = productRep.FindOneProductWithProductIDOrCustSN(productID);
                            pizzaID = _product.PizzaID;
                            newStatus = _product.Status;
                            CUSTSN = node.custSn;
                            CustPartNo = node.custPno; //_product.ModelObj.CustPN;
                            found = true;
                            first_in = false;
                        }

                        product_list.Add(node.productId);
                        break;
                    }

                    if (found == false)
                    {
                        //FisException _ex = new FisException("CHK238"); //Get COA no bounding product info error!
                        //throw _ex;
                    }
                    /////////////////////////////////////////////////////////////////////////////
                    /* 
                     * delete Pizza_Part where PartSn=@coano and PizzaID=@PizzaId
                     */
                    ////////////////////////////////////////////////////////////////////////////////

                    IList<IProduct> pizza_list = productRep.GetProductInfoListByPizzaPartSn(partSn);
                    foreach (IProduct node in pizza_list)
                    {
                        pizzaID = node.PizzaID;
                        productID = node.ProId;
                        product_list.Add(productID);

                        break;
                    }
                    if (pizzaID != "")
                    {
                        PizzaPart delpizza = new PizzaPart();

                        delpizza.PizzaID = pizzaID;
                        delpizza.PartSn = partSn;

                        repPizza.DeletePizzaPartDefered(CurrentSession.UnitOfWork, delpizza);
                    }

                    /*
                     * 
                     * 6.解除Product与COA No的绑定:
                     * delete Product_Part where PartSn=@coano and ProductID=@productID
                     * 设置对应Product的当前状态:
                     * Update ProductStatus set Station=’69’, Editor=@user, Udt=GetDate where ProducntID=@productID
                     * 设置COA状态:
                     * Update COAStatus set Line=’REM’,Status=’A2’,Editor=@user, Udt=GetDate where COASN=@coano
                     * 记录COA Log:
                     * insert COALog values (@coano, 'A2',custsn+'/'+hppno, rtrim(@user), GetDate, ‘COA’)
                     * -----------------------------------------------------------------------------------------------
                     * IProductRepository::
                     * void DeleteProductPartByPartSn(string prodId, string partSn);
                     * 或void DeleteProductPartByPartSnDefered(IUnitOfWork uow, string prodId, string partSn);
                     * 
                     * 
                     * ProductStatus的修改请使用主体对象Product的Status属性,其被修改后,调用IProductRepository的Update方法来更新修改。
                     * 
                     * 
                     * COAStatus的更新使用ICOAStatusRepository的Update方法.
                     *
                     *
                     * ICOAStatusRepository::
                     * void InsertCOALog(COALog newLog);
                     * 或void InsertCOALogDefered(IUnitOfWork uow, COALog newLog);
                     * 
                     */

                    // if found == false, product_list has no node, and it does not exist in product_part.
                    // so we need not do:
                    //    1. productRep.DeleteProductPartByPartSn(productID, partSn)
                    //    2. productRep.UpdateProductListStatus.
                    if (found == true || pizzaID != "")
                    {
                        productRep.DeleteProductPartByPartSnDefered(CurrentSession.UnitOfWork, productID, partSn);
                        
                        //IMES.FisObject.FA.Product.ProductStatus newStatus = new IMES.FisObject.FA.Product.ProductStatus();
                        //Station=’69’, Editor=@user, Udt=GetDate where ProducntID=@productID
                        //上海mantis 0002406: PAK Remove COA 功能優化-- 判斷目前機器停留在 FA 站時不需要修改站點為69 站
                        IPartRepository partRep = RepositoryFactory.GetInstance().GetRepository<IPartRepository, IPart>();
                        IList<ConstValueTypeInfo> nonChange69StationList  = partRep.GetConstValueTypeList("RemoveCOANotChange69Station");

                        if (nonChange69StationList==null  ||  
                            nonChange69StationList.Count==0 ||  
                            !nonChange69StationList.Any(x => x.value == newStatus.StationId))
                        {
                            IList<IMES.DataModel.TbProductStatus> stationList = productRep.GetProductStatus(new List<string>() { productID });
                            productRep.UpdateProductPreStationDefered(CurrentSession.UnitOfWork, stationList);

                            newStatus.StationId = "CR";
                            newStatus.Editor = editor;
                            newStatus.Udt = DateTime.UtcNow;
                            newStatus.ProId = productID;
                            productRep.UpdateProductListStatusDefered(CurrentSession.UnitOfWork, newStatus, product_list); //Defered(CurrentSession.UnitOfWork, newStatus, ProductIDList);
                            productRep.WriteProductLogDefered(CurrentSession.UnitOfWork, 
                                                                                        new List<string>() { productID }, 
                                                                                        "RemoveCOA", 
                                                                                        newStatus.StationId , 
                                                                                        (int)newStatus.Status,
                                                                                        newStatus.Editor);
                        }
                    }

                    COAStatus _coaStatus = coaStatusRep.GetCoaStatus(coaNo);

                    if (Actionlist[i] == "Scrap")
                    {
                        ////////////////////////////////////////////////////////////////////////////
                        //Update COAStatus set Status=@cause,Editor=@user, Udt=GetDate where COASN=@coano
                        string strcause;
                        strcause = Causelist[i].Substring(0, Causelist[i].IndexOf(" "));

                        _coaStatus.Status = strcause;
                        _coaStatus.Editor = editor;
                        _coaStatus.Udt = DateTime.UtcNow;
                        _coaStatus.COASN = coaNo;
                        coaStatusRep.UpdateCOAStatusDefered(CurrentSession.UnitOfWork, _coaStatus);

                        ////////////////////////////////////////////////////////////////////////////
                        COAReturnInfo setCOA = new COAReturnInfo();
                        setCOA.status = strcause;
                        setCOA.editor = editor.Trim();
                        setCOA.udt = DateTime.UtcNow;

                        COAReturnInfo conditionCOA = new COAReturnInfo();
                        conditionCOA.coasn = coaNo;

                        coaStatusRep.UpdateCOAReturnInfoDefered(CurrentSession.UnitOfWork, setCOA, conditionCOA);

                    }
                    else
                    {
                        // found == true || found == false, program comes here, that is to say, COA Staus = 'A1',
                        // so we must update COA status to be 'A2'.
                        //Update COAStatus set Line=’REM’,Status=’A2’,Editor=@user, Udt=GetDate where COASN=@coano
                        _coaStatus.LineID = "REM";
                        _coaStatus.Status = "A2";
                        _coaStatus.Editor = editor;
                        _coaStatus.Udt = DateTime.UtcNow;
                        _coaStatus.COASN = coaNo;
                        coaStatusRep.UpdateCOAStatusDefered(CurrentSession.UnitOfWork, _coaStatus);
                    
                    }

                    // if found == false, we do not know the CUSTSN, and so we can not make a COALog.
                    if (found == true || pizzaID != "")
                    {
                        if (Actionlist[i] == "Scrap")
                        {
                            // insert COALog values (@coano, @cause,@coapn, rtrim(@user), GetDate, ‘COA’)
                            //Note:
                            //@cause – 该COA No录入时,选择的Cause
                            //@coapn – 该COA No 对应的COAStatus.IECPN
                            string strcause;
                            strcause = Causelist[i].Substring(0, Causelist[i].IndexOf(" "));

                            COALog newLog = new COALog();
                            newLog.COASN = coaNo;
                            newLog.StationID = strcause;
                            newLog.LineID = _coaStatus.IECPN;
                            newLog.Editor = editor.Trim();
                            newLog.Cdt = DateTime.Now;
                            newLog.Tp = "COA";

                            coaStatusRep.InsertCOALogDefered(CurrentSession.UnitOfWork, newLog);
                        }
 
                        else
                        {
                            //insert COALog values (@coano, 'A2',custsn+'/'+hppno, rtrim(@user), GetDate, ‘COA’)
                            COALog newLog = new COALog();
                            newLog.COASN = coaNo;
                            newLog.StationID = "A2";
                            newLog.LineID = CUSTSN + "/" + CustPartNo;
                            newLog.Editor = editor.Trim();
                            newLog.Cdt = DateTime.Now;
                            newLog.Tp = "COA";

                            coaStatusRep.InsertCOALogDefered(CurrentSession.UnitOfWork, newLog);
                        }
                    }
                    i++;
                }
            }
            catch(FisException e)
            {
                throw e;
            }
            catch (Exception e)
            {
                throw e;
            }

            return base.DoExecute(executionContext);
        }
Example #2
0
 /// <summary>
 /// Get Product Table
 /// </summary>
 /// <param name="line">line</param>
 /// <param name="editor">editor</param>
 /// <param name="station">station</param>
 /// <param name="customer">customer</param>
 /// <param name="key">key</param>
 /// <param name="SN">SN</param> 
 /// <param name="complete">complete</param>  
 public S_COAReturn GetProductTable(string line, string editor, string station, string customer, string key, List<string> SN, bool complete)
 {
     string keyStr = "";
     try
     {
         bool first = false ;
         S_COAReturn ret = new S_COAReturn();
         ret.reValue = "false";
         string sessionKey = key;
         keyStr = sessionKey;
         List<string> validTemp = new List<string>() ;
         Session currentSession = SessionManager.GetInstance.GetSession(sessionKey, SessionType);
         if (null == currentSession)
         {
             first = true;
             currentSession = new Session(sessionKey, SessionType, editor, station, line, customer);
             currentSession.AddValue("SNListForCOAReturn", validTemp);
         }
         validTemp = (List<string>)currentSession.GetValue("SNListForCOAReturn");
         
         foreach (string tmp in SN)
         {
             if (validTemp.Contains(tmp))
             {
             }
             else
             {
                 validTemp.Add(tmp);
             }
         }
         currentSession.AddValue("SNListForCOAReturn", validTemp);
         
         validTemp = (List<string>)currentSession.GetValue("SNListForCOAReturn");
         List<S_RowData_COAReturn> inValidProduct = new List<S_RowData_COAReturn>();
         List<S_RowData_COAReturn> validProduct = new List<S_RowData_COAReturn>();
         foreach (string tmp in validTemp)
         {
             S_RowData_COAReturn aRow = new S_RowData_COAReturn();
             aRow.SN = tmp;
             aRow.COAorError = "";
             IProduct temp = productRepository.GetProductByCustomSn(tmp);
             if (null != temp)
             {
                 // IMES_FA..Product_Part 表中与当前Product 绑定的Parts 
                 IList<IProductPart> productParts = new List<IProductPart>();
                 productParts = temp.ProductParts;
                 /*if (productParts == null || productParts.Count <= 0)
                 {
                     aRow.COAorError = "未结合COA / OOA";
                     inValidProduct.Add(aRow);
                     continue;
                 }*/
                 COAReturnInfo cond = new COAReturnInfo();
                 cond.custsn = tmp;
                 COAReturnInfo empty = new COAReturnInfo();
                 empty.status = "";
                 IList<COAReturnInfo> reCOAReturnInfo =  coaRepository.GetCOAReturnInfoList(cond, empty);
                 if (null != reCOAReturnInfo && reCOAReturnInfo.Count > 0)
                 {
                    aRow.COAorError = "已经完成本站!";
                    inValidProduct.Add(aRow);
                    continue;
                 }
                 foreach (ProductPart iprodpart in productParts)
                 {
                     IPart curPart = ipartRepository.GetPartByPartNo(iprodpart.PartID);
                     if (curPart.BOMNodeType == "P1" && curPart.Descr.IndexOf("COA") == 0)
                     {
                         COAStatus reCOA = coaRepository.Find(iprodpart.PartSn);
                         if (null == reCOA)
                         {
                             aRow.COAorError = "不存在COA";
                             inValidProduct.Add(aRow);
                         }
                         else
                         {
                             aRow.COAorError = iprodpart.PartSn;
                             validProduct.Add(aRow);
                         }
                         break;
                     }
                 }
                 string[] pizzIds;
                 pizzIds = new string[] { temp.PizzaID };
                 IList<string> partsn = repPizza.GetPartNoListFromPizzaPart(pizzIds, "P1", "DESC", "OOA");
                 foreach (string aPartSn in partsn)
                 {
                     COAStatus reCOA = coaRepository.Find(aPartSn);
                     if (null == reCOA)
                     {
                         aRow.COAorError = "不存在OOA";
                         inValidProduct.Add(aRow);
                     }
                     else
                     {
                         aRow.COAorError = aPartSn;
                         aRow.OOA = "true";
                         validProduct.Add(aRow);
                     }
                     break;
                 }
                 if (aRow.COAorError == "")
                 {
                     aRow.COAorError = "未结合COA / OOA";
                     inValidProduct.Add(aRow);
                 }
                 continue;
             }
             else
             {
                 aRow.COAorError = "Invalid Customer S/N!";
                 inValidProduct.Add(aRow);
                 continue;
             }
         }
         ret.reValue = "true";
         ret.validProduct = validProduct;
         ret.inValidProduct = inValidProduct;
         currentSession.AddValue("ValidProduct", validProduct);
         if (first == true && inValidProduct.Count == 0)
         {
             SessionManager.GetInstance.AddSession(currentSession);
         }
         return ret;
     }
     catch (FisException e)
     {
         logger.Error(e.mErrmsg, e);
         throw new Exception(e.mErrmsg);
     }
     catch (Exception ee)
     {
         throw ee;
     }
 }
Example #3
0
        /// <summary>
        /// 接着做
        /// </summary>
        /// <param name="key"></param>
        public void MakeSureSave(string key)
        {
            logger.Debug("(_COAReturn)MakeSureSave start, [key]: " + key);
            FisException ex;
            List<string> erpara = new List<string>();
            string sessionKey = key;
            try
            {
                Session session = SessionManager.GetInstance.GetSession(sessionKey, SessionType);
                if (session == null)
                {
                    erpara.Add(sessionKey);
                    ex = new FisException("CHK021", erpara);
                    throw ex;
                }
                else
                {

                    List<S_RowData_COAReturn> validProduct = (List < S_RowData_COAReturn >)session.GetValue("ValidProduct");
                    if (null == validProduct || validProduct.Count == 0)
                    {
                        return;
                    }
                    IUnitOfWork uow = new UnitOfWork();
                    foreach (S_RowData_COAReturn tmp in validProduct)
                    {
                        COAStatus reCOA = coaRepository.Find(tmp.COAorError);
                        COAReturnInfo item = new COAReturnInfo();
                        item.custsn = tmp.SN;
                        item.coasn = tmp.COAorError;
                        item.originalStatus = reCOA.Status;
                        item.status = "";
                        item.line = reCOA.LineID;
                        item.editor = reCOA.Editor;
                        item.cdt = DateTime.Now;
                        item.udt = DateTime.Now;
                        coaRepository.InsertCOAReturnDefered(uow, item);
                    }
                    uow.Commit();
                }
            }
            catch (FisException e)
            {
                logger.Error(e.mErrmsg);
                throw e;
            }
            catch (Exception e)
            {
                logger.Error(e.Message);
                throw e;
            }
            finally
            {
                Session sessionDelete = SessionManager.GetInstance.GetSession(key, SessionType);
                if (sessionDelete != null)
                {
                    SessionManager.GetInstance.RemoveSession(sessionDelete);
                }
                logger.Debug("(_COAReturn)MakeSureSave end, key:" + key);
            }
        }
Example #4
0
        /// <summary>
        /// To the input COANumber, check.
        ///    1. if it exists in the given table.
        ///    2. COAStatus.Status必须是'A1'
        ///    3. 此COA不可已经与机器绑定并且该机器当前在“85”或“9A”站。
        /// </summary>
        /// <param name="COANumber"></param>
        /// <param name="pdLine"></param>
        /// <param name="prodId"></param>
        /// <param name="editor"></param>
        /// <param name="stationId"></param>
        /// <param name="customerId"></param>
        /// <returns></returns>
        public ArrayList InputCOANumber(/*string _guid, */string COANumber, string pdLine, string prodId, string editor, string stationId, string customerId, string action, string cause)
        {
            logger.Debug("(_COARemoval)InputCOANumber start, COANumber:" + COANumber + " pdLine:" + pdLine + " prodId:" + prodId + " editor:" + editor + " stationId:" + stationId + " customerId:" + customerId);
            ArrayList this_array_list_return = new ArrayList();
            FisException ex;
            List<string> erpara = new List<string>();
            //string sessionKey = prodId;
            try
            {
                string CurrentCOASN = COANumber;
                IProductRepository productRep = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>();
                ICOAStatusRepository coaStatusRepository = RepositoryFactory.GetInstance().GetRepository<ICOAStatusRepository, COAStatus>();
                /* 1)所输入COA No在COAStatus数据表中存在。否则提示“无此COA记录!”
                 */
                COAStatus status = coaStatusRepository.Find(CurrentCOASN);
                if (status == null)
                {
                    //This COA does not exist!
                    FisException _ex = new FisException("CHK235", new string[]{});
                    throw _ex;
                }

                /* 2)5.	For Remove,COAStatus.Status必须是'A1'; 
                 * For Scrap,COAStatus.Status必须是'A0' or 'A2' or 'A3'。
                 * 否则提示 该COA的当前状态是”+COAStatus.Status+“。”
                 */
                if (action != "scrap")
                {
                    if (!status.Status.Equals("A1"))
                    {
                        // Only can remove a COA whose status is 'A1', current COA's status is %1
                        FisException _ex = new FisException("CHK236", new string[] { status.Status });
                        throw _ex;
                    }

                }
                else
                {
                    if (!status.Status.Equals("A0") && !status.Status.Equals("A2") && !status.Status.Equals("A3"))
                    {
                        // Only can remove a COA whose status is 'A0''A2''A3', current COA's status is %1
                        FisException _ex = new FisException("CHK525", new string[] { status.Status });
                        throw _ex;
                    }
                    var cond = new COAReturnInfo();
                    cond.coasn = "coano";
                    /*示例
                    var set = [ICOAStatusRepository Instance].GetCOAReturnInfoList(cond, null);
                    int cnt = (from item in set where item.status == string.Empty select item).Count();*/
                    IList<COAReturnInfo> coareturnlist = coaStatusRepository.GetCOAReturnInfoList(cond, null);
                    if (coareturnlist.Count != 0)
                    {
                        //报告错误:“该COA No 已Scarp!” !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!未改全
                        FisException _ex = new FisException("CHK526", new string[] { });
                        throw _ex;

                    }


                }
                /* 
                 *  Attention: now I think status.IECPN 就是 product 的 SN
                 *             所以,从它来得到 product 对象
                 *             
                 * 3)此COA不可已经与机器绑定并且该机器当前在“85”或“99”站。否则提示“机器已上栈板或已经出货 !!”
                 * 
                 *   If exists (select a.ProductID from Product a (nolock), 
                 *   Product_Part b (nolock), ProductStatus c (nolock) 
                 *   where a.ProductID=b.ProductID and b.PartSn=@coano and 
                 *   a.ProductID=c.ProductID and (c.Station=’85’ or c.Station=’99’))
                 * 
                 * IProductRepository::
                 *   bool CheckExistProductByPartSnAndStations(string partSn, string[] stations);
                 * 
                 */
                string partSn = CurrentCOASN;
                string[] stations = { "85", "9A" };
                if (productRep.CheckExistProductByPartSnAndStations(partSn, stations) || productRep.CheckExistProductByPartSnAndStationsWithPizzaPart(partSn, stations))
                {
                    FisException _ex = new FisException("CHK237", new string[]{ }); //"Machine has been in stack or out!"
                    throw _ex;
                }

                this_array_list_return.Add("OK!");
                this_array_list_return.Add(COANumber);
                this_array_list_return.Add(action);
                this_array_list_return.Add(cause);

                return this_array_list_return;

                /*
                string sessionKey = Guid.NewGuid().ToString(); //COANumber;
                if (_guid != "") sessionKey = _guid;

                Session Session = SessionManager.GetInstance.GetSession(sessionKey, TheType);

                if (Session == null)
                {
                    Session = new Session(sessionKey, TheType, editor, stationId, pdLine, customerId);

                    Dictionary<string, object> wfArguments = new Dictionary<string, object>();

                    wfArguments.Add("Key", sessionKey); // key must be COANumber.
                    wfArguments.Add("Station", stationId);
                    wfArguments.Add("CurrentFlowSession", Session);
                    wfArguments.Add("Editor", editor);
                    wfArguments.Add("PdLine", pdLine);
                    wfArguments.Add("Customer", customerId);
                    wfArguments.Add("SessionType", TheType);
                    string wfName, rlName;
                    RouteManagementUtils.GetWorkflow(stationId, "COARemoval.xoml", "COARemoval.rules", out wfName, out rlName);
                    WorkflowInstance instance = WorkflowRuntimeManager.getInstance.CreateXomlFisWorkflow(wfName, rlName, wfArguments);

                    IList<string> COANumberList = new List<string>();
                    Session.AddValue("_COANumberList", COANumberList);
                    Session.AddValue(Session.SessionKeys.IsComplete, false);
                    Session.AddValue(Session.SessionKeys.COASN, COANumber);
                    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();
                    //if (hasDealWithOneFKU == false) hasDealWithOneFKU = true;
                    this_array_list_return.Add("OK!");
                    this_array_list_return.Add(COANumber);
                    this_array_list_return.Add(sessionKey);
                }
                else
                {
                    //erpara.Add(sessionKey);
                    //ex = new FisException("CHK020", erpara);
                    //throw ex;
                    Session.AddValue(Session.SessionKeys.COASN, COANumber);
                    Session.Exception = null;
                    Session.SwitchToWorkFlow();

                    this_array_list_return.Add("OK!");
                    this_array_list_return.Add(COANumber);
                    this_array_list_return.Add(sessionKey);
                }
                               
                //check workflow exception
                if (Session.Exception != null)
                {
                    if (Session.GetValue(Session.SessionKeys.WFTerminated) != null)
                    {
                        Session.ResumeWorkFlow();
                    }
                    throw Session.Exception;
                }

                return this_array_list_return;
                */
            }
            catch (FisException e)
            {
                throw e;
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                logger.Debug("(_COARemoval)InputCOANumber end, COANumber:" + COANumber + " pdLine:" + pdLine + " prodId:" + prodId + " editor:" + editor + " stationId:" + stationId + " customerId:" + customerId);
            }
        }
Example #5
0
        /// <summary>
        /// To the input COANumber list, check.
        ///    1. if it exists in the given table.
        ///    2. COAStatus.Status必须是'A1'
        ///    3. 此COA不可已经与机器绑定并且该机器当前在“85”或“9A”站。
        /// </summary>
        /// <param name="COANumber"></param>
        /// <param name="pdLine"></param>
        /// <param name="prodId"></param>
        /// <param name="editor"></param>
        /// <param name="stationId"></param>
        /// <param name="customerId"></param>
        /// <returns></returns>
        public ArrayList InputCOANumberList(IList<string> COANumberList, string pdLine, string prodId, string editor, string stationId, string customerId, string action)
        {
            logger.Debug("(_COARemoval)InputCOANumber start, COANumber List:" + COANumberList + " pdLine:" + pdLine + " prodId:" + prodId + " editor:" + editor + " stationId:" + stationId + " customerId:" + customerId);
            ArrayList this_array_list_return = new ArrayList();
            FisException ex;
            FisException _ex;
            string error = "";
            List<string> erpara = new List<string>();

            List<string> errorList = new List<string>();

            try
            {
                foreach (string node in COANumberList)
                {
                    if (node != "")
                    {
                        //string CurrentCOASN = COANumberList[0]; modify by 2012.8.9
                        string CurrentCOASN = node;

                        IProductRepository productRep = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>();
                        ICOAStatusRepository coaStatusRepository = RepositoryFactory.GetInstance().GetRepository<ICOAStatusRepository, COAStatus>();
                        /* 1)所输入COA No在COAStatus数据表中存在。否则提示“无此COA记录!”
                         */
                        COAStatus status = coaStatusRepository.Find(CurrentCOASN);
                        if (status == null)
                        {
                            //This COA does not exist!
                            errorList.Add(CurrentCOASN);
                        }
                        else
                        {
                            /* 2)5.	For Remove,COAStatus.Status必须是'A1'; 
                             * For Scrap,COAStatus.Status必须是'A0' or 'A2' or 'A3'。
                             * 否则提示 该COA的当前状态是”+COAStatus.Status+“。”
                             */
                            if (action != "scrap")
                            {
                                if (!status.Status.Equals("A1"))
                                {
                                    errorList.Add(CurrentCOASN);
                                }
                            }
                            else
                            {
                                if (!status.Status.Equals("A0") && !status.Status.Equals("A2") && !status.Status.Equals("A3"))
                                {
                                    errorList.Add(CurrentCOASN);
                                }
                                var cond = new COAReturnInfo();
                                cond.coasn = "coano";
                                /*示例
                                var set = [ICOAStatusRepository Instance].GetCOAReturnInfoList(cond, null);
                                int cnt = (from item in set where item.status == string.Empty select item).Count();*/
                                IList<COAReturnInfo> coareturnlist = coaStatusRepository.GetCOAReturnInfoList(cond, null);
                                if (coareturnlist.Count != 0)
                                {
                                    errorList.Add(CurrentCOASN);

                                }
                            }
                            /* 
                             *  Attention: now I think status.IECPN 就是 product 的 SN
                             *             所以,从它来得到 product 对象
                             *             
                             * 3)此COA不可已经与机器绑定并且该机器当前在“85”或“9A”站。否则提示“机器已上栈板或已经出货 !!”
                             * 
                             *   If exists (select a.ProductID from Product a (nolock), 
                             *   Product_Part b (nolock), ProductStatus c (nolock) 
                             *   where a.ProductID=b.ProductID and b.PartSn=@coano and 
                             *   a.ProductID=c.ProductID and (c.Station=’85’ or c.Station=’9A’))
                             * 
                             * IProductRepository::
                             *   bool CheckExistProductByPartSnAndStations(string partSn, string[] stations);
                             * 
                             */
                            string partSn = CurrentCOASN;
                            string[] stations = { "85", "9A" };
                            if (productRep.CheckExistProductByPartSnAndStations(partSn, stations) || productRep.CheckExistProductByPartSnAndStationsWithPizzaPart(partSn, stations))
                            {
                                errorList.Add(CurrentCOASN);
                            }
                        }
                    }
               }
                IEnumerable<string> distinctAges = errorList.Distinct();
                List<string> returnerrorList = distinctAges.ToList();
                string strerrorlist = "";

                if (returnerrorList != null && returnerrorList.Count > 0)
                {
                    foreach (string tmp in returnerrorList)
                    {
                        //“文件中存在Invalid COA No,请注意!” – No1 / No2 / … / Non No1 ,No2,Non – 前文解析时发现的Invalid COA No
                        strerrorlist += tmp + "/";

                    }
                    strerrorlist = "-" + strerrorlist.Substring(0, strerrorlist.Length - 1);
                    _ex = new FisException("CHK527", new string[] { strerrorlist });//错误提示:“文件中存在Invalid COA No,请注意! – No1 / No2 / … / Non”
                    error = _ex.mErrmsg;
                    //throw _ex;

                }

                bool bExist = false;
                for (int j = 0; j < COANumberList.Count; j++)
                {
                    for (int m = 0; m < returnerrorList.Count; m++)
                    {
                        if (returnerrorList[m] == COANumberList[j])
                        {
                            //this_array_list_return.Add(error);
                            bExist = true;

                        }

                    }
                    if (bExist == false)
                    {
                        //this_array_list_return.Add("OK!");
                        if (COANumberList[j] != "")
                            this_array_list_return.Add(COANumberList[j]);

                    }
                    bExist = false;
                }

                this_array_list_return.Add(error);

                 return this_array_list_return;
                    
 

            }
            catch (FisException e)
            {
                throw e;
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                //logger.Debug("(_COARemoval)InputCOANumber end, COANumber:" + COANumber + " pdLine:" + pdLine + " prodId:" + prodId + " editor:" + editor + " stationId:" + stationId + " customerId:" + customerId);
            }
        }
Example #6
0
        /// <summary>
        /// To the input COANumber, check.
        ///    1. if it exists in the given table.
        ///    2. COAStatus.Status必须是'A1'
        ///    3. 此COA不可已经与机器绑定并且该机器当前在“85”或“9A”站。
        /// </summary>
        /// <param name="COANumber"></param>
        /// <param name="pdLine"></param>
        /// <param name="prodId"></param>
        /// <param name="editor"></param>
        /// <param name="stationId"></param>
        /// <param name="customerId"></param>
        /// <returns></returns>
        public ArrayList InputCOANumber(/*string _guid, */string COANumber, string pdLine, string prodId, string editor, string stationId, string customerId, string action, string cause)
        {
            logger.Debug("(_COARemoval)InputCOANumber start, COANumber:" + COANumber + " pdLine:" + pdLine + " prodId:" + prodId + " editor:" + editor + " stationId:" + stationId + " customerId:" + customerId);
            ArrayList this_array_list_return = new ArrayList();
           // FisException ex;
            List<string> erpara = new List<string>();
            //string sessionKey = prodId;
            try
            {
                string CurrentCOASN = COANumber;
                IProductRepository productRep = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>();
                ICOAStatusRepository coaStatusRepository = RepositoryFactory.GetInstance().GetRepository<ICOAStatusRepository, COAStatus>();
                /* 1)所输入COA No在COAStatus数据表中存在。否则提示“无此COA记录!”
                 */
                COAStatus status = coaStatusRepository.Find(CurrentCOASN);
                if (status == null)
                {
                    //This COA does not exist!
                    FisException _ex = new FisException("CHK235", new string[]{});
                    throw _ex;
                }

                /* 2)5.	For Remove,COAStatus.Status必须是'A1'; 
                 * For Scrap,COAStatus.Status必须是'A0' or 'A2' or 'A3'。
                 * 否则提示 该COA的当前状态是”+COAStatus.Status+“。”
                 */
                if (action != "scrap")
                {
                    if (!status.Status.Equals("A1"))
                    {
                        // Only can remove a COA whose status is 'A1', current COA's status is %1
                        FisException _ex = new FisException("CHK236", new string[] { status.Status });
                        throw _ex;
                    }

                }
                else
                {
                    if (!status.Status.Equals("A0") && !status.Status.Equals("A2") && !status.Status.Equals("A3"))
                    {
                        // Only can remove a COA whose status is 'A0''A2''A3', current COA's status is %1
                        FisException _ex = new FisException("CHK525", new string[] { status.Status });
                        throw _ex;
                    }
                    var cond = new COAReturnInfo();
                    cond.coasn = "coano";
                    /*示例
                    var set = [ICOAStatusRepository Instance].GetCOAReturnInfoList(cond, null);
                    int cnt = (from item in set where item.status == string.Empty select item).Count();*/
                    IList<COAReturnInfo> coareturnlist = coaStatusRepository.GetCOAReturnInfoList(cond, null);
                    if (coareturnlist.Count != 0)
                    {
                        //报告错误:“该COA No 已Scarp!” !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!未改全
                        FisException _ex = new FisException("CHK526", new string[] { });
                        throw _ex;

                    }


                }
                /* 
                 *  Attention: now I think status.IECPN 就是 product 的 SN
                 *             所以,从它来得到 product 对象
                 *             
                 * 3)此COA不可已经与机器绑定并且该机器当前在“85”或“9A”站。否则提示“机器已上栈板或已经出货 !!”
                 * 
                 *   If exists (select a.ProductID from Product a (nolock), 
                 *   Product_Part b (nolock), ProductStatus c (nolock) 
                 *   where a.ProductID=b.ProductID and b.PartSn=@coano and 
                 *   a.ProductID=c.ProductID and (c.Station=’85’ or c.Station=’9A’))
                 * 
                 * IProductRepository::
                 *   bool CheckExistProductByPartSnAndStations(string partSn, string[] stations);
                 * 
                 */
                string partSn = CurrentCOASN;
/////////////////////////////////////////////////////////////////////////

                string productID = "";
                string CUSTSN = "";
                bool first_in = true;

                IMES.FisObject.FA.Product.ProductStatus newStatus = new IMES.FisObject.FA.Product.ProductStatus();
                IList<string> product_list = new List<string>();
                IList<ProductAndCustInfo> product_and_cust_info_list = productRep.GetProductAndCustInfoListByPartSn(partSn);
                foreach (ProductAndCustInfo node in product_and_cust_info_list)
                {
                    if (first_in)
                    {

                        productID = node.productId;
                        IProduct _product = productRep.FindOneProductWithProductIDOrCustSN(productID);
                        CUSTSN = node.custSn;

                        COAReturnInfo cod = new COAReturnInfo();
                        cod.custsn = CUSTSN;
                        IList<COAReturnInfo> reCOAReturnInfo = coaStatusRepository.GetCOAReturnInfoList(cod, null);
                        if (reCOAReturnInfo.Count == 0)
                        {

                            string[] stations = { "85", "9A" };
                            if (productRep.CheckExistProductByPartSnAndStations(partSn, stations) || productRep.CheckExistProductByPartSnAndStationsWithPizzaPart(partSn, stations))
                            {
                                FisException _ex = new FisException("CHK237", new string[] { }); //"Machine has been in stack or out!"
                                throw _ex;
                            }
                        }
                        first_in = false;
                    }
                    break;
                }
                IList<IProduct> pizza_list = productRep.GetProductInfoListByPizzaPartSn(partSn);
                foreach (IProduct node in pizza_list)
                {
                    productID = node.ProId;

                    IProduct _product = productRep.FindOneProductWithProductIDOrCustSN(productID);
                    CUSTSN = node.CUSTSN;

                    COAReturnInfo cod = new COAReturnInfo();
                    cod.custsn = CUSTSN;
                    IList<COAReturnInfo> reCOAReturnInfo = coaStatusRepository.GetCOAReturnInfoList(cod, null);
                    if (reCOAReturnInfo.Count == 0)
                    {

                        string[] stations = { "85", "9A" };
                        if (productRep.CheckExistProductByPartSnAndStations(partSn, stations) || productRep.CheckExistProductByPartSnAndStationsWithPizzaPart(partSn, stations))
                        {
                            FisException _ex = new FisException("CHK237", new string[] { }); //"Machine has been in stack or out!"
                            throw _ex;
                        }
                    }



                    break;
                }
/////////////////////////////////////////////////////////////////////////


                this_array_list_return.Add("OK!");
                this_array_list_return.Add(COANumber);
                this_array_list_return.Add(action);
                this_array_list_return.Add(cause);

                return this_array_list_return;

        }
            catch (FisException e)
            {
                throw e;
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                logger.Debug("(_COARemoval)InputCOANumber end, COANumber:" + COANumber + " pdLine:" + pdLine + " prodId:" + prodId + " editor:" + editor + " stationId:" + stationId + " customerId:" + customerId);
            }
        }