Esempio n. 1
0
        public BaseDCTAction GetEndNodeAction(IDCTClient client)
        {
            BaseDCTAction action = null;

            SQLDomainDataProvider domainProvider = null;

            if (client.DBConnection != null)
            {
                domainProvider = client.DBConnection as BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider;
            }
            else
            {
                domainProvider      = DomainDataProviderManager.DomainDataProvider() as SQLDomainDataProvider;
                client.DBConnection = domainProvider;
            }

            BaseModelFacade baseModelFacade = new BaseModelFacade(domainProvider);

            if (client.ResourceCode != null && client.ResourceCode.Trim().Length > 0)
            {
                Resource res = (Resource)baseModelFacade.GetResource(client.ResourceCode.Trim().ToUpper());

                if (res != null && res.DctCode != null & res.DctCode.Trim().Length > 0)
                {
                    action = (new ActionHelper()).GetActionByCommand(res.DctCode.Trim().ToUpper());
                }
            }

            if (action == null)
            {
                action = new ActionIdle();
            }

            return(action);
        }
Esempio n. 2
0
        public void Open()
        {
            try
            {
                if (_DataProvider == null)
                {
                    _DataProvider = (SQLDomainDataProvider)DomainDataProviderManager.DomainDataProvider();
                }

                if (_DCTFacade == null)
                {
                    _DCTFacade = new DCTFacade(_DataProvider);

                    _DCTFacade.ClearAllDCTMessage();

                    this.SendCommand(DCTCommand.ClearText);
                    this.SendCommand(DCTCommand.SpeakerOff);
                    this.SendCommand(DCTCommand.AutoReportingOff);
                    this.SendCommand(DCTCommand.AutoReportingOn);
                    this.SendCommand(DCTCommand.HostReportSetting);
                    this.SendCommand(DCTCommand.ClearText);
                    this.SendCommand(DCTCommand.ClearGraphic);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 3
0
        public static void UploadError(string msg, string innserMsg)
        {
            SQLDomainDataProvider provider = BenQGuru.eMES.Common.DomainDataProvider.DomainDataProviderManager.DomainDataProvider() as SQLDomainDataProvider;
            SystemSettingFacade   facade   = new SystemSettingFacade(provider);

            SystemError systemError = facade.CreateNewSystemError();

            systemError.SystemErrorCode   = Guid.NewGuid().ToString();
            systemError.ErrorMessage      = FormatHelper.CleanString(msg, 100);
            systemError.InnerErrorMessage = FormatHelper.CleanString(innserMsg, 100);
            systemError.TriggerModuleCode = SessionHelper.Current(HttpContext.Current.Session).ModuleCode;
            systemError.SendUser          = SessionHelper.Current(HttpContext.Current.Session).UserCode;
            if (systemError.SendUser == null || systemError.SendUser == string.Empty)
            {
                systemError.SendUser = "******";
            }
            systemError.SendDate     = FormatHelper.TODateInt(DateTime.Now);
            systemError.SendTime     = FormatHelper.TOTimeInt(DateTime.Now);
            systemError.IsResolved   = FormatHelper.BooleanToString(false);
            systemError.MaintainUser = SessionHelper.Current(HttpContext.Current.Session).UserCode;
            if (systemError.MaintainUser == null || systemError.MaintainUser == string.Empty)
            {
                systemError.MaintainUser = "******";
            }

            facade.AddSystemError(systemError);
            provider.PersistBroker.CloseConnection();
        }
Esempio n. 4
0
        public Form1()
        {
            InitializeComponent();

            _DataProvider = (SQLDomainDataProvider)DomainDataProviderManager.DomainDataProvider();
            _DCTFacade    = new DCTFacade(_DataProvider);

            IPAddress[] addressList = Dns.GetHostEntry(Dns.GetHostName()).AddressList;
            _LocalAddress = addressList[0].ToString();
            _LocalPort    = 12345;

            textBoxServerIP.Text = _LocalAddress;
            _ServerAddress       = textBoxServerIP.Text;
            _ServerPort          = 12345;

            labelSpeaker.BackColor = Color.LightGray;
            textBoxMessage.Text    = " \r\n \r\n ";
        }
Esempio n. 5
0
        private bool KeyPartUsed(SQLDomainDataProvider sqlDomainDataProvider, string keyPartRCard, string MItemCode, bool checkCache)
        {
            if (checkCache)
            {
                //Check objAllList
                if (opBomdetailRealCollectList != null)
                {
                    foreach (MINNO minno in opBomdetailRealCollectList)
                    {
                        if (minno.EAttribute1 == MCardType.MCardType_Keyparts &&
                            minno.MItemPackedNo.Trim().ToUpper() == keyPartRCard.Trim().ToUpper())
                        {
                            return(true);
                        }
                    }
                }
            }

            //Check DB
            DataCollectFacade dataCollectFacade = new DataCollectFacade(sqlDomainDataProvider);

            object[] onWIPItemList = dataCollectFacade.QueryOnWIPItem(keyPartRCard, MItemCode);
            if (onWIPItemList != null)
            {
                foreach (OnWIPItem onWIPItem in onWIPItemList)
                {
                    if (onWIPItem.MCardType == MCardType.MCardType_Keyparts &&
                        onWIPItem.ActionType == (int)MaterialType.CollectMaterial)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Esempio n. 6
0
 public void Close()
 {
     _DCTFacade    = null;
     _DataProvider = null;
 }
Esempio n. 7
0
        public override Messages Action(object act)
        {
            Messages msgs = new Messages();

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

            SQLDomainDataProvider domainProvider = null;

            if ((act as IDCTClient).DBConnection != null)
            {
                domainProvider = (act as IDCTClient).DBConnection as SQLDomainDataProvider;
            }
            else
            {
                domainProvider = DomainDataProviderManager.DomainDataProvider() as SQLDomainDataProvider;
                (act as IDCTClient).DBConnection = domainProvider;
            }

            PerformanceFacade performanceFacade = new PerformanceFacade(domainProvider);

            string resCode          = (act as IDCTClient).ResourceCode;
            string maintainUserCode = (act as IDCTClient).LoginedUser;
            string userCode         = FormatHelper.PKCapitalFormat(FormatHelper.CleanString(act.ToString()));

            if (act.ToString().ToUpper() == "CONFIRM")
            {
                if (_userList.Count <= 0)
                {
                    msgs.Add(new UserControl.Message(MessageType.Error, "$Message_AtLeastOneUser"));
                }

                if (msgs.IsSuccess())
                {
                    msgs = performanceFacade.GoOnPost(resCode, _userList, maintainUserCode);

                    if (msgs.IsSuccess())
                    {
                        msgs.ClearMessages();
                        msgs.Add(new UserControl.Message(MessageType.Success, "$Message_DCTGoOnPostSuccessfully [" + _userList.Count.ToString() + "] $Message_People"));
                    }
                }

                base.Action(act);
                _userList.Clear();
                ProcessBeforeReturn(this.Status, msgs);
                return(msgs);
            }

            bool userIsExist = false;

            for (int i = 0; i < _userList.Count; i++)
            {
                if (_userList.Contains(userCode))
                {
                    userIsExist = true;
                }
            }

            if (userIsExist)
            {
                msgs.Add(new UserControl.Message(MessageType.Error, "$Message_User_Is_Exist"));
                msgs.Add(new UserControl.Message(MessageType.Normal, "$Messag_Please_Input_UserCode"));
                msgs.Add(new UserControl.Message(MessageType.Normal, "$Message_Confirm_GoOnPost"));
                ProcessBeforeReturn(this.Status, msgs);
                return(msgs);
            }

            _userList.Add(userCode);

            msgs = performanceFacade.CheckBeforeGoOnPost(resCode, _userList);

            if (!msgs.IsSuccess())
            {
                _userList.Remove(userCode);
            }

            msgs.Add(new UserControl.Message(MessageType.Normal, "$Messag_Please_Input_UserCode"));
            msgs.Add(new UserControl.Message(MessageType.Normal, "$Message_Confirm_GoOnPost"));
            ProcessBeforeReturn(this.Status, msgs);
            return(msgs);
        }
Esempio n. 8
0
        public virtual void SendMessage(object sender, Messages msgs, string command)
        {
            IDCTClient client = sender as IDCTClient;

            Message msg = new Message();

            for (int i = 0; i < msgs.Count(); i++)
            {
                if (msgs.Objects(i).Type != MessageType.Data)
                {
                    msg = msgs.Objects(i);

                    //处理一般的输出信息
                    if (msg.Body != String.Empty)
                    {
                        string send_msg = MutiLanguages.ParserMessage(msg.Body);

                        if (send_msg.IndexOf("$") < 0)
                        {
                            if (msg.Type == MessageType.DCTClear)
                            {
                                client.SendMessage(empty);
                            }
                            if (msg.Type == MessageType.DCTData)
                            {
                                SendMessageEx(client, send_msg);
                            }
                            else
                            {
                                SendMessageEx(client, send_msg);
                            }
                        }
                        else    // 将缺失的Message记录下来
                        {
                            try
                            {
                                string strFile = @"C:\DCT_EmptyMessage.txt";
                                System.IO.StreamWriter writer = new System.IO.StreamWriter(strFile, true);
                                writer.WriteLine(msg.Body);
                                writer.Close();
                            }
                            catch { }
                        }

                        if (msg.Type == MessageType.Normal && msg.Body.Trim().Length > 0)
                        {
                            this._LastPrompt = send_msg.Trim();
                        }
                    }

                    //处理异常
                    if (msg.Exception != null)
                    {
                        string send_msg = MutiLanguages.ParserMessage(msg.Exception.Message);
                        if (send_msg.IndexOf("$") < 0)
                        {
                            if (msg.Type == MessageType.DCTClear)
                            {
                                client.SendMessage(empty);
                            }

                            if (msg.Type == MessageType.DCTData)
                            {
                                SendMessageEx(client, send_msg);
                            }
                            else
                            {
                                SendMessageEx(client, send_msg);
                            }
                        }
                    }

                    //发出声音
                    if (msg != null)
                    {
                        switch (msg.Type)
                        {
                        case MessageType.Success:
                        {
                            //if(CurrentDirect == FlowDirect.WaitingOutPut && BeepSuccess)
                            if (BeepSuccess)
                            {
                                client.SendCommand(DCTCommand.SpeakerOn);
                            }

                            break;
                        }

                        case MessageType.Error:
                        {
                            if (BeepError)
                            {
                                for (int j = 0; j < BeepCount; j++)
                                {
                                    client.SendCommand(BeepType);
                                    System.Threading.Thread.Sleep(BeepInterval);
                                }
                            }
                            break;
                        }

                        default:
                        {
                            if (BeepSuccess)
                            {
                                client.SendCommand(DCTCommand.SpeakerOn);
                            }

                            break;
                        }
                        }
                    }

                    //记录WorkingError
                    if (msg.Type == MessageType.Error || msg.Exception != null)
                    {
                        try
                        {
                            SQLDomainDataProvider domainProvider = null;
                            if (client.DBConnection != null)
                            {
                                domainProvider = client.DBConnection as BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider;
                            }
                            else
                            {
                                domainProvider      = DomainDataProviderManager.DomainDataProvider() as SQLDomainDataProvider;
                                client.DBConnection = domainProvider;
                            }

                            DataCollectFacade dataCollectFacade = new DataCollectFacade(domainProvider);

                            string userCode      = client.LoginedUser;
                            string resCode       = client.ResourceCode;
                            string segCode       = client.SegmentCode;
                            string ssCode        = client.StepSequenceCode;
                            string shiftTypeCode = client.ShiftTypeCode;

                            string errorMessageCode = string.Empty;
                            string errorMessage     = string.Empty;
                            if (msg.Type == MessageType.Error)
                            {
                                errorMessageCode = msg.Body;
                                errorMessage     = MutiLanguages.ParserMessage(msg.Body);
                            }

                            if (msg.Exception != null)
                            {
                                errorMessageCode = msg.Exception.Message;
                                errorMessage     = MutiLanguages.ParserMessage(msg.Exception.Message);
                            }

                            dataCollectFacade.LogWorkingError(userCode, resCode, segCode, ssCode, shiftTypeCode,
                                                              WorkingErrorFunctionType.DCT, command, this._LastPrompt + ": " + client.ToString(), errorMessageCode, errorMessage);
                        }
                        catch (Exception ex)
                        {
                            //throw ex;
                        }
                    }
                }
            }
        }
Esempio n. 9
0
        public override Messages Action(object act)
        {
            Messages msgs = new Messages();

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

            SQLDomainDataProvider domainProvider = null;

            if ((act as IDCTClient).DBConnection != null)
            {
                domainProvider = (act as IDCTClient).DBConnection as SQLDomainDataProvider;
            }
            else
            {
                domainProvider = DomainDataProviderManager.DomainDataProvider() as SQLDomainDataProvider;
                (act as IDCTClient).DBConnection = domainProvider;
            }

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

            if (msgs.IsSuccess())
            {
                ActionOnLineHelper _helper = new ActionOnLineHelper(domainProvider);

                msgs = _helper.GetIDInfo(args.RunningCard);

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

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

                    domainProvider.BeginTransaction();

                    try
                    {
                        IDCTClient client = act as IDCTClient;

                        // 同时做归属工单
                        if (this.NeedGoMO == true && this.NeedGoMOCode != string.Empty)
                        {
                            ActionGotoMO actionGoMO = new ActionGotoMO();
                            msgs.AddMessages(actionGoMO.CheckSNFormat(args));

                            if (msgs.IsSuccess())
                            {
                                IAction dataCollectModuleGoMO = new BenQGuru.eMES.DataCollect.Action.ActionFactory(domainProvider).CreateAction(ActionType.DataCollectAction_GoMO);
                                msgs.AddMessages(((IActionWithStatus)dataCollectModuleGoMO).Execute(
                                                     new GoToMOActionEventArgs(
                                                         ActionType.DataCollectAction_GoMO,
                                                         args.RunningCard,
                                                         client.LoginedUser,
                                                         client.ResourceCode,
                                                         product,
                                                         this.NeedGoMOCode)));
                            }

                            // 做归属工单后,重新获取ProductInfo
                            if (msgs.IsSuccess())
                            {
                                msgs    = _helper.GetIDInfo(args.RunningCard);
                                product = (ProductInfo)msgs.GetData().Values[0];
                            }
                        }

                        //良品采集
                        if (msgs.IsSuccess())
                        {
                            msgs.AddMessages(((IActionWithStatus)dataCollectModule).Execute(
                                                 new ActionEventArgs(
                                                     ActionType.DataCollectAction_GOOD,
                                                     args.RunningCard,
                                                     client.LoginedUser,
                                                     client.ResourceCode,
                                                     product)));
                        }

                        // 做SMT物料关联
                        if (msgs.IsSuccess())
                        {
                            if (System.Configuration.ConfigurationSettings.AppSettings["PartConn"] != null &&
                                System.Configuration.ConfigurationSettings.AppSettings["PartConn"].ToUpper().Trim() == "TRUE")
                            {
                                msgs.AddMessages(this.SMTLoadItem(args.RunningCard.ToUpper().Trim(), client.ResourceCode.ToUpper(), client.LoginedUser.ToUpper(), domainProvider));
                            }
                        }

                        if (msgs.IsSuccess())
                        {
                            domainProvider.CommitTransaction();
                            msgs.Add(new UserControl.Message(MessageType.Success, string.Format("$CS_GOODSUCCESS")));
                        }
                        else
                        {
                            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);
            }

            ProcessBeforeReturn(this.Status, msgs);
            return(msgs);
        }
Esempio n. 10
0
 public DCTFacade(SQLDomainDataProvider dataProvider)
 {
     _DataProvider = dataProvider;
 }
Esempio n. 11
0
        public override Messages PreAction(object act)
        {
            Messages msgs = new Messages();

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

            SQLDomainDataProvider domainProvider = null;

            if ((act as IDCTClient).DBConnection != null)
            {
                domainProvider = (act as IDCTClient).DBConnection as BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider;
            }
            else
            {
                domainProvider = DomainDataProviderManager.DomainDataProvider() as SQLDomainDataProvider;
                (act as IDCTClient).DBConnection = domainProvider;
            }

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

            if (_UserCode.Trim().Length <= 0)
            {
                //输入用户名

                if (msgs.IsSuccess())
                {
                    if (data.Length <= 0)
                    {
                        msgs.Add(new UserControl.Message(UserControl.MessageType.Error, "$Error_User_Code_Empty"));
                    }
                }

                if (msgs.IsSuccess())
                {
                    _User = (new BaseSetting.UserFacade(domainProvider)).GetUser(data);
                    if (_User == null)
                    {
                        msgs.Add(new UserControl.Message(UserControl.MessageType.Error, "$Error_User_Not_Exist"));
                    }
                }

                if (msgs.IsSuccess())
                {
                    _UserCode = data;
                    msgs.Add(new UserControl.Message(UserControl.MessageType.Normal, "$DCT_PLEASE_INPUT_PASSWORD"));
                }
            }
            else if (_Password.Trim().Length <= 0)
            {
                //输入密码

                if (msgs.IsSuccess())
                {
                    if (data.Length <= 0)
                    {
                        msgs.Add(new UserControl.Message(UserControl.MessageType.Error, "$Error_Password_Empty"));
                    }
                }

                if (msgs.IsSuccess())
                {
                    try
                    {
                        _User = (new Security.SecurityFacade(domainProvider)).LoginCheck(_UserCode, data, out _UserGroup);
                    }
                    catch (Exception ex)
                    {
                        msgs.Add(new UserControl.Message(UserControl.MessageType.Error, ex.Message));
                    }
                }

                if (msgs.IsSuccess())
                {
                    _Password = data;
                    msgs.Add(new UserControl.Message(UserControl.MessageType.Normal, "$DCT_PLEASE_INPUT_RESOURCE"));

                    this.Status = ActionStatus.Working;
                }
            }

            ProcessBeforeReturn(this.Status, msgs);

            return(msgs);
        }
Esempio n. 12
0
        public override Messages Action(object act)
        {
            Messages msgs = new Messages();

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

            SQLDomainDataProvider domainProvider = null;

            if ((act as IDCTClient).DBConnection != null)
            {
                domainProvider = (act as IDCTClient).DBConnection as SQLDomainDataProvider;
            }
            else
            {
                domainProvider = DomainDataProviderManager.DomainDataProvider() as SQLDomainDataProvider;
                (act as IDCTClient).DBConnection = domainProvider;
            }

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

            if (msgs.IsSuccess())
            {
                ActionOnLineHelper _helper = new ActionOnLineHelper(domainProvider);

                msgs = _helper.GetIDInfo(args.RunningCard);

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

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

                    domainProvider.BeginTransaction();

                    try
                    {
                        IDCTClient client = act as IDCTClient;

                        //良品采集
                        if (msgs.IsSuccess())
                        {
                            msgs.AddMessages(((IActionWithStatus)dataCollectModule).Execute(
                                                 new ActionEventArgs(
                                                     ActionType.DataCollectAction_GOOD,
                                                     args.RunningCard,
                                                     client.LoginedUser,
                                                     client.ResourceCode,
                                                     product)));
                        }


                        if (msgs.IsSuccess())
                        {
                            domainProvider.CommitTransaction();
                            msgs.Add(new UserControl.Message(MessageType.Success, string.Format("$CS_GOODSUCCESS")));
                        }
                        else
                        {
                            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);
            }

            ProcessBeforeReturn(this.Status, msgs);
            return(msgs);
        }