示例#1
0
 public Blotter(int objectId) : base(objectId)
 {
     // Initialize the object
     ClientMarketData.BlotterRow blotterRow = ClientMarketData.Blotter.FindByBlotterId(objectId);
     if (!(this.IsWorkingOrderStylesheetIdNull = blotterRow.IsWorkingOrderStylesheetIdNull()))
     {
         this.WorkingOrderStylesheetId = blotterRow.WorkingOrderStylesheetId;
     }
     if (!(this.IsDestinationOrderStylesheetIdNull = blotterRow.IsDestinationOrderStylesheetIdNull()))
     {
         this.DestinationOrderStylesheetId = blotterRow.DestinationOrderStylesheetId;
     }
     if (!(this.IsMatchesStylesheetIdNull = blotterRow.IsMatchStylesheetIdNull()))
     {
         this.MatchesStylesheetId = blotterRow.MatchStylesheetId;
     }
     if (!(this.IsAdvertisementStylesheetIdNull = blotterRow.IsAdvertisementStylesheetIdNull()))
     {
         this.AdvertisementStylesheetId = blotterRow.AdvertisementStylesheetId;
     }
 }
示例#2
0
        /// <summary>
        /// Opens the Blotter Document.
        /// </summary>
        /// <param name="blotterId">The blotter identifier.</param>
        protected override void OpenCommand()
        {
            try
            {
                // Lock the tables.
                System.Diagnostics.Debug.Assert(!ClientMarketData.IsLocked);
                ClientMarketData.BlotterLock.AcquireReaderLock(CommonTimeout.LockWait);
                ClientMarketData.MatchLock.AcquireReaderLock(CommonTimeout.LockWait);
                ClientMarketData.ObjectLock.AcquireReaderLock(CommonTimeout.LockWait);
                ClientMarketData.StylesheetLock.AcquireReaderLock(CommonTimeout.LockWait);
                ClientMarketData.WorkingOrderLock.AcquireReaderLock(CommonTimeout.LockWait);

                if (this.Tag is BlotterMatchDetail)
                {
                    this.blotter = ((BlotterMatchDetail)this.Tag).Blotter;
                }

                if (this.Tag is Blotter)
                {
                    this.blotter = (Blotter)this.Tag;
                }

                // Each blotter can have a stylesheet assigned to it so Fixed Income traders view Fixed Income data,
                // equity traders Equity data, and so forth.  If no blotter is assigned, a default will be provided.
                ClientMarketData.BlotterRow blotterRow = ClientMarketData.Blotter.FindByBlotterId(this.blotter.BlotterId);
                if (blotterRow == null)
                {
                    throw new ArgumentException("This blotter has been deleted", this.blotter.BlotterId.ToString());
                }

                // If a viewer is avaiable for the objects associated with the blotter, then we'll enable the viewers for those
                // objects.  For example, debt blotters don't require destinationOrder viewers, so there won't be one associated
                // with that blotter.
                this.hasAdvertisementViewer    = !blotterRow.IsAdvertisementStylesheetIdNull();
                this.hasDestinationOrderViewer = !blotterRow.IsDestinationOrderStylesheetIdNull();
                this.hasExecutionViewer        = !blotterRow.IsExecutionStylesheetIdNull();
                this.hasMatchViewer            = !blotterRow.IsMatchStylesheetIdNull();
                this.hasMatchHistoryViewer     = !blotterRow.IsMatchHistoryStylesheetIdNull();
                this.hasSourceOrderViewer      = !blotterRow.IsSourceOrderStylesheetIdNull();
                this.hasWorkingOrderViewer     = !blotterRow.IsWorkingOrderStylesheetIdNull();
            }
            catch (Exception exception)
            {
                // Write the error out to the debug listener
                EventLog.Error("{0}, {1}", exception.Message, exception.StackTrace);
            }
            finally
            {
                // Release the tables.
                if (ClientMarketData.BlotterLock.IsReaderLockHeld)
                {
                    ClientMarketData.BlotterLock.ReleaseReaderLock();
                }
                if (ClientMarketData.MatchLock.IsReaderLockHeld)
                {
                    ClientMarketData.MatchLock.ReleaseReaderLock();
                }
                if (ClientMarketData.ObjectLock.IsReaderLockHeld)
                {
                    ClientMarketData.ObjectLock.ReleaseReaderLock();
                }
                if (ClientMarketData.StylesheetLock.IsReaderLockHeld)
                {
                    ClientMarketData.StylesheetLock.ReleaseReaderLock();
                }
                if (ClientMarketData.WorkingOrderLock.IsReaderLockHeld)
                {
                    ClientMarketData.WorkingOrderLock.ReleaseReaderLock();
                }
                System.Diagnostics.Debug.Assert(!ClientMarketData.IsLocked);
            }

            BeginInvoke(new EventHandler(OpenChildren));
        }
示例#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);
            }
        }