Exemplo n.º 1
0
        /// <summary>
        /// Verifies the operation access.
        /// </summary>
        /// <param name="operatorID">The operator ID.</param>
        /// <param name="operation">The operation.</param>
        /// <param name="transactionId">The transaction id.</param>
        /// <returns>
        /// /// True if operator has access, false otherwise.
        /// </returns>
        private bool VerifyOperationAccess(string operatorID, PosisOperations operation, string transactionId)
        {
            bool result = true;
            IUserAccessSystem userAccess = Application.BusinessLogic.UserAccessSystem;

            if (!userAccess.UserHasAccess(operatorID, operation))
            {
                ManagerAccessConfirmation managerAccessInteraction = new ManagerAccessConfirmation()
                {
                    Operation = (int)operation
                };

                // If a manager key is already in "Supervisor" position then don't prompt manager access.
                if (Application.Services.Peripherals.KeyLock.SupervisorPosition())
                {
                    managerAccessInteraction.Confirmed = true;
                }
                else
                {
                    InteractionRequestedEventArgs request = new InteractionRequestedEventArgs(managerAccessInteraction, () => { });
                    Application.Services.Interaction.InteractionRequest(request);
                }

                if (managerAccessInteraction.Confirmed)
                {
                    string authorizedBy = string.IsNullOrWhiteSpace(managerAccessInteraction.OperatorId) // If no operator ID is found then key was used
                        ? "Keylock"
                        : managerAccessInteraction.OperatorId;

                    // Log manager authorizations to audit log
                    ApplicationLog.WriteAuditEntry("LogOn:VerifyOperationAccess()",
                                                   string.Format("Manager '{0}' authorized the operation '{1}' for transaction '{2}'", authorizedBy, operation, transactionId));
                }
                else
                {
                    ApplicationLog.WriteAuditEntry("LogOn:VerifyOperationAccess()",
                                                   string.Format("Manager authorization either failed or was cancelled for operation '{0}'.", operation));

                    Application.Services.Dialog.ShowMessage(3540, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    result = false;
                }
            }

            return(result);
        }