Ejemplo n.º 1
0
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                MessageBox.Show("Insert key to read");

                ReadKeyCommand readCommand = new ReadKeyCommand(settings.ComPort);
                readCommand.Execute();

                FuelTrakKeyData inputData = FuelTrakKeyData.Parse(readCommand.DataRead);

                MessageBox.Show("Data read successful. Insert key to write.");

                string dataToWrite = inputData.ToKeyDataString();

                LogDebugMessage("Writing data: " + dataToWrite);

                WriteKeyCommand writeKeyCommand = new WriteKeyCommand(settings.ComPort, dataToWrite);
                writeKeyCommand.Execute();

                if (writeKeyCommand.ExecutionStatus)
                {
                    LogDebugMessage("Data written to key successfully");
                }
                else
                {
                    LogDebugMessage("Data NOT written to key successfully");
                }
            }
            catch (Exception ex)
            {
                LogDebugMessage("ERROR: " + ex.Message);
                LogDebugMessage("ERROR: " + ex.StackTrace);
            }
        }
Ejemplo n.º 2
0
        private void ReadRequestCallback(IAsyncResult result)
        {
            try
            {
                AsyncResult r = (AsyncResult)result;
                Action      originalAction = (Action)r.AsyncDelegate;
                originalAction.EndInvoke(result);

                ReadKeyCommand command = (ReadKeyCommand)result.AsyncState;

                if (command.DataRead.StartsWith("+"))
                {
                    DisplayStatusMessage("Successful Read", false);
                }
                else
                {
                    DisplayStatusMessage("Read Failed", false);
                }

                FuelTrakKeyData data = FuelTrakKeyData.Parse(command.DataRead,
                                                             command.DataReadMileage, command.DataReadMileageWindow);
                BindDataToView(data);
            }
            catch (Exception ex)
            {
                Log(ex.Message);
                Log(ex.StackTrace);

                DisplayStatusMessage("Error attempting read", false);
            }
        }
Ejemplo n.º 3
0
 private void OnReadKeyRequest(object sender, EventArgs e)
 {
     try
     {
         DisplayStatusMessage("Reading data", true);
         pnlInformationDisplay.Controls.Clear();
         ReadKeyCommand readCommand = new ReadKeyCommand(settings.ComPort);
         Action         readAction  = new Action(readCommand.Execute);
         readAction.BeginInvoke(ReadRequestCallback, readCommand);
     }
     catch (Exception ex)
     {
         MessageBox.Show("Probelm Reading Key:" + ex.InnerException.ToString(), "ERROR", MessageBoxButtons.OK);
     }
 }
Ejemplo n.º 4
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                ReadKeyCommand readCommand = new ReadKeyCommand(settings.ComPort);
                readCommand.Execute();

                LogDebugMessage("Recieved data: " + readCommand.DataRead);

                FuelTrakKeyData data = FuelTrakKeyData.Parse(readCommand.DataRead);
                BindDataToView(data);
            }
            catch (Exception ex)
            {
                LogDebugMessage("ERROR: " + ex.Message);
                LogDebugMessage("ERROR: " + ex.StackTrace);
            }
        }