/// <summary> /// Initialize the Clover Device for use /// </summary> /// <param name="configuration"></param> public virtual void Initialize(CloverDeviceConfiguration configuration) { string logSource = "_TransportEventLog"; try { // If this EventLog code crashes, you don't have the Windows Event Log Source setup, and this code isn't running with sufficient credentials to create it. // See https://github.com/clover/remote-pay-windows/wiki/ "Setting up the Windows Event Log" article for details. // // Quickfixs: run this app _once_ as admin so this code can perform setup, or just run this in an admin PowerShell> New-EventLog -LogName "Application" -Source "_TransportEventLog" // Other fixes available in the project's wiki article. // // When this app is deployed into production, the installer or deploy script should ensure the EventLog is created. if (!EventLog.SourceExists(logSource)) { EventLog.CreateEventSource(logSource, logSource); } // Add the event log trace listener to the collection. EventLogTraceListener eventlog = new EventLogTraceListener(logSource); Trace.Listeners.Add(eventlog); } catch (Exception exception) { // If this has crashed, see the comment just above at the top of the EventLog try for details and quick fixes. throw new CloverException($"Aborting Clover Connector SDK because the Windows Event Log Source \"{logSource}\" does not exist or cannot be accessed.\nSee the https://github.com/clover/remote-pay-windows/wiki article for more information.\n\nref# CLOVER-W230\nDetail Message: {exception.Message}", "CLOVER-W230", exception); } Log(MessageLevel.Detailed, $"CloverDevice.{nameof(Initialize)} {configuration.getName()}, raid: {configuration.getRemoteApplicationID()}"); transport = configuration.getCloverTransport(); transport?.SetLogLevel(logLevel); shortTransportType = !string.IsNullOrWhiteSpace(transport.ShortTitle()) ? transport.ShortTitle() : shortTransportType; packageName = configuration.getMessagePackageName(); remoteSourceSDK = getSDKInfoString(); deviceInfo = new DeviceInfo(); }
private void InitializeConnector(CloverDeviceConfiguration config) { if (cloverConnector != null) { cloverConnector -= (this); OnDeviceDisconnected(); // for any disabling, messaging, etc. PayButton.Enabled = false; // everything can work except Pay } cloverConnector = new CloverConnector(config); cloverConnector += this; //ui cleanup this.Text = OriginalFormTitle + " - " + config.getName(); if (config is TestCloverDeviceConfiguration) { TestDeviceMenuItem.Checked = true; CloverMiniUSBMenuItem.Checked = false; WebSocketMenuItem.Checked = false; } else if (config is USBCloverDeviceConfiguration) { TestDeviceMenuItem.Checked = false; CloverMiniUSBMenuItem.Checked = true; WebSocketMenuItem.Checked = false; } else if (config is WebSocketCloverDeviceConfiguration) { TestDeviceMenuItem.Checked = false; CloverMiniUSBMenuItem.Checked = false; WebSocketMenuItem.Checked = true; } }
public void InitializeConnector(CloverDeviceConfiguration config) { if (cloverConnector != null) { cloverConnector.RemoveCloverConnectorListener(this); OnDeviceDisconnected(); // for any disabling, messaging, etc. SaleButton.Enabled = false; // everything can work except Pay cloverConnector.Dispose(); } if (config is RemoteRESTCloverConfiguration) { cloverConnector = new RemoteRESTCloverConnector(config); cloverConnector.InitializeConnection(); } else if (config is RemoteWebSocketCloverConfiguration) { cloverConnector = new RemoteWebSocketCloverConnector(config); cloverConnector.InitializeConnection(); } else { cloverConnector = new CloverConnector(config); cloverConnector.InitializeConnection(); } cloverConnector.AddCloverConnectorListener(this); //UI cleanup this.Text = OriginalFormTitle + " - " + config.getName(); CardEntryMethod = 34567; ManualEntryCheckbox.Checked = (CardEntryMethod & CloverConnector.CARD_ENTRY_METHOD_MANUAL) == CloverConnector.CARD_ENTRY_METHOD_MANUAL; MagStripeCheckbox.Checked = (CardEntryMethod & CloverConnector.CARD_ENTRY_METHOD_MAG_STRIPE) == CloverConnector.CARD_ENTRY_METHOD_MAG_STRIPE; ChipCheckbox.Checked = (CardEntryMethod & CloverConnector.CARD_ENTRY_METHOD_ICC_CONTACT) == CloverConnector.CARD_ENTRY_METHOD_ICC_CONTACT; ContactlessCheckbox.Checked = (CardEntryMethod & CloverConnector.CARD_ENTRY_METHOD_NFC_CONTACTLESS) == CloverConnector.CARD_ENTRY_METHOD_NFC_CONTACTLESS; }
private void InitializeConnector(CloverDeviceConfiguration config) { if(cloverConnector != null) { cloverConnector -= (this); OnDeviceDisconnected(); // for any disabling, messaging, etc. PayButton.Enabled = false; // everything can work except Pay } cloverConnector = new CloverConnector(config); cloverConnector += this; //ui cleanup this.Text = OriginalFormTitle + " - " + config.getName(); if (config is TestCloverDeviceConfiguration) { TestDeviceMenuItem.Checked = true; CloverMiniUSBMenuItem.Checked = false; WebSocketMenuItem.Checked = false; } else if (config is USBCloverDeviceConfiguration) { TestDeviceMenuItem.Checked = false; CloverMiniUSBMenuItem.Checked = true; WebSocketMenuItem.Checked = false; } else if (config is WebSocketCloverDeviceConfiguration) { TestDeviceMenuItem.Checked = false; CloverMiniUSBMenuItem.Checked = false; WebSocketMenuItem.Checked = true; } }