/// <summary> /// Gets the status. /// </summary> /// <returns>DispenserStatus</returns> public static DispenserStatus GetStatus(out string errorDesc, out uint iErrorcode) { DispenserStatus status = DispenserStatus.NotAvailable; ICoinDispenser coinDispenser = null; errorDesc = string.Empty; iErrorcode = 1; try { coinDispenser = GetCoinDispenser(); CoinDispStatus dispStatus = coinDispenser.GetStatus(); if (dispStatus != null) { if (IsSucceeded(dispStatus.ErrorCode)) { status = DispenserStatus.Available; } errorDesc = dispStatus.ErrDesc; iErrorcode = dispStatus.ErrorCode; } else { errorDesc = "Unable to connect cash dispenser."; } LogManager.WriteLog("|=> (GetStatus) : " + errorDesc, LogManager.enumLogLevel.Info); } //catch (System.IO.IOException ex) //{ // ExceptionManager.Publish(ex); //} catch (Exception ex) { ExceptionManager.Publish(ex); } finally { coinDispenser = null; if (string.IsNullOrEmpty(errorDesc)) { errorDesc = "Unable to connect cash dispenser."; } } return(status); }
/// <summary> /// Tests the status. /// </summary> /// <param name="errorDesc">The error desc.</param> /// <returns>DispenserStatus</returns> public DispenserStatus TestStatus(out string errorDesc) { DispenserStatus status = DispenserStatus.NotAvailable; ICoinDispenser coinDispenser = null; errorDesc = string.Empty; string deckMsg = "Deck Type : " + ((this.DeckType == TypeOfDeck.Lower) ? "Lower" : "Upper"); CoinDispStatus dispStatus = null; bool canUpdateToDB = false; decimal issuedValue = 0; decimal rejectedValue = 0; decimal? issuedValue2 = 0; decimal? rejectedValue2 = 0; try { coinDispenser = GetCoinDispenser(); if (this.DeckType == TypeOfDeck.Lower) { dispStatus = coinDispenser.TestLowerDeck(); } else { dispStatus = coinDispenser.TestUpperDeck(); } if (dispStatus != null) { if (IsSucceeded(dispStatus.ErrorCode)) { status = DispenserStatus.Available; } errorDesc = dispStatus.ErrDesc; } else { errorDesc = "Unable to connect cash dispenser."; } LogManager.WriteLog("|=> (TestStatus) : " + deckMsg + ", " + errorDesc, LogManager.enumLogLevel.Info); } catch (Exception ex) { ExceptionManager.Publish(ex); } finally { try { if (dispStatus != null) { LogManager.WriteLog("|=> (Dispense) : Error Code : " + dispStatus.ErrorCode.ToString(), LogManager.enumLogLevel.Info); canUpdateToDB = true; if (this.DeckType == TypeOfDeck.Lower) { issuedValue = dispStatus.LowDispNotes; rejectedValue = dispStatus.LowRejNotes; } else { issuedValue = dispStatus.UPDispNotes; rejectedValue = dispStatus.UPRejNotes; } } if (canUpdateToDB) { // UPDATE IT INTO DATABASE using (CashDispenserDBDataContext context = new CashDispenserDBDataContext(CashDispenserFactory.ExchangeConnectionString)) { int?iResult = 0; context.UpdateCashDispenserItemValues(this.CassetteID, issuedValue, rejectedValue, ref issuedValue2, ref rejectedValue2, ref iResult); LogManager.WriteLog("|=> (TestStatus) : Result : " + (iResult.Value > 0).ToString(), LogManager.enumLogLevel.Info); } } } catch (Exception ex) { ExceptionManager.Publish(ex); } coinDispenser = null; } return(status); }