Example #1
0
        /// <summary>
        /// Creates the default cash drawer.
        /// </summary>
        /// <param name="instance">Specifies the cash drawer instance that should be used.</param>
        /// <returns>True if the cash drawer was created, false otherwise.</returns>
        private async Task <bool> CreateDefaultCashDrawerObject(CashDrawerInstance instance)
        {
            rootPage.NotifyUser("Creating cash drawer object.", NotifyType.StatusMessage);

            CashDrawer tempDrawer = null;

            tempDrawer = await DeviceHelpers.GetFirstCashDrawerAsync();

            if (tempDrawer == null)
            {
                rootPage.NotifyUser("Cash drawer not found. Please connect a cash drawer.", NotifyType.ErrorMessage);
                return(false);
            }

            switch (instance)
            {
            case CashDrawerInstance.Instance1:
                cashDrawerInstance1 = tempDrawer;
                break;

            case CashDrawerInstance.Instance2:
                cashDrawerInstance2 = tempDrawer;
                break;

            default:
                return(false);
            }

            return(true);
        }
        /// <summary>
        /// Creates the default cash drawer.
        /// </summary>
        /// <param name="instance">Specifies the cash drawer instance that should be used.</param>
        /// <returns>True if the cash drawer was created, false otherwise.</returns>
        private async Task<bool> CreateDefaultCashDrawerObject(CashDrawerInstance instance)
        {
            rootPage.NotifyUser("Creating cash drawer object.", NotifyType.StatusMessage);

            CashDrawer tempDrawer = null;
            tempDrawer = await CashDrawer.GetDefaultAsync();

            if (tempDrawer == null)
            {
                rootPage.NotifyUser("Cash drawer not found. Please connect a cash drawer.", NotifyType.ErrorMessage);
                return false;
            }

            switch (instance)
            {
                case CashDrawerInstance.Instance1:
                    cashDrawerInstance1 = tempDrawer;
                    break;
                case CashDrawerInstance.Instance2:
                    cashDrawerInstance2 = tempDrawer;
                    break;
                default:
                    return false;
            }

            return true;
        }
Example #3
0
        /// <summary>
        /// Sets the UI elements to a state corresponding to the specified instace being released.
        /// </summary>
        /// <param name="instance">Corresponds to instance that has been released.</param>
        private void SetReleasedUI(CashDrawerInstance instance)
        {
            switch (instance)
            {
            case CashDrawerInstance.Instance1:
                ClaimButton1.IsEnabled   = true;
                ReleaseButton1.IsEnabled = false;
                break;

            case CashDrawerInstance.Instance2:
                ClaimButton2.IsEnabled   = true;
                ReleaseButton2.IsEnabled = false;
                break;

            default:
                break;
            }
        }
Example #4
0
        /// <summary>
        /// Attempt to claim the connected cash drawer.
        /// </summary>
        /// <param name="instance">Specifies the cash drawer instance that should be used.</param>
        /// <returns>True if the cash drawer was successfully claimed, false otherwise.</returns>
        private async Task <bool> ClaimCashDrawer(CashDrawerInstance instance)
        {
            bool claimAsyncStatus = false;

            switch (instance)
            {
            case CashDrawerInstance.Instance1:

                claimedCashDrawerInstance1 = await cashDrawerInstance1.ClaimDrawerAsync();

                if (claimedCashDrawerInstance1 != null)
                {
                    rootPage.NotifyUser("Successfully claimed instance 1.", NotifyType.StatusMessage);
                    claimAsyncStatus = true;
                }
                else
                {
                    rootPage.NotifyUser("Failed to claim instance 1.", NotifyType.ErrorMessage);
                }
                break;

            case CashDrawerInstance.Instance2:

                claimedCashDrawerInstance2 = await cashDrawerInstance2.ClaimDrawerAsync();

                if (claimedCashDrawerInstance2 != null)
                {
                    rootPage.NotifyUser("Successfully claimed instance 2.", NotifyType.StatusMessage);
                    claimAsyncStatus = true;
                }
                else
                {
                    rootPage.NotifyUser("Failed to claim instance 2.", NotifyType.ErrorMessage);
                }
                break;

            default:
                break;
            }

            return(claimAsyncStatus);
        }
        /// <summary>
        /// Sets the UI elements to a state corresponding to the specified instace being released.
        /// </summary>
        /// <param name="instance">Corresponds to instance that has been released.</param>
        private void SetReleasedUI(CashDrawerInstance instance)
        {
            switch (instance)
            {
                case CashDrawerInstance.Instance1:
                    ClaimButton1.IsEnabled = true;
                    ReleaseButton1.IsEnabled = false;
                    break;

                case CashDrawerInstance.Instance2:
                    ClaimButton2.IsEnabled = true;
                    ReleaseButton2.IsEnabled = false;
                    break;

                default:
                    break;
            }
        }
        /// <summary>
        /// Attempt to claim the connected cash drawer.
        /// </summary>
        /// <param name="instance">Specifies the cash drawer instance that should be used.</param>
        /// <returns>True if the cash drawer was successfully claimed, false otherwise.</returns>
        private async Task<bool> ClaimCashDrawer(CashDrawerInstance instance)
        {
            bool claimAsyncStatus = false;

            switch (instance)
            {
                case CashDrawerInstance.Instance1:

                    claimedCashDrawerInstance1 = await cashDrawerInstance1.ClaimDrawerAsync();
                    if (claimedCashDrawerInstance1 != null)
                    {
                        rootPage.NotifyUser("Successfully claimed instance 1.", NotifyType.StatusMessage);
                        claimAsyncStatus = true;
                    }
                    else
                    {
                        rootPage.NotifyUser("Failed to claim instance 1.", NotifyType.ErrorMessage);
                    }
                    break;

                case CashDrawerInstance.Instance2:

                    claimedCashDrawerInstance2 = await cashDrawerInstance2.ClaimDrawerAsync();
                    if (claimedCashDrawerInstance2 != null)
                    {
                        rootPage.NotifyUser("Successfully claimed instance 2.", NotifyType.StatusMessage);
                        claimAsyncStatus = true;
                    }
                    else
                    {
                        rootPage.NotifyUser("Failed to claim instance 2.", NotifyType.ErrorMessage);
                    }
                    break;

                default:
                    break;
            }

            return claimAsyncStatus;
        }