public static List <PreparedRecord> Prepare(global::Statistics.Statistics statistics)
        {
            var states = Configurator.Config();

            return
                (statistics.Records.Select(
                     item =>
                     new PreparedRecord(item.TimeOfOperation.ToString(CultureInfo.InvariantCulture),
                                        item.RequestedSum.ToString(CultureInfo.InvariantCulture), states[item.ResultOfOperation],
                                        PrepareMoney(item.Money))).ToList());
        }
Esempio n. 2
0
        private static void Main()
        {
            XmlConfigurator.Configure();
            Log.Info("start");
            try
            {
                _signalHandler += HandleConsoleSignal;
                ConsoleHelper.SetSignalHandler(_signalHandler, true);

                var errors = Configurator.Config();

                _atm = CashMachine.Deserialize(ConfigurationManager.AppSettings["SerializationAtm"]) ??
                       new CashMachine(new GreedyAlgorithm());
                _statistics = Statistics.Statistics.Deserialize(ConfigurationManager.AppSettings["SerializationStatistics"]) ??
                              new Statistics.Statistics();

                AtmEvent.InsertCassettesEvent += _statistics.InsertCassettes;
                AtmEvent.WithdrawMoneyEvent   += _statistics.WithdrawMoney;
                AtmEvent.RemoveCassettesEvent += _statistics.RemoveCassettes;

                var commandPerfomer = new Commands.CommandPerfomer(_atm, errors, _statistics);
                Console.WriteLine(ConsoleLanguagePack.MainMessage);

                while (true)
                {
                    var input = Console.ReadLine();
                    Log.Debug(input);
                    if (string.IsNullOrEmpty(input))
                    {
                        continue;
                    }
                    if (ConsoleLanguagePack.ExitFlags.Contains(input))
                    {
                        break;
                    }

                    if (!commandPerfomer.TryPerform(input))
                    {
                        Console.WriteLine(ConsoleLanguagePack.CommandNotFound);
                    }
                }
                _atm.Serialize(ConfigurationManager.AppSettings["SerializationAtm"]);
                _statistics.Serialize(ConfigurationManager.AppSettings["SerializationStatistics"]);
            }
            catch (Exception ex)
            {
                Log.Fatal(ex);
            }

            Log.Info("end");
        }
Esempio n. 3
0
        public AtmGui()
        {
            Log.Info("start");
            InitializeComponent();

            DisenableButtonSelection();

            XmlConfigurator.Configure();
            _errors = Configurator.Config();
            Atm     = CashMachine.Deserialize(ConfigurationManager.AppSettings["SerializationAtm"]) ??
                      new CashMachine(new GreedyAlgorithm());
            Stat = global::Statistics.Statistics.Deserialize(ConfigurationManager.AppSettings["SerializationStatistics"]) ??
                   new global::Statistics.Statistics();
            AtmEvent.InsertCassettesEvent += Stat.InsertCassettes;
            AtmEvent.WithdrawMoneyEvent   += Stat.WithdrawMoney;
            AtmEvent.RemoveCassettesEvent += Stat.RemoveCassettes;

            _operation = Operations.Withdraw;
            InitializeBanknotes();
        }