Beispiel #1
0
        /// <summary>
        /// Handles a changed stylesheet in the data model.
        /// </summary>
        /// <param name="sender">The object that originated the event.</param>
        /// <param name="stylesheetRowChangeEvent">The event argument.</param>
        private void StylesheetChangedEvent(object sender, ClientMarketData.StylesheetRowChangeEvent stylesheetRowChangeEvent)
        {
            // This will make it easier to operate on the changed record.
            ClientMarketData.StylesheetRow stylesheetRow = stylesheetRowChangeEvent.Row;

            // Reopen the document if the style sheet has changed.
            if (this.IsOpen && stylesheetRow.StylesheetId == this.stylesheetId)
            {
                DrawDocument();
            }
        }
Beispiel #2
0
        /// <summary>
        /// Handles a changed stylesheet in the data model.
        /// </summary>
        /// <param name="sender">The object that originated the event.</param>
        /// <param name="stylesheetRowChangeEvent">The event argument.</param>
        private void ChangeStylesheetRow(object sender, ClientMarketData.StylesheetRowChangeEvent stylesheetRowChangeEvent)
        {
            // The only changes that impact the viewer are committed records.
            if (stylesheetRowChangeEvent.Action == DataRowAction.Commit)
            {
                // This will make it easier to operate on the changed record.
                ClientMarketData.StylesheetRow stylesheetRow = stylesheetRowChangeEvent.Row;

                // Reload the stylesheet if the modified stylesheet is the one currently used by this viewer.
                if (stylesheetRow.StylesheetId == this.stylesheetId)
                {
                    // This will read the stylesheet out of the changed record and into the viewers internal data structures.
                    XmlDocument   xslStylesheet = new XmlDocument();
                    StringReader  stringReader  = new StringReader(stylesheetRow.Text);
                    XmlTextReader xmlTextReader = new XmlTextReader(stringReader);
                    xslStylesheet.Load(xmlTextReader);
                    this.XslStylesheet = xslStylesheet;

                    // This indicates that the list of fragments is invalid and the entire document should be redrawn.
                    this.fragmentList.IsValid = false;
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// Opens the Advertisement Viewer.
        /// </summary>
        protected void OpenCommand(params object[] parameters)
        {
            this.blotter = (Blotter)parameters[0];

            try
            {
                // Lock the tables
                System.Diagnostics.Debug.Assert(!ClientMarketData.IsLocked);
                ClientMarketData.BlotterLock.AcquireReaderLock(CommonTimeout.LockWait);
                ClientMarketData.BrokerLock.AcquireReaderLock(CommonTimeout.LockWait);
                ClientMarketData.ExecutionLock.AcquireReaderLock(CommonTimeout.LockWait);
                ClientMarketData.StylesheetLock.AcquireReaderLock(CommonTimeout.LockWait);

                // Install the event handlers.  The ClientMarketData component will advise us when the data has changed.
                ClientMarketData.Blotter.BlotterRowChanged       += new ClientMarketData.BlotterRowChangeEventHandler(this.BlotterRowChangeEvent);
                ClientMarketData.Blotter.BlotterRowDeleted       += new ClientMarketData.BlotterRowChangeEventHandler(this.BlotterRowChangeEvent);
                ClientMarketData.Broker.BrokerRowChanged         += new ClientMarketData.BrokerRowChangeEventHandler(this.BrokerRowChangeEvent);
                ClientMarketData.Broker.BrokerRowDeleted         += new ClientMarketData.BrokerRowChangeEventHandler(this.BrokerRowChangeEvent);
                ClientMarketData.Execution.ExecutionRowChanged   += new ClientMarketData.ExecutionRowChangeEventHandler(this.ExecutionRowChangeEvent);
                ClientMarketData.Execution.ExecutionRowDeleted   += new ClientMarketData.ExecutionRowChangeEventHandler(this.ExecutionRowChangeEvent);
                ClientMarketData.Stylesheet.StylesheetRowChanged += new ClientMarketData.StylesheetRowChangeEventHandler(this.StylesheetRowChangeEvent);
                ClientMarketData.Stylesheet.StylesheetRowDeleted += new ClientMarketData.StylesheetRowChangeEventHandler(this.StylesheetRowChangeEvent);
                ClientMarketData.EndMerge += new EventHandler(this.EndMerge);

                // Find the block order and extract the securty level data if it exists.  This security level data is
                // needed to calculate the trade and settlement dates and other defaults for the executions.
                ClientMarketData.BlotterRow blotterRow = ClientMarketData.Blotter.FindByBlotterId(this.blotter.BlotterId);
                if (blotterRow == null)
                {
                    throw new Exception(String.Format("Blotter {0} has been deleted", this.blotter.BlotterId));
                }

                // See if a stylesheet has been associated with the blotter.
                ClientMarketData.StylesheetRow stylesheetRow = blotterRow.IsAdvertisementStylesheetIdNull() ? null :
                                                               ClientMarketData.Stylesheet.FindByStylesheetId(blotterRow.AdvertisementStylesheetId);
                if (stylesheetRow == null)
                {
                    throw new Exception(String.Format("Blotter {0} has no Advertisement stylesheet", this.blotter.BlotterId));
                }

                // As an optimization, don't reload the stylesheet if the prevous document used the same stylesheet. This
                // will save a few hundred milliseconds when scrolling through similar documents.
                if (this.stylesheetId != stylesheetRow.StylesheetId)
                {
                    // Keep track of the stylesheet id in case it is changed while we're viewing it.  The event handler
                    // will use this id to determine if an incoming stylesheet will trigger a refresh of the document.
                    this.stylesheetId = stylesheetRow.StylesheetId;
                }
            }
            catch (Exception exception)
            {
                // Write the error and stack trace out to the debug listener
                EventLog.Error("{0}, {1}", exception.Message, exception.StackTrace);
            }
            finally
            {
                // Release the table locks.
                if (ClientMarketData.BlotterLock.IsReaderLockHeld)
                {
                    ClientMarketData.BlotterLock.ReleaseReaderLock();
                }
                if (ClientMarketData.BrokerLock.IsReaderLockHeld)
                {
                    ClientMarketData.BrokerLock.ReleaseReaderLock();
                }
                if (ClientMarketData.ExecutionLock.IsReaderLockHeld)
                {
                    ClientMarketData.ExecutionLock.ReleaseReaderLock();
                }
                if (ClientMarketData.StylesheetLock.IsReaderLockHeld)
                {
                    ClientMarketData.StylesheetLock.ReleaseReaderLock();
                }
                System.Diagnostics.Debug.Assert(!ClientMarketData.IsLocked);
            }
        }
Beispiel #4
0
        /// <summary>
        /// Opens the Quote Viewer
        /// </summary>
        protected override void OpenCommand()
        {
            // This block will attach the Quote viewer to the data mdoel
            try
            {
                // Lock the tables
                System.Diagnostics.Debug.Assert(!ClientMarketData.IsLocked);
                ClientMarketData.BlotterLock.AcquireReaderLock(CommonTimeout.LockWait);
                ClientMarketData.MatchLock.AcquireReaderLock(CommonTimeout.LockWait);
                ClientMarketData.NegotiationLock.AcquireReaderLock(CommonTimeout.LockWait);
                ClientMarketData.ObjectLock.AcquireReaderLock(CommonTimeout.LockWait);
                ClientMarketData.ObjectTreeLock.AcquireReaderLock(CommonTimeout.LockWait);
                ClientMarketData.OrderTypeLock.AcquireReaderLock(CommonTimeout.LockWait);
                ClientMarketData.PriceLock.AcquireReaderLock(CommonTimeout.LockWait);
                ClientMarketData.PriceTypeLock.AcquireReaderLock(CommonTimeout.LockWait);
                ClientMarketData.SecurityLock.AcquireReaderLock(CommonTimeout.LockWait);
                ClientMarketData.StatusLock.AcquireReaderLock(CommonTimeout.LockWait);
                ClientMarketData.StylesheetLock.AcquireReaderLock(CommonTimeout.LockWait);
                ClientMarketData.StylesheetTypeLock.AcquireReaderLock(CommonTimeout.LockWait);

                // The stylesheets take a modest amount of time to parse from a string into an XSL structure.  As an optimization,
                // this action is skipped if the new document in this viewer is using the same stylesheet as the last document
                // loaded.

                // get the StylesheetTypeRow based on the hard-coded stylesheet type
                ClientMarketData.StylesheetTypeRow stylesheetTypeRow =
                    ClientMarketData.StylesheetType.FindByStylesheetTypeCode(STYLESHEET_TYPECODE);

                // get the first stylesheet type row
                if (stylesheetTypeRow == null)
                {
                    throw new Exception("Unable to retrieve the Quote Viewer stylesheet type.");
                }

                // get the stylesheet row for this type
                ClientMarketData.StylesheetRow[] stylesheetRows = stylesheetTypeRow.GetStylesheetRows();
                if (stylesheetRows == null || stylesheetRows.Length < 1)
                {
                    throw new Exception("Unable to retrieve the QuoteViewer stylesheet.");
                }

                ClientMarketData.StylesheetRow stylesheetRow = stylesheetRows[0];
                if (this.stylesheetId != stylesheetRow.StylesheetId)
                {
                    // This is the identity of the stylesheet used by this viewer.
                    this.stylesheetId = stylesheetRow.StylesheetId;

                    // This will load the TEXT object stored in the Stylesheet table into an internal structure that is used to
                    // transform the document object model (DOM) into a viewable report.
                    XmlDocument   xslStylesheet = new XmlDocument();
                    StringReader  stringReader  = new StringReader(stylesheetRow.Text);
                    XmlTextReader xmlTextReader = new XmlTextReader(stringReader);
                    xslStylesheet.Load(xmlTextReader);
                    this.XslStylesheet = xslStylesheet;
                }

                // Draw the document.
                DrawDocument();


                // Install the event handlers.  The ClientMarketData component will advise us when the data has changed.
                ClientMarketData.Blotter.BlotterRowChanging         += new ClientMarketData.BlotterRowChangeEventHandler(this.ChangeBlotterRow);
                ClientMarketData.Match.MatchRowChanging             += new ClientMarketData.MatchRowChangeEventHandler(this.ChangeMatchRow);
                ClientMarketData.Negotiation.NegotiationRowChanging += new ClientMarketData.NegotiationRowChangeEventHandler(this.ChangeNegotiationRow);
                ClientMarketData.Object.ObjectRowChanging           += new ClientMarketData.ObjectRowChangeEventHandler(this.ChangeObjectRow);
                ClientMarketData.ObjectTree.ObjectTreeRowChanging   += new ClientMarketData.ObjectTreeRowChangeEventHandler(this.ChangeObjectTreeRow);
                ClientMarketData.OrderType.OrderTypeRowChanging     += new ClientMarketData.OrderTypeRowChangeEventHandler(this.ChangeOrderTypeRow);
                ClientMarketData.Price.PriceRowChanging             += new ClientMarketData.PriceRowChangeEventHandler(this.ChangePriceRow);
                ClientMarketData.PriceType.PriceTypeRowChanging     += new ClientMarketData.PriceTypeRowChangeEventHandler(this.ChangePriceTypeRow);
                ClientMarketData.Security.SecurityRowChanging       += new ClientMarketData.SecurityRowChangeEventHandler(this.ChangeSecurityRow);
                ClientMarketData.Status.StatusRowChanging           += new ClientMarketData.StatusRowChangeEventHandler(this.ChangeStatusRow);
                ClientMarketData.Stylesheet.StylesheetRowChanging   += new ClientMarketData.StylesheetRowChangeEventHandler(this.ChangeStylesheetRow);
                ClientMarketData.EndMerge += new EventHandler(this.EndMerge);
            }
            catch (Exception exception)
            {
                // Write the error and stack trace out to the debug listener
                EventLog.Error("{0}, {1}", exception.Message, exception.StackTrace);
            }
            finally
            {
                // Release the table locks.
                if (ClientMarketData.BlotterLock.IsReaderLockHeld)
                {
                    ClientMarketData.BlotterLock.ReleaseReaderLock();
                }
                if (ClientMarketData.MatchLock.IsReaderLockHeld)
                {
                    ClientMarketData.MatchLock.ReleaseReaderLock();
                }
                if (ClientMarketData.NegotiationLock.IsReaderLockHeld)
                {
                    ClientMarketData.NegotiationLock.ReleaseReaderLock();
                }
                if (ClientMarketData.ObjectLock.IsReaderLockHeld)
                {
                    ClientMarketData.ObjectLock.ReleaseReaderLock();
                }
                if (ClientMarketData.ObjectTreeLock.IsReaderLockHeld)
                {
                    ClientMarketData.ObjectTreeLock.ReleaseReaderLock();
                }
                if (ClientMarketData.OrderTypeLock.IsReaderLockHeld)
                {
                    ClientMarketData.OrderTypeLock.ReleaseReaderLock();
                }
                if (ClientMarketData.PriceLock.IsReaderLockHeld)
                {
                    ClientMarketData.PriceLock.ReleaseReaderLock();
                }
                if (ClientMarketData.PriceTypeLock.IsReaderLockHeld)
                {
                    ClientMarketData.PriceTypeLock.ReleaseReaderLock();
                }
                if (ClientMarketData.SecurityLock.IsReaderLockHeld)
                {
                    ClientMarketData.SecurityLock.ReleaseReaderLock();
                }
                if (ClientMarketData.StatusLock.IsReaderLockHeld)
                {
                    ClientMarketData.StatusLock.ReleaseReaderLock();
                }
                if (ClientMarketData.StylesheetLock.IsReaderLockHeld)
                {
                    ClientMarketData.StylesheetLock.ReleaseReaderLock();
                }
                if (ClientMarketData.StylesheetTypeLock.IsReaderLockHeld)
                {
                    ClientMarketData.StylesheetTypeLock.ReleaseReaderLock();
                }
                System.Diagnostics.Debug.Assert(!ClientMarketData.IsLocked);
            }
        }