コード例 #1
0
        /// <summary>
        /// Unload the device.
        /// </summary>
        public void Unload()
        {
            if (IsActive && oposCashDrawer != null)
            {
                NetTracer.Information("Peripheral [CashDrawer] - Device Released");

                oposCashDrawer.StatusUpdateEvent -= new _IOPOSCashDrawerEvents_StatusUpdateEventEventHandler(posCashDrawer_StatusUpdateEvent);
                oposCashDrawer.ReleaseDevice();
                oposCashDrawer.Close();
            }

            IsActive = false;
        }
コード例 #2
0
        public string openCashBox()
        {
            string posNum  = string.Empty;
            string posType = string.Empty;

            try
            {
                //nec的机子,此方法不会真正调钱箱方法,只是会用返回的posNum。真正真正调钱箱方法在IsNec的判断里面
                OpenCashBox.OpenCashBox.openCashBox(out posNum, out posType);
                LogTools.Info(string.Format("调OpenCashBox.openCashBox的结果:posNum:{0},posType:{1}。", posNum, posType));
            }
            catch (Exception ex)
            {
                LogTools.Info("调弹钱箱异常:" + ex.ToString());
            }
            if (IsNec == 1)
            {
                try
                {
                    int num = this.cashDrawer1.Open(cashBox_name);
                    if (num != 0)
                    {
                        cashDrawer1.Close();
                        num = cashDrawer1.Open(cashBox_name);
                        if (num != 0)
                        {
                            throw new Exception("[Pos 2001] 钱箱驱动Open失败!返回码:" + num.ToString());
                        }
                    }
                    int claimResult = cashDrawer1.ClaimDevice(1000);
                    if (claimResult != 0)
                    {
                        throw new Exception("[Pos 2002] 钱箱声明失败!返回码:" + claimResult.ToString());
                    }
                    cashDrawer1.DeviceEnabled = true;
                    cashDrawer1.OpenDrawer();
                    cashDrawer1.DeviceEnabled = false;
                }
                catch (Exception ex)
                {
                    LogTools.Debug("开钱箱异常:" + ex.ToString());
                }
                finally
                {
                    cashDrawer1.ReleaseDevice();
                    cashDrawer1.Close();
                }
            }
            return(posNum);
        }