예제 #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);
        }
예제 #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;
            }
        }
예제 #3
0
 public FacadeFactory()
 {
     if (_domainDataProvider == null)
     {
         _domainDataProvider = DomainDataProviderManager.DomainDataProvider();
     }
 }
예제 #4
0
        private void RunSP(object jobName)
        {
            try
            {
                DataRow rowOfJob = this.FindRow(jobName.ToString());
                rowOfJob["RunStatus"] = "运行中";

                ProcedureParameter pp1 = new ProcedureParameter("v_jobList", typeof(string), 40, DirectionType.Input, jobName.ToString());
                ProcedureParameter pp2 = new ProcedureParameter("v_date", typeof(int), 8, DirectionType.Input, m_InputDate);

                ProcedureCondition pc = new ProcedureCondition("PKG_DBTRANSFER.Transfer", new ProcedureParameter[] { pp1, pp2 });

                // 多线程Run每一个任务,每一个任务自己创建自己的数据库链接
                IDomainDataProvider newProvider = DomainDataProviderManager.DomainDataProvider();
                newProvider.CustomProcedure(ref pc);

                Thread.Sleep(10000);

                rowOfJob["RunStatus"] = "完成";

                TransferJob job = TransferFacade.GetTransferJob(Convert.ToInt32(rowOfJob["Serial"])) as TransferJob;
                rowOfJob["LastRunDate"]     = job.LastRunDate == 0 ? "0" : FormatHelper.TODateTimeString(job.LastRunDate, job.LastRunTime);
                rowOfJob["LastSuccessDate"] = job.LastSuccessDate == 0 ? "0" : FormatHelper.TODateTimeString(job.LastSuccessDate, job.LastSuccessTime);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                this.Invoke(new Action <int>(this.SetFlag), 1);
            }
        }
예제 #5
0
 public ReportSQLHelper(IDomainDataProvider domainDataProvider)
 {
     this._DomainDataProvider = domainDataProvider;
     if (_DomainDataProvider == null)
     {
         _DomainDataProvider = DomainDataProviderManager.DomainDataProvider();
     }
 }
예제 #6
0
 private void Init()
 {
     //_persistBroker = PersistBrokerManager.PersistBroker(@"Provider=Microsoft.Jet.OLEDB.4.0;Password=;Data Source=" + this.FullPath + ";Persist Security Info=True", null);
     //add by klaus
     _persistBroker = PersistBrokerManager.PersistBroker(@"Provider=Microsoft.ACE.OLEDB.12.0;Password=;Data Source=" + this.FullPath + ";Persist Security Info=False", null);
     //end
     _domainDataProvider = DomainDataProviderManager.DomainDataProvider(_persistBroker, null);
     _languageHashtable  = new System.Collections.Hashtable();
     this.CacheLanguage();
 }
예제 #7
0
        public void SetUp()
        {
            _domainDataProvider = DomainDataProviderManager.DomainDataProvider();

            if (_domainDataProvider.CustomSearch(typeof(User), new object[] { "UserCode" }) == null)
            {
                User user = new User();
                user.UserCode       = "UserCode";
                user.UserPassword   = "******";
                user.UserDepartment = "GRD2";
                user.MaintainUser   = "******";
                user.MaintainDate   = 20050412;
                user.MaintainTime   = 190212;
                _domainDataProvider.Insert(user);
            }
        }
예제 #8
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 ";
        }
예제 #9
0
        public Message GetActionDesc(BaseDCTAction action)
        {
            Message msg     = null;
            string  command = GetCommandByAction(action);

            if (command.Length > 0)
            {
                BaseModelFacade facade = new BaseModelFacade((SQLDomainDataProvider)DomainDataProviderManager.DomainDataProvider());

                Dct dctAction = (Dct)facade.GetDCT(command);

                if (dctAction != null)
                {
                    msg = new Message("$DCT_CurrentDCTCommand " + dctAction.Dctdesc);
                }
            }

            return(msg);
        }
예제 #10
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);
        }
예제 #11
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;
                        }
                    }
                }
            }
        }
예제 #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 (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);
        }
예제 #13
0
        public ServiceResult Run(RunMethod runMethod)
        {
            /*------ Get WebService URL and UserName and Password ------*/
            SAPWebServiceEntity webServiceEntity = System.Configuration.ConfigurationManager.GetSection("MOBOMTransferConfig") as SAPWebServiceEntity;

            if (webServiceEntity == null)
            {
                return(new ServiceResult(false, "没有维护MOBOMTransferConfig对应的Service地址", this.m_Argument.TransactionCode));
            }

            #region Begin for Prepare input Paremente
            // Prepare input parameter
            DT_MES_POBOM_REQ moBOMParameter = new DT_MES_POBOM_REQ();
            moBOMParameter.Mocode           = this.m_Argument.MOCodeList;
            moBOMParameter.Transaction_code = this.m_Argument.TransactionCode;
            #endregion

            // Serialize the Input Parameter
            string xmlFilePath = SerializeUtil.SerializeFile(this.m_Argument.TransactionCode + "_Request.xml",
                                                             typeof(DT_MES_POBOM_REQ), moBOMParameter);

            #region For Request Log
            DBDateTime         requestDateTime = FormatHelper.GetNowDBDateTime(this.DataProvider);
            SAPDataTransferLog log             = new SAPDataTransferLog();
            // new trans
            TransferFacade transferFacade = new TransferFacade(DomainDataProviderManager.DomainDataProvider());
            log.JobID               = TransferFacade.MOMaterialTransferJobID;
            log.TransactionCode     = this.m_Argument.TransactionCode;
            log.TransactionSequence = 1;
            log.RequestDate         = requestDateTime.DBDate;
            log.RequestTime         = requestDateTime.DBTime;
            log.RequestContent      = xmlFilePath;
            log.OrganizationID      = InternalVariables.MS_OrganizationID;
            log.SendRecordCount     = 1;
            transferFacade.AddSAPDataTransferLog(log);
            #endregion

            #region Begin for Calling WebService
            // Call Web Service through MaterialServiceClientProxy
            DT_MES_POBOM_RESP returnValue;
            try
            {
                MOBOMServiceClientProxy clientProxy = new MOBOMServiceClientProxy();
                clientProxy.RequestEncoding = Encoding.UTF8;
                clientProxy.Timeout         = InternalVariables.MS_TimeOut * 1000;
                clientProxy.Url             = webServiceEntity.Url;
                clientProxy.PreAuthenticate = true;
                System.Uri uri = new Uri(clientProxy.Url);
                clientProxy.Credentials = new NetworkCredential(webServiceEntity.UserName, webServiceEntity.Password).GetCredential(uri, "");
                returnValue             = clientProxy.MI_MES_POBOM_REQ(moBOMParameter);
                clientProxy.Dispose();
                clientProxy = null;

                //Serialize the output Parameter
                xmlFilePath = SerializeUtil.SerializeFile(this.m_Argument.TransactionCode + "_Response.xml",
                                                          typeof(DT_MES_POBOM_RESP), returnValue);

                // Update Log
                DBDateTime responseDateTime = FormatHelper.GetNowDBDateTime(this.DataProvider);
                log.ResponseDate    = responseDateTime.DBDate;
                log.ResponseTime    = responseDateTime.DBTime;
                log.ResponseContent = xmlFilePath;
                transferFacade.UpdateSAPDataTransferLog(log);
            }
            catch (Exception e)
            {
                log.Result       = "Fail";
                log.ErrorMessage = e.Message;
                transferFacade.UpdateSAPDataTransferLog(log);
                return(new ServiceResult(false, e.Message, log.TransactionCode));
            }
            #endregion

            if (string.Compare(returnValue.FLAG, "Y", true) == 0)
            {
                int moBOMCount = returnValue.POCONFIRM_LIST.Length;

                if (runMethod == RunMethod.Manually)
                {
                    ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)DataProvider).PersistBroker.AutoCloseConnection = false;
                    ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)DataProvider).PersistBroker.OpenConnection();
                    this.DataProvider.BeginTransaction();
                }

                try
                {
                    #region Main flow
                    MOFacade moBOMFacade = new MOFacade(this.DataProvider);
                    MOBOM    moBOM;
                    DT_MES_POBOM_RESPPOCONFIRM_LIST moBOMObject;

                    for (int j = 0; j < this.m_Argument.MOCodeList.Length; j++)
                    {
                        moBOMFacade.DeleteMOBOMByMOCode(this.m_Argument.MOCodeList[j].ToUpper());

                        for (int i = 0; i < moBOMCount; i++)
                        {
                            if (string.Compare(returnValue.POCONFIRM_LIST[i].MOCODE, this.m_Argument.MOCodeList[j], true) != 0)
                            {
                                continue;
                            }
                            else
                            {
                                moBOMObject = returnValue.POCONFIRM_LIST[i];

                                moBOM               = moBOMFacade.CreateNewMOBOM();
                                moBOM.MOCode        = moBOMObject.MOCODE;
                                moBOM.ItemCode      = InternalVariables.MatchItemCode(moBOMObject.ITEMCODE);
                                moBOM.MOBOMItemCode = InternalVariables.MatchItemCode(moBOMObject.MOBITEMCODE);
                                //moBOM.MOBOMItemName = moBOMObject.MOBITEMDESC;
                                //moBOM.MOBOMItemDescription = moBOMObject.MOBITEMDESC;
                                moBOM.MOBOMItemName          = "";
                                moBOM.MOBOMItemDescription   = "";
                                moBOM.MOBOMItemQty           = decimal.Parse(moBOMObject.MOBITEMQTY);
                                moBOM.MOBOMSourceItemCode    = InternalVariables.MatchItemCode(moBOMObject.MOBITEMCODE);
                                moBOM.MOBOMItemUOM           = moBOMObject.MOBOMITEMUOM;
                                moBOM.Sequence               = moBOMFacade.GetMOBOMMaxSequence(moBOMObject.MOCODE);
                                moBOM.MOBOMItemStatus        = "0";
                                moBOM.MOBOMItemEffectiveDate = 20080101;
                                moBOM.MOBOMItemEffectiveTime = 1;
                                moBOM.MOBOMItemInvalidDate   = 29991231;
                                moBOM.MOBOMItemInvalidTime   = 1;
                                moBOM.MaintainUser           = "******";
                                moBOM.MOBOMItemECN           = "";
                                moBOM.MOBOMItemLocation      = "";
                                moBOM.MOBOMItemVersion       = "";
                                moBOM.MOBOMItemControlType   = "";
                                moBOM.EAttribute1            = "";
                                moBOM.OPCode     = "";
                                moBOM.MoBOM      = moBOMObject.MOBOM;
                                moBOM.MOBOMLine  = moBOMObject.MOBOMLINE;
                                moBOM.MOFactory  = moBOMObject.MOFAC;
                                moBOM.MOResource = moBOMObject.MORESOURCE;

                                moBOMFacade.AddMOBOM(moBOM);
                            }
                        }
                    }

                    if (runMethod == RunMethod.Manually)
                    {
                        this.DataProvider.CommitTransaction();
                    }
                    #endregion

                    log.Result       = "OK";
                    log.ErrorMessage = "";
                }
                catch (Exception ex)
                {
                    if (runMethod == RunMethod.Manually)
                    {
                        this.DataProvider.RollbackTransaction();
                    }

                    // Log
                    log.Result       = "Fail";
                    log.ErrorMessage = ex.Message;
                }
                finally
                {
                    if (runMethod == RunMethod.Manually)
                    {
                        ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)DataProvider).PersistBroker.CloseConnection();
                        ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)DataProvider).PersistBroker.AutoCloseConnection = true;
                    }
                }

                log.ReceivedRecordCount = moBOMCount;
                DBDateTime finishedDateTime = FormatHelper.GetNowDBDateTime(this.DataProvider);
                log.FinishedDate = finishedDateTime.DBDate;
                log.FinishedTime = finishedDateTime.DBTime;
                transferFacade.UpdateSAPDataTransferLog(log);

                if (log.Result == "OK")
                {
                    return(new ServiceResult(true, "", log.TransactionCode));
                }
                else
                {
                    return(new ServiceResult(false, log.ErrorMessage, log.TransactionCode));
                }
            }
            else //  status!="OK"
            {
                log.Result              = "Fail";
                log.ErrorMessage        = returnValue.message;
                log.ReceivedRecordCount = 0;
                transferFacade.UpdateSAPDataTransferLog(log);
                return(new ServiceResult(false, log.ErrorMessage, log.TransactionCode));
            }
        }
예제 #14
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);
        }
예제 #15
0
        public override Messages Action(object act)
        {
            Messages msgs = new Messages();

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

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

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

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

            if (_ResCode.Trim().Length <= 0)
            {
                //输入资源

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

                if (msgs.IsSuccess())
                {
                    object resource = new BaseModelFacade(domainProvider).GetResource(data);
                    if (resource == null)
                    {
                        msgs.Add(new UserControl.Message(UserControl.MessageType.Error, "$Error_Resource_Not_Exist"));
                    }
                }

                if (msgs.IsSuccess())
                {
                    _ResCode = data;
                }
            }

            if (msgs.IsSuccess())
            {
                bool bIsAdmin = false;
                if (_UserGroup != null)
                {
                    foreach (object o in _UserGroup)
                    {
                        if (((UserGroup)o).UserGroupType == "ADMIN")
                        {
                            bIsAdmin = true;
                            break;
                        }
                    }
                }

                if (!bIsAdmin)
                {
                    if (!(new Security.SecurityFacade(domainProvider)).CheckResourceRight(_UserCode, _ResCode))
                    {
                        msgs.Add(new UserControl.Message(UserControl.MessageType.Error, "$Error_No_Resource_Right"));
                    }
                }
            }

            if (msgs.IsSuccess())
            {
                object res = new BaseModelFacade(domainProvider).GetResource(_ResCode);
                object org = (new BaseModelFacade(domainProvider)).GetOrg(((Resource)res).OrganizationID);
                if (org != null)
                {
                    GlobalVariables.CurrentOrganizations.Clear();
                    GlobalVariables.CurrentOrganizations.Add((Organization)org);
                }
                else
                {
                    msgs.Add(new UserControl.Message(UserControl.MessageType.Error, "$Error_NoOrganizationOfTheResource"));
                }
            }

            if (msgs.IsSuccess())
            {
                msgs.Add(new UserControl.Message(UserControl.MessageType.Success, "$DCT_WELCOME"));

                if (act is IDCTClient)
                {
                    IDCTClient client = act as IDCTClient;
                    client.Authorized      = true;
                    client.LoginedUser     = _UserCode;
                    client.LoginedPassword = _Password;
                    client.ResourceCode    = _ResCode;

                    Resource resource = (Resource)(new BaseModelFacade(domainProvider)).GetResource(data);
                    if (resource != null)
                    {
                        client.SegmentCode      = resource.SegmentCode;
                        client.StepSequenceCode = resource.StepSequenceCode;
                        client.ShiftTypeCode    = resource.ShiftTypeCode;
                    }
                }
            }

            if (msgs.IsSuccess())
            {
                this.Status = ActionStatus.Pass;
            }

            ProcessBeforeReturn(this.Status, msgs);

            return(msgs);
        }
예제 #16
0
 private void Init()
 {
     _persistBroker      = PersistBrokerManager.PersistBroker(@"Provider=Microsoft.Jet.OLEDB.4.0;Password=;Data Source=" + this.FullPath + ";Persist Security Info=True", null);
     _domainDataProvider = DomainDataProviderManager.DomainDataProvider(_persistBroker, null);
 }
예제 #17
0
 public DataFileParser()
 {
     _dataProvider = DomainDataProviderManager.DomainDataProvider();
 }
예제 #18
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            JavaScriptSerializer jss = new JavaScriptSerializer();

            //OracleDbHelper oracleHelper = new OracleDbHelper("Mes64");
            IDomainDataProvider dataProvider = DomainDataProviderManager.DomainDataProvider();
            BaseModelFacade     facade       = new BaseModelFacade(dataProvider);

            string action    = context.Request["action"];
            string routecode = context.Request["routecode"];

            if (action == "getRouteByCode")
            {
                Route route = facade.GetRoute(routecode) as Route;

                string strJson = jss.Serialize(route);
                context.Response.Write(strJson);
            }
            else if (action == "getOpByRoute")
            {
                OperationOfRoute[] opList = facade.GetOpByRouteCode(routecode) as OperationOfRoute[];

                string strJson = jss.Serialize(opList);

                context.Response.Write(strJson);
            }
            else if (action == "getOtherOp")
            {
                string opcode = context.Request["opcode"];
                if (opcode == null)
                {
                    opcode = string.Empty;
                }

                Operation[] opList  = facade.GetOtherOpByRouteCode(routecode, opcode) as Operation[];
                string      strJson = jss.Serialize(opList);

                context.Response.Write(strJson);
            }
            else if (action == "save")
            {
                string opJson = context.Request["opJson"];
                Op[]   opList = jss.Deserialize <Op[]>(opJson);
                //List<Op> opList = opArray.ToList<Op>();
                //context.Response.Write(jss.Serialize(opList));

                try
                {
                    dataProvider.BeginTransaction();

                    foreach (Op op in opList)
                    {
                        Route2Operation opNew = new Route2Operation();
                        opNew.RouteCode    = routecode;
                        opNew.OPCode       = op.OpCode;
                        opNew.OPSequence   = op.OpSeq;
                        opNew.OPControl    = op.OpControl + "0000000000";
                        opNew.MaintainUser = "******";
                        opNew.MaintainDate = Convert.ToInt32(DateTime.Now.ToString("yyyyMMdd"));
                        opNew.MaintainTime = Convert.ToInt32(DateTime.Now.ToString("HHmmss"));

                        if (op.DataType == 0)
                        {
                            facade.AddRoute2Operation(opNew);
                        }
                        else if (op.DataType == 1)
                        {
                            facade.UpdateRoute2Operation(opNew);
                        }
                        else if (op.DataType == 2)
                        {
                            facade.DeleteRoute2Operation(opNew);
                        }
                    }
                    dataProvider.CommitTransaction();
                }
                catch (Exception ex)
                {
                    dataProvider.RollbackTransaction();
                    context.Response.StatusCode = 500;
                    context.Response.Write(ex.Message);
                    context.Response.End();
                }
            }
        }
예제 #19
0
        private void Import(DataName _dataName)
        {
            DateTime jobLogStartTime = DateTime.Now;                            //JobLog日志开始时间

            #region 从sap数据库获取数据
            //从sap数据库获取数据
            IDomainDataProvider _sapDataProvider = DomainDataProviderManager.DomainDataProvider(DBName.SAP);
            IDomainDataProvider _mesDataProvider = DomainDataProviderManager.DomainDataProvider(DBName.MES);

            if (_sapDataProvider != null && ((SQLDomainDataProvider)_sapDataProvider).PersistBroker != null)
            {
                importLogger.Write(string.Format("已经连接到SAP的数据库 {0}", _dataName));
                System.Console.WriteLine(string.Format("已经连接到SAP的数据库 {0}", _dataName));
            }
            else
            {
                importLogger.Write(string.Format("连接到SAP的数据库失败 {0}", _dataName));
                System.Console.WriteLine(string.Format("连接到SAP的数据库失败 {0}", _dataName));
            }

            if (_mesDataProvider != null && ((SQLDomainDataProvider)_mesDataProvider).PersistBroker != null)
            {
                importLogger.Write(string.Format("已经连接到MES的数据库 {0}", _dataName));
                System.Console.WriteLine(string.Format("已经连接到MES的数据库 {0}", _dataName));
            }
            else
            {
                importLogger.Write(string.Format("连接到MES的数据库失败 {0}", _dataName));
                System.Console.WriteLine(string.Format("连接到MES的数据库失败 {0}", _dataName));
            }

            importLogger.Write("");
            System.Console.WriteLine("");

            bool isImportSuccess = true;             //导入是否成功
            try
            {
                SAPDataGeter dateGetter = new SAPDataGeter(_sapDataProvider);
                int          count      = dateGetter.GetImportCount(_dataName);
                importLogger.Write(string.Format("获取到{0}数据 {1}条", _dataName, count.ToString()));

                if (count > 0)
                {
                    int pageCount = (int)Math.Floor(Convert.ToDecimal(count / this.page_exclusive)) + 1;                   //获取总页数
                    importLogger.Write(string.Format("将要分成{0}页进行导入,每页数据{1}条", pageCount.ToString(), page_exclusive.ToString()));
                    importLogger.Write(string.Format("正在导入{0}数据 ", _dataName));
                    System.Console.WriteLine(string.Format("正在导入{0}数据 ", _dataName));
                    int SucceedNum = 0;                                 //成功导入的数据
                    for (int i = 1; i < pageCount + 1; i++)
                    {
                        if (i == 1)
                        {
                            System.Console.WriteLine(string.Format("将要分成{0}页进行导入,每页数据{1}条", pageCount.ToString(), page_exclusive.ToString()));
                        }
                        SucceedNum += this.RunItemImportByPage(_dataName, _sapDataProvider, _mesDataProvider, i);
                        System.Console.WriteLine(string.Format("正在导入{0}第{1}页数据", _dataName, i.ToString()));
                    }
                    importLogger.Write(string.Format("成功导入{0}  {1}条数据 ", _dataName, SucceedNum));
                    System.Console.WriteLine(string.Format("成功导入{0}  {1}条数据 ", _dataName, SucceedNum));
                    System.Console.WriteLine("");
                }
            }
            catch (Exception ex)
            {
                importLogger.Write(string.Format("导入{0}数据 出错,详细信息为{1}", _dataName, ex.Message));
                isImportSuccess = false;
            }
            finally
            {
                if (_sapDataProvider != null)
                {
                    ((SQLDomainDataProvider)_sapDataProvider).PersistBroker.CloseConnection();
                }
                if (_mesDataProvider != null)
                {
                    ((SQLDomainDataProvider)_mesDataProvider).PersistBroker.CloseConnection();
                }
            }

            #endregion

            //#region 写JobLog

            IDomainDataProvider _JobLogDataProvider = DomainDataProviderManager.DomainDataProvider(DBName.SAP);

            if (_JobLogDataProvider != null && ((SQLDomainDataProvider)_JobLogDataProvider).PersistBroker != null)
            {
                importLogger.Write("已经连接到JobLog的数据库");
                System.Console.WriteLine("已经连接到JobLog的数据库");
            }
            else
            {
                importLogger.Write("连接到JobLog的数据库失败");
                System.Console.WriteLine("连接到JobLog的数据库失败");
            }

            try
            {
                DateTime jobLogEndTime = DateTime.Now;                                  //JobLog日志结束时间
                importLogger.Write(string.Format("正在写{0} JobLog", _dataName));
                SAPDataGeter JobLogWriter = new SAPDataGeter(_JobLogDataProvider);

                if (isImportSuccess)
                {
                    JobLogWriter.AddSuccessJobLog(this.getJobName(_dataName), jobLogStartTime, jobLogEndTime);
                }
                else
                {
                    JobLogWriter.AddFailedJobLog(this.getJobName(_dataName), jobLogStartTime, jobLogEndTime);
                }

                importLogger.Write(string.Format("写入{0} JobLog 完成", _dataName));
                importLogger.Write("");
            }
            catch (Exception ex)
            {
                importLogger.Write(string.Format("写入{0} JobLog 失败,,详细信息为{1}", _dataName, ex.Message));
            }
            finally
            {
                if (_JobLogDataProvider != null)
                {
                    ((SQLDomainDataProvider)_JobLogDataProvider).PersistBroker.CloseConnection();
                }
            }

            //#endregion
        }
예제 #20
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);
        }