Ejemplo n.º 1
0
 public InitialisationCommand(IZvtTransport transport, ZVTCommandEnvironment environment)
 {
     _environment = environment;
     _transport = transport;
     _initialisation = new InitialisationApdu();
     _commandTransmitter = new MagicResponseCommandTransmitter(_transport);
     _commandTransmitter.ResponseReceived += new Action<IZvtApdu>(_commandTransmitter_ResponseReceived);
 }
Ejemplo n.º 2
0
 public AuthorizationCommand(IZvtTransport transport, ZVTCommandEnvironment commandEnvironment)
 {
     _environment = commandEnvironment;
     _transport = transport;
     _apdu = new AuthorizationApdu();
     _commandTransmitter = new MagicResponseCommandTransmitter(_transport);
     _commandTransmitter.ResponseReceived += new Action<IZvtApdu>(_commandTransmitter_ResponseReceived);
     _commandTransmitter.StatusReceived += new Action<IntermediateStatusApduResponse>(_commandTransmitter_StatusReceived);
 }
        public RegistrationCommand(IZvtTransport transport, ZVTCommandEnvironment env, List <TLVItem> tlvParameters = null)
        {
            _transport    = transport;
            _registration = new RegistrationApdu(tlvParameters);
            _environment  = env;

            XmlElement myConfig = env.RegistrationCommandConfig;

            _registration.ConfigByte.ECRPrintsAdministrationReceipts = XmlHelper.ReadBool(myConfig, "ECRPrintsAdministrationReceipts", true);
            _registration.ConfigByte.ECRPrintsPaymentReceipt         = XmlHelper.ReadBool(myConfig, "ECRPrintsPaymentReceipt", true);
            _registration.ConfigByte.ECRPrintType                      = true;
            _registration.ConfigByte.PTDisableAmountInput              = XmlHelper.ReadBool(myConfig, "PTDisableAmountInput", true);
            _registration.ConfigByte.PTDisableAdministrationFunctions  = XmlHelper.ReadBool(myConfig, "PTDisableAdministrationFunctions", true);
            _registration.ConfigByte.SendIntermediateStatusInformation = true;
            _registration.EnableServiceByte = false;
            _registration.ServiceByte.DisplayAuthorisationInCapitals      = true;
            _registration.ServiceByte.NotAssignPTServiceMenuToFunctionKey = true;
        }
Ejemplo n.º 4
0
        public RegistrationCommand(IZvtTransport transport, ZVTCommandEnvironment env)
        {
            _transport = transport;
            _registration = new RegistrationApdu();
            _environment = env;

            XmlElement myConfig = env.RegistrationCommandConfig;

            _registration.ConfigByte.ECRPrintsAdministrationReceipts = XmlHelper.ReadBool(myConfig, "ECRPrintsAdministrationReceipts", true);
            _registration.ConfigByte.ECRPrintsPaymentReceipt = XmlHelper.ReadBool(myConfig, "ECRPrintsPaymentReceipt", true);
            _registration.ConfigByte.ECRPrintType = true;
            _registration.ConfigByte.PTDisableAmountInput = XmlHelper.ReadBool(myConfig, "PTDisableAmountInput", true);
            _registration.ConfigByte.PTDisableAdministrationFunctions = XmlHelper.ReadBool(myConfig, "PTDisableAdministrationFunctions", true);
            _registration.ConfigByte.SendIntermediateStatusInformation = true;
            _registration.EnableServiceByte = false;
            _registration.ServiceByte.DisplayAuthorisationInCapitals = true;
            _registration.ServiceByte.NotAssignPTServiceMenuToFunctionKey = true;
        }
Ejemplo n.º 5
0
 public ResetCommand(IZvtTransport transport, ZVTCommandEnvironment environment)
     : base(transport, environment)
 {
     _apdu = new ResetApdu();
 }
        /// <summary>
        /// The entry point of the program, where the program control starts and ends.
        /// </summary>
        /// <param name='args'>
        /// The command-line arguments.
        /// </param>
        public static void Main(string[] args)
        {
            LogManager.Global = new LogManager(true, new TextLogger(null, LogLevel.Everything, "Wiffzack", Starter.getFileLoggerStream()));
            //create XML file with result message
            XmlDocument resultXML = new XmlDocument();
            XmlElement  rootNode  = resultXML.CreateElement("Result");

            resultXML.AppendChild(rootNode);
            //check if the first argument is a file
            if (args == null || args.Length != 1 || !File.Exists(args[0]))
            {
                LogManager.Global.GetLogger("Wiffzack").Info("Please pass a XML configuration file as first argument!");
                XmlHelper.WriteBool(rootNode, "Success", false);
                XmlHelper.WriteInt(rootNode, "ProtocolSpecificErrorCode", -1);
                XmlHelper.WriteString(rootNode, "ProtocolSpecificErrorDescription", "Please pass a XML configuration file as first argument!");
                //save file in /tmp/result.xml
                try{
                    resultXML.Save(Starter.result);
                }catch (Exception saving) {
                    LogManager.Global.GetLogger("Wiffzack").Info("Error Saving Result");
                    LogManager.Global.GetLogger("Wiffzack").Info(saving.Message);
                }
                return;
            }
            if (args[0].Equals("?"))
            {
                LogManager.Global = new LogManager(true, new TextLogger(null, LogLevel.Everything, "Wiffzack", Console.Out));
                Console.WriteLine("repeat <config.xml>");
                printHelp();
                return;
            }

            //load the XML file
            XmlDocument config = new XmlDocument();

            try {
                config.Load(args[0]);
            }
            //if any exception occur, the XML file could not be read and thus the program stops
            catch (Exception) {
                LogManager.Global.GetLogger("Wiffzack").Info("Your XML was probably bad...");
                XmlHelper.WriteBool(rootNode, "Success", false);
                XmlHelper.WriteInt(rootNode, "ProtocolSpecificErrorCode", -2);
                XmlHelper.WriteString(rootNode, "ProtocolSpecificErrorDescription", "Your XML was probably bad.");
                //save file in /tmp/result.xml
                try{
                    resultXML.Save(Starter.result);
                }catch (Exception saving) {
                    LogManager.Global.GetLogger("Wiffzack").Info("Error Saving Result");
                    LogManager.Global.GetLogger("Wiffzack").Info(saving.Message);
                }
                return;
            }
            //initialise environment with the configuration file and execute command
            try{
                ICommandEnvironment environment = new ZVTCommandEnvironment(config.DocumentElement);
                environment.StatusReceived += new IntermediateStatusDelegate(environment_StatusReceived);
                RepeatReceiptResult result = (RepeatReceiptResult)environment.CreateRepeatReceiptCommand((XmlElement)config.DocumentElement.SelectSingleNode("RepeatReceipt")).Execute();
                //create XML file with result message
                if (result.Success == true && result.Data != null)
                {
                    LogManager.Global.GetLogger("Wiffzack").Info("Writing Data");
                    result.Data.WriteXml(resultXML.DocumentElement);
                }
                result.SerializeToXml(resultXML.DocumentElement);
                //save file in /tmp/result.xml
                resultXML.Save(Starter.result);
                //debug message --> remove later
                LogManager.Global.GetLogger("Wiffzack").Info("XML file created");
            }catch (System.ArgumentException) {
                LogManager.Global.GetLogger("Wiffzack").Info("Bad Xml Argument");
                XmlHelper.WriteBool(rootNode, "Success", false);
                XmlHelper.WriteInt(rootNode, "ProtocolSpecificErrorCode", -3);
                XmlHelper.WriteString(rootNode, "ProtocolSpecificErrorDescription", "Bad Xml Argument");
                //save file in /tmp/result.xml
                try{
                    resultXML.Save(Starter.result);
                }catch (Exception saving) {
                    LogManager.Global.GetLogger("Wiffzack").Info("Error Saving Result");
                    LogManager.Global.GetLogger("Wiffzack").Info(saving.Message);
                }
                return;
            }catch (System.FormatException fe) {
                LogManager.Global.GetLogger("Wiffzack").Info("Bad Xml Argument");
                XmlHelper.WriteBool(rootNode, "Success", false);
                XmlHelper.WriteInt(rootNode, "ProtocolSpecificErrorCode", -3);
                XmlHelper.WriteString(rootNode, "ProtocolSpecificErrorDescription", fe.Message);
                //save file in /tmp/result.xml
                try{
                    resultXML.Save(Starter.result);
                }catch (Exception saving) {
                    LogManager.Global.GetLogger("Wiffzack").Info("Error Saving Result");
                    LogManager.Global.GetLogger("Wiffzack").Info(saving.Message);
                }
                return;
            }catch (System.Net.Sockets.SocketException ce) {
                LogManager.Global.GetLogger("Wiffzack").Info("Connection Error: " + ce.Message);
                XmlHelper.WriteBool(rootNode, "Success", false);
                XmlHelper.WriteInt(rootNode, "ProtocolSpecificErrorCode", -4);
                XmlHelper.WriteString(rootNode, "ProtocolSpecificErrorDescription", ce.Message);
                //save file in /tmp/result.xml
                try{
                    resultXML.Save(Starter.result);
                }catch (Exception saving) {
                    LogManager.Global.GetLogger("Wiffzack").Info("Error Saving Result");
                    LogManager.Global.GetLogger("Wiffzack").Info(saving.Message);
                }
                return;
            }catch (ConnectionTimeOutException ce) {
                LogManager.Global.GetLogger("Wiffzack").Info("Network Error:" + ce.Message);
                XmlHelper.WriteBool(rootNode, "Success", false);
                XmlHelper.WriteInt(rootNode, "ProtocolSpecificErrorCode", -150);
                XmlHelper.WriteString(rootNode, "ProtocolSpecificErrorDescription", ce.Message);
                try{
                    resultXML.Save(Starter.result);
                }catch (Exception saving) {
                    LogManager.Global.GetLogger("Wiffzack").Info("Error Saving Result");
                    LogManager.Global.GetLogger("Wiffzack").Info(saving.Message);
                }
            }catch (Exception e) {
                LogManager.Global.GetLogger("Wiffzack").Info("System Error:" + e.Message);
                XmlHelper.WriteBool(rootNode, "Success", false);
                XmlHelper.WriteInt(rootNode, "ProtocolSpecificErrorCode", -255);
                XmlHelper.WriteString(rootNode, "ProtocolSpecificErrorDescription", e.Message);
                //save file in /tmp/result.xml
                try{
                    resultXML.Save(Starter.result);
                }catch (Exception saving) {
                    LogManager.Global.GetLogger("Wiffzack").Info("Error Saving Result");
                    LogManager.Global.GetLogger("Wiffzack").Info(saving.Message);
                }
                return;
            }
        }
Ejemplo n.º 7
0
 public ReportCommand(IZvtTransport transport, ZVTCommandEnvironment commandEnvironment)
     : base(transport, commandEnvironment)
 {
     _apdu = new ReportApdu();
 }
Ejemplo n.º 8
0
 public RepeatReceiptCommand(IZvtTransport transport, ZVTCommandEnvironment env)
     : base(transport, env)
 {
     _repeatReceipt = new RepeatReceiptApdu();
 }
Ejemplo n.º 9
0
 public EndOfDayCommand(IZvtTransport transport, ZVTCommandEnvironment commandEnvironment)
     : base(transport, commandEnvironment)
 {
     _apdu = new EndOfDayApdu();
 }
 public NetworkDiagnosisCommand(IZvtTransport transport, ZVTCommandEnvironment commandEnvironment)
     : base(transport, commandEnvironment)
 {
     base._apdu = new DiagnosisApdu();
 }
Ejemplo n.º 11
0
 public AbortCommand(IZvtTransport transport, ZVTCommandEnvironment commandEnvironment)
     : base(transport, commandEnvironment)
 {
     base._apdu = new AbortApdu();
 }