Ignore:
Timestamp:
Jan 19, 2011, 9:02:59 AM (13 years ago)
Author:
Sam Habiel
Message:

CGDocument:

  • Better constructor to set default values.
  • Removed OnNewDocument and used constructor plus extra arguments instead.
  • Added IsRefreshNeeded method to see if we need to get data from server.

CGDocumentManager:

  • Refactored OnNewDocument out (was going to use Application.Run with the CGView form as argument, that didn't work for re-logging in)
  • Refactored all ChangeServer and ChangeLogin handlers b/c they got broken with previous work.

CGView:

  • this.Activate now in Load to show the form if you use Application.Run(view)
  • Added shortcuts for chaning Server, Login, Division
  • Position the Grid when doing OpenSelectedSchedule to start at the right day.
  • Used IsRefreshNeeded to selectively load the splash screen and contact the database for refresh then close splash screen in RequestRefreshGrid.
File:
1 edited

Legend:

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

    r1070 r1071  
    181181            _current = new CGDocumentManager();
    182182
    183             //Get command line options; store in private variables
     183            //Get command line options; store in private class wide variables
    184184            var opset = new OptionSet() {
    185185                { "s=", s => _current.m_Server = s },
     
    191191
    192192            opset.Parse(args);
    193 
    194193           
     194            //Init app
    195195            bool isEverythingOkay = _current.InitializeApp();
    196196
     197            //if an error occurred, break out.
    197198            if (!isEverythingOkay) return;
    198199
    199200            //Create the first empty document
     201            //A document holds the resources, appointments, and availabilites
    200202            //SAM: Good place for break point
    201203            CGDocument doc = new CGDocument();
    202204            doc.DocManager = _current;
    203             doc.OnNewDocument();
     205
     206            //Create new View
     207            //A view is a specific arrangement of appointments and availabilites that constitute a document
     208            CGView view = new CGView();
     209            view.InitializeDocView(doc, _current, doc.StartDate, doc.Appointments, _current.WindowText);
     210
     211            //Handle BMX Event
    204212            Application.DoEvents();
     213
     214            //Application wide error handler for unhandled errors
     215            Application.ThreadException += new ThreadExceptionEventHandler(App_ThreadException);
     216
    205217#if TRACE
    206218            DateTime EndLoadTime = DateTime.Now;
     
    208220            Debug.Write("Load Time for GUI is " + LoadTime.Seconds + " s & " + LoadTime.Milliseconds + " ms\n");
    209221#endif
    210             //Application wide error handler for unhandled errors
    211             Application.ThreadException += new ThreadExceptionEventHandler(App_ThreadException);
    212 
    213             //Run the application
    214             //Sam's Note: This is an unusual way to call this. Typically, it's run with
    215             //the main form as an argument.
     222           
     223            view.Show();
     224            view.Activate();
     225           
    216226            Application.Run();
    217227        }
     
    368378                    }
    369379                    // My code -- buts looks so ugly!
     380                    // Checks the passed parameters stored in the class variables
    370381                    else
    371382                    {
     
    981992                }
    982993
     994        /// <summary>
     995        /// Accomplishes Changing the Server to which you connect
     996        /// </summary>
     997        /// <remarks>
     998        /// Parameter relog-in for InitializeApp forces initialize app to use
     999        /// 1. The server the user just picked and then BMX saved off to User Preferences
     1000        /// 2. A new access and verify code pair
     1001        /// </remarks>
     1002        /// <param name="sender">unused</param>
     1003        /// <param name="e">unused</param>
    9831004                private void mnuRPMSServer_Click(object sender, EventArgs e)
    9841005                {
     
    9901011                        try
    9911012                        {
     1013                // Close All, but tell the Close All method not to call Applicaiton.Exit since we still plan to continue.
     1014                // Close All does not call Application.Exit, but CGView_Close handler does
    9921015                                m_bExitOK = false;
    993                                 bool bRetry = true;
    994                                 BMXNetConnectInfo tmpInfo;
     1016                CloseAll();
     1017                m_bExitOK = true;
     1018               
     1019                //Used in Do loop
     1020                bool bRetry = true;
     1021                               
     1022                // Do Loop to deal with changing the server and the vagaries of user choices.
    9951023                                do
    9961024                                {
    997                                         tmpInfo = m_ConnectInfo;
    9981025                                        try
    9991026                                        {
    1000                                                 tmpInfo.ChangeServerInfo();
     1027                        //ChangeServerInfo does not re-login the user
     1028                        //It only changes the saved server information in the %APPDATA% folder
     1029                        //so it can be re-used when BMX tries to log in again.
     1030                        //Access and Verify code are prompted for in InitializeApp
     1031                                                m_ConnectInfo.ChangeServerInfo();
    10011032                                                bRetry = false;
    10021033                                        }
     
    10061037                                                {
    10071038                                                        bRetry = false;
     1039                            Application.Exit();
    10081040                                                        return;
    10091041                                                }
     
    10151047                                                {
    10161048                                                        bRetry = false;
     1049                            Application.Exit();
    10171050                                                        return;
    10181051                                                }
     
    10201053                                } while (bRetry == true);
    10211054
    1022                                 CloseAll();
    1023                                 m_bExitOK = true;
    1024                                 m_ConnectInfo = tmpInfo;
    1025 
    1026                                 this.InitializeApp();
    1027 
    1028                                 //Create a new document
    1029                                 CGDocument doc = new CGDocument();
    1030                                 doc.DocManager = _current;
    1031                                 doc.OnNewDocument();
    1032 
     1055                //Parameter for initialize app tells it that this is a re-login and forces a new access and verify code.
     1056                bool isEverythingOkay = this.InitializeApp(true);
     1057
     1058                //if an error occurred, break out. This time we need to call Application.Exit since it's already running.
     1059                if (!isEverythingOkay)
     1060                {
     1061                    Application.Exit();
     1062                    return;
     1063                }
     1064
     1065                //Otherwise, everything is okay. So open document and view, then show and activate view.
     1066                CGDocument doc = new CGDocument();
     1067                doc.DocManager = _current;
     1068
     1069                CGView view = new CGView();
     1070                view.InitializeDocView(doc, _current, doc.StartDate, doc.Appointments, _current.WindowText);
     1071
     1072                view.Show();
     1073                view.Activate();
     1074
     1075                //Application.Run need not be called b/c it is already running.
    10331076                        }
    10341077                        catch (Exception ex)
     
    10391082                }
    10401083
     1084        /// <summary>
     1085        /// Accomplishes Re-login into RPMS/VISTA. Now all logic is in this event handler.
     1086        /// </summary>
     1087        /// <param name="sender">not used</param>
     1088        /// <param name="e">not used</param>
    10411089                private void mnuRPMSLogin_Click(object sender, EventArgs e)
    10421090                {
     
    10481096                        try
    10491097                        {
     1098                // Close All, but tell the Close All method not to call Applicaiton.Exit since we still plan to continue.
     1099                // Close All does not call Application.Exit, but CGView_Close handler does
    10501100                                m_bExitOK = false;
    10511101                                CloseAll();
    10521102                                m_bExitOK = true;
    1053                                 //_current.m_ConnectInfo = new BMXNet.BMXNetConnectInfo();//smh redundant
    1054                                 this.InitializeApp(true);
    1055                                 //Create a new document
    1056                                 CGDocument doc = new CGDocument();
    1057                                 doc.DocManager = _current;
    1058                                 doc.OnNewDocument();
     1103
     1104                //Parameter for initialize app tells it that this is a re-login and forces a new access and verify code.
     1105                bool isEverythingOkay = this.InitializeApp(true);
     1106
     1107                //if an error occurred, break out. This time we need to call Application.Exit since it's already running.
     1108                if (!isEverythingOkay)
     1109                {
     1110                    Application.Exit();
     1111                    return;
     1112                }
     1113
     1114                //Otherwise, everything is okay. So open document and view, then show and activate view.
     1115                CGDocument doc = new CGDocument();
     1116                doc.DocManager = _current;
     1117
     1118                CGView view = new CGView();
     1119                view.InitializeDocView(doc, _current, doc.StartDate, doc.Appointments, _current.WindowText);
     1120
     1121                view.Show();
     1122                view.Activate();
     1123
     1124                //Application.Run need not be called b/c it is already running.
    10591125                        }
    10601126                        catch (Exception ex)
Note: See TracChangeset for help on using the changeset viewer.