Index: Scheduling/branches/BMX4Support/CGView.cs
===================================================================
--- Scheduling/branches/BMX4Support/CGView.cs	(revision 1175)
+++ Scheduling/branches/BMX4Support/CGView.cs	(revision 1194)
@@ -114,4 +114,5 @@
         private MenuItem sepApptMenu3;
         private MenuItem mnuReprintApptSlip;
+        private MenuItem mnuViewBrokerLog;
         private IContainer components;
 
@@ -132,9 +133,9 @@
 		public void InitializeDocView(string sText)
 		{
-			this.Text = this.DocManager.ConnectInfo.UserName;
+            this.Text = CGDocumentManager.Current.RemoteSession.User.Name;
 			if (sText != null)
 				this.Text += " - " + sText;
-			if (DocManager.ConnectInfo.DivisionName != null)
-				this.Text += " - " + DocManager.ConnectInfo.DivisionName;
+            if (CGDocumentManager.Current.RemoteSession.User.Division.Name != null)
+                this.Text += " - " + CGDocumentManager.Current.RemoteSession.User.Division.Name;
 		}
 
@@ -157,16 +158,12 @@
 
             // Set username and division up top
-            this.Text = this.DocManager.ConnectInfo.UserName;
+            this.Text = CGDocumentManager.Current.RemoteSession.User.Name;
 			if (sText != null)
 				this.Text += " - " + sText;
-			if (DocManager.ConnectInfo.DivisionName != null)
-				this.Text += " - " + DocManager.ConnectInfo.DivisionName;
-
-			this.m_ConnectInfo = m_DocManager.ConnectInfo;
-			m_bmxDelegate = new BMXNetConnectInfo.BMXNetEventDelegate(BMXNetEventHandler);
-			m_ConnectInfo.BMXNetEvent += m_bmxDelegate;
-		}
-
-		private BMXNetConnectInfo.BMXNetEventDelegate m_bmxDelegate;
+			if (CGDocumentManager.Current.RemoteSession.User.Division.Name != null)
+                this.Text += " - " + CGDocumentManager.Current.RemoteSession.User.Division.Name;
+
+            CGDocumentManager.Current.RemoteSession.EventServices.RpmsEvent += BMXNetEventHandler;
+		}
 		
 
@@ -235,4 +232,5 @@
             this.mnuHelp = new System.Windows.Forms.MenuItem();
             this.mnuHelpAbout = new System.Windows.Forms.MenuItem();
+            this.mnuViewBrokerLog = new System.Windows.Forms.MenuItem();
             this.mnuTest = new System.Windows.Forms.MenuItem();
             this.mnuTest1 = new System.Windows.Forms.MenuItem();
@@ -680,5 +678,6 @@
             this.mnuHelp.Index = 3;
             this.mnuHelp.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
-            this.mnuHelpAbout});
+            this.mnuHelpAbout,
+            this.mnuViewBrokerLog});
             this.mnuHelp.Text = "&Help";
             // 
@@ -688,4 +687,10 @@
             this.mnuHelpAbout.Text = "&About";
             this.mnuHelpAbout.Click += new System.EventHandler(this.mnuHelpAbout_Click);
+            // 
+            // mnuViewBrokerLog
+            // 
+            this.mnuViewBrokerLog.Index = 1;
+            this.mnuViewBrokerLog.Text = "&View Broker Log";
+            this.mnuViewBrokerLog.Click += new System.EventHandler(this.mnuViewBrokerLog_Click);
             // 
             // mnuTest
@@ -702,5 +707,4 @@
             this.mnuTest1.Index = 0;
             this.mnuTest1.Text = "Test1";
-            this.mnuTest1.Click += new System.EventHandler(this.mnuTest1_Click);
             // 
             // tvSchedules
@@ -712,5 +716,5 @@
             this.tvSchedules.Location = new System.Drawing.Point(0, 0);
             this.tvSchedules.Name = "tvSchedules";
-            this.tvSchedules.Size = new System.Drawing.Size(128, 392);
+            this.tvSchedules.Size = new System.Drawing.Size(128, 389);
             this.tvSchedules.Sorted = true;
             this.tvSchedules.TabIndex = 1;
@@ -781,5 +785,5 @@
             this.panelRight.Location = new System.Drawing.Point(996, 0);
             this.panelRight.Name = "panelRight";
-            this.panelRight.Size = new System.Drawing.Size(128, 392);
+            this.panelRight.Size = new System.Drawing.Size(128, 389);
             this.panelRight.TabIndex = 3;
             this.panelRight.Visible = false;
@@ -877,5 +881,5 @@
             this.panelCenter.Location = new System.Drawing.Point(136, 24);
             this.panelCenter.Name = "panelCenter";
-            this.panelCenter.Size = new System.Drawing.Size(857, 344);
+            this.panelCenter.Size = new System.Drawing.Size(857, 341);
             this.panelCenter.TabIndex = 7;
             // 
@@ -984,5 +988,5 @@
             this.panelBottom.Controls.Add(this.statusBar1);
             this.panelBottom.Dock = System.Windows.Forms.DockStyle.Bottom;
-            this.panelBottom.Location = new System.Drawing.Point(136, 368);
+            this.panelBottom.Location = new System.Drawing.Point(136, 365);
             this.panelBottom.Name = "panelBottom";
             this.panelBottom.Size = new System.Drawing.Size(857, 24);
@@ -1002,5 +1006,5 @@
             this.splitter1.Location = new System.Drawing.Point(128, 24);
             this.splitter1.Name = "splitter1";
-            this.splitter1.Size = new System.Drawing.Size(8, 368);
+            this.splitter1.Size = new System.Drawing.Size(8, 365);
             this.splitter1.TabIndex = 9;
             this.splitter1.TabStop = false;
@@ -1011,5 +1015,5 @@
             this.splitter2.Location = new System.Drawing.Point(993, 24);
             this.splitter2.Name = "splitter2";
-            this.splitter2.Size = new System.Drawing.Size(3, 368);
+            this.splitter2.Size = new System.Drawing.Size(3, 365);
             this.splitter2.TabIndex = 10;
             this.splitter2.TabStop = false;
@@ -1034,5 +1038,5 @@
             this.calendarGrid1.Resources = ((System.Collections.ArrayList)(resources.GetObject("calendarGrid1.Resources")));
             this.calendarGrid1.SelectedAppointment = 0;
-            this.calendarGrid1.Size = new System.Drawing.Size(857, 344);
+            this.calendarGrid1.Size = new System.Drawing.Size(857, 341);
             this.calendarGrid1.StartDate = new System.DateTime(2003, 1, 27, 0, 0, 0, 0);
             this.calendarGrid1.TabIndex = 0;
@@ -1047,5 +1051,5 @@
             // 
             this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
-            this.ClientSize = new System.Drawing.Size(1124, 392);
+            this.ClientSize = new System.Drawing.Size(1124, 389);
             this.Controls.Add(this.panelCenter);
             this.Controls.Add(this.panelBottom);
@@ -1086,6 +1090,4 @@
 		private Hashtable			m_htModifySchedule;
 		private Hashtable			m_htChangeAppts;
-		private BMXNetConnectInfo	m_ConnectInfo = null;
-		public BMXNetConnectInfo.BMXNetEventDelegate	BMXNetEvent;
 
 		#endregion Fields
@@ -1308,5 +1310,5 @@
 			DataTable dt = this.DocManager.GlobalDataSet.Tables["ResourceUser"];
 			DataView dv = new DataView(dt, "", "RESOURCENAME ASC", DataViewRowState.OriginalRows);
-			string sDuz = this.DocManager.ConnectInfo.DUZ;
+            string sDuz = CGDocumentManager.Current.RemoteSession.User.Duz;
 			bool bModSchedule = false;
 			DataRowView[] drvA = dv.FindRows(sResource);
@@ -1756,5 +1758,5 @@
 					doc.ResourceID = Convert.ToInt32(sResourceID);
 
-					bool bLock = DocManager.ConnectInfo.bmxNetLib.Lock("^BSDXRES(" + sResourceID + ")", "+");
+                    bool bLock = CGDocumentManager.Current.RemoteSession.Lock("^BSDXRES(" + sResourceID + ")", "+");
 					if (bLock == false)
 					{
@@ -1929,5 +1931,5 @@
 			dt = this.DocManager.GlobalDataSet.Tables["ResourceUser"];
 			dv = new DataView(dt, "", "RESOURCENAME ASC", DataViewRowState.OriginalRows);
-			dv.RowFilter = "USERNAME = '" + this.DocManager.ConnectInfo.UserName + "'";
+            dv.RowFilter = "USERNAME = '" + CGDocumentManager.Current.RemoteSession.User.Name + "'";
 			for (int j=0; j < dv.Count; j++)
 			{
@@ -2504,6 +2506,6 @@
 			{
                 string msg;
-                if (BMXNetLib.Piece(ex.Message, "~", 1) == "-10") // -10 means that BSDXAPI reported an error.
-                    msg = BMXNetLib.Piece(ex.Message, "~", 4);
+                if (M.Piece(ex.Message, "~", 1) == "-10") // -10 means that BSDXAPI reported an error.
+                    msg = M.Piece(ex.Message, "~", 4);
                 else
                     msg = ex.Message;
@@ -2615,6 +2617,6 @@
 			{   
                 string msg;
-                if (BMXNetLib.Piece(ex.Message, "~", 1) == "-10") // -10 means that BSDXAPI reported an error.
-                    msg = BMXNetLib.Piece(ex.Message, "~", 4);
+                if (M.Piece(ex.Message, "~", 1) == "-10") // -10 means that BSDXAPI reported an error.
+                    msg = M.Piece(ex.Message, "~", 4);
                 else
                     msg = ex.Message;
@@ -2716,5 +2718,5 @@
         /// <param name="e">BMXEvent Args: 
         /// e.BMXEvent is free text for Event Type; e.BMXParam is free text for Event Arguments</param>
-        private void BMXNetEventHandler(Object obj, BMXNet.BMXNetEventArgs e)
+        private void BMXNetEventHandler(Object obj, RemoteEventArgs e)
         {
             try
@@ -2724,5 +2726,5 @@
 
                 // if event is Autofire event
-                if (e.BMXEvent == "BMXNet AutoFire")
+                if (e.EventType == "BMXNet AutoFire")
                 {
                     Debug.Write("CGView caught AutoFire event.\n");
@@ -2737,5 +2739,5 @@
 
                 // if event is BSDX SCHEDULE
-                else if (e.BMXEvent == "BSDX SCHEDULE")
+                else if (e.EventType == "BSDX SCHEDULE")
                 {
                     //See if any of the resources in the event argument matches BSDX Schedule.
@@ -2745,5 +2747,5 @@
                     {
                         sResourceName = m_Document.m_sResourcesArray[j].ToString();
-                        if (e.BMXParam == sResourceName)
+                        if (e.Details == sResourceName)
                         {
                             Debug.Write("CGView caught BSDX SCHEDULE event.\n");
@@ -2813,5 +2815,5 @@
             {
                 //Signal RPMS to raise an event
-                m_ConnectInfo.RaiseEvent(sEvent, sParams, false);
+                CGDocumentManager.Current.RemoteSession.EventServices.TriggerEvent(sEvent, sParams, false);
             }
             catch (Exception ex)
@@ -2859,5 +2861,5 @@
             try
             {
-                bool bLock = DocManager.ConnectInfo.Lock("^BSDXMGR", "+", "");
+                bool bLock = CGDocumentManager.Current.RemoteSession.Lock("^BSDXMGR", "+");
                 if (bLock == false)
                 {
@@ -2874,5 +2876,5 @@
                 m_DocManager.GlobalDataSet.Tables["ResourceUser"].Clear();
                 m_DocManager.LoadResourceUserTable(false);
-                bLock = DocManager.ConnectInfo.bmxNetLib.Lock("^BSDXMGR", "-");
+                bLock = CGDocumentManager.Current.RemoteSession.Lock("^BSDXMGR", "-");
             }
             catch (ApplicationException aex)
@@ -3140,47 +3142,9 @@
         }
 
-        /// <summary>
-        /// Useless code now... Good place to test something.
-        /// </summary>
-        /// <param name="sender"></param>
-        /// <param name="e"></param>
-		private void mnuTest1_Click(object sender, System.EventArgs e)
-		{
-			ReaderWriterLock m_rwl = this.DocManager.ConnectInfo.bmxNetLib.BMXRWL;
+		private void CGView_Closing(object sender, System.ComponentModel.CancelEventArgs e)
+		{
 			try
 			{
-				m_rwl.AcquireWriterLock(50);
-				Debug.Write("\nTest Button 1 Acquired first lock\n");
-				m_rwl.AcquireWriterLock(50);
-				Debug.Write("Test Button 1 Acquired second lock\n");
-				this.DocManager.ViewRefresh();
-				Thread.Sleep(5000);
-				try
-				{
-				}
-				catch
-				{
-				}
-				finally
-				{
-					m_rwl.ReleaseWriterLock();
-					Debug.Write ("Test Button 1 released first lock.\n");
-					m_rwl.ReleaseWriterLock();
-					Debug.Write ("Test Button 1 released second lock.\n");
-				}
-
-				return;
-			}
-			catch (Exception ex)
-			{
-				Debug.Write("Test Button 1 exception: " + ex.Message + "\n");
-			}
-		}
-
-		private void CGView_Closing(object sender, System.ComponentModel.CancelEventArgs e)
-		{
-			try
-			{
-				m_ConnectInfo.BMXNetEvent -= m_bmxDelegate;
+				CGDocumentManager.Current.RemoteSession.EventServices.RpmsEvent -= BMXNetEventHandler;
 				this.calendarGrid1.CloseGrid();
 			}
@@ -3904,4 +3868,10 @@
         }
 
+        private void mnuViewBrokerLog_Click(object sender, EventArgs e)
+        {
+            var view = new RPCLoggerView();
+            view.Show();
+        }
+
 
     }//End class
