Exemple #1
0
        void Message(CabControl control, ConfirmLevel level, string message)
        {
            // User can suppress levels None and Information but not Warning, Error and MSGs.
            // Cab control confirmations have level None.
            if (level < ConfirmLevel.Information && Simulator.Settings.SuppressConfirmations)
            {
                return;
            }

            var format = "{2}";

            // Skip control name if not a control
            if (control != CabControl.None)
            {
                format = "{0}: " + format;
            }
            if (level >= ConfirmLevel.Information)
            {
                format = "{1} - " + format;
            }
            var duration = DefaultDurationS;

            if (level >= ConfirmLevel.Warning)
            {
                duration *= 2;
            }
            if (level >= ConfirmLevel.Message)
            {
                duration *= 5;
            }
            DisplayMessage?.Invoke(this, new DisplayMessageEventArgs($"{control}/{level}", string.Format(format, ConfirmText[(int)control][0], Simulator.Catalog.GetString(level.GetDescription()), message), duration));
        }
        public void StartScan()
        {
            // Step 1 - Analyse the directory structure
            DisplayMessage?.Invoke("Step 1 of 3 - Collecting information about the structure of " + this.startLocation + ".");
            if (this.scanSubDir)
            {
                GetDirectoryStructure(this.startLocation, ScanMode.AnalyseDirectoryStructure);
            }
            else
            {
                GetFiles(this.startLocation, ScanMode.AnalyseDirectoryStructure);
            }

            // Step 2 - Perform Scan
            DisplayMessage?.Invoke("Step 2 of 3 - Searching for duplicate files. When this process is complete data will be analyze and displayed.");
            if (this.scanSubDir)
            {
                GetDirectoryStructure(this.startLocation, ScanMode.PerformScan);
            }
            else
            {
                GetFiles(this.startLocation, ScanMode.PerformScan);
            }

            // Step 3 - Analyse the data
            DisplayMessage?.Invoke("Step 3 of 3 - Analyzing file data and preparing for display.");
            Analyzedata();
        }
        public async Task SendMessage(ChatMessage chatMessage)
        {
            try
            {
                await _hubConnection.InvokeAsync("SendMessage", chatMessage);

                _hubConnection.On <string, string, string>("ReceiveMessage", (_message, _username, _secondUserId) =>
                {
                    _newChatMessage.Message      = _message;
                    _newChatMessage.Name         = _username;
                    _newChatMessage.SecondUserId = _secondUserId;
                });

                DisplayMessage += _chatPageViewModel.DisplayMessageInChat;
                DisplayMessage?.Invoke(_newChatMessage);
            }
            catch (Exception ex)
            {
                return;
            }
        }
        protected void SendMessageToClients(string message, Action action)
        {
            MessageArgs args = new MessageArgs(message, action);

            DisplayMessage?.Invoke(this, args);
        }
 protected void OnDisplayMessage(string message)
 {
     DisplayMessage?.Invoke(this, new MessageEventArgs {
         Message = $"[{OrderType}]{message}"
     });
 }
Exemple #6
0
        /*
         *  HandlePosEvent is called from _ui_Notify event listener (above).
         *
         *  Most messages are simply turned into .NET events.  A few do more,
         *  especially:
         *      ADD_TO_BASKET : Updates our own Basket object with new items
         *      REMOVE_FROM_BASKET : Removes item from our own Basket
         *      BASKET_COMMITTED : Updates the Basket state; and fetches all the vouchers
         */
        private void HandlePosEvent(PosEvent posEvent)
        {
            if (posEvent == null)
            {
                // Debug.Assert(false);
                return;
            }
            if (_timeoutTimer != null)
            {
                _timeoutTimer.Enabled = false;
                _timeoutTimer         = null;
            }
            switch (posEvent.EventName)
            {
            case PosEventType.READY:
                Ready?.Invoke(this, null);
                _rollbackHandler.ProcessPendingRollbacks(_config.Url);
                break;

            case PosEventType.SHOW_GUI:
                _ui.Show();
                ShowGUI?.Invoke(this, null);
                break;

            case PosEventType.HIDE_GUI:
                _ui.Hide();
                HideGUI?.Invoke(this, null);
                break;

            case PosEventType.ADD_TO_BASKET:
                var addedItem = (AddToBasketEvent)posEvent;
                _basket.Id = addedItem.BasketId;
                _basket.Items.Add(addedItem.BasketItem);
                ItemAdded?.Invoke(this, addedItem.BasketItem);
                break;

            case PosEventType.BASKET_COMMITTED:
                var basketCommittedEvent = (BasketCommittedEvent)posEvent;
                // Check:
                //  (1) Incoming .BasketId is what we expect.  This is just a sanity check, and should never fail.
                //  (2) basketCommittedEvent.Basket.Committed = TRUE
                //  (3) this.FailOnCommit = FALSE.  This may be set to TRUE to test correct processing of a Commit failure.
                if (_basket.Id == basketCommittedEvent.BasketId && basketCommittedEvent.Basket.Committed && !FailOnCommit)
                {
                    _basket.Clear();
                    _basket.Id = basketCommittedEvent.BasketId;
                    foreach (var basketItem in basketCommittedEvent.Basket.basketItems)
                    {
                        _basket.Items.Add(basketItem);     // Now with Touch ID, and Vouchers (we trust!)
                        if (basketItem is PurchaseBasketItem)
                        {
                            var purchase = (PurchaseBasketItem)basketItem;
                            if (purchase.Vouchers?.Count > 0)
                            {
                                GetVoucher(purchase.Vouchers[0].Link);
                            }
                        }
                        else if (basketItem is RefundBasketItem)
                        {
                            var refund = (RefundBasketItem)basketItem;
                            if (refund.RefundVoucher != null)
                            {
                                GetVoucher(refund.RefundVoucher.Link);
                            }
                        }
                    }
                    _basket.Committed = true;
                    BasketCommitted?.Invoke(this, _basket);
                }
                else
                {
                    ProcessFailedCommit();
                }
                // _basket.Clear();
                break;

            case PosEventType.REMOVE_FROM_BASKET:
                var removeFromBasketEvent = (RemoveFromBasketEvent)posEvent;
                foreach (var basketItem in _basket.Items)
                {
                    if (basketItem.Id == removeFromBasketEvent.BasketItemId)
                    {
                        _basket.Items.Remove(basketItem);
                        ItemRemoved?.Invoke(this, basketItem);
                        break;
                    }
                }
                break;

            case PosEventType.PRINT_VOUCHER:     // This is an "unexpected" ad hoc voucher...
                var PrintVoucherEvent = (PrintVoucherEvent)posEvent;
                VoucherAvailable?.Invoke(this, PrintVoucherEvent.Data);
                break;

            case PosEventType.VOUCHER_HTML:     //...whereas this is the response to the BasketGetVoucherEvent message
                var voucherHtmlEvent = (VoucherHtmlEvent)posEvent;
                if (!string.IsNullOrEmpty(voucherHtmlEvent.VoucherHtml))
                {
                    VoucherAvailable?.Invoke(this, voucherHtmlEvent.VoucherHtml);
                }
                break;

            case PosEventType.START_DEVICE:
                var startDeviceEvent = (StartDeviceEvent)posEvent;
                StartDevice?.Invoke(this, startDeviceEvent.Device);
                break;

            case PosEventType.STOP_DEVICE:
                var stopDeviceEvent = (StopDeviceEvent)posEvent;
                StopDevice?.Invoke(this, stopDeviceEvent.Device);
                break;

            case PosEventType.DISPLAY_MESSAGE:
                var displayMessageEvent = (DisplayMessageEvent)posEvent;
                DisplayMessage?.Invoke(this, displayMessageEvent.Message);
                break;

            case PosEventType.SIMPLE_PRODUCT:
                var simpleProductEvent = (SimpleProductEvent)posEvent;
                SimpleProduct?.Invoke(this, new SimpleProductInfo(simpleProductEvent));
                break;

            case PosEventType.SYNC_BASKET:
                var synBasketEvent = (SyncBasketEvent)posEvent;
                SyncBasket?.Invoke(this, null);
                break;

            case PosEventType.ERROR:
                var errorEvent = (ErrorEvent)posEvent;
                if (errorEvent.Method == "BasketCommitBasket")
                {
                    ProcessFailedCommit();
                }
                Error?.Invoke(this, errorEvent.Reason);
                break;

            default:
                Debug.Assert(false);     // Unknown PosEventType
                break;
            }
        }
 private void ActiveConnectorOnDisplayMessage(object sender, MessageArgs messageArgs)
 {
     DisplayMessage?.Invoke(this, messageArgs);
 }
Exemple #8
0
 private void OnDisplayMessage(string message)
 {
     DisplayMessage?.Invoke(this, new MessageEventArgs {
         Message = message
     });
 }
 public Task DisplayMessageAsync(string method, string message)
 {
     return(DisplayMessage?.Invoke(method, message) ?? Task.CompletedTask);
 }