Ejemplo n.º 1
0
        private void bgwClear_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                bgwClear.ReportProgress(0);

                this._CurrentDevice = PaymentDeviceFactory.CreateDevice(PaymentDeviceFactory.EastRiverDevice);

                for (int index = 0; index < _infoList.Count; index ++ )
                {
                    if (!_isRun)
                    {
                        break;
                    }

                    IPAddress IPAddr = IPAddress.Parse(_infoList[index].cmm_cIPAddr);

                    ReturnValueInfo rvInfo = this._CurrentDevice.Conn(IPAddr, _infoList[index].cmm_iPort, _infoList[index].cmm_iMacNo);

                    if (rvInfo.boolValue)
                    {
                        rvInfo = this._CurrentDevice.RemoveAllBlacklist();
                        if (rvInfo.boolValue && !rvInfo.isError)
                        {
                            bgwClear.ReportProgress(index + 1,true);
                        }
                        else
                        {
                            bgwClear.ReportProgress(index + 1,false);
                        }
                    }
                    else
                    {
                        bgwClear.ReportProgress(index + 1,false);
                    }

                }

                //bgwClear.ReportProgress(_infoList.Count);

                if (!_isRun)
                {
                    bgwClear.ReportProgress( -10);
                }

            }
            catch
            {

            }
        }
Ejemplo n.º 2
0
        private void bgwReceipts_DoWork(object sender, DoWorkEventArgs e)
        {
            String showMessage = "";
            try
            {
                if (_CurrentDevice == null)
                {
                    _CurrentDevice = PaymentDeviceFactory.CreateDevice(PaymentDeviceFactory.EastRiverDevice);
                }

                int number = 1;

                foreach (int lvIndex in _lvList)
                {
                    try
                    {
                        this.bgwReceipts.ReportProgress(number, null);
                        ConsumeMachineMaster_cmm_Info ccmInfo = null;// _cmmList[lvIndex];

                        for (int index = 0; index < _cmmList.Count(); index++)
                        {
                            if (lvIndex == _cmmList[index].cmm_iMacNo)
                            {
                                ccmInfo = _cmmList[index];
                            }
                        }

                        if (ccmInfo != null)
                        {
                            IPAddress ip = IPAddress.Parse(ccmInfo.cmm_cIPAddr);

                            ReturnValueInfo returnInfo = _CurrentDevice.Conn(ip, ccmInfo.cmm_iPort, ccmInfo.cmm_iMacNo);

                            if (returnInfo.isError)
                            {
                                showMessage += "消费机:" + ccmInfo.cmm_cMacName + ",机号:" + ccmInfo.cmm_iMacNo + " 连接失败!\n";
                            }
                            else
                            {
                                List<ConsumeRecord_csr_Info> posList = _CurrentDevice.GetAllProfileRecords();
                                if (posList != null)
                                {
                                    showMessage += "消费机:" + ccmInfo.cmm_cMacName + ",机号:" + ccmInfo.cmm_iMacNo + " 收数成功!\n";
                                }
                                else
                                {
                                    showMessage += "消费机:" + ccmInfo.cmm_cMacName + ",机号:" + ccmInfo.cmm_iMacNo + " 收数失败!\n";
                                }
                            }
                        }
                    }
                    catch
                    {

                    }
                    finally
                    {
                        _CurrentDevice.DisConn();

                        number++;
                    }
                }
                showMessage += "\n已完成收数操作,共处理" + _lvList.Count + "台收费机。";

            }
            catch
            {

            }
            finally
            {
                this.bgwReceipts.ReportProgress(100, null);
                MessageBox.Show(showMessage, "提示");
                this.bgwReceipts.ReportProgress(101, null);
            }
        }
        private void btnConn_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(tbxIPAddr.Text.Trim()))
            {
                this.ShowWarningMessage("请输入设备IP地址。");
                tbxIPAddr.Focus();
                return;
            }
            if (string.IsNullOrEmpty(tbxPort.Text.Trim()))
            {
                this.ShowWarningMessage("请输入设备端口号。");
                tbxPort.Focus();
                return;
            }
            if (string.IsNullOrEmpty(tbxMacNo.Text.Trim()))
            {
                this.ShowWarningMessage("请输入设备机号。");
                tbxMacNo.Focus();
                return;
            }

            IPAddress IPAddr = IPAddress.Parse(tbxIPAddr.Text.Trim());
            if (IPAddr == null)
            {
                this.ShowWarningMessage("请检查IP地址的格式。");
                tbxIPAddr.Focus();
                return;
            }

            int iPort;
            bool res = int.TryParse(tbxPort.Text.Trim(), out iPort);
            if (!res)
            {
                this.ShowWarningMessage("请输入检查设备端口号的格式。");
                tbxPort.Focus();
                return;
            }

            int iMacNo;
            res = int.TryParse(tbxMacNo.Text.Trim(), out iMacNo);
            if (!res)
            {
                this.ShowWarningMessage("请输入检查设备机号的格式。");
                tbxMacNo.Focus();
                return;
            }

            this.Cursor = Cursors.WaitCursor;

            this._CurrentDevice = PaymentDeviceFactory.CreateDevice(PaymentDeviceFactory.EastRiverDevice);
            ReturnValueInfo rvInfo = this._CurrentDevice.Conn(IPAddr, iPort, iMacNo);

            if (rvInfo.boolValue && !rvInfo.isError)
            {
                this.ShowInformationMessage("设备连接成功。");
                gbxMacOpt.Enabled = true;
            }
            else
            {
                this.ShowWarningMessage("设备连接失败。异常:" + rvInfo.messageText);
            }

            this.Cursor = Cursors.Default;
        }