Esempio n. 1
0
        // Added by Icyer 2006/12/15
        // 检查产品
        private Messages CheckProduct(object act, string runningCard)
        {
            // 查询产品信息
            BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider domainProvider = null;
            if ((act as IDCTClient).DBConnection != null)
            {
                domainProvider = (act as IDCTClient).DBConnection as BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider;
            }
            else
            {
                domainProvider = Common.DomainDataProvider.DomainDataProviderManager.DomainDataProvider()
                                 as BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider;
                (act as IDCTClient).DBConnection = domainProvider;
            }

            try
            {
                //为改善性能
                ((SQLDomainDataProvider)domainProvider).PersistBroker.AutoCloseConnection = false;
                ((SQLDomainDataProvider)domainProvider).PersistBroker.OpenConnection();

                ActionOnLineHelper _helper = new ActionOnLineHelper(domainProvider);

                // Added by Icyer 2007/03/16	如果归属工单,则做归属工单检查,否则做序列号途程检查
                UserControl.Messages msgProduct = _helper.GetIDInfo(runningCard);
                ProductInfo          product    = (ProductInfo)msgProduct.GetData().Values[0];
                MO           moWillGo           = null;
                ActionGoToMO actionGoMO         = new ActionGoToMO(domainProvider);
                Messages     msgMo = actionGoMO.GetItemCodeFromGoMoRCard(((IDCTClient)act).ResourceCode, runningCard);
                if (msgMo.IsSuccess() == false)         // 如果有错误,表示需要归属工单,但是解析工单或查询工单发生错误
                {
                    return(msgMo);
                }
                if (msgMo.GetData() != null)    // 需要归属工单,做归属工单检查
                {
                    product.NowSimulation = new BenQGuru.eMES.Domain.DataCollect.Simulation();
                    UserControl.Message msgMoData = msgMo.GetData();
                    moWillGo = (MO)msgMoData.Values[0];
                    moCode   = moWillGo.MOCode;
                    ActionGoToMO          goToMO            = new ActionGoToMO(domainProvider);
                    GoToMOActionEventArgs MOActionEventArgs = new GoToMOActionEventArgs(
                        ActionType.DataCollectAction_GoMO,
                        runningCard,
                        ((IDCTClient)act).LoginedUser,
                        ((IDCTClient)act).ResourceCode,
                        product,
                        moWillGo.MOCode);
                    msgMo = goToMO.CheckIn(MOActionEventArgs);
                    if (!MOActionEventArgs.PassCheck)
                    {
                        msgMo = _helper.CheckID(new CKeypartsActionEventArgs(
                                                    ActionType.DataCollectAction_CollectINNO,
                                                    runningCard,
                                                    ((IDCTClient)act).LoginedUser,
                                                    ((IDCTClient)act).ResourceCode,
                                                    product, null, null));
                    }
                }
                else    // 不需要归属工单,检查序列号途程
                {
                    if (product == null || product.LastSimulation == null)
                    {
                        msgProduct.ClearMessages();
                        msgProduct.Add(new UserControl.Message(MessageType.Error, "$NoSimulation"));
                        return(msgProduct);
                    }
                    msgMo = _helper.CheckID(new CKeypartsActionEventArgs(
                                                ActionType.DataCollectAction_CollectINNO,
                                                runningCard,
                                                ((IDCTClient)act).LoginedUser,
                                                ((IDCTClient)act).ResourceCode,
                                                product, null, null));
                }
                if (msgMo.IsSuccess() == false)
                {
                    return(msgMo);
                }
                // Added end

                keypartsHT = new Hashtable();
                keypartsHT.Add("ProdcutInfo", product);
                keypartsHT.Add("MOWillGo", moWillGo);

                IDCTClient  client       = act as IDCTClient;
                OPBOMFacade opBOMFacade  = new OPBOMFacade(domainProvider);
                MOFacade    moFacade     = new MOFacade(domainProvider);
                object[]    objBomDetail = null;
                Messages    messages1    = new Messages();
                if (moWillGo == null)
                {
                    // 检查途程
                    messages1 = _helper.CheckID(
                        new CKeypartsActionEventArgs(
                            ActionType.DataCollectAction_CollectINNO,
                            product.LastSimulation.RunningCard,
                            client.LoginedUser,
                            client.ResourceCode,
                            product,
                            null,
                            null));
                }
                if (messages1.IsSuccess() == true)
                {
                    //objBomDetail = opBOMFacade.GetOPBOMDetails(
                    //    product.NowSimulation.MOCode,
                    //    product.NowSimulation.RouteCode,
                    //    product.NowSimulation.OPCode);

                    //Miodified by Scott
                    MO moNew = (MO)moFacade.GetMO(product.NowSimulation.MOCode);

                    objBomDetail = opBOMFacade.QueryOPBOMDetail(product.NowSimulation.ItemCode, string.Empty, string.Empty, moNew.BOMVersion,
                                                                product.NowSimulation.RouteCode, product.NowSimulation.OPCode, (int)MaterialType.CollectMaterial,
                                                                int.MinValue, int.MaxValue, moNew.OrganizationID, true);

                    if (objBomDetail == null)
                    {
                        messages1.Add(new UserControl.Message(MessageType.Error, "$CS_OPBOM_NotFound"));
                    }
                }
                else
                {
                    return(messages1);
                }

                //object mo = moFacade.GetMO( product.LastSimulation.MOCode );
                object mo = moWillGo;
                if (moWillGo == null)
                {
                    mo = moFacade.GetMO(product.LastSimulation.MOCode);
                }

                //OPBomKeyparts opBomKeyparts = new OPBomKeyparts(objBomDetail, Convert.ToInt32(((MO)mo).IDMergeRule), domainProvider);
                // 查询OPBOM
                if (objBomDetail == null)
                {
                    msgProduct.Add(new Message(MessageType.Error, "$CS_NOOPBomInfo $CS_Param_MOCode=" + product.NowSimulation.MOCode
                                               + " $CS_Param_RouteCode=" + product.NowSimulation.RouteCode
                                               + " $CS_Param_OPCode =" + product.NowSimulation.OPCode));
                    return(msgProduct);
                }
                else
                {
                    this.filterOpBomDetail(ref objBomDetail);

                    if (objBomDetail == null || objBomDetail.Length <= 0)
                    {
                        msgProduct.Add(new Message(MessageType.Error, "$CS_OPBOM_NotFound"));
                        return(msgProduct);
                    }

                    for (int i = 0; i < objBomDetail.Length; i++)
                    {
                        if (((OPBOMDetail)objBomDetail[i]).OPBOMItemControlType == "item_control_lot")
                        {
                            opBomDetailCount += 1;
                        }
                        else
                        {
                            opBomDetailCount += Convert.ToInt32(((OPBOMDetail)objBomDetail[i]).OPBOMItemQty);
                        }
                    }
                    for (int i = 0; i < objBomDetail.Length; i++)
                    {
                        if (((OPBOMDetail)objBomDetail[i]).OPBOMItemControlType == "item_control_lot")
                        {
                            opBomDetailList.Add(objBomDetail[i]);
                        }
                        else
                        {
                            int number = Convert.ToInt32(((OPBOMDetail)objBomDetail[i]).OPBOMItemQty);
                            for (int j = 0; j < number; j++)
                            {
                                opBomDetailList.Add(objBomDetail[i]);
                            }
                        }
                    }

                    if (((OPBOMDetail)objBomDetail[0]).OPBOMItemControlType == BOMItemControlType.ITEM_CONTROL_LOT)
                    {
                        msgProduct.Add(new UserControl.Message(MessageType.Normal, ">>$DCT_PLEASE_INPUT_Lot " + ((OPBOMDetail)objBomDetail[0]).OPBOMSourceItemCode));
                    }
                    else
                    {
                        msgProduct.Add(new UserControl.Message(MessageType.Normal, ">>$DCT_PLEASE_INPUT_Keyparts " + ((OPBOMDetail)objBomDetail[0]).OPBOMSourceItemCode));
                    }
                    // keypartsHT.Add("KeypartsInfo", opBomKeyparts);
                    keypartsHT.Add("Opbomdetail", objBomDetail);
                }
                return(msgProduct);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                ((SQLDomainDataProvider)domainProvider).PersistBroker.CloseConnection();
                ((SQLDomainDataProvider)domainProvider).PersistBroker.AutoCloseConnection = true;
            }
        }
Esempio n. 2
0
        // Added by Icyer 2006/12/15
        // 检查产品
        private Messages CheckProduct(object act, string runningCard)
        {
            // 查询产品信息
            BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider domainProvider = null;
            if ((act as IDCTClient).DBConnection != null)
            {
                domainProvider = (act as IDCTClient).DBConnection as BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider;
            }
            else
            {
                domainProvider = Common.DomainDataProvider.DomainDataProviderManager.DomainDataProvider()
                                 as BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider;
                (act as IDCTClient).DBConnection = domainProvider;
            }

            ActionOnLineHelper _helper = new ActionOnLineHelper(domainProvider);

            /*	Removed by Icyer 2007/03/16
             * UserControl.Messages msgProduct =  _helper.GetIDInfo( runningCard ) ;
             * ProductInfo product= (ProductInfo)msgProduct.GetData().Values[0];
             * if (product == null || product.LastSimulation == null)
             * {
             *      msgProduct.ClearMessages();
             *      msgProduct.Add(new UserControl.Message(MessageType.Error, "$NoSimulation"));
             *      return msgProduct;
             * }
             */

            // Added by Icyer 2007/03/16	如果归属工单,则做归属工单检查,否则做序列号途程检查
            UserControl.Messages msgProduct = _helper.GetIDInfo(runningCard);
            ProductInfo          product    = (ProductInfo)msgProduct.GetData().Values[0];
            MO           moWillGo           = null;
            ActionGoToMO actionGoMO         = new ActionGoToMO(domainProvider);
            Messages     msgMo = actionGoMO.GetItemCodeFromGoMoRCard(((IDCTClient)act).ResourceCode, runningCard);

            if (msgMo.IsSuccess() == false)                     // 如果有错误,表示需要归属工单,但是解析工单或查询工单发生错误
            {
                return(msgMo);
            }
            if (msgMo.GetData() != null)                // 需要归属工单,做归属工单检查
            {
                product.NowSimulation = new BenQGuru.eMES.Domain.DataCollect.Simulation();
                UserControl.Message msgMoData = msgMo.GetData();
                moWillGo = (MO)msgMoData.Values[0];
                ActionGoToMO          goToMO            = new ActionGoToMO(domainProvider);
                GoToMOActionEventArgs MOActionEventArgs = new GoToMOActionEventArgs(
                    ActionType.DataCollectAction_GoMO,
                    runningCard,
                    ((IDCTClient)act).LoginedUser,
                    ((IDCTClient)act).ResourceCode,
                    product,
                    moWillGo.MOCode);
                msgMo = goToMO.CheckIn(MOActionEventArgs);
                if (!MOActionEventArgs.PassCheck)
                {
                    msgMo = _helper.CheckID(new CKeypartsActionEventArgs(
                                                ActionType.DataCollectAction_CollectKeyParts,
                                                runningCard,
                                                ((IDCTClient)act).LoginedUser,
                                                ((IDCTClient)act).ResourceCode,
                                                product, null, null));
                }
            }
            else                // 不需要归属工单,检查序列号途程
            {
                if (product == null || product.LastSimulation == null)
                {
                    msgProduct.ClearMessages();
                    msgProduct.Add(new UserControl.Message(MessageType.Error, "$NoSimulation"));
                    return(msgProduct);
                }
                msgMo = _helper.CheckID(new CKeypartsActionEventArgs(
                                            ActionType.DataCollectAction_CollectKeyParts,
                                            runningCard,
                                            ((IDCTClient)act).LoginedUser,
                                            ((IDCTClient)act).ResourceCode,
                                            product, null, null));
            }
            if (msgMo.IsSuccess() == false)
            {
                return(msgMo);
            }
            // Added end

            keypartsHT = new Hashtable();
            keypartsHT.Add("ProdcutInfo", msgProduct);
            keypartsHT.Add("MOWillGo", moWillGo);

            IDCTClient  client      = act as IDCTClient;
            OPBOMFacade opBOMFacade = new OPBOMFacade(domainProvider);

            object[] objBomDetail = null;
            Messages messages1    = new Messages();

            if (moWillGo == null)
            {
                // 检查途程
                messages1 = _helper.CheckID(
                    new CKeypartsActionEventArgs(
                        ActionType.DataCollectAction_CollectKeyParts,
                        product.LastSimulation.RunningCard,
                        client.LoginedUser,
                        client.ResourceCode,
                        product,
                        null,
                        null));
            }
            if (messages1.IsSuccess() == true)
            {
                objBomDetail = opBOMFacade.GetOPBOMDetails(
                    product.NowSimulation.MOCode,
                    product.NowSimulation.RouteCode,
                    product.NowSimulation.OPCode);
            }
            else
            {
                return(messages1);
            }

            MOFacade moFacade = new MOFacade(domainProvider);
            //object mo = moFacade.GetMO( product.LastSimulation.MOCode );
            object mo = moWillGo;

            if (moWillGo == null)
            {
                mo = moFacade.GetMO(product.LastSimulation.MOCode);
            }

            // 查询OPBOM
            OPBomKeyparts opBomKeyparts = new OPBomKeyparts(objBomDetail, Convert.ToInt32(((MO)mo).IDMergeRule), domainProvider);

            if (opBomKeyparts.Count == 0)
            {
                msgProduct.Add(new Message(MessageType.Error, "$CS_NOOPBomInfo $CS_Param_MOCode=" + product.NowSimulation.MOCode
                                           + " $CS_Param_RouteCode=" + product.NowSimulation.RouteCode
                                           + " $CS_Param_OPCode =" + product.NowSimulation.OPCode));
                return(msgProduct);
            }
            else
            {
                this.OutMesssage = new UserControl.Message(MessageType.Normal, "$DCT_PLEASE_INPUT_Keyparts " + (opBomKeyparts.GetbomKeypartCount() + 1).ToString() + "/" + opBomKeyparts.Count.ToString());
                keypartsHT.Add("KeypartsInfo", opBomKeyparts);
            }
            return(msgProduct);
        }