Changeset 1050


Ignore:
Timestamp:
Jan 5, 2011, 4:10:20 AM (13 years ago)
Author:
Sam Habiel
Message:

Bumped version number to 1.5
DSplash: Changes intended to support Asynchronous invokation of Splash Screen.
CGDocumentManager: Extensive changes to increase speed and invoke Splash screen async.

Location:
Scheduling/trunk/cs/bsdx0200GUISourceCode
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • Scheduling/trunk/cs/bsdx0200GUISourceCode/AssemblyInfo.cs

    r1011 r1050  
    2828// by using the '*' as shown below:
    2929
    30 [assembly: AssemblyVersion("1.4.2.*")]
     30[assembly: AssemblyVersion("1.5.0.*")]
    3131
    3232//
     
    5858[assembly: AssemblyKeyFile("")]
    5959[assembly: AssemblyKeyName("")]
    60 [assembly: AssemblyFileVersionAttribute("1.4.2.0")]
     60[assembly: AssemblyFileVersionAttribute("1.5.0.0")]
    6161[assembly: ComVisibleAttribute(false)]
  • Scheduling/trunk/cs/bsdx0200GUISourceCode/CGDocument.cs

    r1038 r1050  
    430430                                        m_DocManager.ConnectInfo.LoadConnectInfo();
    431431                                }
    432                                 System.IntPtr pHandle = m_DocManager.Handle;
    433432
    434433                                m_pAvArray.Clear();
  • Scheduling/trunk/cs/bsdx0200GUISourceCode/CGDocumentManager.cs

    r1039 r1050  
    44using System.Data;
    55using System.Diagnostics;
     6using System.Threading;
    67using IndianHealthService.BMXNet;
    78using Mono.Options;
     
    1112{
    1213        /// <summary>
    13         /// Summary description for DocumentManager.
     14        /// Main Worker. Handles sub-forms.
    1415        /// </summary>
    15         public class CGDocumentManager : System.Windows.Forms.Form
     16        public class CGDocumentManager //: System.Windows.Forms.Form
    1617        {
    1718                #region Member Variables
    1819
    1920                private static CGDocumentManager        _current;
    20                 private Hashtable                                       _views = new Hashtable();
    21                 private Hashtable                                       m_AVViews = new Hashtable();
     21                private Hashtable                                       _views = new Hashtable();       //Returns the list of currently opened documents
     22                private Hashtable                                       m_AVViews = new Hashtable();    // List of currently opened CGAVViews
    2223                private string                                          m_sWindowText = "Clinical Scheduling"; //Default Window Text
    23                 private bool                                            m_bSchedManager;
    24                 private bool                                            m_bExitOK = true;
    25         public string                       m_sHandle = "0";
     24                private bool                                            m_bSchedManager = false;    // Do you have the XUPROGMODE or BSDXZMGR?
     25                private bool                                            m_bExitOK = true;           // Okay to exit program? Used to control Re-logins. Default true.
     26        public string                       m_sHandle = "0";            // Not Used
    2627       
    27         //Connection variables
     28        //Connection variables (tied to command line parameters /a /v /s /p /e)
    2829        private string                      m_AccessCode="";
    2930        private string                      m_VerifyCode="";
    3031        private string                      m_Server="";
    3132        private int                         m_Port=0;
    32 
    33         //Encoding string (empty by default)
    34         private string                      m_Encoding="";
     33        private string                      m_Encoding="";  //Encoding is "" by default;
    3534
    3635        //Data Access Layer
     
    3837
    3938                //M Connection member variables
    40                 private DataSet                                                                 m_dsGlobal = null;
    41                 private System.ComponentModel.IContainer                components = null;
    42                 private BMXNetConnectInfo                                               m_ConnectInfo = null;
    43                 private BMXNetConnectInfo.BMXNetEventDelegate   CDocMgrEventDelegate;
     39                private DataSet                                                                 m_dsGlobal = null;      // Holds all user data
     40                private BMXNetConnectInfo                                               m_ConnectInfo = null;   // Connection to VISTA object
     41        private BMXNetConnectInfo.BMXNetEventDelegate CDocMgrEventDelegate;     // Delegate to respond to messages from VISTA. Responds to event: BMXNetConnectInfo.BMXNetEvent
    4442
    4543                #endregion
    4644
     45        #region Properties
     46
    4747        /// <summary>
    48         /// Constructor. Sets up connector, and ties BMXNet Events to function here.
     48        /// Returns the document manager's BMXNetConnectInfo member
     49        /// </summary>
     50        public BMXNetConnectInfo ConnectInfo
     51        {
     52            get
     53            {
     54                return m_ConnectInfo;
     55            }
     56        }
     57
     58        /// <summary>
     59        /// True if the current user holds the BSDXZMGR or XUPROGMODE keys in RPMS
     60        /// </summary>
     61        public bool ScheduleManager
     62        {
     63            get
     64            {
     65                return m_bSchedManager;
     66            }
     67        }
     68
     69        /// <summary>
     70        /// Holds the user and division
     71        /// </summary>
     72        public string WindowText
     73        {
     74            get
     75            {
     76                return m_sWindowText;
     77            }
     78        }
     79
     80        /// <summary>
     81        /// This dataset contains tables used by the entire application
     82        /// </summary>         
     83        public DataSet GlobalDataSet
     84        {
     85            get
     86            {
     87                return m_dsGlobal;
     88            }
     89            set
     90            {
     91                m_dsGlobal = value;
     92            }
     93        }
     94 
     95        /// <summary>
     96        /// Returns the single CGDocumentManager object
     97        /// </summary>
     98        public static CGDocumentManager Current
     99        {
     100            get
     101            {
     102                return _current;
     103            }
     104        }
     105
     106
     107        /// <summary>
     108        /// Returns the list of currently opened documents
     109        /// </summary>
     110        public Hashtable Views
     111        {
     112            get
     113            {
     114                return _views;
     115            }
     116        }
     117
     118        /// <summary>
     119        /// Returns the list of currently opened CGAVViews
     120        /// </summary>
     121        public Hashtable AvailabilityViews
     122        {
     123            get
     124            {
     125                return this.m_AVViews;
     126            }
     127        }
     128
     129        public DAL DAL
     130        {
     131            get { return this._dal; }
     132        }
     133
     134
     135        #endregion
     136
     137        /// <summary>
     138        /// Constructor. Does absolutely nothing at this point.
    49139        /// </summary>
    50140                public CGDocumentManager()
    51141                {
    52                         InitializeComponent();
    53             m_bSchedManager = false;
    54142        }
     143
     144
     145#if DEBUG
     146        //To write to the console
     147        [DllImport("kernel32.dll")]
     148        static extern bool AttachConsole(int dwProcessId);
     149        private const int ATTACH_PARENT_PROCESS = -1;
     150#endif
     151        /// <summary>
     152        /// Main Entry Point
     153        /// </summary>
     154        /// <param name="args">We accept the following Arguments:
     155        /// /s or -s = Server ip address or name
     156        /// /p or -p = port number (must be numeric)
     157        /// /a or -a = Access Code
     158        /// /v or -v = Verify Code
     159        /// /e or -e = Encoding (name of encoding as known to windows, such as windows-1256)
     160        /// </param>
     161        /// <remarks>
     162        /// Encoding decision is complex. This is the order of priority:
     163        /// - If the M DB runs in UTF-8, that's what we are going to use.
     164        /// - If that's not so, /e sets the default encoding. If /e is a non-existent encoding, move forward.
     165        /// - If /e is not supplied or is not recognized, the default encoding is the Windows default Encoding for the user.
     166        /// </remarks>
     167        [STAThread()]
     168        static void Main(string[] args)
     169        {
     170#if DEBUG
     171            // Print console messages to console if launched from console
     172            // Note: Imported From kernel32.dll
     173            AttachConsole(ATTACH_PARENT_PROCESS);
     174#endif
     175            //Store a class instance of manager. Actual constructor does nothing.
     176            _current = new CGDocumentManager();
     177
     178            //Get command line options; store in private variables
     179            var opset = new OptionSet() {
     180                { "s=", s => _current.m_Server = s },
     181                { "p=", p => _current.m_Port = int.Parse(p) },
     182                { "a=", a => _current.m_AccessCode = a },
     183                { "v=", v => _current.m_VerifyCode = v },
     184                { "e=", e => _current.m_Encoding = e}
     185            };
     186
     187            opset.Parse(args);
     188
     189           
     190            _current.InitializeApp();
     191
     192            //Create the first empty document
     193            CGDocument doc = new CGDocument();
     194            doc.DocManager = _current;
     195            doc.OnNewDocument();
     196            Application.DoEvents();
     197
     198            //Run the application
     199            Application.Run();
     200        }
     201
    55202
    56203        #region BMXNet Event Handler
     
    71218                                string sMsg = e.BMXParam;
    72219                                ShowAdminMsgDelegate samd = new ShowAdminMsgDelegate(ShowAdminMsg);
    73                                 this.Invoke(samd, new object [] {sMsg});
     220                                //this.Invoke(samd, new object [] {sMsg});
     221                samd.Invoke(sMsg);
    74222                        }
    75223                        if (e.BMXEvent == "BSDX ADMIN SHUTDOWN")
     
    77225                                string sMsg = e.BMXParam;
    78226                                CloseAllDelegate cad = new CloseAllDelegate(CloseAll);
    79                                 this.Invoke(cad, new object [] {sMsg});
     227                                //this.Invoke(cad, new object [] {sMsg});
     228                cad.Invoke(sMsg);
    80229                        }
    81230                }
     
    90239        #endregion  BMXNet Event Handler
    91240
    92         #region Properties
     241
     242                #region Methods & Events
     243
     244       
     245                private void StartSplash(object form)
     246                {
     247            ((DSplash)form).ShowDialog();
     248                }
    93249
    94250        /// <summary>
    95                 /// Returns the document manager's BMXNetConnectInfo member
     251        /// See InitializeApp(bool) below
     252        /// </summary>
     253                private void InitializeApp()
     254                {
     255                        InitializeApp(false);
     256                }
     257
     258                /// <summary>
     259                /// Does a million things:
     260        /// 1. Starts Connection and displays log-in dialogs
     261        /// 2. Starts Splash screen
     262        /// 3. Loads data tables
    96263                /// </summary>
    97                 public BMXNetConnectInfo ConnectInfo
    98                 {
    99                         get
    100                         {
    101                                 return m_ConnectInfo;
    102                         }
    103                 }
    104 
    105                 /// <summary>
    106                 /// True if the current user holds the BSDXZMGR or XUPROGMODE keys in RPMS
    107                 /// </summary>
    108                 public bool ScheduleManager
    109                 {
    110                         get
    111                         {
    112                                 return m_bSchedManager;
    113                         }
    114                 }
    115 
    116                 /// <summary>
    117                 /// Holds the user and division
    118                 /// </summary>
    119                 public string WindowText
    120                 {
    121                         get
    122                         {
    123                                 return m_sWindowText;
    124                         }
    125                 }
    126 
    127                 /// <summary>
    128                 /// This dataset contains tables used by the entire application
    129                 /// </summary>         
    130                 public DataSet GlobalDataSet
    131                 {
    132                         get
    133                         {
    134                                 return m_dsGlobal;
    135                         }
    136                         set
    137                         {
    138                                 m_dsGlobal = value;
    139                         }
    140                 }
    141         //public BMXNetConnection ADOConnection
    142         //{
    143         //    get
    144         //    {
    145         //        return m_ADOConnection;
    146         //    }
    147         //}
    148 
    149                 /// <summary>
    150                 /// Returns the single CGDocumentManager object
    151                 /// </summary>
    152                 public static CGDocumentManager Current
    153                 {
    154                         get
    155                         {
    156                                 return _current;
    157                         }
    158                 }
    159 
    160                 /// <summary>
    161                 /// Returns the list of currently opened documents
    162                 /// </summary>
    163                 public Hashtable Views
    164                 {
    165                         get
    166                         {
    167                                 return _views;
    168                         }
    169                 }
    170 
    171                 /// <summary>
    172                 /// Returns the list of currently opened CGAVViews
    173                 /// </summary>
    174                 public Hashtable AvailabilityViews
    175                 {
    176                         get
    177                         {
    178                                 return this.m_AVViews;
    179                         }
    180                 }
    181 
    182         public DAL DAL
    183         {
    184             get { return this._dal; }
    185         }
    186 
    187 
    188                 #endregion
    189 
    190                 #region Methods & Events
    191                 /// <summary>
    192                 /// Clean up any resources being used.
    193                 /// </summary>
    194                 protected override void Dispose( bool disposing )
    195                 {
    196                         if( disposing )
    197                         {
    198                                 if (m_ConnectInfo != null)
    199                                 {
    200                                         m_ConnectInfo.EventPollingEnabled = false;
    201                                         m_ConnectInfo.UnSubscribeEvent("BSDX SCHEDULE");
    202                                         m_ConnectInfo.UnSubscribeEvent("BSDX CALL WORKSTATIONS");
    203                                         m_ConnectInfo.CloseConnection();
    204                                 }
    205                                 if (components != null)
    206                                 {
    207                                         components.Dispose();
    208                                 }
    209                         }
    210                         base.Dispose( disposing );
    211                 }
    212 
    213 
    214                 private void InitializeComponent()
    215                 {
    216                 }
    217 
    218 
    219                 private DSplash m_ds;
    220                 public void StartSplash()
    221                 {
    222                         m_ds = new DSplash();
    223                         m_ds.ShowDialog();
    224                 }
    225 
    226                 private void InitializeApp()
    227                 {
    228                         InitializeApp(false);
    229                 }
    230 
    231                 private void InitializeApp(bool bReLogin)
    232                 {
     264                /// <param name="bReLogin">Is the User logging in again from a currently running instance?
     265        /// If so, display a dialog to collect access and verify codes.</param>
     266        private void InitializeApp(bool bReLogin)
     267                {
     268            //Set M connection info
    233269            m_ConnectInfo = new BMXNetConnectInfo(m_Encoding); // Encoding is "" unless passed in command line
    234270            _dal = new DAL(m_ConnectInfo);   // Data access layer
    235271            //m_ConnectInfo.bmxNetLib.StartLog();    //This line turns on logging of messages
     272           
     273            //Create a delegate to process events raised by BMX.
    236274            CDocMgrEventDelegate = new BMXNetConnectInfo.BMXNetEventDelegate(CDocMgrEventHandler);
     275            //Tie delegate to Events generated by BMX.
    237276            m_ConnectInfo.BMXNetEvent += CDocMgrEventDelegate;
     277            //Disable polling (But does this really work???? I don't see how it gets disabled)
    238278            m_ConnectInfo.EventPollingEnabled = false;
    239279
    240                         try
    241                         {
    242                                 //Set M connection info
    243                                 //Show a splash screen while initializing
    244                                 m_ds = new DSplash();
    245                 m_ds.Show(this);
    246                                 m_ds.SetStatus("Loading Configuration Settings...");
    247                 m_ds.Refresh();
    248                                 this.Activate();
    249                 // smh--not used System.Configuration.ConfigurationManager.GetSection("appSettings");
    250                 m_ds.SetStatus("Connecting to VistA Server...");
    251                 m_ds.Refresh();
    252                                 bool bRetry = true;
    253 
    254                 //Try to connect using supplied values for Server and Port
    255                 //Why am I doing this? The library BMX net uses prompts for access and verify code
    256                 //whether you can connect or not. Not good. So I test first whether
    257                 //we can connect at all by doing a simple connection and disconnect.
    258                 //TODO: Make this more robust by sending a TCPConnect message and seeing if you get a response.
    259 
    260                 if (m_Server != "" && m_Port != 0)
     280            //Show a splash screen while initializing
     281            DSplash m_ds = new DSplash();
     282            DSplash.dSetStatus setStatusDelegate = new DSplash.dSetStatus(m_ds.SetStatus);
     283            DSplash.dAny closeSplashDelegate = new DSplash.dAny(m_ds.RemoteClose);
     284            DSplash.dAny hideSplashDelegate = new DSplash.dAny(m_ds.RemoteHide);
     285
     286            Thread threadSplash = new Thread(new ParameterizedThreadStart(StartSplash));
     287            threadSplash.IsBackground = true; //expendable -- exit even if still running.
     288            threadSplash.Start(m_ds);
     289
     290           
     291                //m_ds.SetStatus("Loading Configuration Settings...");
     292            //m_ds.Refresh();
     293                        //this.Activate();
     294            // smh--not used System.Configuration.ConfigurationManager.GetSection("appSettings");
     295            setStatusDelegate("Connecting to VISTA");
     296            //m_ds.Refresh();
     297                        bool bRetry = true;
     298
     299            //Try to connect using supplied values for Server and Port
     300            //Why am I doing this? The library BMX net uses prompts for access and verify code
     301            //whether you can connect or not. Not good. So I test first whether
     302            //we can connect at all by doing a simple connection and disconnect.
     303            //TODO: Make this more robust by sending a TCPConnect message and seeing if you get a response.
     304
     305            //m_ds.Refresh();
     306
     307            if (m_Server != "" && m_Port != 0)
     308            {
     309                System.Net.Sockets.TcpClient tcpClient = new System.Net.Sockets.TcpClient();
     310                try
    261311                {
    262                     System.Net.Sockets.TcpClient tcpClient = new System.Net.Sockets.TcpClient();
    263                     try
     312                    tcpClient.Connect(m_Server, m_Port); // open it
     313                    tcpClient.Close();                  // then close it
     314                }
     315                catch (System.Net.Sockets.SocketException ex)
     316                {
     317                    throw ex;
     318                }
     319            }
     320
     321                        do
     322                        {
     323                // login crap
     324                try
     325                {
     326                    // Not my code
     327                    if (bReLogin == true)
    264328                    {
    265                         tcpClient.Connect(m_Server, m_Port); // open it
    266                         tcpClient.Close();                  // then close it
     329                        //Prompt for Access and Verify codes
     330                        _current.m_ConnectInfo.LoadConnectInfo("", "");
    267331                    }
    268                     catch (System.Net.Sockets.SocketException ex)
     332                    // My code -- buts looks so ugly!
     333                    else
    269334                    {
     335                        if (m_Server != String.Empty && m_Port != 0 && m_AccessCode != String.Empty
     336                            && m_VerifyCode != String.Empty)
     337                        {
     338                            m_ConnectInfo.LoadConnectInfo(m_Server, m_Port, m_AccessCode, m_VerifyCode);
     339                        }
     340                        else if (m_Server != String.Empty && m_Port != 0)
     341                            m_ConnectInfo.LoadConnectInfo(m_Server, m_Port, "", "");
     342                        else
     343                            m_ConnectInfo.LoadConnectInfo();
     344                    }
     345                    bRetry = false;
     346                }
     347                catch (System.Net.Sockets.SocketException)
     348                {
     349                    MessageBox.Show("Cannot connect to VistA. ");
     350                }
     351                catch (Exception ex)
     352                {
     353                    //m_ds.Close();
     354                    if (MessageBox.Show("Unable to connect to VistA.  " + ex.Message, "Clinical Scheduling", MessageBoxButtons.RetryCancel) == DialogResult.Retry)
     355                    {
     356                        bRetry = true;
     357                        _current.m_ConnectInfo.ChangeServerInfo();
     358                    }
     359                    else
     360                    {
     361                        closeSplashDelegate();
     362                        bRetry = false;
    270363                        throw ex;
    271364                    }
    272365                }
    273                                 do
    274                                 {
    275                     // login crap
    276                     try
    277                     {
    278                         // Not my code
    279                         if (bReLogin == true)
    280                         {
    281                             //Prompt for Access and Verify codes
    282                             _current.m_ConnectInfo.LoadConnectInfo("", "");
    283                         }
    284                         // My code -- buts looks so ugly!
    285                         else
    286                         {
    287                             if (m_Server != String.Empty && m_Port != 0 && m_AccessCode != String.Empty
    288                                 && m_VerifyCode != String.Empty)
    289                             {
    290                                 m_ConnectInfo.LoadConnectInfo(m_Server, m_Port, m_AccessCode, m_VerifyCode);
    291                             }
    292                             else if (m_Server != String.Empty && m_Port != 0)
    293                                 m_ConnectInfo.LoadConnectInfo(m_Server, m_Port, "", "");
    294                             else
    295                                 m_ConnectInfo.LoadConnectInfo();
    296                         }
    297                         bRetry = false;
    298                     }
    299                     catch (System.Net.Sockets.SocketException)
    300                     {
    301                         MessageBox.Show("Cannot connect to VistA. ");
    302                     }
    303                     catch (Exception ex)
    304                     {
    305                         m_ds.Close();
    306                         if (MessageBox.Show("Unable to connect to VistA.  " + ex.Message, "Clinical Scheduling", MessageBoxButtons.RetryCancel) == DialogResult.Retry)
    307                         {
    308                             bRetry = true;
    309                             _current.m_ConnectInfo.ChangeServerInfo();
    310                         }
    311                         else
    312                         {
    313                             bRetry = false;
    314                             throw ex;
    315                         }
    316                     }
    317                                 }while (bRetry == true);
    318 
    319                                 //Create global dataset
    320                                 _current.m_dsGlobal = new DataSet("GlobalDataSet");
    321 
    322                                 //Version info
    323                                 m_ds.SetStatus("Getting Version Info...");
    324                 m_ds.Refresh();
    325 
    326                 DataTable ver = _dal.GetVersion("BSDX");
    327                 ver.TableName = "VersionInfo";
    328                 m_dsGlobal.Tables.Add(ver);
     366                        }while (bRetry == true);
     367           
     368            //Create global dataset
     369                        _current.m_dsGlobal = new DataSet("GlobalDataSet");
     370
     371                        //Version info
     372            //m_ds.Activate();
     373                        setStatusDelegate("Getting Version Info from Server...");
     374
     375            DataTable ver = _dal.GetVersion("BSDX");
     376            ver.TableName = "VersionInfo";
     377            m_dsGlobal.Tables.Add(ver);
    329378               
    330                                 //How to extract the version numbers:
    331                 DataTable dtVersion = m_dsGlobal.Tables["VersionInfo"];
    332                 Debug.Assert(dtVersion.Rows.Count == 1);
    333                 DataRow rVersion = dtVersion.Rows[0];
    334                 string sMajor = rVersion["MAJOR_VERSION"].ToString();
    335                 string sMinor = rVersion["MINOR_VERSION"].ToString();
    336                 string sBuild = rVersion["BUILD"].ToString();
    337                 decimal fBuild = Convert.ToDecimal(sBuild);
    338 
    339                 //Make sure that the server is running the same version the client is.
    340                 Version x = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
    341 
    342                 //if version numbers mismatch, don't continue.
    343                 //TODO: For future: Include in v. 1.5
    344                 /*
    345                 if (!(x.Major.ToString() == sMajor && x.Minor.ToString() + x.Build.ToString() == sMinor))
    346                 {
    347                     MessageBox.Show(
    348                         "Server runs version " + sMajor + "." + sMinor + "\r\n" +
    349                         "You are running " + x.ToString() + "\r\n\r\n" +
    350                         "Major, Minor and Build versions must match",
    351                         "Version Mismatch");
    352                     m_ds.Close();
    353                     return;
    354                 }
    355                 */
     379                        //How to extract the version numbers:
     380            DataTable dtVersion = m_dsGlobal.Tables["VersionInfo"];
     381            Debug.Assert(dtVersion.Rows.Count == 1);
     382            DataRow rVersion = dtVersion.Rows[0];
     383            string sMajor = rVersion["MAJOR_VERSION"].ToString();
     384            string sMinor = rVersion["MINOR_VERSION"].ToString();
     385            string sBuild = rVersion["BUILD"].ToString();
     386            decimal fBuild = Convert.ToDecimal(sBuild);
     387
     388            //Make sure that the server is running the same version the client is.
     389            Version x = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
     390
     391            //if version numbers mismatch, don't continue.
     392            //TODO: For future: Include in v. 1.5
     393            /*
     394            if (!(x.Major.ToString() == sMajor && x.Minor.ToString() + x.Build.ToString() == sMinor))
     395            {
     396                MessageBox.Show(
     397                    "Server runs version " + sMajor + "." + sMinor + "\r\n" +
     398                    "You are running " + x.ToString() + "\r\n\r\n" +
     399                    "Major, Minor and Build versions must match",
     400                    "Version Mismatch");
     401                m_ds.Close();
     402                return;
     403            }
     404            */
    356405 
    357406
    358                 //Change encoding
    359                 if (m_Encoding == String.Empty)
    360                 {
    361                     string utf8_server_support = m_ConnectInfo.bmxNetLib.TransmitRPC("BMX UTF-8", "");
    362                     if (utf8_server_support == "1")
    363                         m_ConnectInfo.bmxNetLib.Encoder = System.Text.UTF8Encoding.UTF8;
    364                 }
    365                                 //Set application context
    366                                 m_ds.SetStatus("Setting Application Context to BSDXRPC...");
    367                 m_ds.Refresh();
    368                                 m_ConnectInfo.AppContext = "BSDXRPC";
     407            //Change encoding
     408            setStatusDelegate("Setting encoding...");
     409
     410            if (m_Encoding == String.Empty)
     411            {
     412                string utf8_server_support = m_ConnectInfo.bmxNetLib.TransmitRPC("BMX UTF-8", "");
     413                if (utf8_server_support == "1")
     414                    m_ConnectInfo.bmxNetLib.Encoder = System.Text.UTF8Encoding.UTF8;
     415            }
     416                        //Set application context
     417                        setStatusDelegate("Setting Application Context to BSDXRPC...");
     418                        m_ConnectInfo.AppContext = "BSDXRPC";
    369419       
    370                                 //Load global recordsets
    371                                 m_ds.SetStatus("Loading VistA data tables...");
    372                 m_ds.Refresh();
    373                                 if (_current.LoadGlobalRecordsets() == false)
    374                                 {
    375                                         MessageBox.Show("Unable to create VistA recordsets"); //TODO Improve this message
    376                                         m_ds.Close();
    377                                         return;
    378                                 }
    379                                
    380                 //smh -- why get handles?
    381                                 System.IntPtr pHandle = this.Handle;
    382                                 System.IntPtr pConnHandle = this.ConnectInfo.Handle;
    383                 this.m_sHandle = pHandle.ToString();
    384 
    385                 _current.m_ConnectInfo.ReceiveTimeout = 30000; //30-second timeout
     420                        //Load global recordsets
     421            string statusConst = "Loading VistA data tables...";
     422                        setStatusDelegate(statusConst);
     423
     424            string sCommandText;
     425
     426            setStatusDelegate(statusConst + " Schedule User");
     427            //Schedule User Info
     428            DataTable dtUser = _dal.GetUserInfo(m_ConnectInfo.DUZ);
     429            dtUser.TableName = "SchedulingUser";
     430            m_dsGlobal.Tables.Add(dtUser);
     431            Debug.Assert(dtUser.Rows.Count == 1);
     432
     433            // Only one row and one column named "MANAGER". Set local var m_bSchedManager to true if Manager.
     434            DataRow rUser = dtUser.Rows[0];
     435            Object oUser = rUser["MANAGER"];
     436            string sUser = oUser.ToString();
     437            m_bSchedManager = (sUser == "YES") ? true : false;
     438
     439            setStatusDelegate(statusConst + " Access Types");
     440            //Get Access Types
     441            DataTable dtAccessTypes = _dal.GetAccessTypes();
     442            dtAccessTypes.TableName = "AccessTypes";
     443            m_dsGlobal.Tables.Add(dtAccessTypes);
     444
     445            setStatusDelegate(statusConst + " Access Groups");
     446            //AccessGroups
     447            LoadAccessGroupsTable();
     448
     449            //Build Primary Key for AccessGroup table
     450            DataTable dtGroups = m_dsGlobal.Tables["AccessGroup"];
     451            DataColumn dcKey = dtGroups.Columns["ACCESS_GROUP"];
     452            DataColumn[] dcKeys = new DataColumn[1];
     453            dcKeys[0] = dcKey;
     454            dtGroups.PrimaryKey = dcKeys;
     455
     456            setStatusDelegate(statusConst + " Access Group Types");
     457            //AccessGroupType
     458            LoadAccessGroupTypesTable();
     459
     460            //Build Primary Key for AccessGroupType table
     461            DataTable dtAGTypes = m_dsGlobal.Tables["AccessGroupType"];
     462            DataColumn dcGTKey = dtAGTypes.Columns["ACCESS_GROUP_TYPEID"];
     463            DataColumn[] dcGTKeys = new DataColumn[1];
     464            dcGTKeys[0] = dcGTKey;
     465            dtAGTypes.PrimaryKey = dcGTKeys;
     466
     467            //Build Data Relationship between AccessGroupType and AccessTypes tables
     468            DataRelation dr = new DataRelation("AccessGroupType",       //Relation Name
     469                m_dsGlobal.Tables["AccessGroup"].Columns["BMXIEN"],     //Parent
     470                m_dsGlobal.Tables["AccessGroupType"].Columns["ACCESS_GROUP_ID"]);       //Child
     471            m_dsGlobal.Relations.Add(dr);
     472
     473            setStatusDelegate(statusConst + " Resource Groups By User");
     474            //ResourceGroup Table (Resource Groups by User)
     475            LoadResourceGroupTable();
     476
     477            setStatusDelegate(statusConst + " Resources By User");
     478            //Resources by user
     479            LoadBSDXResourcesTable();
     480
     481            //Build Primary Key for Resources table
     482            DataColumn[] dc = new DataColumn[1];
     483            dc[0] = m_dsGlobal.Tables["Resources"].Columns["RESOURCEID"];
     484            m_dsGlobal.Tables["Resources"].PrimaryKey = dc;
     485
     486            setStatusDelegate(statusConst + " Group Resources");
     487            //GroupResources table
     488            LoadGroupResourcesTable();
     489
     490            //Build Primary Key for ResourceGroup table
     491            dc = new DataColumn[1];
     492            dc[0] = m_dsGlobal.Tables["ResourceGroup"].Columns["RESOURCE_GROUP"];
     493            m_dsGlobal.Tables["ResourceGroup"].PrimaryKey = dc;
     494
     495            //Build Data Relationships between ResourceGroup and GroupResources tables
     496            dr = new DataRelation("GroupResource",      //Relation Name
     497                m_dsGlobal.Tables["ResourceGroup"].Columns["RESOURCE_GROUP"],   //Parent
     498                m_dsGlobal.Tables["GroupResources"].Columns["RESOURCE_GROUP"]); //Child
     499            CGSchedLib.OutputArray(m_dsGlobal.Tables["GroupResources"], "GroupResources");
     500            m_dsGlobal.Relations.Add(dr);
     501
     502            setStatusDelegate(statusConst + " Clinics");
     503            //HospitalLocation table
     504            //cmd.CommandText = "SELECT BMXIEN 'HOSPITAL_LOCATION_ID', NAME 'HOSPITAL_LOCATION', DEFAULT_PROVIDER, STOP_CODE_NUMBER, INACTIVATE_DATE, REACTIVATE_DATE FROM HOSPITAL_LOCATION";
     505            sCommandText = "BSDX HOSPITAL LOCATION";
     506            ConnectInfo.RPMSDataTable(sCommandText, "HospitalLocation", m_dsGlobal);
     507            Debug.Write("LoadGlobalRecordsets -- HospitalLocation loaded\n");
     508
     509            //Build Primary Key for HospitalLocation table
     510            dc = new DataColumn[1];
     511            DataTable dtTemp = m_dsGlobal.Tables["HospitalLocation"];
     512            dc[0] = dtTemp.Columns["HOSPITAL_LOCATION_ID"];
     513            m_dsGlobal.Tables["HospitalLocation"].PrimaryKey = dc;
     514
     515            //Build Data Relationships between Resources and HospitalLocation tables
     516            dr = new DataRelation("HospitalLocationResource",   //Relation Name
     517                m_dsGlobal.Tables["HospitalLocation"].Columns["HOSPITAL_LOCATION_ID"],  //Parent
     518                m_dsGlobal.Tables["Resources"].Columns["HOSPITAL_LOCATION_ID"], false); //Child
     519            m_dsGlobal.Relations.Add(dr);
     520
     521            setStatusDelegate(statusConst + " Schedule User");
     522            //Build ScheduleUser table
     523            this.LoadScheduleUserTable();
     524
     525            //Build Primary Key for ScheduleUser table
     526            dc = new DataColumn[1];
     527            dtTemp = m_dsGlobal.Tables["ScheduleUser"];
     528            dc[0] = dtTemp.Columns["USERID"];
     529            m_dsGlobal.Tables["ScheduleUser"].PrimaryKey = dc;
     530
     531            setStatusDelegate(statusConst + " Resource User");
     532            //Build ResourceUser table
     533            this.LoadResourceUserTable();
     534
     535            //Build Primary Key for ResourceUser table
     536            dc = new DataColumn[1];
     537            dtTemp = m_dsGlobal.Tables["ResourceUser"];
     538            dc[0] = dtTemp.Columns["RESOURCEUSER_ID"];
     539            m_dsGlobal.Tables["ResourceUser"].PrimaryKey = dc;
     540
     541            //Create relation between BSDX Resource and BSDX Resource User tables
     542            dr = new DataRelation("ResourceUser",       //Relation Name
     543                m_dsGlobal.Tables["Resources"].Columns["RESOURCEID"],   //Parent
     544                m_dsGlobal.Tables["ResourceUser"].Columns["RESOURCEID"]);       //Child
     545            m_dsGlobal.Relations.Add(dr);
     546
     547            setStatusDelegate(statusConst + " Providers");
     548            //Build active provider table
     549            sCommandText = "SELECT BMXIEN, NAME FROM NEW_PERSON WHERE INACTIVE_DATE = '' AND BMXIEN > 1";
     550            ConnectInfo.RPMSDataTable(sCommandText, "Provider", m_dsGlobal);
     551            Debug.Write("LoadGlobalRecordsets -- Provider loaded\n");
     552
     553            setStatusDelegate(statusConst + " Clinic Stops");
     554            //Build the CLINIC_STOP table
     555            // sCommandText = "SELECT BMXIEN, CODE, NAME FROM CLINIC_STOP"; //SMH
     556            sCommandText = "SELECT BMXIEN, AMIS_REPORTING_STOP_CODE, NAME FROM CLINIC_STOP";
     557            ConnectInfo.RPMSDataTable(sCommandText, "ClinicStop", m_dsGlobal);
     558            Debug.Write("LoadGlobalRecordsets -- ClinicStop loaded\n");
     559
     560            setStatusDelegate(statusConst + " Holiday");
     561            //Build the HOLIDAY table
     562            sCommandText = "SELECT NAME, DATE FROM HOLIDAY WHERE DATE > '" + DateTime.Today.ToShortDateString() + "'";
     563            ConnectInfo.RPMSDataTable(sCommandText, "HOLIDAY", m_dsGlobal);
     564            Debug.Write("LoadingGlobalRecordsets -- Holidays loaded\n");
     565
     566
     567            //Save the xml schema
     568            //m_dsGlobal.WriteXmlSchema(@"..\..\csSchema20060526.xsd");
     569            //----------------------------------------------
     570           
     571
     572            _current.m_ConnectInfo.ReceiveTimeout = 30000; //30-second timeout
    386573
    387574#if DEBUG
    388                 _current.m_ConnectInfo.ReceiveTimeout = 600000; //longer timeout for debugging
     575            _current.m_ConnectInfo.ReceiveTimeout = 600000; //longer timeout for debugging
    389576#endif
    390                                 _current.m_ConnectInfo.SubscribeEvent("BSDX SCHEDULE");
    391                                 _current.m_ConnectInfo.SubscribeEvent("BSDX CALL WORKSTATIONS");
    392                                 _current.m_ConnectInfo.SubscribeEvent("BSDX ADMIN MESSAGE");
    393                                 _current.m_ConnectInfo.SubscribeEvent("BSDX ADMIN SHUTDOWN");
    394 
    395                                 _current.m_ConnectInfo.EventPollingInterval = 5000; //in milliseconds
    396                                 _current.m_ConnectInfo.EventPollingEnabled = true;
    397                                 _current.m_ConnectInfo.AutoFire = 12; //AutoFire every 12*5 seconds
    398 
    399                                 m_ds.Close();
    400                         }
    401                         catch (Exception ex)
    402                         {
    403                                 m_ds.Close();
    404                                 Debug.Write(ex.Message);
    405                                 MessageBox.Show(ex.Message + ex.StackTrace, "Clinical Scheduling Error -- Closing Application");
    406                                 throw ex;
    407                         }
    408                 }
    409 
    410         //To write to the console
    411         [DllImport("kernel32.dll")]
    412         static extern bool AttachConsole(int dwProcessId);
    413         private const int ATTACH_PARENT_PROCESS = -1;
    414 
    415                 [STAThread()]
    416         static void Main(string[] args)
    417                 {
    418 #if DEBUG
    419             // Print console messages to console if launched from console
    420             // Note: Imported From kernel32.dll
    421             AttachConsole(ATTACH_PARENT_PROCESS);
    422 #endif
    423             try
    424             {
    425                  //Store the current manager
    426                 _current = new CGDocumentManager();
    427                
    428                 //Get command line options; store in private variables
    429                 var opset = new OptionSet () {
    430                     { "s=", s => _current.m_Server = s },
    431                     { "p=", p => _current.m_Port = int.Parse(p) },
    432                     { "a=", a => _current.m_AccessCode = a },
    433                     { "v=", v => _current.m_VerifyCode = v },
    434                     { "e=", e => _current.m_Encoding = e}
    435                 };
    436 
    437                 opset.Parse(args);
    438                
    439                 try
    440                 {
    441                     _current.InitializeApp();
    442                 }
    443                 catch (Exception ex)
    444                 {
    445                     Debug.Write(ex.Message);
    446                     return;
    447                 }
    448 
    449                 //Create the first empty document
    450                 CGDocument doc = new CGDocument();
    451                 doc.DocManager = _current;
    452                 doc.OnNewDocument();
    453                 Application.DoEvents();
    454 
    455                 //Run the application
    456                 Application.Run();
    457             }
    458             catch (Exception ex)
    459             {
    460                 Debug.Write(ex.Message);
    461                 MessageBox.Show(ex.Message + ex.StackTrace, "CGDocumentManager.Main(): Clinical Scheduling Error -- Closing Application");
    462                 return;
    463             }
    464                 }
     577                        _current.m_ConnectInfo.SubscribeEvent("BSDX SCHEDULE");
     578                        _current.m_ConnectInfo.SubscribeEvent("BSDX CALL WORKSTATIONS");
     579                        _current.m_ConnectInfo.SubscribeEvent("BSDX ADMIN MESSAGE");
     580                        _current.m_ConnectInfo.SubscribeEvent("BSDX ADMIN SHUTDOWN");
     581
     582                        _current.m_ConnectInfo.EventPollingInterval = 5000; //in milliseconds
     583                        _current.m_ConnectInfo.EventPollingEnabled = true;
     584                        _current.m_ConnectInfo.AutoFire = 12; //AutoFire every 12*5 seconds
     585
     586            //Close Splash Screen
     587            closeSplashDelegate();
     588                       
     589                }
     590
    465591
    466592
     
    529655                public void LoadResourceUserTable(bool bAllUsers)
    530656                {
    531             string sCommandText = "SELECT BMXIEN RESOURCEUSER_ID, RESOURCENAME, INTERNAL[RESOURCENAME] RESOURCEID, OVERBOOK, MODIFY_SCHEDULE, MODIFY_APPOINTMENTS, USERNAME, INTERNAL[USERNAME] USERID FROM BSDX_RESOURCE_USER"; // WHERE INTERNAL[INSTITUTION]=" + m_ConnectInfo.DUZ2;
     657            string sCommandText = @"SELECT BMXIEN RESOURCEUSER_ID, RESOURCENAME, INTERNAL[RESOURCENAME] RESOURCEID, OVERBOOK, MODIFY_SCHEDULE, MODIFY_APPOINTMENTS, USERNAME, INTERNAL[USERNAME] USERID FROM BSDX_RESOURCE_USER"; // WHERE INTERNAL[INSTITUTION]=" + m_ConnectInfo.DUZ2;
     658           
     659            if (!bAllUsers)
     660            {
     661                sCommandText += String.Format(" WHERE INTERNAL[USERNAME] = {0}", m_ConnectInfo.DUZ);
     662            }
     663
    532664                        ConnectInfo.RPMSDataTable(sCommandText, "ResourceUser", m_dsGlobal);
    533665                        Debug.Write("LoadGlobalRecordsets -- ResourceUser loaded\n");
    534666                }
    535667
    536                 private bool LoadGlobalRecordsets()
    537                 {
    538                        
    539             string sCommandText;
    540 
    541             //Schedule User Info
    542                         DataTable dtUser = _dal.GetUserInfo(m_ConnectInfo.DUZ);
    543             dtUser.TableName = "SchedulingUser";
    544             m_dsGlobal.Tables.Add(dtUser);
    545                         Debug.Assert(dtUser.Rows.Count == 1);
    546 
    547             // Only one row and one column named "MANAGER". Set local var m_bSchedManager to true if Manager.
    548                         DataRow rUser = dtUser.Rows[0];
    549                         Object oUser = rUser["MANAGER"];
    550                         string sUser = oUser.ToString();
    551                         m_bSchedManager = (sUser == "YES")?true:false;
    552 
    553             //Get Access Types
    554             DataTable dtAccessTypes = _dal.GetAccessTypes();
    555             dtAccessTypes.TableName = "AccessTypes";
    556             m_dsGlobal.Tables.Add(dtAccessTypes);
    557 
    558                         //AccessGroups
    559                         LoadAccessGroupsTable();
    560 
    561                         //Build Primary Key for AccessGroup table
    562                         DataTable dtGroups = m_dsGlobal.Tables["AccessGroup"];
    563             DataColumn dcKey = dtGroups.Columns["ACCESS_GROUP"];
    564             DataColumn[] dcKeys = new DataColumn[1];
    565                         dcKeys[0] = dcKey;
    566                         dtGroups.PrimaryKey = dcKeys;
    567 
    568                         //AccessGroupType
    569                         LoadAccessGroupTypesTable();
    570 
    571                         //Build Primary Key for AccessGroupType table
    572                         DataTable dtAGTypes = m_dsGlobal.Tables["AccessGroupType"];
    573                         DataColumn dcGTKey = dtAGTypes.Columns["ACCESS_GROUP_TYPEID"];
    574                         DataColumn[] dcGTKeys = new DataColumn[1];
    575                         dcGTKeys[0] = dcGTKey;
    576                         dtAGTypes.PrimaryKey = dcGTKeys;
    577 
    578                         //Build Data Relationship between AccessGroupType and AccessTypes tables
    579                         DataRelation dr = new DataRelation("AccessGroupType",   //Relation Name
    580                                 m_dsGlobal.Tables["AccessGroup"].Columns["BMXIEN"],     //Parent
    581                                 m_dsGlobal.Tables["AccessGroupType"].Columns["ACCESS_GROUP_ID"]);       //Child
    582                         m_dsGlobal.Relations.Add(dr);
    583 
    584                         //ResourceGroup Table (Resource Groups by User)
    585                         LoadResourceGroupTable();
    586                        
    587                         //Resources by user
    588                         LoadBSDXResourcesTable();
    589 
    590                         //Build Primary Key for Resources table
    591                         DataColumn[] dc = new DataColumn[1];
    592                         dc[0] = m_dsGlobal.Tables["Resources"].Columns["RESOURCEID"];
    593                         m_dsGlobal.Tables["Resources"].PrimaryKey = dc;
    594 
    595                         //GroupResources table
    596                         LoadGroupResourcesTable();
    597 
    598                         //Build Primary Key for ResourceGroup table
    599                         dc = new DataColumn[1];
    600                         dc[0] = m_dsGlobal.Tables["ResourceGroup"].Columns["RESOURCE_GROUP"];
    601                         m_dsGlobal.Tables["ResourceGroup"].PrimaryKey = dc;
    602                        
    603                         //Build Data Relationships between ResourceGroup and GroupResources tables
    604                         dr = new DataRelation("GroupResource",  //Relation Name
    605                                 m_dsGlobal.Tables["ResourceGroup"].Columns["RESOURCE_GROUP"],   //Parent
    606                                 m_dsGlobal.Tables["GroupResources"].Columns["RESOURCE_GROUP"]); //Child
    607                         CGSchedLib.OutputArray(m_dsGlobal.Tables["GroupResources"], "GroupResources");
    608                         m_dsGlobal.Relations.Add(dr);
    609 
    610                         //HospitalLocation table
    611                         //cmd.CommandText = "SELECT BMXIEN 'HOSPITAL_LOCATION_ID', NAME 'HOSPITAL_LOCATION', DEFAULT_PROVIDER, STOP_CODE_NUMBER, INACTIVATE_DATE, REACTIVATE_DATE FROM HOSPITAL_LOCATION";
    612                         sCommandText = "BSDX HOSPITAL LOCATION";
    613                         ConnectInfo.RPMSDataTable(sCommandText, "HospitalLocation", m_dsGlobal);
    614                         Debug.Write("LoadGlobalRecordsets -- HospitalLocation loaded\n");
    615 
    616                         //Build Primary Key for HospitalLocation table
    617                         dc = new DataColumn[1];
    618                         DataTable dtTemp = m_dsGlobal.Tables["HospitalLocation"];
    619                         dc[0] = dtTemp.Columns["HOSPITAL_LOCATION_ID"];
    620                         m_dsGlobal.Tables["HospitalLocation"].PrimaryKey = dc;
    621 
    622             //smh
    623                         //LoadClinicSetupTable();
    624 
    625             //smh
    626                         //Build Primary Key for ClinicSetupParameters table
    627                         /*dc = new DataColumn[1];
    628                         dtTemp = m_dsGlobal.Tables["ClinicSetupParameters"];
    629                         dc[0] = dtTemp.Columns["HOSPITAL_LOCATION_ID"];
    630                         m_dsGlobal.Tables["ClinicSetupParameters"].PrimaryKey = dc;
    631 
    632                         //Build Data Relationships between ClinicSetupParameters and HospitalLocation tables
    633                         dr = new DataRelation("HospitalLocationClinic", //Relation Name
    634                                 m_dsGlobal.Tables["HospitalLocation"].Columns["HOSPITAL_LOCATION_ID"],  //Parent
    635                                 m_dsGlobal.Tables["ClinicSetupParameters"].Columns["HOSPITAL_LOCATION_ID"], false);     //Child
    636                         m_dsGlobal.Relations.Add(dr);*/
    637             /*SMH
    638                         dtTemp.Columns.Add("PROVIDER", System.Type.GetType("System.String"), "Parent.DEFAULT_PROVIDER");
    639                         dtTemp.Columns.Add("CLINIC_STOP", System.Type.GetType("System.String"), "Parent.STOP_CODE_NUMBER");
    640                         dtTemp.Columns.Add("INACTIVATE_DATE", System.Type.GetType("System.String"), "Parent.INACTIVATE_DATE");
    641                         dtTemp.Columns.Add("REACTIVATE_DATE", System.Type.GetType("System.String"), "Parent.REACTIVATE_DATE");
    642             */
    643 
    644                         //Build Data Relationships between Resources and HospitalLocation tables
    645                         dr = new DataRelation("HospitalLocationResource",       //Relation Name
    646                                 m_dsGlobal.Tables["HospitalLocation"].Columns["HOSPITAL_LOCATION_ID"],  //Parent
    647                                 m_dsGlobal.Tables["Resources"].Columns["HOSPITAL_LOCATION_ID"], false); //Child
    648                         m_dsGlobal.Relations.Add(dr);
    649 
    650                         //Build ScheduleUser table
    651                         this.LoadScheduleUserTable();
    652 
    653                         //Build Primary Key for ScheduleUser table
    654                         dc = new DataColumn[1];
    655                         dtTemp = m_dsGlobal.Tables["ScheduleUser"];
    656                         dc[0] = dtTemp.Columns["USERID"];
    657                         m_dsGlobal.Tables["ScheduleUser"].PrimaryKey = dc;
    658 
    659                         //Build ResourceUser table
    660                         this.LoadResourceUserTable();
    661 
    662                         //Build Primary Key for ResourceUser table
    663                         dc = new DataColumn[1];
    664                         dtTemp = m_dsGlobal.Tables["ResourceUser"];
    665                         dc[0] = dtTemp.Columns["RESOURCEUSER_ID"];
    666                         m_dsGlobal.Tables["ResourceUser"].PrimaryKey = dc;
    667 
    668                         //Create relation between BSDX Resource and BSDX Resource User tables
    669                         dr = new DataRelation("ResourceUser",   //Relation Name
    670                                 m_dsGlobal.Tables["Resources"].Columns["RESOURCEID"],   //Parent
    671                                 m_dsGlobal.Tables["ResourceUser"].Columns["RESOURCEID"]);       //Child
    672                         m_dsGlobal.Relations.Add(dr);
    673 
    674                         //Build active provider table
    675                         sCommandText = "SELECT BMXIEN, NAME FROM NEW_PERSON WHERE INACTIVE_DATE = '' AND BMXIEN > 1";
    676                         ConnectInfo.RPMSDataTable(sCommandText, "Provider", m_dsGlobal);
    677                         Debug.Write("LoadGlobalRecordsets -- Provider loaded\n");
    678 
    679                         //Build the CLINIC_STOP table
    680                         // sCommandText = "SELECT BMXIEN, CODE, NAME FROM CLINIC_STOP"; //SMH
    681             sCommandText = "SELECT BMXIEN, AMIS_REPORTING_STOP_CODE, NAME FROM CLINIC_STOP";
    682                         ConnectInfo.RPMSDataTable(sCommandText, "ClinicStop", m_dsGlobal);
    683                         Debug.Write("LoadGlobalRecordsets -- ClinicStop loaded\n");
    684 
    685                         //Build the HOLIDAY table
    686                         sCommandText = "SELECT NAME, DATE FROM HOLIDAY WHERE DATE > '" + DateTime.Today.ToShortDateString() + "'";
    687                         ConnectInfo.RPMSDataTable(sCommandText, "HOLIDAY", m_dsGlobal);
    688             Debug.Write("LoadingGlobalRecordsets -- Holidays loaded\n");
    689 
    690 
    691                         //Save the xml schema
    692                         //m_dsGlobal.WriteXmlSchema(@"..\..\csSchema20060526.xsd");
    693 
    694                         return true;
    695                 }
    696668
    697669                public void RegisterDocumentView(CGDocument doc, CGView view)
     
    792764                }
    793765
     766        /// <summary>
     767        /// Removes view and Handles Disconnection from Database if no views are left.
     768        /// </summary>
     769        /// <param name="sender"></param>
     770        /// <param name="e"></param>
    794771                private void ViewClosed(object sender, EventArgs e)
    795772                {
     
    996973                                CloseAll();
    997974                                m_bExitOK = true;
    998                                 _current.m_ConnectInfo = new BMXNet.BMXNetConnectInfo();
     975                                //_current.m_ConnectInfo = new BMXNet.BMXNetConnectInfo();//smh redundant
    999976                                this.InitializeApp(true);
    1000977                                //Create a new document
     
    10681045                                //System.IntPtr pHandle = this.Handle;
    10691046                                RPMSDataTableDelegate rdtd = new RPMSDataTableDelegate(ConnectInfo.RPMSDataTable);
    1070                                 dtOut = (DataTable) this.Invoke(rdtd, new object[] {sSQL, sTableName});
     1047                                //dtOut = (DataTable) this.Invoke(rdtd, new object[] {sSQL, sTableName});
     1048                dtOut = rdtd.Invoke(sSQL, sTableName);
    10711049                        }
    10721050
  • Scheduling/trunk/cs/bsdx0200GUISourceCode/ClinicalScheduling.csproj

    r1039 r1050  
    192192      <SubType>Code</SubType>
    193193    </Compile>
    194     <Compile Include="CGDocumentManager.cs">
    195       <SubType>Form</SubType>
    196     </Compile>
     194    <Compile Include="CGDocumentManager.cs" />
    197195    <Compile Include="CGRange.cs" />
    198196    <Compile Include="CGResource.cs" />
  • Scheduling/trunk/cs/bsdx0200GUISourceCode/ClinicalScheduling.csproj.user

    r1049 r1050  
    3737    </RemoteDebugMachine>
    3838    <StartAction>Project</StartAction>
    39     <StartArguments>/s=172.16.16.51 /p=9250 /a=s.habiel /v=catdog.55</StartArguments>
     39    <StartArguments>/s=10.161.20.25 /p=9280 /a=s.habiel /v=catdog.55</StartArguments>
    4040    <StartPage>
    4141    </StartPage>
  • Scheduling/trunk/cs/bsdx0200GUISourceCode/DSplash.cs

    r627 r1050  
    1313        {
    1414                private System.Windows.Forms.Label label1;
    15         //private System.Windows.Forms.Label lblVersion;
    1615                private System.Windows.Forms.LinkLabel lnkMail;
    1716                private System.Windows.Forms.Label lblStatus;
     17        private Label lblVersion;
     18        private Label label2;
    1819                /// <summary>
    1920                /// Required designer variable.
     
    5556                private void InitializeComponent()
    5657                {
     58            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DSplash));
    5759            this.label1 = new System.Windows.Forms.Label();
    5860            this.lnkMail = new System.Windows.Forms.LinkLabel();
    5961            this.lblStatus = new System.Windows.Forms.Label();
     62            this.lblVersion = new System.Windows.Forms.Label();
     63            this.label2 = new System.Windows.Forms.Label();
    6064            this.SuspendLayout();
    6165            //
     
    6367            //
    6468            this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 21.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
    65             this.label1.Location = new System.Drawing.Point(24, 32);
     69            this.label1.Location = new System.Drawing.Point(12, 67);
    6670            this.label1.Name = "label1";
    67             this.label1.Size = new System.Drawing.Size(448, 40);
     71            this.label1.Size = new System.Drawing.Size(464, 40);
    6872            this.label1.TabIndex = 0;
    69             this.label1.Text = "VistA Clinical Scheduling";
     73            this.label1.Text = "Clinical Scheduling";
    7074            this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
    7175            //
     
    8084            //
    8185            this.lblStatus.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
    82             this.lblStatus.Location = new System.Drawing.Point(88, 160);
     86            this.lblStatus.Location = new System.Drawing.Point(80, 159);
    8387            this.lblStatus.Name = "lblStatus";
    8488            this.lblStatus.Size = new System.Drawing.Size(328, 16);
     
    8690            this.lblStatus.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
    8791            //
     92            // lblVersion
     93            //
     94            this.lblVersion.AutoSize = true;
     95            this.lblVersion.Location = new System.Drawing.Point(210, 117);
     96            this.lblVersion.Name = "lblVersion";
     97            this.lblVersion.Size = new System.Drawing.Size(52, 13);
     98            this.lblVersion.TabIndex = 5;
     99            this.lblVersion.Text = "lblVersion";
     100            this.lblVersion.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
     101            //
     102            // label2
     103            //
     104            this.label2.AutoSize = true;
     105            this.label2.Font = new System.Drawing.Font("Book Antiqua", 27.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     106            this.label2.Location = new System.Drawing.Point(180, 21);
     107            this.label2.Name = "label2";
     108            this.label2.Size = new System.Drawing.Size(130, 46);
     109            this.label2.TabIndex = 6;
     110            this.label2.Text = "VISTA";
     111            //
    88112            // DSplash
    89113            //
    90114            this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
     115            this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(192)))));
    91116            this.ClientSize = new System.Drawing.Size(488, 252);
    92117            this.ControlBox = false;
     118            this.Controls.Add(this.label2);
     119            this.Controls.Add(this.lblVersion);
    93120            this.Controls.Add(this.lblStatus);
    94121            this.Controls.Add(this.lnkMail);
    95122            this.Controls.Add(this.label1);
    96             this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
     123            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
     124            this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
    97125            this.Name = "DSplash";
    98126            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
     
    100128            this.Load += new System.EventHandler(this.DSplash_Load);
    101129            this.ResumeLayout(false);
     130            this.PerformLayout();
    102131
    103132                }
    104133                #endregion
    105134
    106                 public void SetStatus(string sStatus)
     135        public delegate void dSetStatus(string sStatus);
     136        public delegate void dAny();
     137               
     138        public void SetStatus(string sStatus)
    107139                {
    108                         this.Status = sStatus;
     140            if (this.InvokeRequired == true)
     141            {
     142                dSetStatus d = new dSetStatus(SetStatus);
     143                this.Invoke(d, new object[] { sStatus });
     144                return;
     145            }
     146           
     147            System.Diagnostics.Debug.Assert(this.InvokeRequired == false);
     148                        this.lblStatus.Text = sStatus;
     149            this.Refresh();
    109150                }
    110151
    111152                private void DSplash_Load(object sender, System.EventArgs e)
    112153                {
    113                         //this.lblVersion.Text = "Version " + Application.ProductVersion;
     154                        this.lblVersion.Text = "Version " + Application.ProductVersion;
    114155                }
    115156
    116                 #region Properties
    117                 /// <summary>
    118                 /// Gets or sets the value of the Status displayed on the splash screen
    119                 /// </summary>
    120                 public String Status
    121                 {
    122                         get
    123                         {
    124                                 return lblStatus.Text;
    125                         }
    126                         set
    127                         {
    128                                 lblStatus.Text = value;
    129                         }
    130                 }
    131                 #endregion Properties
     157        public void RemoteClose()
     158        {
     159            dAny d = new dAny(this.Close);
     160            this.Invoke(d);
     161        }
     162
     163        public void RemoteHide()
     164        {
     165            dAny d = new dAny(this.Hide);
     166            this.Invoke(d);
     167        }
    132168        }
     169
     170
     171   
    133172}
  • Scheduling/trunk/cs/bsdx0200GUISourceCode/DSplash.resx

    r614 r1050  
    118118    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
    119119  </resheader>
     120  <assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
     121  <data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
     122    <value>
     123        AAABAAIAICAQAAAAAADoAgAAJgAAABAQEAAAAAAAKAEAAA4DAAAoAAAAIAAAAEAAAAABAAQAAAAAAIAC
     124        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAgAAAAICAAIAAAACAAIAAgIAAAMDAwACAgIAAAAD/AAD/
     125        AAAA//8A/wAAAP8A/wD//wAA////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIh3iI
     126        iId4iAAAAAAAAAAACId4iIiHeIAiIiIggAAAAAAAAAAAAAgCqqqqoggAAAAAAAAAAACAKqqqqiAIAAiH
     127        eId4iIiIAqqqqqIAAIAIh3iHeIiIgCqqqqogAACAAAAAAAAACAKqqqqiAAAAgAAAAAAAAIAqqqqqIAAA
     128        AIAAAAAAAAgCqqqqogAAAAgAAAAAAAAAIiIiIiAAAACAAAAA////8AAAAAAAAAAIAAAAAP////8Aqqqq
     129        IAAAgAAAAAD/iIj/gCqqqqIACAAAAAAA/4iI/4gCqqqqIIAAAAAAAP//////8AAAAAgAAAAAAAD/////
     130        //+IiIiPAAAAAAAA/4iI/4iI/4iI/wAAAAAAAP+IiP+IiP+IiP8AAAAAAAD/////////////AAAAAAAA
     131        /////////////wAAAAAAAP+IiP+IiP+IiP8AAAAAAAD/iIj/iIj/iIj/AAAAAAAA/////////////wAA
     132        AAAAAP////////////8AAAAAAERERERERERERERERAAAAABEREREREREREREREQAAAAARERERERERERE
     133        REREAAAAAERERERERERERERERAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////////
     134        ///4AAAP+AAAB///gAP//wADgAAAAYAAAAH/+AAB//AAAcAAAAPAAAAHwAAAD8AAAB/AAAA/wAAAP8AA
     135        AD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/////////
     136        //8oAAAAEAAAACAAAAABAAQAAAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAgAAAAICAAIAA
     137        AACAAIAAgIAAAMDAwACAgIAAAAD/AAD/AAAA//8A/wAAAP8A/wD//wAA////AAAAAAAAAAAAAHh4iHgA
     138        CAAAAAAAACIiAAh4eIgCqqIIAAAAACqqIAAAAAACqqIAAAAP/wAAAAAAAA+IgKqiAAAAD//4AADwAAAP
     139        iPiPiPAAAA//////8AAAD4j4j4jwAAAP//////AAAERERERERAAAREREREREAAAAAAAAAAAA//8AAMAD
     140        AAD/gQAAgAAAAP4AAADAAQAAwAMAAMADAADAAwAAwAMAAMADAADAAwAAwAMAAMADAADAAwAA//8AAA==
     141</value>
     142  </data>
    120143</root>
Note: See TracChangeset for help on using the changeset viewer.