// Added end

        public override Messages Action(object act)
        {
            Messages           msg     = new Messages();
            ActionOnLineHelper _helper = null;

            BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider domainProvider = null;

            if (act == null)
            {
                return(msg);
            }

            DataCollect.Action.ActionEventArgs args;
            if (ObjectState == null)
            {
                args             = new BenQGuru.eMES.DataCollect.Action.ActionEventArgs();
                args.RunningCard = act.ToString().ToUpper().Trim();
            }
            else
            {
                args = ObjectState as DataCollect.Action.ActionEventArgs;
            }

            string data = act.ToString().ToUpper().Trim();            //Keyparts

            //Laws Lu,2006/06/03	添加	获取已有连接
            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;
            }


            msg = CheckData(data, domainProvider);

            if (keypartsHT == null)
            {
                // 按照逻辑,走到这个分支应该是错误的
                string strFile = @"C:\DCT_EmptyMessage.txt";
                string strLine = DateTime.Now.ToString("yyyy-MM-dd HH:mi:ss") + "\t" + "ActionCollectKeyParts" + "\t" + "Missing Product In Action, RunningCard:" + args.RunningCard + ",Input:" + data;
                System.IO.StreamWriter writer = new System.IO.StreamWriter(strFile, true);
                writer.WriteLine(strLine);
                writer.Close();
                //
                if (msg.IsSuccess() &&
                    (keypartsHT == null || keypartsHT.ContainsKey("ProdcutInfo") == false))
                {
                    //检查序列号
                    _helper = new ActionOnLineHelper(domainProvider);
                    msg     = _helper.GetIDInfo(args.RunningCard);
                    // Added by Icyer 2006/12/14
                    // 检查序列号
                    ProductInfo product = (ProductInfo)msg.GetData().Values[0];
                    if (product == null || product.LastSimulation == null)
                    {
                        msg.ClearMessages();
                        msg.Add(new Message(MessageType.Error, "$NoSimulation"));
                    }
//					base.Action (act);
//					ActionCollectKeyparts actionCollectKeyparts = this;
//					this.NextAction = actionCollectKeyparts;
//					this.Status = ActionStatus.PrepareData;
//					return msg;
                    // Added end
                }

                if (msg.IsSuccess() &&
                    (keypartsHT == null || keypartsHT.ContainsKey("KeypartsInfo") == false))
                {
                    try
                    {
                        keypartsHT = new Hashtable();
                        keypartsHT.Add("ProdcutInfo", msg);

                        ProductInfo product = (ProductInfo)msg.GetData().Values[0];

                        /*	Removed by Icyer 2006/12/14
                         * 如果序列号已在本上料工序,则GetMORouteNextOperation会取下一个工序,导致找不到OPBOM
                         * 改变推导OPBOM的逻辑
                         * ItemFacade itemFacade = new ItemFacade(domainProvider);
                         * object op = itemFacade.GetMORouteNextOperation(
                         *      product.LastSimulation.MOCode,
                         *      product.LastSimulation.RouteCode,
                         *      product.LastSimulation.OPCode);
                         *
                         * OPBOMFacade opBOMFacade=new OPBOMFacade( domainProvider);
                         * object[] objBomDetail = opBOMFacade.GetOPBOMDetails(
                         *      product.LastSimulation.MOCode,
                         *      product.LastSimulation.RouteCode,
                         *      (op as ItemRoute2OP).OPCode);
                         */
                        // Added by Icyer 2006/12/14
                        IDCTClient  client       = act as IDCTClient;
                        OPBOMFacade opBOMFacade  = new OPBOMFacade(domainProvider);
                        object[]    objBomDetail = null;
                        DataCollect.ActionOnLineHelper onLine = new ActionOnLineHelper(domainProvider);
                        Messages messages1 = onLine.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
                        {
                            throw new Exception(messages1.OutPut());
                        }
                        // Added end

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

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

                        if (opBomKeyparts.Count == 0)
                        {
                            /*	Removed by Icyer 2006/12/27 @ YHI
                             * msg.Add(new Message(MessageType.Error, "$CS_NOOPBomInfo $CS_Param_MOCode="+product.LastSimulation.MOCode
                             +" $CS_Param_RouteCode="+product.LastSimulation.RouteCode
                             +" $CS_Param_OPCode ="+product.LastSimulation.OPCode));
                             * throw new Exception(msg.OutPut());
                             */
                            throw new Exception("$CS_NOOPBomInfo");
                        }
                        else
                        {
                            //opBomKeyparts.AddKeyparts(data, product.LastSimulation.MOCode);	// Removed by Icyer 2006/12/14

                            keypartsHT.Add("KeypartsInfo", opBomKeyparts);
                        }
                    }
                    catch (Exception ex)
                    {
                        /*	Removed by Icyer 2006/12/27 @ YHI
                         * keypartsHT = null;
                         * this.NeedCancel = true;
                         * throw ex;
                         */
                        // Added by Icyer 2006/12/27 @ YHI
                        base.Action(act);
                        ActionCollectKeyparts actionCollectKeyparts = this;
                        this.NextAction = actionCollectKeyparts;
                        this.Status     = ActionStatus.PrepareData;
                        msg.ClearMessages();
                        msg.Add(new UserControl.Message(MessageType.Error, ex.Message));
                        msg.Add(new UserControl.Message(MessageType.Normal, "$DCT_PLEASE_INPUT_Keyparts"));
                        return(msg);
                        // Added end
                    }
                }
            }

            if (msg.IsSuccess())
            {
                OPBomKeyparts opBomKeyparts = (OPBomKeyparts)keypartsHT["KeypartsInfo"];
                msg = keypartsHT["ProdcutInfo"] as Messages;
                MO moWillGo = (MO)keypartsHT["MOWillGo"];

                ProductInfo product = (ProductInfo)msg.GetData().Values[0];

                Messages msgResult = new Messages();
                if (opBomKeyparts.Count > opBomKeyparts.GetbomKeypartCount())
                {
                    try
                    {
                        //opBomKeyparts.AddKeyparts(data, product.LastSimulation.MOCode);
                        if (moWillGo == null)
                        {
                            msgResult.AddMessages(opBomKeyparts.AddKeyparts(data, product.LastSimulation.MOCode));
                        }
                        else
                        {
                            msgResult.AddMessages(opBomKeyparts.AddKeyparts(data, moWillGo.MOCode));
                        }
                    }
                    catch (Exception ex)
                    {
                        msgResult.Add(new UserControl.Message(MessageType.Error, ex.Message));
                    }

                    keypartsHT["KeypartsInfo"] = opBomKeyparts;
                }

                if (msgResult.IsSuccess() == false || opBomKeyparts.Count > opBomKeyparts.GetbomKeypartCount())
                {
                    base.Action(act);
                    ActionCollectKeyparts actionCollectKeyparts = this;
                    this.NextAction = actionCollectKeyparts;

                    this.Status = ActionStatus.PrepareData;

                    this.OutMesssage = new UserControl.Message(MessageType.Normal, "$DCT_PLEASE_INPUT_Keyparts " + (opBomKeyparts.GetbomKeypartCount() + 1).ToString() + "/" + opBomKeyparts.Count.ToString());
                    if (msgResult.IsSuccess() == false)
                    {
                        //msgResult.Add(new UserControl.Message(MessageType.Normal, "$DCT_PLEASE_INPUT_Keyparts"));
                        return(msgResult);
                    }
                    else
                    {
                        return(msg);
                    }
                }

                //((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)domainProvider).PersistBroker.OpenConnection();
                domainProvider.BeginTransaction();
                try
                {
                    BenQGuru.eMES.BaseSetting.BaseModelFacade dataModel = new BenQGuru.eMES.BaseSetting.BaseModelFacade(domainProvider);
                    Resource resource = (Resource)dataModel.GetResource(args.ResourceCode);

                    _helper = new ActionOnLineHelper(domainProvider);
                    DataCollectFacade dataCollect       = new DataCollect.DataCollectFacade(domainProvider);
                    ActionCheckStatus actionCheckStatus = new ActionCheckStatus();
                    actionCheckStatus.ProductInfo          = product;
                    actionCheckStatus.ProductInfo.Resource = resource;
                    ExtendSimulation lastSimulation = actionCheckStatus.ProductInfo.LastSimulation;

                    BenQGuru.eMES.Material.WarehouseFacade wfacade = null;
                    if (System.Configuration.ConfigurationSettings.AppSettings["NeedMaterialModule"].Trim() == "1")
                    {
                        wfacade = new WarehouseFacade(domainProvider);
                    }

                    IDCTClient client = act as IDCTClient;

                    msg.AddMessages(_helper.ActionWithTransaction(
                                        new CKeypartsActionEventArgs(
                                            ActionType.DataCollectAction_CollectKeyParts,
                                            product.NowSimulation.RunningCard,
                                            client.LoginedUser,
                                            client.ResourceCode,
                                            product,
                                            opBomKeyparts,
                                            wfacade), actionCheckStatus));

                    // Added by Icyer 2006/12/28 @ YHI	采集集成上料
                    bool bLoadedINNO = false;
                    if (this.NeedCollectINNO == true && msg.IsSuccess() == true)
                    {
                        string strRCard = product.NowSimulation.RunningCard;
                        UserControl.Messages msgProduct = _helper.GetIDInfo(strRCard);
                        product = (ProductInfo)msgProduct.GetData().Values[0];
                        CINNOActionEventArgs argsInno = new CINNOActionEventArgs(
                            ActionType.DataCollectAction_CollectINNO,
                            strRCard,
                            client.LoginedUser,
                            client.ResourceCode,
                            product,
                            INNOCode,
                            wfacade
                            );
                        IAction action = new BenQGuru.eMES.DataCollect.Action.ActionFactory(domainProvider).CreateAction(ActionType.DataCollectAction_CollectINNO);
                        msg.AddMessages(action.Execute(argsInno));
                        if (msg.IsSuccess() == true)
                        {
                            bLoadedINNO = true;
                            msg.Add(new UserControl.Message(MessageType.Success, string.Format("$CS_INNO_CollectSuccess[" + this.INNOCode + "] $CS_Keyparts_CollectSuccess")));
                        }
                    }
                    // Added end
                    if (msg.IsSuccess())
                    {
                        if (System.Configuration.ConfigurationSettings.AppSettings["NeedMaterialModule"].Trim() == "1")
                        {
                            if (wfacade != null)
                            {
                                wfacade.ExecCacheSQL();
                            }
                        }

                        domainProvider.CommitTransaction();
                        if (bLoadedINNO == false)
                        {
                            msg.Add(new UserControl.Message(MessageType.Success, string.Format("$CS_Keyparts_CollectSuccess")));
                        }
                    }
                    else
                    {
                        domainProvider.RollbackTransaction();
                    }
                }
                catch (Exception ex)
                {
                    domainProvider.RollbackTransaction();

                    msg.Add(new UserControl.Message(ex));
                }
                finally
                {
                    ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)domainProvider).PersistBroker.CloseConnection();
                }
                base.Action(act);
                ActionRCard actRcard1 = new ActionRCard();
                actRcard1.OutMesssage = new UserControl.Message(MessageType.Normal, "$CS_Please_Input_RunningCard");
                this.NextAction       = actRcard1;
                this.ObjectState      = null;
                this.keypartsHT       = null;
                this.Status           = ActionStatus.PrepareData;
                return(msg);
            }

            base.Action(act);

            //Web.Helper.ActionType acttype = new Web.Helper.ActionType();
//			if(acttype.Items.Contains(args.RunningCard))
//			{
//				(act as IDCTClient).CachedAction = null;
//			}

            ActionRCard actRcard = new ActionRCard();

            actRcard.OutMesssage = new UserControl.Message(MessageType.Normal, "$CS_Please_Input_RunningCard");
            this.NextAction      = actRcard;
            // Added by Icyer 2006/12/14
            this.ObjectState = null;
            this.keypartsHT  = null;
            this.Status      = ActionStatus.PrepareData;
            // Added end

            return(msg);
        }
Exemple #2
0
        public override Messages Action(object act)
        {
            Messages msg = new Messages();

            BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider domainProvider = null;

            if (act == null)
            {
                return(msg);
            }

            if (currentProductInfo == null)
            {
                return(msg);
            }

            DataCollect.Action.ActionEventArgs args;
            if (ObjectState == null)
            {
                args = new BenQGuru.eMES.DataCollect.Action.ActionEventArgs();
            }
            else
            {
                args = ObjectState as DataCollect.Action.ActionEventArgs;
            }

            string data = act.ToString().ToUpper().Trim();            //Errorcode

            //Laws Lu,2006/06/03	添加	获取已有连接
            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;
            }


            if (string.Compare(data, BaseDCTDriver.FINERROR, true) != 0)//结束的标志
            {
                msg = CheckData(data, domainProvider);

                if (msg.IsSuccess())
                {
                    if (errorCodesHT == null)
                    {
                        errorCodesHT = new Hashtable();
                    }

                    bool bExist = false;
                    if (!errorCodesHT.ContainsKey(data))
                    {
                        errorCodesHT.Add(data, data);
                    }
                    else
                    {
                        bExist = true;
                    }

                    if (bExist == false)
                    {
                        //msg.Add(new UserControl.Message(MessageType.Succes,data));	// Removed by Icyer 2007/01/09	避免重复输出
                    }
                    else
                    {
                        msg.Add(new UserControl.Message(MessageType.Success, "$ErrorCodeCollected"));
                    }
                    this.Status = ActionStatus.PrepareData;
                    return(msg);
                }
                else
                {
                    this.Status = ActionStatus.PrepareData;
                    return(msg);
                }
            }


            if (msg.IsSuccess())
            {
                //检查序列号

                ActionOnLineHelper _helper = new ActionOnLineHelper(domainProvider);

                msg = _helper.GetIDInfo(args.RunningCard);

                if (msg.IsSuccess())
                {
                    ProductInfo product = (ProductInfo)msg.GetData().Values[0];

                    TSModelFacade tsmodelFacade = new TSModelFacade(domainProvider);

                    if (errorCodesHT == null)
                    {
                        msg.Add(new UserControl.Message(UserControl.MessageType.Error, "$ErrorCode_Not_Exist"));
                    }

                    if (msg.IsSuccess())
                    {
                        string[] errorcs = new string[errorCodesHT.Count];
                        int      i       = 0;
                        foreach (DictionaryEntry dic in errorCodesHT)
                        {
                            errorcs[i] = dic.Key.ToString();
                            i++;
                        }

                        /*	Removed by Icyer 2007/03/15		允许自动归属工单
                         * //Laws Lu,2006/06/22 modify fix the bug that system alert object not set an instance when the product.LastSimulation is null
                         * if(product.LastSimulation == null)
                         * {
                         *      msg.Add(new UserControl.Message(UserControl.MessageType.Error,"$NoSimulation"));
                         * }
                         */
                        object[] errorcodes = null;
                        if (msg.IsSuccess())
                        {
                            //errorcodes = tsmodelFacade.QueryECG2ECByECAndModelCode(errorcs, product.LastSimulation.ModelCode);
                            string strModelCode = this.GetModelCodeFromProduct(product, this.moWillGo, domainProvider);
                            if (strModelCode != "")
                            {
                                errorcodes = tsmodelFacade.QueryECG2ECByECAndModelCode(errorcs, strModelCode);
                            }

                            if (errorcodes == null || errorcodes.Length == 0)
                            {
                                msg.Add(new UserControl.Message(UserControl.MessageType.Error, "$ErrorCode_Not_BelongTo_ModelCode"));
                                this.Status = ActionStatus.PrepareData;
                                return(msg);
                            }
                        }

                        if (msg.IsSuccess())
                        {
                            IAction dataCollectModule
                                = new BenQGuru.eMES.DataCollect.Action.ActionFactory(domainProvider).CreateAction(ActionType.DataCollectAction_NG);

                            //((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)domainProvider).PersistBroker.OpenConnection();
                            domainProvider.BeginTransaction();
                            try
                            {
                                IDCTClient client = act as IDCTClient;

                                msg.AddMessages(((IActionWithStatus)dataCollectModule).Execute(
                                                    new TSActionEventArgs(ActionType.DataCollectAction_NG,
                                                                          args.RunningCard,
                                                                          client.LoginedUser,
                                                                          client.ResourceCode,
                                                                          product,
                                                                          errorcodes,
                                                                          null,
                                                                          "")));

                                if (msg.IsSuccess())
                                {
                                    domainProvider.CommitTransaction();
                                    msg.Add(new UserControl.Message(MessageType.Success, string.Format("$CS_NGSUCCESS")));

                                    //msg.Add( new UserControl.Message(MessageType.Succes ,string.Format("$CS_NGSUCCESS,$CS_Param_ID: {0}", args.RunningCard)));
                                }
                                else
                                {
                                    domainProvider.RollbackTransaction();
                                }
                            }
                            catch (Exception ex)
                            {
                                domainProvider.RollbackTransaction();

                                msg.Add(new UserControl.Message(ex));
                            }
                            finally
                            {
                                ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)domainProvider).PersistBroker.CloseConnection();
                            }
                        }
                    }
                }
            }

            //if((act as IDCTClient).CachedAction is ActionCollectNG)
            //{
            //    if(this.Status == BenQGuru.eMES.Common.DCT.Core.ActionStatus.Working)
            //    {
            //        this.ObjectState = null;
            //        if(this.errorCodesHT != null)
            //        {
            //            this.errorCodesHT.Clear();
            //        }
            //    }

            //    this.Status = BenQGuru.eMES.Common.DCT.Core.ActionStatus.PrepareData;


            //    (act as IDCTClient).CachedAction = this;
            //}
            if (this.errorCodesHT == null)
            {
                msg.ClearMessages();
            }
            if (msg.IsSuccess() || this.errorCodesHT == null)
            {
                base.Action(act);
            }
            else
            {
                msg.Add(new UserControl.Message(MessageType.Normal, "$DCT_NG_Please_Input_NG_SN"));
                this.Status     = ActionStatus.PrepareData;
                this.FlowDirect = FlowDirect.WaitingInput;
            }
            currentProductInfo = null;
            moWillGo           = null;
            this.ObjectState   = null;
            if (this.errorCodesHT != null)
            {
                this.errorCodesHT.Clear();
            }
            return(msg);
        }
        public override Messages Action(object act)
        {
            Messages msg = new Messages();

            BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider domainProvider = null;


            if (act == null)
            {
                return(msg);
            }

            DataCollect.Action.ActionEventArgs args;
            if (ObjectState == null)
            {
                args             = new BenQGuru.eMES.DataCollect.Action.ActionEventArgs();
                args.RunningCard = act.ToString().ToUpper().Trim();
            }
            else
            {
                args = ObjectState as DataCollect.Action.ActionEventArgs;
            }

            //Laws Lu,2006/06/03	添加	获取已有连接
            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;
            }


            if (msg.IsSuccess())
            {
                //检查序列号
                ActionOnLineHelper _helper = new ActionOnLineHelper(domainProvider);

                msg = _helper.GetIDInfo(args.RunningCard);

                if (msg.IsSuccess())
                {
                    ProductInfo product = (ProductInfo)msg.GetData().Values[0];

                    if (product.LastSimulation == null)
                    {
                        msg.Add(new UserControl.Message(UserControl.MessageType.Error, "$NoSimulation"));
                    }

                    object[] oplist = null;
                    if (msg.IsSuccess())
                    {
                        oplist = GetOutLineOP(domainProvider, (act as IDCTClient).ResourceCode);

                        if (oplist == null || oplist.Length == 0)
                        {
                            msg.Add(new UserControl.Message(MessageType.Error, "$CSError_Res_Cannot_Collect_OUtlineGood"));
                        }
                    }
                    string opcode = string.Empty;

                    if (msg.IsSuccess())
                    {
                        opcode = (oplist[0] as Operation).OPCode;
                        if (CheckOutlineOPInRoute(domainProvider, product.LastSimulation.RouteCode, opcode))
                        {
                            msg.Add(new UserControl.Message(MessageType.Error, "$CS_OutLineOP_In_ThisRoute"));
                        }
                    }

                    if (msg.IsSuccess())
                    {
                        if (IsLastOP(domainProvider, product.LastSimulation.MOCode, product.LastSimulation.RouteCode, product.LastSimulation.OPCode))
                        {
                            msg.Add(new UserControl.Message(MessageType.Error, "$CS_Op_IsLast_OutLineOP_Cannot_Collect"));
                        }
                    }
                    if (msg.IsSuccess())
                    {
                        //((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)Common.DomainDataProvider.DomainDataProviderManager.DomainDataProvider()).PersistBroker.OpenConnection();
                        domainProvider.BeginTransaction();
                        try
                        {
                            IDCTClient client = act as IDCTClient;

                            IAction dataCollectModule = new BenQGuru.eMES.DataCollect.Action.ActionFactory(domainProvider).CreateAction(ActionType.DataCollectAction_OutLineGood);

                            msg.AddMessages((dataCollectModule).Execute(new OutLineActionEventArgs(
                                                                            ActionType.DataCollectAction_OutLineGood,
                                                                            args.RunningCard,
                                                                            client.LoginedUser,
                                                                            client.ResourceCode,
                                                                            product,
                                                                            opcode)));

                            if (msg.IsSuccess())
                            {
                                domainProvider.CommitTransaction();
                                msg.Add(new UserControl.Message(MessageType.Success, string.Format("$CS_GOODSUCCESS")));
                            }
                            else
                            {
                                domainProvider.RollbackTransaction();
                            }
                        }
                        catch (Exception ex)
                        {
                            domainProvider.RollbackTransaction();

                            msg.Add(new UserControl.Message(ex));
                        }
                        finally
                        {
                            ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)domainProvider).PersistBroker.CloseConnection();
                        }
                    }
                }
            }

            base.Action(act);
//
//			Web.Helper.ActionType acttype = new Web.Helper.ActionType();
//			if(acttype.Items.Contains(args.RunningCard))
//			{
//				(act as IDCTClient).CachedAction = null;
//			}
//

            ActionRCard actRcard = new ActionRCard();

            this.NextAction = actRcard;



            return(msg);
        }
Exemple #4
0
        public override Messages Action(object act)
        {
            Messages msg = new Messages();

            BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider domainProvider = null;

            if (act == null)
            {
                return(msg);
            }

            DataCollect.Action.ActionEventArgs args;
            if (ObjectState == null)
            {
                args = new BenQGuru.eMES.DataCollect.Action.ActionEventArgs();
            }
            else
            {
                args = ObjectState as DataCollect.Action.ActionEventArgs;
            }

            string data = act.ToString().ToUpper().Trim();            //Errorcode

            //Laws Lu,2006/06/03	添加	获取已有连接
            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;
            }


            if (string.Compare(data, BaseDCTDriver.FINERROR, true) != 0)           //结束的标志
            {
                msg = CheckData(data, domainProvider);

                if (msg.IsSuccess())
                {
                    if (errorCodesHT == null)
                    {
                        errorCodesHT = new Hashtable();
                    }

                    if (!errorCodesHT.ContainsKey(data))
                    {
                        errorCodesHT.Add(data, data);
                    }

                    base.Action(act);
                    ActionCollectOutlineNG actionCollectOutlineNG = this;

                    actionCollectOutlineNG.IsTopAction = false;
                    this.NextAction = actionCollectOutlineNG;
                    this.Status     = ActionStatus.PrepareData;
                    //Laws Lu,2006/07/11 write back error code
                    msg.Add(new UserControl.Message(MessageType.Success, data));

                    return(msg);
                }
            }

            if (msg.IsSuccess())
            {
                //检查序列号

                ActionOnLineHelper _helper = new ActionOnLineHelper(domainProvider);

                msg = _helper.GetIDInfo(args.RunningCard);

                if (msg.IsSuccess())
                {
                    ProductInfo product = (ProductInfo)msg.GetData().Values[0];

                    TSModelFacade tsmodelFacade = new TSModelFacade(domainProvider);

                    if (errorCodesHT == null)
                    {
                        msg.Add(new UserControl.Message(UserControl.MessageType.Error, "$ErrorCode_Not_Exist"));
                    }

                    if (msg.IsSuccess())
                    {
                        string[] errorcs = new string[errorCodesHT.Count];
                        int      i       = 0;
                        foreach (DictionaryEntry dic in errorCodesHT)
                        {
                            errorcs[i] = dic.Key.ToString();
                            i++;
                        }
                        //Laws Lu,2006/06/22 modify fix the bug that system alert object not set an instance when the product.LastSimulation is null
                        if (product.LastSimulation == null)
                        {
                            msg.Add(new UserControl.Message(UserControl.MessageType.Error, "$NoSimulation"));
                        }
                        object[] errorcodes = null;
                        if (msg.IsSuccess())
                        {
                            errorcodes = tsmodelFacade.QueryECG2ECByECAndModelCode(errorcs, product.LastSimulation.ModelCode);

                            if (errorcodes == null || errorcodes.Length == 0)
                            {
                                msg.Add(new UserControl.Message(UserControl.MessageType.Error, "$ErrorCode_Not_BelongTo_ModelCode"));
                            }
                        }

                        object[] oplist = null;
                        if (msg.IsSuccess())
                        {
                            oplist = GetOutLineOP(domainProvider, (act as IDCTClient).ResourceCode);

                            if (oplist == null || oplist.Length == 0)
                            {
                                msg.Add(new UserControl.Message(MessageType.Error, "$CSError_Res_Cannot_Collect_OUtlineGood"));
                            }
                        }

                        string opcode = string.Empty;
                        if (msg.IsSuccess())
                        {
                            opcode = (oplist[0] as Operation).OPCode;
                            if (CheckOutlineOPInRoute(domainProvider, product.LastSimulation.RouteCode, opcode))
                            {
                                msg.Add(new UserControl.Message(MessageType.Error, "$CS_OutLineOP_In_ThisRoute"));
                            }
                        }

                        if (msg.IsSuccess())
                        {
                            if (IsLastOP(domainProvider, product.LastSimulation.MOCode, product.LastSimulation.RouteCode, product.LastSimulation.OPCode))
                            {
                                msg.Add(new UserControl.Message(MessageType.Error, "$CS_Op_IsLast_OutLineOP_Cannot_Collect"));
                            }
                        }

                        if (msg.IsSuccess())
                        {
                            IAction dataCollectModule
                                = new BenQGuru.eMES.DataCollect.Action.ActionFactory(domainProvider).CreateAction(ActionType.DataCollectAction_OutLineNG);

                            domainProvider.BeginTransaction();
                            try
                            {
                                IDCTClient client = act as IDCTClient;

                                msg.AddMessages((dataCollectModule).Execute(new OutLineActionEventArgs(
                                                                                ActionType.DataCollectAction_OutLineNG,
                                                                                args.RunningCard,
                                                                                client.LoginedUser,
                                                                                client.ResourceCode,
                                                                                product,
                                                                                opcode,
                                                                                errorcodes,
                                                                                "")));

                                if (msg.IsSuccess())
                                {
                                    domainProvider.CommitTransaction();
                                    msg.Add(new UserControl.Message(MessageType.Success, string.Format("$CS_NGSUCCESS")));

                                    //msg.Add( new UserControl.Message(MessageType.Succes ,string.Format("$CS_NGSUCCESS,$CS_Param_ID: {0}", args.RunningCard)));
                                }
                                else
                                {
                                    domainProvider.RollbackTransaction();
                                }
                            }
                            catch (Exception ex)
                            {
                                domainProvider.RollbackTransaction();

                                msg.Add(new UserControl.Message(ex));
                            }
                            finally
                            {
                                ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)domainProvider).PersistBroker.CloseConnection();
                            }
                        }
                    }
                }
            }

            if ((act as IDCTClient).CachedAction is ActionCollectOutlineNG)
            {
                if (this.Status == BenQGuru.eMES.Common.DCT.Core.ActionStatus.Working)
                {
                    this.ObjectState = null;
                    if (this.errorCodesHT != null)
                    {
                        this.errorCodesHT.Clear();
                    }
                }

                this.Status = BenQGuru.eMES.Common.DCT.Core.ActionStatus.PrepareData;


                (act as IDCTClient).CachedAction = this;
            }

            base.Action(act);

            ActionRCard actRcard = new ActionRCard();

            this.NextAction = actRcard;


            return(msg);
        }
Exemple #5
0
        public override Messages Action(object act)
        {
            Messages msg = new Messages();

            BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider domainProvider = null;

            if (act == null)
            {
                return(msg);
            }

            if (currentProductInfo == null)
            {
                return(msg);
            }

            DataCollect.Action.ActionEventArgs args;
            if (ObjectState == null)
            {
                args = new BenQGuru.eMES.DataCollect.Action.ActionEventArgs();
            }
            else
            {
                args = ObjectState as DataCollect.Action.ActionEventArgs;
            }

            string data = act.ToString().ToUpper().Trim();//Errorcode

            //Laws Lu,2006/06/03	添加	获取已有连接
            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;
            }

            //msg = CheckData(data, domainProvider);


            if (msg.IsSuccess())
            {
                //检查序列号

                ActionOnLineHelper _helper = new ActionOnLineHelper(domainProvider);
                msg = _helper.GetIDInfo(args.RunningCard);

                if (msg.IsSuccess())
                {
                    ProductInfo product = (ProductInfo)msg.GetData().Values[0];

                    TSModelFacade tsmodelFacade = new TSModelFacade(domainProvider);

                    if (msg.IsSuccess())
                    {
                        SystemSettingFacade systemSettingFacade = new SystemSettingFacade(domainProvider);
                        object parameter = systemSettingFacade.GetParameter("DEFAULTERRORCODE", "NGCOLLECTDEFAULTERRORCODE");
                        if (parameter == null)
                        {
                            msg.Add(new UserControl.Message(MessageType.Error, "$Error_NoDefaultErrorCode"));
                            msg.Add(new UserControl.Message(MessageType.Normal, "$DCT_NG_Please_Input_NG_SN"));
                            this.Status     = ActionStatus.PrepareData;
                            this.FlowDirect = FlowDirect.WaitingInput;
                            //base.Action(act);
                            return(msg);
                        }
                        Parameter errorCodeParameter = parameter as Parameter;
                        object    errorCode          = tsmodelFacade.GetErrorCode(errorCodeParameter.ParameterAlias);
                        if (errorCode == null)
                        {
                            msg.Add(new UserControl.Message(MessageType.Error, "$ErrorCode_Not_Exist"));
                            msg.Add(new UserControl.Message(MessageType.Normal, "$DCT_NG_Please_Input_NG_SN"));
                            this.Status     = ActionStatus.PrepareData;
                            this.FlowDirect = FlowDirect.WaitingInput;
                            return(msg);
                        }

                        object[] ecgObjects = tsmodelFacade.GetErrorCodeGroupByErrorCodeCode(((ErrorCodeA)errorCode).ErrorCode);
                        if (ecgObjects == null || ecgObjects.Length == 0)
                        {
                            msg.Add(new UserControl.Message(MessageType.Error, "$Error_ErrorCodeNoErrorGroup"));
                            msg.Add(new UserControl.Message(MessageType.Normal, "$DCT_NG_Please_Input_NG_SN"));
                            this.Status     = ActionStatus.PrepareData;
                            this.FlowDirect = FlowDirect.WaitingInput;
                            return(msg);
                        }

                        ErrorCodeGroup2ErrorCode ecg2ec = (ErrorCodeGroup2ErrorCode)tsmodelFacade.GetErrorCodeGroup2ErrorCodeByecCode(((ErrorCodeA)errorCode).ErrorCode);

                        object[] errorcodes = new object[] { ecg2ec };
                        //if (msg.IsSuccess())
                        //{
                        //    string strModelCode = this.GetModelCodeFromProduct(product, this.moWillGo, domainProvider);
                        //    if (strModelCode != "")
                        //    {
                        //        errorcodes = tsmodelFacade.QueryECG2ECByECAndModelCode(new string[] { ((ErrorCodeA)errorCode).ErrorCode }, strModelCode);
                        //    }

                        //    if (errorcodes == null || errorcodes.Length == 0)
                        //    {
                        //        msg.Add(new UserControl.Message(UserControl.MessageType.Error, "$ErrorCode_Not_BelongTo_ModelCode"));
                        //        base.Action(act);
                        //        ActionRCard actRcard = new ActionRCard();
                        //        this.NextAction = actRcard;
                        //        return msg;
                        //    }
                        //}

                        if (msg.IsSuccess())
                        {
                            IAction dataCollectModule
                                = new BenQGuru.eMES.DataCollect.Action.ActionFactory(domainProvider).CreateAction(ActionType.DataCollectAction_NG);
                            domainProvider.BeginTransaction();
                            try
                            {
                                IDCTClient client = act as IDCTClient;

                                msg.AddMessages(((IActionWithStatus)dataCollectModule).Execute(
                                                    new TSActionEventArgs(ActionType.DataCollectAction_NG,
                                                                          args.RunningCard,
                                                                          client.LoginedUser,
                                                                          client.ResourceCode,
                                                                          product,
                                                                          errorcodes,
                                                                          null,
                                                                          "")));

                                if (msg.IsSuccess())
                                {
                                    domainProvider.CommitTransaction();
                                    base.Action(act);
                                    msg.Add(new UserControl.Message(MessageType.Success, string.Format("$CS_NGSUCCESS")));
                                    return(msg);
                                }
                                else
                                {
                                    domainProvider.RollbackTransaction();
                                }
                            }
                            catch (Exception ex)
                            {
                                domainProvider.RollbackTransaction();
                                msg.Add(new UserControl.Message(ex));
                            }
                            finally
                            {
                                ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)domainProvider).PersistBroker.CloseConnection();
                            }
                        }
                    }
                }
            }
            if (msg.IsSuccess())
            {
                base.Action(act);
            }
            else
            {
                msg.Add(new UserControl.Message(MessageType.Normal, "$DCT_NG_Please_Input_NG_SN"));
                this.FlowDirect = FlowDirect.WaitingInput;
            }
            return(msg);
        }
Exemple #6
0
        public override Messages Action(object act)
        {
            Messages msg = new Messages();

            BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider domainProvider = null;

            if (act == null)
            {
                return(msg);
            }

            IDCTClient client = act as IDCTClient;

            if (currentProductInfo == null)
            {
                return(msg);
            }

            DataCollect.Action.ActionEventArgs args;
            if (ObjectState == null)
            {
                args = new BenQGuru.eMES.DataCollect.Action.ActionEventArgs();
            }
            else
            {
                args = ObjectState as DataCollect.Action.ActionEventArgs;
            }

            string data = act.ToString().ToUpper().Trim();            //Errorcode

            //Laws Lu,2006/06/03	添加	获取已有连接
            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;
            }


            if (string.Compare(data, BaseDCTDriver.FINERROR, true) != 0)           //结束的标志
            {
                msg = CheckData(data, domainProvider);

                if (msg.IsSuccess())
                {
                    if (_currInputStep.StepType == InputStepType.ErrorCode)  //一次完整的ErrorCode 与 Error Location的输入完成
                    {
                        if (errorCodesHT == null)
                        {
                            errorCodesHT = new Hashtable();
                        }

                        string key = _currInputStep.ErrorCode + "&" + _currInputStep.ErrorLoc;

                        bool bExist = false;
                        if (!errorCodesHT.ContainsKey(key))
                        {
                            errorCodesHT.Add(key, key);
                        }
                        else
                        {
                            bExist = true;
                        }


                        if (bExist == false)
                        {
                            //msg.Add(new UserControl.Message(MessageType.Succes,data));	// Removed by Icyer 2007/01/09	避免重复输出
                        }
                        else
                        {
                            msg.Add(new UserControl.Message(MessageType.Success, "$ErrorCodeCollected"));
                        }
                        this.Status = ActionStatus.PrepareData;
                        return(msg);
                    }
                    else
                    {
                        this.Status = ActionStatus.PrepareData;
                        return(msg);
                    }
                }
                else
                {
                    this.Status = ActionStatus.PrepareData;
                    return(msg);
                }
            }

            if (msg.IsSuccess())
            {
                //检查序列号

                ActionOnLineHelper _helper = new ActionOnLineHelper(domainProvider);

                msg = _helper.GetIDInfo(args.RunningCard);

                if (msg.IsSuccess())
                {
                    ProductInfo product = (ProductInfo)msg.GetData().Values[0];

                    TSModelFacade tsmodelFacade = new TSModelFacade(domainProvider);

                    if (errorCodesHT == null)
                    {
                        msg.Add(new UserControl.Message(UserControl.MessageType.Error, "$ErrorCode_Not_Exist"));
                    }

                    if (msg.IsSuccess())
                    {
                        #region 得到用户输入的 Error Code和Error Location

                        BenQGuru.eMES.Domain.TS.TSErrorCode2Location[] errorInfo = new BenQGuru.eMES.Domain.TS.TSErrorCode2Location[errorCodesHT.Count];
                        TSModel.TSModelFacade tsFacade = new TSModelFacade(domainProvider);
                        int i = 0;
                        foreach (DictionaryEntry dic in errorCodesHT)
                        {
                            string[] keys = dic.Key.ToString().Split('&');
                            if (keys.Length > 1)
                            {
                                //没有Location
                                if (keys[1].Contains(NoLoc))
                                {
                                    object[] objs = tsFacade.GetErrorCodeGroupByErrorCodeCode(keys[0]);
                                    errorInfo[i] = new BenQGuru.eMES.Domain.TS.TSErrorCode2Location();
                                    if (objs != null && objs.Length > 0)
                                    {
                                        ErrorCodeGroupA errorgroup = (ErrorCodeGroupA)objs[0];
                                        errorInfo[i].ErrorCode      = keys[0];
                                        errorInfo[i].ErrorCodeGroup = errorgroup.ErrorCodeGroup;
                                        errorInfo[i].ErrorLocation  = string.Empty;
                                        errorInfo[i].AB             = ItemLocationSide.ItemLocationSide_AB;
                                    }
                                }
                                else //有location
                                {
                                    object[] objs = tsFacade.GetErrorCodeGroupByErrorCodeCode(keys[0]);
                                    errorInfo[i] = new BenQGuru.eMES.Domain.TS.TSErrorCode2Location();
                                    if (objs != null && objs.Length > 0)
                                    {
                                        ErrorCodeGroupA errorgroup = (ErrorCodeGroupA)objs[0];
                                        errorInfo[i].ErrorCode      = keys[0];
                                        errorInfo[i].ErrorCodeGroup = errorgroup.ErrorCodeGroup;
                                        errorInfo[i].ErrorLocation  = keys[1];
                                        errorInfo[i].AB             = ItemLocationSide.ItemLocationSide_AB;
                                    }
                                }
                            }
                            else //没有Location
                            {
                                object[] objs = tsFacade.GetErrorCodeGroupByErrorCodeCode(keys[0]);
                                errorInfo[i] = new BenQGuru.eMES.Domain.TS.TSErrorCode2Location();
                                if (objs != null && objs.Length > 0)
                                {
                                    ErrorCodeGroupA errorgroup = (ErrorCodeGroupA)objs[0];
                                    errorInfo[i].ErrorCode      = keys[0];
                                    errorInfo[i].ErrorCodeGroup = errorgroup.ErrorCodeGroup;
                                    errorInfo[i].ErrorLocation  = string.Empty;
                                    errorInfo[i].AB             = ItemLocationSide.ItemLocationSide_AB;
                                }
                            }

                            i++;
                        }

                        #endregion

                        /*
                         * string[] errorcs = new string[errorCodesHT.Count];
                         *                      int i=0;
                         *                      foreach( DictionaryEntry dic in errorCodesHT )
                         *                      {
                         *                              errorcs[i] = dic.Key.ToString();
                         *                              i++;
                         *                      }
                         * */
                        /*	Removed by Icyer 2007/03/15		允许自动归属工单
                         * //Laws Lu,2006/06/22 modify fix the bug that system alert object not set an instance when the product.LastSimulation is null
                         * if(product.LastSimulation == null)
                         * {
                         *      msg.Add(new UserControl.Message(UserControl.MessageType.Error,"$NoSimulation"));
                         * }
                         */
                        /*
                         *                      object[] errorcodes = null;
                         *                      if(msg.IsSuccess())
                         *                      {
                         *                              //errorcodes = tsmodelFacade.QueryECG2ECByECAndModelCode(errorcs, product.LastSimulation.ModelCode);
                         *                              string strModelCode = this.GetModelCodeFromProduct(product, this.moWillGo, domainProvider);
                         *                              if (strModelCode != "")
                         *                              {
                         *                                      errorcodes = tsmodelFacade.QueryECG2ECByECAndModelCode(errorcs, strModelCode);
                         *                              }
                         *
                         *                              if( errorcodes==null || errorcodes.Length==0 )
                         *                              {
                         *                                      msg.Add(new UserControl.Message(UserControl.MessageType.Error,"$ErrorCode_Not_BelongTo_ModelCode"));
                         *                                      base.Action (act);
                         *                                      ActionCollectSMTNG actionCollectNG = this;
                         *                                      actionCollectNG.IsTopAction = false;
                         *                                      this.NextAction = actionCollectNG;
                         *                                      this.Status = ActionStatus.PrepareData;
                         *                                      return msg;
                         *                              }
                         *                      }
                         */
                        if (msg.IsSuccess())
                        {
                            IAction dataCollectModule
                                = new BenQGuru.eMES.DataCollect.Action.ActionFactory(domainProvider).CreateAction(ActionType.DataCollectAction_NG);

                            //((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)domainProvider).PersistBroker.OpenConnection();
                            domainProvider.BeginTransaction();
                            try
                            {
                                //IDCTClient client = act as IDCTClient;
                                ActionCheckStatus actionCheckStatus = new ActionCheckStatus();

                                msg.AddMessages(((IActionWithStatus)dataCollectModule).Execute(
                                                    new TSActionEventArgs(ActionType.DataCollectAction_SMTNG,
                                                                          args.RunningCard,
                                                                          client.LoginedUser,
                                                                          client.ResourceCode,
                                                                          product,
                                                                          errorInfo,
                                                                          ""), actionCheckStatus));

                                if (msg.IsSuccess())
                                {
                                    domainProvider.CommitTransaction();
                                    msg.Add(new UserControl.Message(MessageType.Success, string.Format("$CS_NGSUCCESS")));
                                }
                                else
                                {
                                    domainProvider.RollbackTransaction();
                                }
                            }
                            catch (Exception ex)
                            {
                                domainProvider.RollbackTransaction();

                                msg.Add(new UserControl.Message(ex));
                            }
                            finally
                            {
                                ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)domainProvider).PersistBroker.CloseConnection();
                            }
                        }
                    }
                }
            }

            //if((act as IDCTClient).CachedAction is ActionCollectSMTNG)
            //{
            //    if(this.Status == BenQGuru.eMES.Common.DCT.Core.ActionStatus.Working)
            //    {
            //        this.ObjectState = null;
            //        if(this.errorCodesHT != null)
            //        {
            //            this.errorCodesHT.Clear();
            //        }
            //    }
            //    this.Status = BenQGuru.eMES.Common.DCT.Core.ActionStatus.PrepareData;
            //    (act as IDCTClient).CachedAction = this;
            //}
            if (this.errorCodesHT == null)
            {
                msg.ClearMessages();
            }
            if (msg.IsSuccess() || this.errorCodesHT == null)
            {
                base.Action(act);
            }
            else
            {
                msg.Add(new UserControl.Message(MessageType.Normal, "$DCT_NG_Please_Input_NG_SN"));
                this.Status     = ActionStatus.PrepareData;
                this.FlowDirect = FlowDirect.WaitingInput;
            }
            currentProductInfo = null;
            moWillGo           = null;
            this.ObjectState   = null;
            if (this.errorCodesHT != null)
            {
                this.errorCodesHT.Clear();
            }
            return(msg);
        }
Exemple #7
0
        public override Messages Action(object act)
        {
            Messages msg = new Messages();

            BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider domainProvider = null;


            if (act == null)
            {
                return(msg);
            }

            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;
            }


            if (m_FlowControl == 1)
            {
                string itemCode = ((Item)_item).ItemCode.ToString();
                strCarton = act.ToString().Trim().ToUpper();

                if (((Item)_item).NeedCheckCarton == FormatHelper.TRUE_STRING)
                {
                    if (strRcard.StartsWith(itemCode, StringComparison.CurrentCultureIgnoreCase))
                    {
                        if (string.Compare(strRcard, strCarton, true) == 0)
                        {
                            msg.Add(new UserControl.Message(MessageType.Error, "$Error_CartonNotMatchTheRule"));
                            msg.Add(new UserControl.Message(MessageType.Success, "$CS_PLEASE_INPUT_CARTONNO"));

                            this.Status = ActionStatus.PrepareData;
                            return(msg);
                        }
                        else
                        {
                            if (string.Compare(strRcard.Replace(" ", ""), strCarton.Replace(" ", ""), true) != 0)
                            {
                                msg.Add(new UserControl.Message(MessageType.Error, "$Error_CartonCheckFailed"));
                                msg.Add(new UserControl.Message(MessageType.Success, "$CS_PLEASE_INPUT_CARTONNO"));
                                this.Status = ActionStatus.PrepareData;
                                return(msg);
                            }
                            else
                            {
                                msg.Add(new UserControl.Message(MessageType.Success, "$CARTON_COMPARE_ISSUCCESS"));
                            }
                        }
                    }
                    else
                    {
                        if (string.Compare(strRcard, strCarton, true) == 0)
                        {
                            msg.Add(new UserControl.Message(MessageType.Success, "$CARTON_COMPARE_ISSUCCESS"));
                        }
                        else
                        {
                            msg.Add(new UserControl.Message(MessageType.Error, "$Error_CartonCheckFailed"));
                            msg.Add(new UserControl.Message(MessageType.Success, "$CS_PLEASE_INPUT_CARTONNO"));
                            this.Status = ActionStatus.PrepareData;
                            return(msg);
                        }
                    }
                }

                object obj = (new Package.PackageFacade(domainProvider)).GetCARTONINFO(act.ToString().Trim().ToUpper());
                if (obj != null && ((CARTONINFO)obj).CAPACITY.ToString() == ((CARTONINFO)obj).COLLECTED.ToString())
                {
                    msg.Add(new UserControl.Message(MessageType.Error, "$CARTON_ALREADY_FILL_OUT"));
                    msg.Add(new UserControl.Message(MessageType.Success, "$CS_PLEASE_INPUT_CARTONNO"));
                    this.Status = ActionStatus.PrepareData;
                    return(msg);
                }
                else
                {
                    m_FlowControl++;
                    msg.Add(new UserControl.Message(MessageType.Normal, "$CS_PLEASE_INPUT_WRAPPER"));
                    this.Status = ActionStatus.PrepareData;
                    return(msg);
                }
            }
            else
            {
                //if (((Simulation)_objSimulation).ItemCode.ToUpper().Trim() == act.ToString().ToUpper())
                if (((Simulation)_objSimulation).RunningCard.ToUpper().IndexOf(act.ToString().ToUpper()) == 0)
                {
                    ActionOnLineHelper actionOnLineHelper = new ActionOnLineHelper(domainProvider);
                    BenQGuru.eMES.DataCollect.Action.ActionFactory actionFactory = new BenQGuru.eMES.DataCollect.Action.ActionFactory(domainProvider);
                    IAction actionCartonPack = actionFactory.CreateAction(ActionType.DataCollectAction_Carton);
                    //((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)domainProvider).PersistBroker.OpenConnection();
                    msg = actionOnLineHelper.GetIDInfo(strRcard);
                    string     cartonno = FormatHelper.CleanString(strCarton);
                    IDCTClient client   = act as IDCTClient;

                    //add by hiro 08/09/28
                    DBDateTime dbDateTime;
                    dbDateTime = FormatHelper.GetNowDBDateTime(domainProvider);
                    PackageFacade _Packfacade     = new PackageFacade(domainProvider);
                    PACKINGCHK    newPackingCheck = _Packfacade.CreateNewPACKINGCHK();
                    newPackingCheck.Rcard            = ((Simulation)_objSimulation).RunningCard.ToString().ToUpper();
                    newPackingCheck.CheckAccessory   = FormatHelper.TRUE_STRING;
                    newPackingCheck.CheckProductCode = FormatHelper.FALSE_STRING;
                    newPackingCheck.MUSER            = (act as IDCTClient).LoginedUser;
                    newPackingCheck.MDATE            = dbDateTime.DBDate;
                    newPackingCheck.MTIME            = dbDateTime.DBTime;
                    newPackingCheck.EATTRIBUTE1      = " ";
                    object objGet = _Packfacade.GetPACKINGCHK(((Simulation)_objSimulation).RunningCard.ToString().ToUpper());
                    if (objGet != null)
                    {
                        _Packfacade.DeletePACKINGCHK((PACKINGCHK)objGet);
                        _Packfacade.AddPACKINGCHK(newPackingCheck);
                    }
                    else
                    {
                        _Packfacade.AddPACKINGCHK(newPackingCheck);
                    }
                    //end by hiro

                    Messages msgTwo = new Messages();
                    domainProvider.BeginTransaction();
                    try
                    {
                        if (msg.IsSuccess())
                        {
                            ProductInfo product = (ProductInfo)msg.GetData().Values[0];
                            if (product.LastSimulation == null)
                            {
                                base.Action(act);
                                msgTwo.Add(new UserControl.Message(new Exception("$Error_LastSimulation_IsNull!")));
                                this.ObjectState = null;
                                return(msgTwo);
                            }

                            CartonPackEventArgs cartonPackEventArgs = new CartonPackEventArgs(ActionType.DataCollectAction_Carton,
                                                                                              strRcard, client.LoginedUser,
                                                                                              client.ResourceCode,
                                                                                              "",
                                                                                              cartonno,
                                                                                              product);

                            msgTwo.AddMessages(actionCartonPack.Execute(cartonPackEventArgs));
                        }
                        if (msgTwo.IsSuccess())
                        {
                            domainProvider.CommitTransaction();
                        }
                        else
                        {
                            domainProvider.RollbackTransaction();
                            msgTwo.Add(new UserControl.Message(MessageType.Normal, "$CS_Please_Input_RunningCard"));
                            this.Status      = ActionStatus.PrepareData;
                            this.FlowDirect  = FlowDirect.WaitingInput;
                            this.ObjectState = null;
                            this.clearValue();
                            return(msgTwo);
                        }
                    }
                    catch (Exception ex)
                    {
                        domainProvider.RollbackTransaction();
                        msg.Add(new UserControl.Message(ex));
                        msg.Add(new UserControl.Message(MessageType.Normal, "$CS_Please_Input_RunningCard"));
                        this.Status      = ActionStatus.PrepareData;
                        this.FlowDirect  = FlowDirect.WaitingInput;
                        this.ObjectState = null;
                        this.clearValue();
                        return(msg);
                    }
                    finally
                    {
                        ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)domainProvider).PersistBroker.CloseConnection();
                    }

                    base.Action(act);
                    msg.Add(new UserControl.Message(MessageType.Success, "$CS_COMPAREAPPENDIX_SUCCESS"));
                    msg.Add(new UserControl.Message(MessageType.Success, "$CS_RCARD_CARTON_SUCCESS [" + strCarton + "]"));
                    this.ObjectState = null;
                    this.clearValue();
                    return(msg);
                }
                else
                {
                    msg.Add(new UserControl.Message(MessageType.Error, "$CS_COMPAREAPPENDIX_NOTSUCCESS"));
                    msg.Add(new UserControl.Message(MessageType.Normal, "$CS_PLEASE_INPUT_WRAPPER"));
                    this.Status = ActionStatus.PrepareData;
                    return(msg);
                }
            }
        }
Exemple #8
0
        // Added end

        public override Messages Action(object act)
        {
            Messages msgs = new Messages();

            BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider domainProvider = null;

            if (act == null)
            {
                return(msgs);
            }

            DataCollect.Action.ActionEventArgs args;
            if (ObjectState == null)
            {
                args = new BenQGuru.eMES.DataCollect.Action.ActionEventArgs();
            }
            else
            {
                args = ObjectState as DataCollect.Action.ActionEventArgs;
            }

            string data = act.ToString().ToUpper().Trim();//产品序列号

            args.RunningCard = data;
            //Laws Lu,2006/06/03	添加	获取已有连接
            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;
            }

            //msg = CheckData(data,domainProvider);		// Removed by Icyer 2006/12/15
            msgs = CheckSN(this._moCode, args.RunningCard, domainProvider);

            //add by hiro 08/11/05
            if (msgs.IsSuccess())
            {
                msgs = this.CheckSNContent(this._moCode, args.RunningCard, domainProvider);
            }
            //end by hiro

            if (msgs.IsSuccess())
            {
                //检查序列号
                ActionOnLineHelper _helper = new ActionOnLineHelper(domainProvider);
                //msg.AddMessages(  _helper.GetIDInfo( args.RunningCard ) );
                msgs = _helper.GetIDInfoByMoCodeAndId(_moCode, args.RunningCard);

                if (msgs.IsSuccess())
                {
                    IDCTClient client = act as IDCTClient;

                    ProductInfo product = (ProductInfo)msgs.GetData().Values[0];

                    GoToMOActionEventArgs gotoMOArgs = new GoToMOActionEventArgs(
                        ActionType.DataCollectAction_GoMO,
                        args.RunningCard,
                        client.LoginedUser,
                        client.ResourceCode,
                        product,
                        _moCode);

                    IAction action = new BenQGuru.eMES.DataCollect.Action.ActionFactory(domainProvider).CreateAction(ActionType.DataCollectAction_GoMO);

                    //((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)domainProvider).PersistBroker.OpenConnection();
                    domainProvider.BeginTransaction();
                    try
                    {
                        msgs = ((IActionWithStatus)action).Execute(gotoMOArgs);

                        if (msgs.IsSuccess())
                        {
                            domainProvider.CommitTransaction();
                            msgs.Add(new UserControl.Message(MessageType.Success, string.Format("$CS_GOMO_CollectSuccess")));
                        }
                        else
                        {
                            if (msgs.OutPut().IndexOf("$CS_ID_Has_Already_Belong_To_This_MO") == 0)
                            {
                                msgs.ClearMessages();
                                msgs.Add(new UserControl.Message(UserControl.MessageType.Error, "$CS_ID_Has_Already_Belong_To_This_MO"));
                            }
                            domainProvider.RollbackTransaction();
                        }
                    }
                    catch (Exception ex)
                    {
                        domainProvider.RollbackTransaction();

                        msgs.Add(new UserControl.Message(ex));
                    }
                    finally
                    {
                        ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)domainProvider).PersistBroker.CloseConnection();
                    }
                }
            }

            if (msgs.IsSuccess())
            {
                base.Action(act);
            }

            this.ObjectState = null;

            ProcessBeforeReturn(this.Status, msgs);

            return(msgs);
        }