Пример #1
0
        /// <summary>
        /// Prompt the user to select a report group.
        /// </summary>
        private void SelectReportGroup()
        {
            if (UserLoggedIn())
            {
                ManageReportGroups rptGroup = new ManageReportGroups();
                DialogResult result = rptGroup.ShowDialog();
                if (result == DialogResult.Cancel && UserAccount.CurrentGroup == null)
                {
                    _status = SystemStatus.NoReportGroupSelected;
                    InitaliseUpdatesRunning();
                    RefreshDisplay();
                }
                else if (result == DialogResult.Cancel && UserAccount.CurrentGroup != null)
                {                    _status = SystemStatus.Complete;
                    RefreshDisplay();
                }
                else if (result != DialogResult.Cancel)
                {
                    try
                    {
                        UserAccount.CurrentGroup = rptGroup.SelectedGroup;
                        UserAccount.Settings.FirstRun = false;
                        _status = SystemStatus.Complete;
                        InitaliseUpdatesRunning();
                        if (_updateStatus != null && _updateStatus.Visible)
                        {
                            _updateStatus.Close();
                            _updateStatus = null;
                        }
                        if (_unackOrders != null && _unackOrders.Visible)
                        {
                            _unackOrders.Close();
                            _unackOrders = null;
                        }
                        if (_unackAssets != null && _unackAssets.Visible)
                        {
                            _unackAssets.Close();
                            _unackAssets = null;
                        }
                        RefreshDisplay();
                    }
                    catch (Exception ex)
                    {
                        if (!(ex is EMMAException)) { new EMMAException(ExceptionSeverity.Error,
                            "Error while trying to change report group", ex); }
                        MessageBox.Show("Error while trying to change report group: " + ex.Message,
                            "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }

                }
            }
        }
Пример #2
0
        private void RefreshUnackOrders(bool forceDisplay)
        {
            if (this.InvokeRequired)
            {
                RefreshUnackOrdersCallback callback = new RefreshUnackOrdersCallback(RefreshUnackOrders);
                object[] parameters = new object[1];
                parameters[0] = forceDisplay;
                this.Invoke(callback, parameters);
            }
            else
            {
                bool updateForm = false;
                bool showForm = false;

                // If order notification window is not displayed and there is at least one unacknowledged
                // order then display it.
                // If the order notification window is displayed and the number of unacnowledged orders
                // has changed then refresh it.
                // _unackOrders.Visible will be false if EMMA is minimised but in this case we just
                // want to refresh the existing window, not display a new one.
                if (_unackOrders == null || (!_unackOrders.Visible && this.Visible))
                {
                    OrdersList unack = Orders.LoadOrders(UserAccount.CurrentGroup.GetAssetAccessParams(
                        APIDataType.Orders), new List<int>(), new List<long>(),
                        (int)OrderState.ExpiredOrFilledAndUnacknowledged, "Any");
                    if (_unackOrders == null && unack.Count > 0)
                    {
                        _unackOrders = new ViewUnacknowledgedOrders();
                        _unackOrders.MdiParent = this;
                        showForm = true;
                    }
                    else if (_unackOrders != null && !_unackOrders.Visible &&
                        ((_unackOrders.LastNumberOfOrders() != unack.Count) || forceDisplay))
                    {
                        // For some reason, calling 'Show' on the form after it's been closed will
                        // no longer work.
                        // Instead, we just have to create a new instance.
                        _unackOrders = new ViewUnacknowledgedOrders();
                        _unackOrders.MdiParent = this;
                        showForm = true;
                        //updateForm = true;
                    }
                }
                else { updateForm = true; }

                if (showForm)
                {
                    _unackOrders.Show();
                }
                if (updateForm)
                {
                    _unackOrders.DisplayOrders();
                }
            }
        }