Exemple #1
0
        public void Start(Block block)
        {
            Block = block;

            new Thread(() =>
            {
                Log.Write(Block.BlockID, $"Started thread for queue {Block.BlockName}");

                while (true)
                {
                    IControlAction action = null;
                    ControlResponse response;

                    try
                    {
                        action = _queue.Take();

                        Log.Write(Block.BlockID, $"RECV:{action.GetType().Name}:{action.MessageID}");

                        RequestReceived?.Invoke(this, new ControlActionEventArgs()
                        {
                            ID = action.MessageID, TimeStamp = action.Timestamp, MessageType = "Request"
                        });

                        if (action is StopAction)
                        {
                            break;
                        }

                        //process the message
                        using (ServiceProvider.Current.DataAccess.StartUnitOfWork())
                        {
                            response = action.Execute(_connection);
                        }

                        _responses.Add(action.MessageID, response);

                        lock (locker)
                        {
                            _lastMessage = action;
                        }
                    }
                    catch (Exception ex)
                    {
                        // If a return message is expected make sure one is sent back even when an error occurred.
                        // There is no way to get a message back via _responses if action is null because we don't
                        // know which MessageID to use. The only thing we can do in this case is just log it.

                        if (action != null)
                        {
                            response = new ErrorResponse(ex);
                            _responses.Add(action.MessageID, response);
                        }

                        Log.Write(Block.BlockID, ex.ToString());
                    }
                }
            }).Start();
        }
Exemple #2
0
        public void Push(IControlAction action)
        {
            //put a WagoMessage on the queue
            Log.Write(Block.BlockID, $"SEND:{action.GetType().Name}:{action.MessageID}");

            _queue.Add(action);

            //when WagoService sees the message it will communicate with the wago block and add an entry to the response collection
        }
Exemple #3
0
        private void SetRowDetailTemplate()
        {
            if (this.orderDetailGridInfo.RowDetailDataPanel != null)
            {
                #region RowDetailTemplate
                DataTemplate dt = DataTemplateHelper.GetEmptyGrid();

                this.ADGrid.RowDetailsTemplate = dt;
                this.ADGrid.LoadingRowDetails += (o, e) =>
                {

                    IDataPanel panel = this.orderDetailGridInfo.RowDetailDataPanel;
                    IControlAction control = panel.GetUIElement();
                    Grid grid = e.DetailsElement as Grid;
                    grid.Background = e.Row.Background;

                    if (grid.Children.Count == 0)
                    {                   
                        Border border = new Border();
                        border.Style = (Style)Application.Current.Resources["DetailShow_1"];

                        grid.Children.Add(border);
                        if (control.GetType() == typeof(DetailGrid))
                        {
                            DetailGrid dgrid = control as DetailGrid;
                            border.Child = dgrid;
               
                            // dgrid.Margin = new Thickness(80, 0, 0, 0);
                            control.InitControl(this.operationType);
                        }
                        else
                        {
                            border.Child = (control as UIElement);
                            OperationTypes cOpType = this.operationType;
                            if (this.operationType == OperationTypes.Audit)
                            {
                                cOpType = OperationTypes.Edit;
                            }
                            control.InitControl(cOpType);
                        }
                    }
                    DependencyObject dObj = VisualTreeHelper.GetChild(e.DetailsElement,0);
                    UIElement curControl = (dObj as Border).Child;
                    if (curControl.GetType() == typeof(DetailGrid))
                    {
                        DetailGrid dgrid = curControl as DetailGrid;
                        string entityType = dgrid.OrderDetailGridInfo.OrderDetailEntityInfo.Entity.Type;
                        FBEntity source = e.Row.DataContext as FBEntity; ;
                        if (source != null)
                        {
                            ObservableCollection<FBEntity> list = source.GetRelationFBEntities(entityType);
                            if (list.Count > 0)
                            {
                                dgrid.ItemsSource = list;
                                
                            }
                            else
                            {
                                
                                dgrid.Visibility = Visibility.Collapsed;
                            }
                        }
                    }

                    if (LoadRowDetailComplete != null)
                    {
                        ActionCompletedEventArgs<UIElement> args = new ActionCompletedEventArgs<UIElement>(curControl);
                        LoadRowDetailComplete(o, args);
                    }
                };
                #endregion
            }
            
        }