/// <summary> /// Creates extended log on in AX. /// </summary> /// <param name="extendedLogOnInfo">The extended log on info.</param> /// <exception cref="PosisException">Thrown if save failed.</exception> private void AxCreateExtendedLogOn(IExtendedLogOnInfo extendedLogOnInfo) { ReadOnlyCollection <object> containerArray = PosApplication.Instance.TransactionServices.Invoke( "CreateExtendedLogon", this.SelectedResult.OperatorID, extendedLogOnInfo.LogOnKey, (int)extendedLogOnInfo.LogOnType, extendedLogOnInfo.ExtraData == null ? string.Empty : Convert.ToBase64String(extendedLogOnInfo.ExtraData)); bool result = Convert.ToBoolean(containerArray[1]); if (!result) { switch (Convert.ToInt32(containerArray[2])) { case ERROR_ALREADY_EXISTS: throw new PosisException() { ErrorMessageNumber = STRING_ALREADY_EXISTS }; case ERROR_STAFF_NOTFOUND: throw new PosisException() { ErrorMessageNumber = STRING_STAFF_NOT_FOUND }; default: throw new PosisException() { ErrorMessageNumber = STRING_SAVE_ERROR }; } } }
/// <summary> /// Executes the assign on currently selected operator. /// </summary> /// <param name="extendedLogOnInfo">The extended log on info.</param> /// <exception cref="PosisException">Thrown if save failed.</exception> public void ExecuteAssign(IExtendedLogOnInfo extendedLogOnInfo) { NetTracer.Information("ExtendedLogOnViewModel::ExecuteAssign: Start."); bool saved = false; try { logonData.DbUtil.BeginTransaction(); // Save a local copy for immediate availability at store. logonData.CreateExtendedLogOn(this.SelectedResult.OperatorID, extendedLogOnInfo); // Save in HQ this.AxCreateExtendedLogOn(extendedLogOnInfo); saved = true; } catch (SqlException ex) { if (ex.Number == SQL_ERROR_DUPLICATE_RECORD) { throw new PosisException(ex.Number, ex) { ErrorMessageNumber = STRING_ALREADY_EXISTS }; } else if (ex.Number == SQL_ERROR_NULL_DATA) { throw new PosisException(ex.Number, ex) { ErrorMessageNumber = STRING_STAFF_NOT_FOUND }; } // Any other Sql error will be thrown as it is. throw; } finally { if (saved) { logonData.DbUtil.EndTransaction(); SelectedResult.ExtendedLogOnAssigned = true; OnPropertyChanged("Results"); NetTracer.Information("ExtendedLogOnViewModel::ExecuteAssign: Successful."); } else { logonData.DbUtil.CancelTransaction(); NetTracer.Error("ExtendedLogOnViewModel::ExecuteAssign: Failed."); } } }
private void HandleExtendedLogOnInfo(IExtendedLogOnInfo extendedLogOnInfo) { this.ExtendedLogOnInfo = extendedLogOnInfo; this.lblMessage.Text = ExtendedLogOnInfo.Message; if (string.IsNullOrWhiteSpace(ExtendedLogOnInfo.LogOnKey)) { this.btnOk.Enabled = false; } else { this.btnOk.Enabled = true; this.btnOk.Select(); } }
/// <summary> /// Identifies the specified capture data. /// </summary> /// <param name="captureData">The capture data.</param> /// <returns>The matched staff ID if found, null otherwise</returns> public string Identify(IExtendedLogOnInfo captureData) { const string SoundSuccess = "HubOnSound"; const string SoundFail = "HubOffSound"; string staffID = null; if (captureData != null && !string.IsNullOrWhiteSpace(captureData.LogOnKey)) { LogonData logonData = new LogonData(ApplicationSettings.Database.LocalConnection, ApplicationSettings.Database.DATAAREAID); string logOnKey = captureData.LogOnKey; switch (captureData.LogOnType) { case ExtendedLogOnType.Barcode: case ExtendedLogOnType.MagneticStripeReader: // For these devices, logKey is directy mapped. break; case ExtendedLogOnType.Biometric: // Delegate identification to biometric device specific engine. logOnKey = biometricReader.Identify(captureData, logonData.GetExtendedLogOnExtraData(ExtendedLogOnType.Biometric, ApplicationSettings.Terminal.StorePrimaryId)); break; default: throw new NotSupportedException(string.Format("Log on type is not supported: {0}", captureData.LogOnType)); } if (!string.IsNullOrWhiteSpace(logOnKey)) { staffID = logonData.GetStaffIDWithLogOnKey(logOnKey, captureData.LogOnType); } } if (!string.IsNullOrWhiteSpace(staffID)) { PlaySound(SoundSuccess); } else { PlaySound(SoundFail); NetTracer.Information("Unrecognized log on key provided."); } return(staffID); }
/// <summary> /// Processes the extended log on key. /// </summary> /// <param name="extendedLogOnInfo">The extended log on info.</param> private void ProcessExtendedLogOnKey(IExtendedLogOnInfo extendedLogOnInfo) { try { if (status == LogOnStatus.None) { operatorId = PosApplication.Instance.Services.Peripherals.LogOnDevice.Identify(extendedLogOnInfo); if (!string.IsNullOrWhiteSpace(operatorId)) { HandleStaffId(extendedLogOnInfo.PasswordRequired); } } } catch (Exception ex) { NetTracer.Error(ex, "Unabled to process extended log on type: {0}", extendedLogOnInfo.LogOnType); } }
private void FireDataReceived(IExtendedLogOnInfo extendedLogOnInfo) { LogOnDeviceEventHandler eventHandler = DataReceived; if (eventHandler != null) { foreach (Delegate listener in eventHandler.GetInvocationList()) { ISynchronizeInvoke invoker = listener.Target as ISynchronizeInvoke; if (invoker != null && invoker.InvokeRequired) { // Marshal to the UI thread invoker.EndInvoke(invoker.BeginInvoke(listener, new object[] { extendedLogOnInfo })); } else { listener.DynamicInvoke(new object[] { extendedLogOnInfo }); } } } }
/// <summary> /// Processes the extended log on key. /// </summary> /// <param name="extendedLogOnInfo">The extended log on info.</param> private void ProcessExtendedLogOnKey(IExtendedLogOnInfo extendedLogOnInfo) { try { operatorId = PosApplication.Instance.Services.Peripherals.LogOnDevice.Identify(extendedLogOnInfo); if (!string.IsNullOrEmpty(this.operatorId)) { if (extendedLogOnInfo.PasswordRequired) { PromptForPassword(); } else { ValidateCredentials(ApplicationSettings.Terminal.StoreId, this.operatorId, null); } } } catch (Exception ex) { NetTracer.Error(ex, "Unabled to process extended log on type: {0}", extendedLogOnInfo.LogOnType); } }
private void OnLogOnDevice_DataReceived(IExtendedLogOnInfo extendedLogOnInfo) { ProcessExtendedLogOnKey(extendedLogOnInfo); }
private void OnLogOnDevice_DataReceived(IExtendedLogOnInfo extendedLogOnInfo) { HandleExtendedLogOnInfo(extendedLogOnInfo); }