Exemple #1
0
        /// <summary>
        /// Gets the dispenser.
        /// </summary>
        /// <returns>ICashDispenser</returns>
        public static ICashDispenser GetDispenser()
        {
            ICashDispenser dispenser = new CashDispenserImpl(new List <CashDispenserItem>());

            LogManager.WriteLog("|=> (GetDispenser) : Inside Get Cash Dispenser.", LogManager.enumLogLevel.Info);

            try
            {
                try
                {
                    using (CashDispenserDBDataContext context = new CashDispenserDBDataContext(ExchangeConnectionString))
                    {
                        ISingleResult <rsp_GetCashDispenserItemsResult> items = context.GetCashDispenserItems();
                        if (items != null)
                        {
                            CashDispenserItem.TypeOfDeck prevDeckType = CashDispenserItem.TypeOfDeck.None;
                            foreach (rsp_GetCashDispenserItemsResult item in items)
                            {
                                CashDispenserItem item2 = new CashDispenserItem(item.CassetteName, item.CassetteAlias);
                                item2.CassetteID    = item.CassetteID;
                                item2.Denimination  = item.Denomination;
                                item2.TotalValue    = item.TotalValue;
                                item2.IssuedValue   = item.IssuedValue;
                                item2.RejectedValue = item.RejectedValue;
                                LogManager.WriteLog(string.Format("|=> (GetDispenser) : Cassette [{0}], Denonimation : [{1:D}], Balance : [{2:F}].",
                                                                  item2.CassetteAlias,
                                                                  item2.Denimination,
                                                                  item2.RemainingValueCalculated), LogManager.enumLogLevel.Debug);

                                if (prevDeckType == CashDispenserItem.TypeOfDeck.Upper)
                                {
                                    item2.DeckType = CashDispenserItem.TypeOfDeck.Lower;
                                    //LogManager.WriteLog(string.Format("|=> (GetDispenser) : Upper Deck [{0}].", item2.CassetteAlias), LogManager.enumLogLevel.Info);
                                }
                                else
                                {
                                    prevDeckType = item2.DeckType;
                                    //LogManager.WriteLog(string.Format("|=> (GetDispenser) : Lower Deck [{0}].", item2.CassetteAlias), LogManager.enumLogLevel.Info);
                                }

                                dispenser.DispenserItems.Add(item2);
                            }
                        }
                    }
                }
                finally
                {
                }
            }
            catch (Exception ex)
            {
                ExceptionManager.Publish(ex);
            }

            return(dispenser);
        }
        /// <summary>
        /// Gets the dispenser.
        /// </summary>
        /// <returns>ICashDispenser</returns>
        public static ICashDispenser GetDispenser()
        {
            ICashDispenser dispenser = new CashDispenserImpl(new List<CashDispenserItem>());
            LogManager.WriteLog("|=> (GetDispenser) : Inside Get Cash Dispenser.", LogManager.enumLogLevel.Info);

            try
            {
                try
                {
                    using (CashDispenserDBDataContext context = new CashDispenserDBDataContext(ExchangeConnectionString))
                    {
                        ISingleResult<rsp_GetCashDispenserItemsResult> items = context.GetCashDispenserItems();
                        if (items != null)
                        {
                            CashDispenserItem.TypeOfDeck prevDeckType = CashDispenserItem.TypeOfDeck.None;
                            foreach (rsp_GetCashDispenserItemsResult item in items)
                            {
                                CashDispenserItem item2 = new CashDispenserItem(item.CassetteName, item.CassetteAlias);
                                item2.CassetteID = item.CassetteID;
                                item2.Denimination = item.Denomination;
                                item2.TotalValue = item.TotalValue;
                                item2.IssuedValue = item.IssuedValue;
                                item2.RejectedValue = item.RejectedValue;
                                LogManager.WriteLog(string.Format("|=> (GetDispenser) : Cassette [{0}], Denonimation : [{1:D}], Balance : [{2:F}].", 
                                    item2.CassetteAlias, 
                                    item2.Denimination,
                                    item2.RemainingValueCalculated), LogManager.enumLogLevel.Debug);

                                if (prevDeckType == CashDispenserItem.TypeOfDeck.Upper)
                                {
                                    item2.DeckType = CashDispenserItem.TypeOfDeck.Lower;
                                    //LogManager.WriteLog(string.Format("|=> (GetDispenser) : Upper Deck [{0}].", item2.CassetteAlias), LogManager.enumLogLevel.Info);
                                }
                                else
                                {
                                    prevDeckType = item2.DeckType;
                                    //LogManager.WriteLog(string.Format("|=> (GetDispenser) : Lower Deck [{0}].", item2.CassetteAlias), LogManager.enumLogLevel.Info);
                                }

                                dispenser.DispenserItems.Add(item2);
                            }
                        }
                    }
                }
                finally
                {
                }
            }
            catch (Exception ex)
            {
                ExceptionManager.Publish(ex);
            }

            return dispenser;
        }