Changeset 1051


Ignore:
Timestamp:
Jan 6, 2011, 4:25:38 AM (13 years ago)
Author:
Sam Habiel
Message:

Progress Bar on Splash Screen and supporting code

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

Legend:

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

    r1050 r1051  
    188188
    189189           
    190             _current.InitializeApp();
     190            bool isEverythingOkay = _current.InitializeApp();
     191
     192            if (!isEverythingOkay) return;
    191193
    192194            //Create the first empty document
     
    251253        /// See InitializeApp(bool) below
    252254        /// </summary>
    253                 private void InitializeApp()
    254                 {
    255                         InitializeApp(false);
     255                private bool InitializeApp()
     256                {
     257                        return InitializeApp(false);
    256258                }
    257259
     
    264266                /// <param name="bReLogin">Is the User logging in again from a currently running instance?
    265267        /// If so, display a dialog to collect access and verify codes.</param>
    266         private void InitializeApp(bool bReLogin)
     268        private bool InitializeApp(bool bReLogin)
    267269                {
    268270            //Set M connection info
     
    278280            m_ConnectInfo.EventPollingEnabled = false;
    279281
    280             //Show a splash screen while initializing
     282            //Show a splash screen while initializing; define delegates to remote thread
    281283            DSplash m_ds = new DSplash();
    282284            DSplash.dSetStatus setStatusDelegate = new DSplash.dSetStatus(m_ds.SetStatus);
    283285            DSplash.dAny closeSplashDelegate = new DSplash.dAny(m_ds.RemoteClose);
    284             DSplash.dAny hideSplashDelegate = new DSplash.dAny(m_ds.RemoteHide);
    285 
     286            DSplash.dProgressBarSet setMaxProgressDelegate = new DSplash.dProgressBarSet(m_ds.RemoteProgressBarMaxSet);
     287            DSplash.dProgressBarSet setProgressDelegate = new DSplash.dProgressBarSet(m_ds.RemoteProgressBarValueSet);
     288
     289            //Start new thread for the Splash screen.
    286290            Thread threadSplash = new Thread(new ParameterizedThreadStart(StartSplash));
    287             threadSplash.IsBackground = true; //expendable -- exit even if still running.
    288             threadSplash.Start(m_ds);
    289 
     291            threadSplash.IsBackground = true; //expendable thread -- exit even if still running.
     292            threadSplash.Name = "Splash Thread";
     293            threadSplash.Start(m_ds); // pass form as parameter.
     294
     295            //There are 20 steps to load the application. That's max for the progress bar.
     296            setMaxProgressDelegate(20);
    290297           
    291                 //m_ds.SetStatus("Loading Configuration Settings...");
    292             //m_ds.Refresh();
    293                         //this.Activate();
    294             // smh--not used System.Configuration.ConfigurationManager.GetSection("appSettings");
     298            // smh--not used: System.Configuration.ConfigurationManager.GetSection("appSettings");
     299           
    295300            setStatusDelegate("Connecting to VISTA");
    296             //m_ds.Refresh();
     301           
    297302                        bool bRetry = true;
    298303
     
    301306            //whether you can connect or not. Not good. So I test first whether
    302307            //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 
     308            //TODO: Make this more robust by sending a TCPConnect message and seeing if you get a response
    307309            if (m_Server != "" && m_Port != 0)
    308310            {
     
    313315                    tcpClient.Close();                  // then close it
    314316                }
    315                 catch (System.Net.Sockets.SocketException ex)
     317                catch (System.Net.Sockets.SocketException)
    316318                {
    317                     throw ex;
     319                    MessageBox.Show("Cannot connect to VistA. Network Error");
     320                    return false;
    318321                }
    319322            }
    320323
    321                         do
     324                       
     325            // Do block is Log-in logic
     326            do
    322327                        {
    323328                // login crap
     
    347352                catch (System.Net.Sockets.SocketException)
    348353                {
    349                     MessageBox.Show("Cannot connect to VistA. ");
     354                    MessageBox.Show("Cannot connect to VistA. Network Error");
    350355                }
    351                 catch (Exception ex)
     356                catch (BMXNetException ex)
    352357                {
    353                     //m_ds.Close();
    354358                    if (MessageBox.Show("Unable to connect to VistA.  " + ex.Message, "Clinical Scheduling", MessageBoxButtons.RetryCancel) == DialogResult.Retry)
    355359                    {
     
    361365                        closeSplashDelegate();
    362366                        bRetry = false;
    363                         throw ex;
     367                        return false; //tell main that it's a no go.
    364368                    }
    365369                }
     
    370374
    371375                        //Version info
    372             //m_ds.Activate();
     376            // Table #1
     377            setProgressDelegate(1);
    373378                        setStatusDelegate("Getting Version Info from Server...");
    374379
     
    406411
    407412            //Change encoding
     413            // Call #2
     414            setProgressDelegate(2);
    408415            setStatusDelegate("Setting encoding...");
    409416
     
    414421                    m_ConnectInfo.bmxNetLib.Encoder = System.Text.UTF8Encoding.UTF8;
    415422            }
    416                         //Set application context
     423                       
     424            //Set application context
     425            // Call #3
     426            setProgressDelegate(3);
    417427                        setStatusDelegate("Setting Application Context to BSDXRPC...");
    418428                        m_ConnectInfo.AppContext = "BSDXRPC";
     
    424434            string sCommandText;
    425435
     436            //Schedule User Info
     437            // Table #4
     438            setProgressDelegate(4);
    426439            setStatusDelegate(statusConst + " Schedule User");
    427             //Schedule User Info
    428440            DataTable dtUser = _dal.GetUserInfo(m_ConnectInfo.DUZ);
    429441            dtUser.TableName = "SchedulingUser";
     
    437449            m_bSchedManager = (sUser == "YES") ? true : false;
    438450
     451            //Get Access Types
     452            // Table #5
     453            setProgressDelegate(5);
    439454            setStatusDelegate(statusConst + " Access Types");
    440             //Get Access Types
    441455            DataTable dtAccessTypes = _dal.GetAccessTypes();
    442456            dtAccessTypes.TableName = "AccessTypes";
    443457            m_dsGlobal.Tables.Add(dtAccessTypes);
    444458
     459            //Get Access Groups
     460            // Table #6
     461            setProgressDelegate(6);
    445462            setStatusDelegate(statusConst + " Access Groups");
    446             //AccessGroups
    447463            LoadAccessGroupsTable();
    448464
     
    454470            dtGroups.PrimaryKey = dcKeys;
    455471
     472            //Get Access Group Types (??)
     473            // Table #7
     474            setProgressDelegate(7);
    456475            setStatusDelegate(statusConst + " Access Group Types");
    457             //AccessGroupType
    458476            LoadAccessGroupTypesTable();
    459477
     
    471489            m_dsGlobal.Relations.Add(dr);
    472490
     491            //ResourceGroup Table (Resource Groups by User)
     492            // Table #8
     493            setProgressDelegate(8);
    473494            setStatusDelegate(statusConst + " Resource Groups By User");
    474             //ResourceGroup Table (Resource Groups by User)
    475495            LoadResourceGroupTable();
    476496
     497            //Resources by user
     498            // Table #9
     499            setProgressDelegate(9);
    477500            setStatusDelegate(statusConst + " Resources By User");
    478             //Resources by user
    479501            LoadBSDXResourcesTable();
    480502
     
    484506            m_dsGlobal.Tables["Resources"].PrimaryKey = dc;
    485507
     508            //GroupResources table
     509            // Table #10
     510            setProgressDelegate(10);
    486511            setStatusDelegate(statusConst + " Group Resources");
    487             //GroupResources table
    488512            LoadGroupResourcesTable();
    489513
     
    500524            m_dsGlobal.Relations.Add(dr);
    501525
     526            //HospitalLocation table
     527            //Table #11
     528            setProgressDelegate(11);
    502529            setStatusDelegate(statusConst + " Clinics");
    503             //HospitalLocation table
    504530            //cmd.CommandText = "SELECT BMXIEN 'HOSPITAL_LOCATION_ID', NAME 'HOSPITAL_LOCATION', DEFAULT_PROVIDER, STOP_CODE_NUMBER, INACTIVATE_DATE, REACTIVATE_DATE FROM HOSPITAL_LOCATION";
    505531            sCommandText = "BSDX HOSPITAL LOCATION";
     
    519545            m_dsGlobal.Relations.Add(dr);
    520546
     547            //Build ScheduleUser table
     548            //Table #12
     549            setProgressDelegate(12);
    521550            setStatusDelegate(statusConst + " Schedule User");
    522             //Build ScheduleUser table
    523551            this.LoadScheduleUserTable();
    524552
     
    529557            m_dsGlobal.Tables["ScheduleUser"].PrimaryKey = dc;
    530558
     559            //Build ResourceUser table
     560            //Table #13
     561            setProgressDelegate(13);
    531562            setStatusDelegate(statusConst + " Resource User");
    532             //Build ResourceUser table
    533563            this.LoadResourceUserTable();
    534564
     
    545575            m_dsGlobal.Relations.Add(dr);
    546576
     577            //Build active provider table
     578            //Table #14
     579            setProgressDelegate(14);
    547580            setStatusDelegate(statusConst + " Providers");
    548             //Build active provider table
    549581            sCommandText = "SELECT BMXIEN, NAME FROM NEW_PERSON WHERE INACTIVE_DATE = '' AND BMXIEN > 1";
    550582            ConnectInfo.RPMSDataTable(sCommandText, "Provider", m_dsGlobal);
    551583            Debug.Write("LoadGlobalRecordsets -- Provider loaded\n");
    552584
     585            //Build the CLINIC_STOP table
     586            //Table #15
     587            setProgressDelegate(15);
    553588            setStatusDelegate(statusConst + " Clinic Stops");
    554             //Build the CLINIC_STOP table
    555589            // sCommandText = "SELECT BMXIEN, CODE, NAME FROM CLINIC_STOP"; //SMH
    556590            sCommandText = "SELECT BMXIEN, AMIS_REPORTING_STOP_CODE, NAME FROM CLINIC_STOP";
     
    558592            Debug.Write("LoadGlobalRecordsets -- ClinicStop loaded\n");
    559593
     594            //Build the HOLIDAY table
     595            //Table #16
     596            setProgressDelegate(16);
    560597            setStatusDelegate(statusConst + " Holiday");
    561             //Build the HOLIDAY table
    562598            sCommandText = "SELECT NAME, DATE FROM HOLIDAY WHERE DATE > '" + DateTime.Today.ToShortDateString() + "'";
    563599            ConnectInfo.RPMSDataTable(sCommandText, "HOLIDAY", m_dsGlobal);
     
    568604            //m_dsGlobal.WriteXmlSchema(@"..\..\csSchema20060526.xsd");
    569605            //----------------------------------------------
    570            
    571 
     606
     607            setStatusDelegate("Setting Receive Timeout");
    572608            _current.m_ConnectInfo.ReceiveTimeout = 30000; //30-second timeout
    573609
     
    575611            _current.m_ConnectInfo.ReceiveTimeout = 600000; //longer timeout for debugging
    576612#endif
    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");
     613                        // Event Subsriptions
     614            setStatusDelegate("Subscribing to Server Events");
     615            //Table #17
     616            setProgressDelegate(17);
     617            _current.m_ConnectInfo.SubscribeEvent("BSDX SCHEDULE");
     618                        //Table #18
     619            setProgressDelegate(18);
     620            _current.m_ConnectInfo.SubscribeEvent("BSDX CALL WORKSTATIONS");
     621                        //Table #19
     622            setProgressDelegate(19);
     623            _current.m_ConnectInfo.SubscribeEvent("BSDX ADMIN MESSAGE");
     624                        //Table #20
     625            setProgressDelegate(20);
     626            _current.m_ConnectInfo.SubscribeEvent("BSDX ADMIN SHUTDOWN");
    581627
    582628                        _current.m_ConnectInfo.EventPollingInterval = 5000; //in milliseconds
     
    586632            //Close Splash Screen
    587633            closeSplashDelegate();
     634
     635            return true;
    588636                       
    589637                }
  • Scheduling/trunk/cs/bsdx0200GUISourceCode/ClinicalScheduling.csproj.user

    r1050 r1051  
    3737    </RemoteDebugMachine>
    3838    <StartAction>Project</StartAction>
    39     <StartArguments>/s=10.161.20.25 /p=9280 /a=s.habiel /v=catdog.55</StartArguments>
     39    <StartArguments>/s=192.168.56.101 /p=9260 /a=shabiel12 /v=catdog.66</StartArguments>
    4040    <StartPage>
    4141    </StartPage>
  • Scheduling/trunk/cs/bsdx0200GUISourceCode/DSplash.cs

    r1050 r1051  
    1717        private Label lblVersion;
    1818        private Label label2;
     19        private ProgressBar progressBar1;
    1920                /// <summary>
    2021                /// Required designer variable.
     
    6263            this.lblVersion = new System.Windows.Forms.Label();
    6364            this.label2 = new System.Windows.Forms.Label();
     65            this.progressBar1 = new System.Windows.Forms.ProgressBar();
    6466            this.SuspendLayout();
    6567            //
     
    110112            this.label2.Text = "VISTA";
    111113            //
     114            // progressBar1
     115            //
     116            this.progressBar1.Location = new System.Drawing.Point(18, 207);
     117            this.progressBar1.Name = "progressBar1";
     118            this.progressBar1.Size = new System.Drawing.Size(458, 14);
     119            this.progressBar1.Style = System.Windows.Forms.ProgressBarStyle.Continuous;
     120            this.progressBar1.TabIndex = 7;
     121            //
    112122            // DSplash
    113123            //
     
    116126            this.ClientSize = new System.Drawing.Size(488, 252);
    117127            this.ControlBox = false;
     128            this.Controls.Add(this.progressBar1);
    118129            this.Controls.Add(this.label2);
    119130            this.Controls.Add(this.lblVersion);
     
    135146        public delegate void dSetStatus(string sStatus);
    136147        public delegate void dAny();
     148        public delegate void dProgressBarSet(int number);
    137149               
    138150        public void SetStatus(string sStatus)
     
    145157            }
    146158           
    147             System.Diagnostics.Debug.Assert(this.InvokeRequired == false);
    148159                        this.lblStatus.Text = sStatus;
    149             this.Refresh();
    150160                }
    151161
     
    166176            this.Invoke(d);
    167177        }
     178
     179        public void RemoteProgressBarMaxSet(int max)
     180        {
     181            if (this.InvokeRequired == true)
     182            {
     183                dProgressBarSet d = new dProgressBarSet(RemoteProgressBarMaxSet);
     184                this.Invoke(d, new object[] { max });
     185                return;
     186            }
     187
     188            this.progressBar1.Maximum = max;
     189        }
     190
     191        public void RemoteProgressBarValueSet(int val)
     192        {
     193            if (this.InvokeRequired == true)
     194            {
     195                dProgressBarSet d = new dProgressBarSet(RemoteProgressBarValueSet);
     196                this.Invoke(d, new object[] { val });
     197                return;
     198            }
     199
     200            this.progressBar1.Value = val;
     201        }
     202
    168203        }
    169204
Note: See TracChangeset for help on using the changeset viewer.