[614] | 1 | using System;
|
---|
| 2 | using System.Windows.Forms;
|
---|
| 3 | using System.Collections;
|
---|
| 4 | using System.Data;
|
---|
| 5 | using System.Diagnostics;
|
---|
[1050] | 6 | using System.Threading;
|
---|
[614] | 7 | using IndianHealthService.BMXNet;
|
---|
[772] | 8 | using Mono.Options;
|
---|
[788] | 9 | using System.Runtime.InteropServices;
|
---|
[1112] | 10 | using System.Globalization;
|
---|
[614] | 11 |
|
---|
| 12 | namespace IndianHealthService.ClinicalScheduling
|
---|
| 13 | {
|
---|
| 14 | /// <summary>
|
---|
[1050] | 15 | /// Main Worker. Handles sub-forms.
|
---|
[614] | 16 | /// </summary>
|
---|
[1050] | 17 | public class CGDocumentManager //: System.Windows.Forms.Form
|
---|
[614] | 18 | {
|
---|
| 19 | #region Member Variables
|
---|
| 20 |
|
---|
| 21 | private static CGDocumentManager _current;
|
---|
[1050] | 22 | private Hashtable _views = new Hashtable(); //Returns the list of currently opened documents
|
---|
| 23 | private Hashtable m_AVViews = new Hashtable(); // List of currently opened CGAVViews
|
---|
[620] | 24 | private string m_sWindowText = "Clinical Scheduling"; //Default Window Text
|
---|
[1050] | 25 | private bool m_bSchedManager = false; // Do you have the XUPROGMODE or BSDXZMGR?
|
---|
| 26 | private bool m_bExitOK = true; // Okay to exit program? Used to control Re-logins. Default true.
|
---|
| 27 | public string m_sHandle = "0"; // Not Used
|
---|
[824] | 28 |
|
---|
[1050] | 29 | //Connection variables (tied to command line parameters /a /v /s /p /e)
|
---|
[772] | 30 | private string m_AccessCode="";
|
---|
| 31 | private string m_VerifyCode="";
|
---|
| 32 | private string m_Server="";
|
---|
| 33 | private int m_Port=0;
|
---|
[1050] | 34 | private string m_Encoding=""; //Encoding is "" by default;
|
---|
[614] | 35 |
|
---|
[1112] | 36 | //Globalization Object (tied to command line parameter /culture)
|
---|
| 37 | private string m_CultureName = "";
|
---|
| 38 |
|
---|
[843] | 39 | //Data Access Layer
|
---|
| 40 | private DAL _dal = null;
|
---|
| 41 |
|
---|
[614] | 42 | //M Connection member variables
|
---|
[1050] | 43 | private DataSet m_dsGlobal = null; // Holds all user data
|
---|
| 44 | private BMXNetConnectInfo m_ConnectInfo = null; // Connection to VISTA object
|
---|
| 45 | private BMXNetConnectInfo.BMXNetEventDelegate CDocMgrEventDelegate; // Delegate to respond to messages from VISTA. Responds to event: BMXNetConnectInfo.BMXNetEvent
|
---|
[614] | 46 |
|
---|
[1091] | 47 | //Custom Printing
|
---|
[1110] | 48 | private Printing m_PrintingObject = null;
|
---|
[614] | 49 | #endregion
|
---|
| 50 |
|
---|
[1050] | 51 | #region Properties
|
---|
| 52 |
|
---|
[824] | 53 | /// <summary>
|
---|
[1050] | 54 | /// Returns the document manager's BMXNetConnectInfo member
|
---|
[824] | 55 | /// </summary>
|
---|
[1050] | 56 | public BMXNetConnectInfo ConnectInfo
|
---|
| 57 | {
|
---|
| 58 | get
|
---|
| 59 | {
|
---|
| 60 | return m_ConnectInfo;
|
---|
| 61 | }
|
---|
| 62 | }
|
---|
| 63 |
|
---|
| 64 | /// <summary>
|
---|
| 65 | /// True if the current user holds the BSDXZMGR or XUPROGMODE keys in RPMS
|
---|
| 66 | /// </summary>
|
---|
| 67 | public bool ScheduleManager
|
---|
| 68 | {
|
---|
| 69 | get
|
---|
| 70 | {
|
---|
| 71 | return m_bSchedManager;
|
---|
| 72 | }
|
---|
| 73 | }
|
---|
| 74 |
|
---|
| 75 | /// <summary>
|
---|
| 76 | /// Holds the user and division
|
---|
| 77 | /// </summary>
|
---|
| 78 | public string WindowText
|
---|
| 79 | {
|
---|
| 80 | get
|
---|
| 81 | {
|
---|
| 82 | return m_sWindowText;
|
---|
| 83 | }
|
---|
| 84 | }
|
---|
| 85 |
|
---|
| 86 | /// <summary>
|
---|
| 87 | /// This dataset contains tables used by the entire application
|
---|
| 88 | /// </summary>
|
---|
| 89 | public DataSet GlobalDataSet
|
---|
| 90 | {
|
---|
| 91 | get
|
---|
| 92 | {
|
---|
| 93 | return m_dsGlobal;
|
---|
| 94 | }
|
---|
| 95 | set
|
---|
| 96 | {
|
---|
| 97 | m_dsGlobal = value;
|
---|
| 98 | }
|
---|
| 99 | }
|
---|
[1111] | 100 |
|
---|
| 101 | /// <summary>
|
---|
[1112] | 102 | /// User Preferences Auto Property
|
---|
[1111] | 103 | /// </summary>
|
---|
| 104 | public UserPreferences UserPreferences { get; private set; }
|
---|
[1050] | 105 |
|
---|
| 106 | /// <summary>
|
---|
| 107 | /// Returns the single CGDocumentManager object
|
---|
| 108 | /// </summary>
|
---|
| 109 | public static CGDocumentManager Current
|
---|
| 110 | {
|
---|
| 111 | get
|
---|
| 112 | {
|
---|
| 113 | return _current;
|
---|
| 114 | }
|
---|
| 115 | }
|
---|
| 116 |
|
---|
| 117 |
|
---|
| 118 | /// <summary>
|
---|
| 119 | /// Returns the list of currently opened documents
|
---|
| 120 | /// </summary>
|
---|
| 121 | public Hashtable Views
|
---|
| 122 | {
|
---|
| 123 | get
|
---|
| 124 | {
|
---|
| 125 | return _views;
|
---|
| 126 | }
|
---|
| 127 | }
|
---|
| 128 |
|
---|
| 129 | /// <summary>
|
---|
| 130 | /// Returns the list of currently opened CGAVViews
|
---|
| 131 | /// </summary>
|
---|
| 132 | public Hashtable AvailabilityViews
|
---|
| 133 | {
|
---|
| 134 | get
|
---|
| 135 | {
|
---|
| 136 | return this.m_AVViews;
|
---|
| 137 | }
|
---|
| 138 | }
|
---|
| 139 |
|
---|
| 140 | public DAL DAL
|
---|
| 141 | {
|
---|
| 142 | get { return this._dal; }
|
---|
| 143 | }
|
---|
| 144 |
|
---|
[1110] | 145 | public Printing PrintingObject
|
---|
[1091] | 146 | {
|
---|
| 147 | get
|
---|
| 148 | {
|
---|
| 149 | return this.m_PrintingObject;
|
---|
| 150 | }
|
---|
| 151 | }
|
---|
[1050] | 152 | #endregion
|
---|
| 153 |
|
---|
| 154 | /// <summary>
|
---|
| 155 | /// Constructor. Does absolutely nothing at this point.
|
---|
| 156 | /// </summary>
|
---|
[614] | 157 | public CGDocumentManager()
|
---|
| 158 | {
|
---|
| 159 | }
|
---|
| 160 |
|
---|
[1050] | 161 |
|
---|
| 162 | #if DEBUG
|
---|
| 163 | //To write to the console
|
---|
| 164 | [DllImport("kernel32.dll")]
|
---|
| 165 | static extern bool AttachConsole(int dwProcessId);
|
---|
| 166 | private const int ATTACH_PARENT_PROCESS = -1;
|
---|
| 167 | #endif
|
---|
| 168 | /// <summary>
|
---|
| 169 | /// Main Entry Point
|
---|
| 170 | /// </summary>
|
---|
| 171 | /// <param name="args">We accept the following Arguments:
|
---|
| 172 | /// /s or -s = Server ip address or name
|
---|
| 173 | /// /p or -p = port number (must be numeric)
|
---|
| 174 | /// /a or -a = Access Code
|
---|
| 175 | /// /v or -v = Verify Code
|
---|
| 176 | /// /e or -e = Encoding (name of encoding as known to windows, such as windows-1256)
|
---|
[1112] | 177 | /// /culture or -culture = Culture Name for UI Culture if you wish to override the Windows Culture
|
---|
[1050] | 178 | /// </param>
|
---|
| 179 | /// <remarks>
|
---|
| 180 | /// Encoding decision is complex. This is the order of priority:
|
---|
| 181 | /// - If the M DB runs in UTF-8, that's what we are going to use.
|
---|
[1095] | 182 | /// - If that's not so, /e sets the default encoding. If /e is a non-existent encoding, move to next step.
|
---|
[1050] | 183 | /// - If /e is not supplied or is not recognized, the default encoding is the Windows default Encoding for the user.
|
---|
| 184 | /// </remarks>
|
---|
| 185 | [STAThread()]
|
---|
| 186 | static void Main(string[] args)
|
---|
| 187 | {
|
---|
[1122] | 188 | //Application wide error handler for unhandled errors (later I figure out that's only for WinForm ex'es)
|
---|
| 189 | Application.SetUnhandledExceptionMode(UnhandledExceptionMode.ThrowException);
|
---|
| 190 | Application.ThreadException += new ThreadExceptionEventHandler(App_ThreadException);
|
---|
| 191 |
|
---|
| 192 | // Add the event handler for handling non-UI thread exceptions to the event.
|
---|
| 193 | AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(App_DomainException);
|
---|
| 194 |
|
---|
[1050] | 195 | #if DEBUG
|
---|
| 196 | // Print console messages to console if launched from console
|
---|
| 197 | // Note: Imported From kernel32.dll
|
---|
| 198 | AttachConsole(ATTACH_PARENT_PROCESS);
|
---|
| 199 | #endif
|
---|
[1065] | 200 |
|
---|
| 201 | #if TRACE
|
---|
| 202 | DateTime startLoadTime = DateTime.Now;
|
---|
| 203 | #endif
|
---|
| 204 |
|
---|
[1050] | 205 | //Store a class instance of manager. Actual constructor does nothing.
|
---|
| 206 | _current = new CGDocumentManager();
|
---|
| 207 |
|
---|
[1071] | 208 | //Get command line options; store in private class wide variables
|
---|
[1050] | 209 | var opset = new OptionSet() {
|
---|
| 210 | { "s=", s => _current.m_Server = s },
|
---|
| 211 | { "p=", p => _current.m_Port = int.Parse(p) },
|
---|
| 212 | { "a=", a => _current.m_AccessCode = a },
|
---|
| 213 | { "v=", v => _current.m_VerifyCode = v },
|
---|
[1112] | 214 | { "e=", e => _current.m_Encoding = e},
|
---|
| 215 | { "culture=", culture => _current.m_CultureName = culture }
|
---|
[1050] | 216 | };
|
---|
| 217 |
|
---|
| 218 | opset.Parse(args);
|
---|
| 219 |
|
---|
[1071] | 220 | //Init app
|
---|
[1051] | 221 | bool isEverythingOkay = _current.InitializeApp();
|
---|
[1050] | 222 |
|
---|
[1071] | 223 | //if an error occurred, break out.
|
---|
[1051] | 224 | if (!isEverythingOkay) return;
|
---|
| 225 |
|
---|
[1050] | 226 | //Create the first empty document
|
---|
[1071] | 227 | //A document holds the resources, appointments, and availabilites
|
---|
[1070] | 228 | //SAM: Good place for break point
|
---|
[1050] | 229 | CGDocument doc = new CGDocument();
|
---|
| 230 | doc.DocManager = _current;
|
---|
[1071] | 231 |
|
---|
| 232 | //Create new View
|
---|
| 233 | //A view is a specific arrangement of appointments and availabilites that constitute a document
|
---|
| 234 | CGView view = new CGView();
|
---|
[1073] | 235 | view.InitializeDocView(doc, _current, doc.StartDate, _current.WindowText);
|
---|
[1071] | 236 |
|
---|
| 237 | //Handle BMX Event
|
---|
[1050] | 238 | Application.DoEvents();
|
---|
[1071] | 239 |
|
---|
[1122] | 240 | //test
|
---|
| 241 | //doc.ThrowException();
|
---|
| 242 | //test
|
---|
[1071] | 243 |
|
---|
[1065] | 244 | #if TRACE
|
---|
| 245 | DateTime EndLoadTime = DateTime.Now;
|
---|
| 246 | TimeSpan LoadTime = EndLoadTime - startLoadTime;
|
---|
| 247 | Debug.Write("Load Time for GUI is " + LoadTime.Seconds + " s & " + LoadTime.Milliseconds + " ms\n");
|
---|
| 248 | #endif
|
---|
[1071] | 249 |
|
---|
| 250 | view.Show();
|
---|
| 251 | view.Activate();
|
---|
| 252 |
|
---|
[1050] | 253 | Application.Run();
|
---|
| 254 | }
|
---|
| 255 |
|
---|
[1065] | 256 | /// <summary>
|
---|
[1122] | 257 | /// Exception handler for application errors. Only for WinForm Errors.
|
---|
[1065] | 258 | /// </summary>
|
---|
[1122] | 259 | /// <remarks>Never tested. I can't get an error to go here!</remarks>
|
---|
[1065] | 260 | /// <param name="sender"></param>
|
---|
| 261 | /// <param name="e"></param>
|
---|
| 262 | static void App_ThreadException(object sender, ThreadExceptionEventArgs e)
|
---|
| 263 | {
|
---|
| 264 | string msg = "A problem has occured in this applicaton. \r\n\r\n" +
|
---|
| 265 | "\t" + e.Exception.Message + "\r\n\r\n" +
|
---|
| 266 | "Would you like to continue the application?";
|
---|
| 267 |
|
---|
| 268 | DialogResult res = MessageBox.Show(msg, "Unexpected Error", MessageBoxButtons.YesNo);
|
---|
| 269 |
|
---|
| 270 | if (res == DialogResult.Yes) return;
|
---|
| 271 | else Application.Exit();
|
---|
| 272 | }
|
---|
| 273 |
|
---|
[1122] | 274 | /// <summary>
|
---|
| 275 | /// If we are here, we are dead meat.
|
---|
| 276 | /// </summary>
|
---|
| 277 | /// <param name="sender"></param>
|
---|
| 278 | /// <param name="e"></param>
|
---|
| 279 | static void App_DomainException(object sender, UnhandledExceptionEventArgs e)
|
---|
| 280 | {
|
---|
| 281 | if (e.ExceptionObject is System.Net.Sockets.SocketException)
|
---|
| 282 | {
|
---|
| 283 | MessageBox.Show("Looks like we lost our connection with the server\nClick OK to terminate the application.");
|
---|
| 284 | }
|
---|
| 285 | else
|
---|
| 286 | {
|
---|
| 287 | Exception ex = e.ExceptionObject as Exception;
|
---|
[1065] | 288 |
|
---|
[1122] | 289 | string msg = "A problem has occured in this applicaton. \r\n\r\n" +
|
---|
| 290 | "\t" + ex.InnerException.Message;
|
---|
| 291 |
|
---|
| 292 | MessageBox.Show(msg, "Unexpected Error");
|
---|
| 293 | }
|
---|
| 294 | }// here application terminates
|
---|
| 295 |
|
---|
[614] | 296 | #region BMXNet Event Handler
|
---|
| 297 | private void CDocMgrEventHandler(Object obj, BMXNet.BMXNetEventArgs e)
|
---|
| 298 | {
|
---|
| 299 | if (e.BMXEvent == "BSDX CALL WORKSTATIONS")
|
---|
| 300 | {
|
---|
| 301 | string sParam = "";
|
---|
| 302 | string sDelim="~";
|
---|
| 303 | sParam += this.m_ConnectInfo.UserName + sDelim;
|
---|
| 304 | sParam += this.m_sHandle + sDelim;
|
---|
| 305 | sParam += Application.ProductVersion + sDelim;
|
---|
| 306 | sParam += this._views.Count.ToString();
|
---|
| 307 | _current.m_ConnectInfo.RaiseEvent("BSDX WORKSTATION REPORT", sParam, true);
|
---|
| 308 | }
|
---|
| 309 | if (e.BMXEvent == "BSDX ADMIN MESSAGE")
|
---|
| 310 | {
|
---|
| 311 | string sMsg = e.BMXParam;
|
---|
| 312 | ShowAdminMsgDelegate samd = new ShowAdminMsgDelegate(ShowAdminMsg);
|
---|
[1050] | 313 | //this.Invoke(samd, new object [] {sMsg});
|
---|
| 314 | samd.Invoke(sMsg);
|
---|
[614] | 315 | }
|
---|
| 316 | if (e.BMXEvent == "BSDX ADMIN SHUTDOWN")
|
---|
| 317 | {
|
---|
| 318 | string sMsg = e.BMXParam;
|
---|
| 319 | CloseAllDelegate cad = new CloseAllDelegate(CloseAll);
|
---|
[1050] | 320 | //this.Invoke(cad, new object [] {sMsg});
|
---|
| 321 | cad.Invoke(sMsg);
|
---|
[614] | 322 | }
|
---|
| 323 | }
|
---|
| 324 |
|
---|
| 325 | delegate void ShowAdminMsgDelegate(string sMsg);
|
---|
| 326 |
|
---|
| 327 | private void ShowAdminMsg(string sMsg)
|
---|
| 328 | {
|
---|
| 329 | MessageBox.Show(sMsg, "Message from Scheduling Administrator", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
---|
| 330 | }
|
---|
| 331 |
|
---|
| 332 | #endregion BMXNet Event Handler
|
---|
| 333 |
|
---|
| 334 |
|
---|
| 335 | #region Methods & Events
|
---|
| 336 |
|
---|
[1050] | 337 | /// <summary>
|
---|
| 338 | /// See InitializeApp(bool) below
|
---|
| 339 | /// </summary>
|
---|
[1051] | 340 | private bool InitializeApp()
|
---|
[614] | 341 | {
|
---|
[1051] | 342 | return InitializeApp(false);
|
---|
[614] | 343 | }
|
---|
| 344 |
|
---|
[1050] | 345 | /// <summary>
|
---|
| 346 | /// Does a million things:
|
---|
| 347 | /// 1. Starts Connection and displays log-in dialogs
|
---|
| 348 | /// 2. Starts Splash screen
|
---|
| 349 | /// 3. Loads data tables
|
---|
| 350 | /// </summary>
|
---|
| 351 | /// <param name="bReLogin">Is the User logging in again from a currently running instance?
|
---|
| 352 | /// If so, display a dialog to collect access and verify codes.</param>
|
---|
[1051] | 353 | private bool InitializeApp(bool bReLogin)
|
---|
[614] | 354 | {
|
---|
[1050] | 355 | //Set M connection info
|
---|
[824] | 356 | m_ConnectInfo = new BMXNetConnectInfo(m_Encoding); // Encoding is "" unless passed in command line
|
---|
[843] | 357 | _dal = new DAL(m_ConnectInfo); // Data access layer
|
---|
[824] | 358 | //m_ConnectInfo.bmxNetLib.StartLog(); //This line turns on logging of messages
|
---|
[1050] | 359 |
|
---|
| 360 | //Create a delegate to process events raised by BMX.
|
---|
[824] | 361 | CDocMgrEventDelegate = new BMXNetConnectInfo.BMXNetEventDelegate(CDocMgrEventHandler);
|
---|
[1050] | 362 | //Tie delegate to Events generated by BMX.
|
---|
[824] | 363 | m_ConnectInfo.BMXNetEvent += CDocMgrEventDelegate;
|
---|
[1050] | 364 | //Disable polling (But does this really work???? I don't see how it gets disabled)
|
---|
[824] | 365 | m_ConnectInfo.EventPollingEnabled = false;
|
---|
| 366 |
|
---|
[1051] | 367 | //Show a splash screen while initializing; define delegates to remote thread
|
---|
[1050] | 368 | DSplash m_ds = new DSplash();
|
---|
| 369 | DSplash.dSetStatus setStatusDelegate = new DSplash.dSetStatus(m_ds.SetStatus);
|
---|
| 370 | DSplash.dAny closeSplashDelegate = new DSplash.dAny(m_ds.RemoteClose);
|
---|
[1051] | 371 | DSplash.dProgressBarSet setMaxProgressDelegate = new DSplash.dProgressBarSet(m_ds.RemoteProgressBarMaxSet);
|
---|
| 372 | DSplash.dProgressBarSet setProgressDelegate = new DSplash.dProgressBarSet(m_ds.RemoteProgressBarValueSet);
|
---|
[794] | 373 |
|
---|
[1051] | 374 | //Start new thread for the Splash screen.
|
---|
[1070] | 375 | Thread threadSplash = new Thread(new ParameterizedThreadStart(frm => ((DSplash)frm).ShowDialog()));
|
---|
[1051] | 376 | threadSplash.IsBackground = true; //expendable thread -- exit even if still running.
|
---|
| 377 | threadSplash.Name = "Splash Thread";
|
---|
| 378 | threadSplash.Start(m_ds); // pass form as parameter.
|
---|
[794] | 379 |
|
---|
[1117] | 380 | //There are 21 steps to load the application. That's max for the progress bar.
|
---|
| 381 | setMaxProgressDelegate(21);
|
---|
[1050] | 382 |
|
---|
[1051] | 383 | // smh--not used: System.Configuration.ConfigurationManager.GetSection("appSettings");
|
---|
| 384 |
|
---|
[1050] | 385 | setStatusDelegate("Connecting to VISTA");
|
---|
[1051] | 386 |
|
---|
[1050] | 387 | //Try to connect using supplied values for Server and Port
|
---|
| 388 | //Why am I doing this? The library BMX net uses prompts for access and verify code
|
---|
| 389 | //whether you can connect or not. Not good. So I test first whether
|
---|
| 390 | //we can connect at all by doing a simple connection and disconnect.
|
---|
[1051] | 391 | //TODO: Make this more robust by sending a TCPConnect message and seeing if you get a response
|
---|
[1050] | 392 | if (m_Server != "" && m_Port != 0)
|
---|
| 393 | {
|
---|
| 394 | System.Net.Sockets.TcpClient tcpClient = new System.Net.Sockets.TcpClient();
|
---|
| 395 | try
|
---|
[794] | 396 | {
|
---|
[1050] | 397 | tcpClient.Connect(m_Server, m_Port); // open it
|
---|
| 398 | tcpClient.Close(); // then close it
|
---|
| 399 | }
|
---|
[1051] | 400 | catch (System.Net.Sockets.SocketException)
|
---|
[1050] | 401 | {
|
---|
[1051] | 402 | MessageBox.Show("Cannot connect to VistA. Network Error");
|
---|
| 403 | return false;
|
---|
[1050] | 404 | }
|
---|
| 405 | }
|
---|
| 406 |
|
---|
[1062] | 407 |
|
---|
| 408 | bool bRetry = true;
|
---|
| 409 |
|
---|
[1051] | 410 | // Do block is Log-in logic
|
---|
| 411 | do
|
---|
[1050] | 412 | {
|
---|
| 413 | // login crap
|
---|
| 414 | try
|
---|
| 415 | {
|
---|
| 416 | // Not my code
|
---|
| 417 | if (bReLogin == true)
|
---|
[794] | 418 | {
|
---|
[1050] | 419 | //Prompt for Access and Verify codes
|
---|
| 420 | _current.m_ConnectInfo.LoadConnectInfo("", "");
|
---|
[794] | 421 | }
|
---|
[1050] | 422 | // My code -- buts looks so ugly!
|
---|
[1071] | 423 | // Checks the passed parameters stored in the class variables
|
---|
[1050] | 424 | else
|
---|
[794] | 425 | {
|
---|
[1050] | 426 | if (m_Server != String.Empty && m_Port != 0 && m_AccessCode != String.Empty
|
---|
| 427 | && m_VerifyCode != String.Empty)
|
---|
[794] | 428 | {
|
---|
[1050] | 429 | m_ConnectInfo.LoadConnectInfo(m_Server, m_Port, m_AccessCode, m_VerifyCode);
|
---|
[794] | 430 | }
|
---|
[1050] | 431 | else if (m_Server != String.Empty && m_Port != 0)
|
---|
| 432 | m_ConnectInfo.LoadConnectInfo(m_Server, m_Port, "", "");
|
---|
[794] | 433 | else
|
---|
[1050] | 434 | m_ConnectInfo.LoadConnectInfo();
|
---|
[794] | 435 | }
|
---|
[1050] | 436 | bRetry = false;
|
---|
| 437 | }
|
---|
| 438 | catch (System.Net.Sockets.SocketException)
|
---|
| 439 | {
|
---|
[1051] | 440 | MessageBox.Show("Cannot connect to VistA. Network Error");
|
---|
[1050] | 441 | }
|
---|
[1051] | 442 | catch (BMXNetException ex)
|
---|
[1050] | 443 | {
|
---|
| 444 | if (MessageBox.Show("Unable to connect to VistA. " + ex.Message, "Clinical Scheduling", MessageBoxButtons.RetryCancel) == DialogResult.Retry)
|
---|
[794] | 445 | {
|
---|
[1050] | 446 | bRetry = true;
|
---|
[1106] | 447 | //I hate this, but this is how the library is designed. It throws an error if the user cancels. XXX: Won't fix library until BMX 4.0 port.
|
---|
| 448 | try { _current.m_ConnectInfo.ChangeServerInfo(); }
|
---|
| 449 | catch (Exception)
|
---|
| 450 | {
|
---|
| 451 | closeSplashDelegate();
|
---|
| 452 | bRetry = false;
|
---|
| 453 | return false; //tell main that it's a no go.
|
---|
| 454 | }
|
---|
[794] | 455 | }
|
---|
[1050] | 456 | else
|
---|
[794] | 457 | {
|
---|
[1050] | 458 | closeSplashDelegate();
|
---|
| 459 | bRetry = false;
|
---|
[1051] | 460 | return false; //tell main that it's a no go.
|
---|
[794] | 461 | }
|
---|
[1050] | 462 | }
|
---|
| 463 | }while (bRetry == true);
|
---|
| 464 |
|
---|
[1091] | 465 | //Printing
|
---|
| 466 |
|
---|
[1098] | 467 | string DllLocation = string.Empty;
|
---|
[1091] | 468 | System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(Application.StartupPath + @"\Printing\");
|
---|
[1098] | 469 | if (di.Exists)
|
---|
[1091] | 470 | {
|
---|
[1098] | 471 | System.IO.FileInfo[] rgFiles = di.GetFiles("*.dll");
|
---|
| 472 |
|
---|
| 473 | foreach (System.IO.FileInfo fi in rgFiles)
|
---|
| 474 | {
|
---|
| 475 | DllLocation = fi.FullName;
|
---|
| 476 | }
|
---|
[1091] | 477 | }
|
---|
| 478 |
|
---|
| 479 | PrintingCreator Creator = null;
|
---|
| 480 | if (DllLocation == string.Empty)
|
---|
| 481 | {
|
---|
[1110] | 482 | this.m_PrintingObject = new Printing();
|
---|
[1091] | 483 | }
|
---|
| 484 | else
|
---|
| 485 | {
|
---|
| 486 | System.Reflection.Assembly assembly = System.Reflection.Assembly.LoadFrom(DllLocation);
|
---|
| 487 | foreach (Type type in assembly.GetTypes())
|
---|
| 488 | {
|
---|
| 489 | if (type.IsClass == true & type.BaseType == typeof(PrintingCreator))
|
---|
| 490 | {
|
---|
| 491 | Creator = (PrintingCreator)Activator.CreateInstance(type);
|
---|
| 492 | break;
|
---|
| 493 | }
|
---|
| 494 | }
|
---|
| 495 | this.m_PrintingObject = Creator.PrintFactory();
|
---|
| 496 | }
|
---|
| 497 |
|
---|
[1117] | 498 |
|
---|
[1111] | 499 |
|
---|
[1112] | 500 | //User Interface Culture (m_CultureName is set from the command line flag /culture)
|
---|
| 501 | try { Thread.CurrentThread.CurrentUICulture = new CultureInfo(m_CultureName); } // if "", invariant culture
|
---|
| 502 | catch (CultureNotFoundException) { Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture; }
|
---|
| 503 |
|
---|
[1050] | 504 | //Create global dataset
|
---|
| 505 | _current.m_dsGlobal = new DataSet("GlobalDataSet");
|
---|
[614] | 506 |
|
---|
[1050] | 507 | //Version info
|
---|
[1051] | 508 | // Table #1
|
---|
| 509 | setProgressDelegate(1);
|
---|
[1050] | 510 | setStatusDelegate("Getting Version Info from Server...");
|
---|
[614] | 511 |
|
---|
[1050] | 512 | DataTable ver = _dal.GetVersion("BSDX");
|
---|
| 513 | ver.TableName = "VersionInfo";
|
---|
| 514 | m_dsGlobal.Tables.Add(ver);
|
---|
[1039] | 515 |
|
---|
[1050] | 516 | //How to extract the version numbers:
|
---|
| 517 | DataTable dtVersion = m_dsGlobal.Tables["VersionInfo"];
|
---|
| 518 | Debug.Assert(dtVersion.Rows.Count == 1);
|
---|
| 519 | DataRow rVersion = dtVersion.Rows[0];
|
---|
| 520 | string sMajor = rVersion["MAJOR_VERSION"].ToString();
|
---|
| 521 | string sMinor = rVersion["MINOR_VERSION"].ToString();
|
---|
| 522 | string sBuild = rVersion["BUILD"].ToString();
|
---|
| 523 | decimal fBuild = Convert.ToDecimal(sBuild);
|
---|
[614] | 524 |
|
---|
[1050] | 525 | //Make sure that the server is running the same version the client is.
|
---|
| 526 | Version x = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
|
---|
[1039] | 527 |
|
---|
[1050] | 528 | //if version numbers mismatch, don't continue.
|
---|
[1121] | 529 | if (!(x.Major.ToString() == sMajor && x.Minor.ToString() == sMinor))
|
---|
[1050] | 530 | {
|
---|
| 531 | MessageBox.Show(
|
---|
| 532 | "Server runs version " + sMajor + "." + sMinor + "\r\n" +
|
---|
| 533 | "You are running " + x.ToString() + "\r\n\r\n" +
|
---|
| 534 | "Major, Minor and Build versions must match",
|
---|
| 535 | "Version Mismatch");
|
---|
[1121] | 536 | closeSplashDelegate();
|
---|
| 537 | return false;
|
---|
[1050] | 538 | }
|
---|
[1039] | 539 |
|
---|
| 540 |
|
---|
[1050] | 541 | //Change encoding
|
---|
[1051] | 542 | // Call #2
|
---|
| 543 | setProgressDelegate(2);
|
---|
[1050] | 544 | setStatusDelegate("Setting encoding...");
|
---|
| 545 |
|
---|
| 546 | if (m_Encoding == String.Empty)
|
---|
| 547 | {
|
---|
| 548 | string utf8_server_support = m_ConnectInfo.bmxNetLib.TransmitRPC("BMX UTF-8", "");
|
---|
| 549 | if (utf8_server_support == "1")
|
---|
| 550 | m_ConnectInfo.bmxNetLib.Encoder = System.Text.UTF8Encoding.UTF8;
|
---|
| 551 | }
|
---|
[1051] | 552 |
|
---|
| 553 | //Set application context
|
---|
| 554 | // Call #3
|
---|
| 555 | setProgressDelegate(3);
|
---|
[1050] | 556 | setStatusDelegate("Setting Application Context to BSDXRPC...");
|
---|
| 557 | m_ConnectInfo.AppContext = "BSDXRPC";
|
---|
[1117] | 558 |
|
---|
| 559 | //User Preferences Object
|
---|
| 560 | setProgressDelegate(4); //next number is 6 b/c two calls
|
---|
| 561 | setStatusDelegate("Getting User Preferences from the Server...");
|
---|
| 562 |
|
---|
| 563 | _current.UserPreferences = new UserPreferences(); // Does the calling to do that...
|
---|
| 564 |
|
---|
| 565 | //Load global recordsets
|
---|
[1050] | 566 | string statusConst = "Loading VistA data tables...";
|
---|
| 567 | setStatusDelegate(statusConst);
|
---|
[614] | 568 |
|
---|
[1050] | 569 | string sCommandText;
|
---|
[614] | 570 |
|
---|
[1051] | 571 | //Schedule User Info
|
---|
| 572 | // Table #4
|
---|
[1117] | 573 | setProgressDelegate(6);
|
---|
[1050] | 574 | setStatusDelegate(statusConst + " Schedule User");
|
---|
| 575 | DataTable dtUser = _dal.GetUserInfo(m_ConnectInfo.DUZ);
|
---|
| 576 | dtUser.TableName = "SchedulingUser";
|
---|
| 577 | m_dsGlobal.Tables.Add(dtUser);
|
---|
| 578 | Debug.Assert(dtUser.Rows.Count == 1);
|
---|
[614] | 579 |
|
---|
[1050] | 580 | // Only one row and one column named "MANAGER". Set local var m_bSchedManager to true if Manager.
|
---|
| 581 | DataRow rUser = dtUser.Rows[0];
|
---|
| 582 | Object oUser = rUser["MANAGER"];
|
---|
| 583 | string sUser = oUser.ToString();
|
---|
| 584 | m_bSchedManager = (sUser == "YES") ? true : false;
|
---|
[614] | 585 |
|
---|
[1051] | 586 | //Get Access Types
|
---|
| 587 | // Table #5
|
---|
[1117] | 588 | setProgressDelegate(7);
|
---|
[1050] | 589 | setStatusDelegate(statusConst + " Access Types");
|
---|
| 590 | DataTable dtAccessTypes = _dal.GetAccessTypes();
|
---|
| 591 | dtAccessTypes.TableName = "AccessTypes";
|
---|
| 592 | m_dsGlobal.Tables.Add(dtAccessTypes);
|
---|
[614] | 593 |
|
---|
[1051] | 594 | //Get Access Groups
|
---|
| 595 | // Table #6
|
---|
[1117] | 596 | setProgressDelegate(8);
|
---|
[1050] | 597 | setStatusDelegate(statusConst + " Access Groups");
|
---|
| 598 | LoadAccessGroupsTable();
|
---|
[788] | 599 |
|
---|
[1050] | 600 | //Build Primary Key for AccessGroup table
|
---|
| 601 | DataTable dtGroups = m_dsGlobal.Tables["AccessGroup"];
|
---|
| 602 | DataColumn dcKey = dtGroups.Columns["ACCESS_GROUP"];
|
---|
| 603 | DataColumn[] dcKeys = new DataColumn[1];
|
---|
| 604 | dcKeys[0] = dcKey;
|
---|
| 605 | dtGroups.PrimaryKey = dcKeys;
|
---|
| 606 |
|
---|
[1062] | 607 | //Get Access Group Types (Combines Access Types and Groups)
|
---|
| 608 | //Optimization Note: Can eliminate Access type and Access Group Table
|
---|
| 609 | // But they are heavily referenced throughout the code.
|
---|
[1051] | 610 | // Table #7
|
---|
[1117] | 611 | setProgressDelegate(9);
|
---|
[1050] | 612 | setStatusDelegate(statusConst + " Access Group Types");
|
---|
| 613 | LoadAccessGroupTypesTable();
|
---|
| 614 |
|
---|
| 615 | //Build Primary Key for AccessGroupType table
|
---|
| 616 | DataTable dtAGTypes = m_dsGlobal.Tables["AccessGroupType"];
|
---|
| 617 | DataColumn dcGTKey = dtAGTypes.Columns["ACCESS_GROUP_TYPEID"];
|
---|
| 618 | DataColumn[] dcGTKeys = new DataColumn[1];
|
---|
| 619 | dcGTKeys[0] = dcGTKey;
|
---|
| 620 | dtAGTypes.PrimaryKey = dcGTKeys;
|
---|
| 621 |
|
---|
| 622 | //Build Data Relationship between AccessGroupType and AccessTypes tables
|
---|
| 623 | DataRelation dr = new DataRelation("AccessGroupType", //Relation Name
|
---|
| 624 | m_dsGlobal.Tables["AccessGroup"].Columns["BMXIEN"], //Parent
|
---|
| 625 | m_dsGlobal.Tables["AccessGroupType"].Columns["ACCESS_GROUP_ID"]); //Child
|
---|
| 626 | m_dsGlobal.Relations.Add(dr);
|
---|
| 627 |
|
---|
[1051] | 628 | //ResourceGroup Table (Resource Groups by User)
|
---|
| 629 | // Table #8
|
---|
[1062] | 630 | // What shows up on the tree. The groups the user has access to.
|
---|
[1117] | 631 | setProgressDelegate(10);
|
---|
[1050] | 632 | setStatusDelegate(statusConst + " Resource Groups By User");
|
---|
| 633 | LoadResourceGroupTable();
|
---|
| 634 |
|
---|
[1051] | 635 | //Resources by user
|
---|
| 636 | // Table #9
|
---|
[1062] | 637 | // Individual Resources
|
---|
[1117] | 638 | setProgressDelegate(11);
|
---|
[1050] | 639 | setStatusDelegate(statusConst + " Resources By User");
|
---|
| 640 | LoadBSDXResourcesTable();
|
---|
| 641 |
|
---|
| 642 | //Build Primary Key for Resources table
|
---|
| 643 | DataColumn[] dc = new DataColumn[1];
|
---|
| 644 | dc[0] = m_dsGlobal.Tables["Resources"].Columns["RESOURCEID"];
|
---|
| 645 | m_dsGlobal.Tables["Resources"].PrimaryKey = dc;
|
---|
| 646 |
|
---|
[1051] | 647 | //GroupResources table
|
---|
| 648 | // Table #10
|
---|
[1062] | 649 | // Resource Groups and Indivdual Resources together
|
---|
[1117] | 650 | setProgressDelegate(12);
|
---|
[1050] | 651 | setStatusDelegate(statusConst + " Group Resources");
|
---|
| 652 | LoadGroupResourcesTable();
|
---|
| 653 |
|
---|
| 654 | //Build Primary Key for ResourceGroup table
|
---|
| 655 | dc = new DataColumn[1];
|
---|
| 656 | dc[0] = m_dsGlobal.Tables["ResourceGroup"].Columns["RESOURCE_GROUP"];
|
---|
| 657 | m_dsGlobal.Tables["ResourceGroup"].PrimaryKey = dc;
|
---|
| 658 |
|
---|
| 659 | //Build Data Relationships between ResourceGroup and GroupResources tables
|
---|
| 660 | dr = new DataRelation("GroupResource", //Relation Name
|
---|
| 661 | m_dsGlobal.Tables["ResourceGroup"].Columns["RESOURCE_GROUP"], //Parent
|
---|
| 662 | m_dsGlobal.Tables["GroupResources"].Columns["RESOURCE_GROUP"]); //Child
|
---|
[1095] | 663 |
|
---|
[1050] | 664 | m_dsGlobal.Relations.Add(dr);
|
---|
| 665 |
|
---|
[1051] | 666 | //HospitalLocation table
|
---|
| 667 | //Table #11
|
---|
[1117] | 668 | setProgressDelegate(13);
|
---|
[1050] | 669 | setStatusDelegate(statusConst + " Clinics");
|
---|
| 670 | //cmd.CommandText = "SELECT BMXIEN 'HOSPITAL_LOCATION_ID', NAME 'HOSPITAL_LOCATION', DEFAULT_PROVIDER, STOP_CODE_NUMBER, INACTIVATE_DATE, REACTIVATE_DATE FROM HOSPITAL_LOCATION";
|
---|
| 671 | sCommandText = "BSDX HOSPITAL LOCATION";
|
---|
| 672 | ConnectInfo.RPMSDataTable(sCommandText, "HospitalLocation", m_dsGlobal);
|
---|
| 673 | Debug.Write("LoadGlobalRecordsets -- HospitalLocation loaded\n");
|
---|
| 674 |
|
---|
| 675 | //Build Primary Key for HospitalLocation table
|
---|
| 676 | dc = new DataColumn[1];
|
---|
| 677 | DataTable dtTemp = m_dsGlobal.Tables["HospitalLocation"];
|
---|
| 678 | dc[0] = dtTemp.Columns["HOSPITAL_LOCATION_ID"];
|
---|
| 679 | m_dsGlobal.Tables["HospitalLocation"].PrimaryKey = dc;
|
---|
| 680 |
|
---|
| 681 | //Build Data Relationships between Resources and HospitalLocation tables
|
---|
| 682 | dr = new DataRelation("HospitalLocationResource", //Relation Name
|
---|
| 683 | m_dsGlobal.Tables["HospitalLocation"].Columns["HOSPITAL_LOCATION_ID"], //Parent
|
---|
| 684 | m_dsGlobal.Tables["Resources"].Columns["HOSPITAL_LOCATION_ID"], false); //Child
|
---|
| 685 | m_dsGlobal.Relations.Add(dr);
|
---|
| 686 |
|
---|
[1051] | 687 | //Build ScheduleUser table
|
---|
| 688 | //Table #12
|
---|
[1117] | 689 | setProgressDelegate(14);
|
---|
[1050] | 690 | setStatusDelegate(statusConst + " Schedule User");
|
---|
| 691 | this.LoadScheduleUserTable();
|
---|
| 692 |
|
---|
| 693 | //Build Primary Key for ScheduleUser table
|
---|
| 694 | dc = new DataColumn[1];
|
---|
| 695 | dtTemp = m_dsGlobal.Tables["ScheduleUser"];
|
---|
| 696 | dc[0] = dtTemp.Columns["USERID"];
|
---|
| 697 | m_dsGlobal.Tables["ScheduleUser"].PrimaryKey = dc;
|
---|
| 698 |
|
---|
[1051] | 699 | //Build ResourceUser table
|
---|
| 700 | //Table #13
|
---|
[1062] | 701 | //Acess to Resources by [this] User
|
---|
[1117] | 702 | setProgressDelegate(15);
|
---|
[1050] | 703 | setStatusDelegate(statusConst + " Resource User");
|
---|
| 704 | this.LoadResourceUserTable();
|
---|
| 705 |
|
---|
| 706 | //Build Primary Key for ResourceUser table
|
---|
| 707 | dc = new DataColumn[1];
|
---|
| 708 | dtTemp = m_dsGlobal.Tables["ResourceUser"];
|
---|
| 709 | dc[0] = dtTemp.Columns["RESOURCEUSER_ID"];
|
---|
| 710 | m_dsGlobal.Tables["ResourceUser"].PrimaryKey = dc;
|
---|
| 711 |
|
---|
| 712 | //Create relation between BSDX Resource and BSDX Resource User tables
|
---|
| 713 | dr = new DataRelation("ResourceUser", //Relation Name
|
---|
| 714 | m_dsGlobal.Tables["Resources"].Columns["RESOURCEID"], //Parent
|
---|
| 715 | m_dsGlobal.Tables["ResourceUser"].Columns["RESOURCEID"]); //Child
|
---|
| 716 | m_dsGlobal.Relations.Add(dr);
|
---|
| 717 |
|
---|
[1051] | 718 | //Build active provider table
|
---|
| 719 | //Table #14
|
---|
[1062] | 720 | //TODO: Lazy load the provider table; no need to load in advance.
|
---|
[1117] | 721 | setProgressDelegate(16);
|
---|
[1050] | 722 | setStatusDelegate(statusConst + " Providers");
|
---|
| 723 | sCommandText = "SELECT BMXIEN, NAME FROM NEW_PERSON WHERE INACTIVE_DATE = '' AND BMXIEN > 1";
|
---|
| 724 | ConnectInfo.RPMSDataTable(sCommandText, "Provider", m_dsGlobal);
|
---|
| 725 | Debug.Write("LoadGlobalRecordsets -- Provider loaded\n");
|
---|
| 726 |
|
---|
[1062] | 727 | //Build the HOLIDAY table
|
---|
[1051] | 728 | //Table #15
|
---|
[1117] | 729 | setProgressDelegate(17);
|
---|
[1050] | 730 | setStatusDelegate(statusConst + " Holiday");
|
---|
[1104] | 731 | sCommandText = "SELECT NAME, DATE FROM HOLIDAY WHERE INTERNAL[DATE] > '" + FMDateTime.Create(DateTime.Today).DateOnly.FMDateString + "'";
|
---|
[1050] | 732 | ConnectInfo.RPMSDataTable(sCommandText, "HOLIDAY", m_dsGlobal);
|
---|
| 733 | Debug.Write("LoadingGlobalRecordsets -- Holidays loaded\n");
|
---|
| 734 |
|
---|
| 735 |
|
---|
| 736 | //Save the xml schema
|
---|
| 737 | //m_dsGlobal.WriteXmlSchema(@"..\..\csSchema20060526.xsd");
|
---|
| 738 | //----------------------------------------------
|
---|
| 739 |
|
---|
[1051] | 740 | setStatusDelegate("Setting Receive Timeout");
|
---|
[1050] | 741 | _current.m_ConnectInfo.ReceiveTimeout = 30000; //30-second timeout
|
---|
| 742 |
|
---|
[788] | 743 | #if DEBUG
|
---|
[1050] | 744 | _current.m_ConnectInfo.ReceiveTimeout = 600000; //longer timeout for debugging
|
---|
| 745 | #endif
|
---|
[1051] | 746 | // Event Subsriptions
|
---|
| 747 | setStatusDelegate("Subscribing to Server Events");
|
---|
[1062] | 748 | //Table #16
|
---|
[1117] | 749 | setProgressDelegate(18);
|
---|
[1062] | 750 | _current.m_ConnectInfo.SubscribeEvent("BSDX SCHEDULE");
|
---|
| 751 | //Table #17
|
---|
[1117] | 752 | setProgressDelegate(19);
|
---|
[1062] | 753 | _current.m_ConnectInfo.SubscribeEvent("BSDX CALL WORKSTATIONS");
|
---|
[1051] | 754 | //Table #18
|
---|
[1117] | 755 | setProgressDelegate(20);
|
---|
[1062] | 756 | _current.m_ConnectInfo.SubscribeEvent("BSDX ADMIN MESSAGE");
|
---|
[1051] | 757 | //Table #19
|
---|
[1117] | 758 | setProgressDelegate(21);
|
---|
[1051] | 759 | _current.m_ConnectInfo.SubscribeEvent("BSDX ADMIN SHUTDOWN");
|
---|
[614] | 760 |
|
---|
[1050] | 761 | _current.m_ConnectInfo.EventPollingInterval = 5000; //in milliseconds
|
---|
| 762 | _current.m_ConnectInfo.EventPollingEnabled = true;
|
---|
| 763 | _current.m_ConnectInfo.AutoFire = 12; //AutoFire every 12*5 seconds
|
---|
[614] | 764 |
|
---|
[1050] | 765 | //Close Splash Screen
|
---|
| 766 | closeSplashDelegate();
|
---|
[1051] | 767 |
|
---|
| 768 | return true;
|
---|
[1050] | 769 |
|
---|
[614] | 770 | }
|
---|
| 771 |
|
---|
| 772 |
|
---|
[1050] | 773 |
|
---|
[614] | 774 | public void LoadAccessGroupsTable()
|
---|
| 775 | {
|
---|
| 776 | string sCommandText = "SELECT * FROM BSDX_ACCESS_GROUP";
|
---|
| 777 | ConnectInfo.RPMSDataTable(sCommandText, "AccessGroup", m_dsGlobal);
|
---|
| 778 | Debug.Write("LoadGlobalRecordsets -- AccessGroups loaded\n");
|
---|
| 779 | }
|
---|
| 780 |
|
---|
| 781 | public void LoadAccessGroupTypesTable()
|
---|
| 782 | {
|
---|
| 783 | string sCommandText = "BSDX GET ACCESS GROUP TYPES";
|
---|
| 784 | ConnectInfo.RPMSDataTable(sCommandText, "AccessGroupType", m_dsGlobal);
|
---|
| 785 | Debug.Write("LoadGlobalRecordsets -- AccessGroupTypes loaded\n");
|
---|
| 786 | }
|
---|
| 787 |
|
---|
| 788 | public void LoadBSDXResourcesTable()
|
---|
| 789 | {
|
---|
| 790 | string sCommandText = "BSDX RESOURCES^" + m_ConnectInfo.DUZ;
|
---|
| 791 | ConnectInfo.RPMSDataTable(sCommandText, "Resources", m_dsGlobal);
|
---|
| 792 | Debug.Write("LoadGlobalRecordsets -- Resources loaded\n");
|
---|
| 793 | }
|
---|
| 794 |
|
---|
| 795 | public void LoadResourceGroupTable()
|
---|
| 796 | {
|
---|
| 797 | //ResourceGroup Table (Resource Groups by User)
|
---|
| 798 | //Table "ResourceGroup" contains all resource group names
|
---|
| 799 | //to which user has access
|
---|
| 800 | //Fields are: RESOURCE_GROUPID, RESOURCE_GROUP
|
---|
| 801 | string sCommandText = "BSDX RESOURCE GROUPS BY USER^" + m_ConnectInfo.DUZ;
|
---|
| 802 | ConnectInfo.RPMSDataTable(sCommandText, "ResourceGroup", m_dsGlobal);
|
---|
| 803 | Debug.Write("LoadGlobalRecordsets -- ResourceGroup loaded\n");
|
---|
| 804 | }
|
---|
| 805 |
|
---|
| 806 | public void LoadGroupResourcesTable()
|
---|
| 807 | {
|
---|
| 808 | //Table "GroupResources" contains all active GROUP/RESOURCE combinations
|
---|
| 809 | //to which user has access based on entries in BSDX RESOURCE USER file
|
---|
| 810 | //If user has BSDXZMGR or XUPROGMODE keys, then ALL Group/Resource combinstions
|
---|
| 811 | //are returned.
|
---|
| 812 | //Fields are: RESOURCE_GROUPID, RESOURCE_GROUP, RESOURCE_GROUP_ITEMID, RESOURCE_NAME, RESOURCE_ID
|
---|
| 813 | string sCommandText = "BSDX GROUP RESOURCE^" + m_ConnectInfo.DUZ;
|
---|
| 814 | ConnectInfo.RPMSDataTable(sCommandText, "GroupResources", m_dsGlobal);
|
---|
| 815 | Debug.Write("LoadGlobalRecordsets -- GroupResources loaded\n");
|
---|
| 816 | }
|
---|
| 817 |
|
---|
| 818 | public void LoadScheduleUserTable()
|
---|
| 819 | {
|
---|
| 820 | //Table "ScheduleUser" contains an entry for each user in File 200 (NEW PERSON)
|
---|
| 821 | //who possesses the BSDXZMENU security key.
|
---|
| 822 | string sCommandText = "BSDX SCHEDULE USER";
|
---|
| 823 | ConnectInfo.RPMSDataTable(sCommandText, "ScheduleUser", m_dsGlobal);
|
---|
| 824 | Debug.Write("LoadGlobalRecordsets -- ScheduleUser loaded\n");
|
---|
| 825 | }
|
---|
| 826 |
|
---|
| 827 | public void LoadResourceUserTable()
|
---|
| 828 | {
|
---|
| 829 | //Table "ResourceUser" duplicates the BSDX RESOURCE USER File.
|
---|
| 830 | //NOTE: Column names are RESOURCEUSER_ID, RESOURCEID,
|
---|
| 831 | // OVERBOOK, MODIFY_SCHEDULE, USERID, USERID1
|
---|
| 832 | //string sCommandText = "SELECT BMXIEN RESOURCEUSER_ID, INTERNAL[RESOURCENAME] RESOURCEID, OVERBOOK, MODIFY_SCHEDULE, USERNAME USERID, INTERNAL[USERNAME] FROM BSDX_RESOURCE_USER";
|
---|
| 833 | LoadResourceUserTable(false);
|
---|
| 834 | }
|
---|
| 835 |
|
---|
| 836 | public void LoadResourceUserTable(bool bAllUsers)
|
---|
| 837 | {
|
---|
[1050] | 838 | 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;
|
---|
| 839 |
|
---|
| 840 | if (!bAllUsers)
|
---|
| 841 | {
|
---|
| 842 | sCommandText += String.Format(" WHERE INTERNAL[USERNAME] = {0}", m_ConnectInfo.DUZ);
|
---|
| 843 | }
|
---|
| 844 |
|
---|
[614] | 845 | ConnectInfo.RPMSDataTable(sCommandText, "ResourceUser", m_dsGlobal);
|
---|
| 846 | Debug.Write("LoadGlobalRecordsets -- ResourceUser loaded\n");
|
---|
| 847 | }
|
---|
| 848 |
|
---|
| 849 |
|
---|
| 850 | public void RegisterDocumentView(CGDocument doc, CGView view)
|
---|
| 851 | {
|
---|
| 852 | //Store the view in the list of views
|
---|
| 853 | this.Views.Add(view, doc);
|
---|
| 854 |
|
---|
| 855 | //Hook into the view's 'closed' event
|
---|
| 856 | view.Closed += new EventHandler(ViewClosed);
|
---|
| 857 |
|
---|
| 858 | //Hook into the view's mnuRPMSServer.Click event
|
---|
| 859 | view.mnuRPMSServer.Click += new EventHandler(mnuRPMSServer_Click);
|
---|
| 860 |
|
---|
| 861 | //Hook into the view's mnuRPMSLogin.Click event
|
---|
| 862 | view.mnuRPMSLogin.Click += new EventHandler(mnuRPMSLogin_Click);
|
---|
| 863 |
|
---|
| 864 | }
|
---|
| 865 |
|
---|
| 866 | public void RegisterAVDocumentView(CGAVDocument doc, CGAVView view)
|
---|
| 867 | {
|
---|
| 868 | //Store the view in the list of views
|
---|
| 869 | this.AvailabilityViews.Add(view, doc);
|
---|
| 870 |
|
---|
| 871 | //Hook into the view's 'closed' event
|
---|
| 872 | view.Closed += new EventHandler(AVViewClosed);
|
---|
| 873 | }
|
---|
| 874 |
|
---|
| 875 | public CGAVView GetAVViewByResource(ArrayList sResourceArray)
|
---|
| 876 | {
|
---|
| 877 | if (sResourceArray == null)
|
---|
| 878 | return null;
|
---|
| 879 |
|
---|
| 880 | bool bEqual = true;
|
---|
| 881 | foreach (CGAVView v in m_AVViews.Keys)
|
---|
| 882 | {
|
---|
| 883 | CGAVDocument d = v.Document;
|
---|
| 884 |
|
---|
| 885 | bEqual = false;
|
---|
| 886 | if (d.Resources.Count == sResourceArray.Count)
|
---|
| 887 | {
|
---|
| 888 | bEqual = true;
|
---|
| 889 | for (int j = 0; j < sResourceArray.Count; j++)
|
---|
| 890 | {
|
---|
| 891 | if (sResourceArray.Contains(d.Resources[j]) == false)
|
---|
| 892 | {
|
---|
| 893 | bEqual = false;
|
---|
| 894 | break;
|
---|
| 895 | }
|
---|
| 896 | if (d.Resources.Contains(sResourceArray[j]) == false)
|
---|
| 897 | {
|
---|
| 898 | bEqual = false;
|
---|
| 899 | break;
|
---|
| 900 | }
|
---|
| 901 | }
|
---|
| 902 | if (bEqual == true)
|
---|
| 903 | return v;
|
---|
| 904 | }
|
---|
| 905 | }
|
---|
| 906 | return null;
|
---|
| 907 | }
|
---|
| 908 | /// <summary>
|
---|
| 909 | /// Return the first view having a resource array matching sResourceArray
|
---|
| 910 | /// </summary>
|
---|
| 911 | /// <param name="sResourceArray"></param>
|
---|
| 912 | /// <returns></returns>
|
---|
| 913 | public CGView GetViewByResource(ArrayList sResourceArray)
|
---|
| 914 | {
|
---|
| 915 | if (sResourceArray == null)
|
---|
| 916 | return null;
|
---|
| 917 |
|
---|
| 918 | bool bEqual = true;
|
---|
| 919 | foreach (CGView v in _views.Keys)
|
---|
| 920 | {
|
---|
| 921 | CGDocument d = v.Document;
|
---|
| 922 |
|
---|
| 923 | bEqual = false;
|
---|
| 924 | if (d.Resources.Count == sResourceArray.Count)
|
---|
| 925 | {
|
---|
| 926 | bEqual = true;
|
---|
| 927 | for (int j = 0; j < sResourceArray.Count; j++)
|
---|
| 928 | {
|
---|
| 929 | if (sResourceArray.Contains(d.Resources[j]) == false)
|
---|
| 930 | {
|
---|
| 931 | bEqual = false;
|
---|
| 932 | break;
|
---|
| 933 | }
|
---|
| 934 | if (d.Resources.Contains(sResourceArray[j]) == false)
|
---|
| 935 | {
|
---|
| 936 | bEqual = false;
|
---|
| 937 | break;
|
---|
| 938 | }
|
---|
| 939 | }
|
---|
| 940 | if (bEqual == true)
|
---|
| 941 | return v;
|
---|
| 942 | }
|
---|
| 943 | }
|
---|
| 944 | return null;
|
---|
| 945 | }
|
---|
| 946 |
|
---|
[1050] | 947 | /// <summary>
|
---|
| 948 | /// Removes view and Handles Disconnection from Database if no views are left.
|
---|
| 949 | /// </summary>
|
---|
| 950 | /// <param name="sender"></param>
|
---|
| 951 | /// <param name="e"></param>
|
---|
[614] | 952 | private void ViewClosed(object sender, EventArgs e)
|
---|
| 953 | {
|
---|
| 954 | //Remove the sender from our document list
|
---|
| 955 | Views.Remove(sender);
|
---|
| 956 |
|
---|
| 957 | //If no documents left, then close RPMS connection & exit the application
|
---|
| 958 | if ((Views.Count == 0)&&(this.AvailabilityViews.Count == 0)&&(m_bExitOK == true))
|
---|
| 959 | {
|
---|
| 960 | m_ConnectInfo.EventPollingEnabled = false;
|
---|
| 961 | m_ConnectInfo.UnSubscribeEvent("BSDX SCHEDULE");
|
---|
| 962 | m_ConnectInfo.CloseConnection();
|
---|
| 963 | Application.Exit();
|
---|
| 964 | }
|
---|
| 965 | }
|
---|
| 966 |
|
---|
| 967 | private void AVViewClosed(object sender, EventArgs e)
|
---|
| 968 | {
|
---|
| 969 | //Remove the sender from our document list
|
---|
| 970 | this.AvailabilityViews.Remove(sender);
|
---|
| 971 |
|
---|
| 972 | //If no documents left, then close RPMS connection & exit the application
|
---|
| 973 | if ((Views.Count == 0)&&(this.AvailabilityViews.Count == 0)&&(m_bExitOK == true))
|
---|
| 974 | {
|
---|
| 975 | m_ConnectInfo.bmxNetLib.CloseConnection();
|
---|
| 976 | Application.Exit();
|
---|
| 977 | }
|
---|
| 978 | }
|
---|
| 979 |
|
---|
[1098] | 980 | /// <summary>
|
---|
| 981 | /// Not used
|
---|
| 982 | /// </summary>
|
---|
[614] | 983 | private void KeepAlive()
|
---|
| 984 | {
|
---|
| 985 | foreach (CGView v in _views.Keys)
|
---|
| 986 | {
|
---|
| 987 | CGDocument d = v.Document;
|
---|
| 988 | DateTime dNow = DateTime.Now;
|
---|
| 989 | DateTime dLast = d.LastRefreshed;
|
---|
| 990 | TimeSpan tsDiff = dNow - dLast;
|
---|
| 991 | if (tsDiff.Seconds > 180)
|
---|
| 992 | {
|
---|
| 993 | for (int j = 0; j < d.Resources.Count; j++)
|
---|
| 994 | {
|
---|
| 995 | v.RaiseRPMSEvent("SCHEDULE-" + d.Resources[j].ToString(), "");
|
---|
| 996 | }
|
---|
| 997 |
|
---|
| 998 | break;
|
---|
| 999 | }
|
---|
| 1000 | }
|
---|
| 1001 | }
|
---|
| 1002 |
|
---|
| 1003 | /// <summary>
|
---|
| 1004 | /// Propogate availability updates to all sRresource's doc/views
|
---|
| 1005 | /// </summary>
|
---|
| 1006 | public void UpdateViews(string sResource, string sOldResource)
|
---|
| 1007 | {
|
---|
| 1008 | if (sResource == null)
|
---|
| 1009 | return;
|
---|
| 1010 | foreach (CGView v in _views.Keys)
|
---|
| 1011 | {
|
---|
| 1012 | CGDocument d = v.Document;
|
---|
| 1013 | for (int j = 0; j < d.Resources.Count; j++)
|
---|
| 1014 | {
|
---|
| 1015 | if ((sResource == "") || (sResource == ((string) d.Resources[j])) || (sOldResource == ((string) d.Resources[j])))
|
---|
| 1016 | {
|
---|
| 1017 | d.RefreshDocument();
|
---|
| 1018 | break;
|
---|
| 1019 | }
|
---|
| 1020 | }
|
---|
| 1021 | v.UpdateTree();
|
---|
| 1022 | }
|
---|
| 1023 | }
|
---|
| 1024 |
|
---|
| 1025 | /// <summary>
|
---|
| 1026 | /// Propogate availability updates to all doc/views
|
---|
| 1027 | /// </summary>
|
---|
| 1028 | public void UpdateViews()
|
---|
| 1029 | {
|
---|
| 1030 | UpdateViews("","");
|
---|
| 1031 | foreach (CGView v in _views.Keys)
|
---|
| 1032 | {
|
---|
| 1033 | v.UpdateTree();
|
---|
| 1034 | }
|
---|
| 1035 | }
|
---|
| 1036 |
|
---|
| 1037 | /// <summary>
|
---|
| 1038 | /// Calls each view associated with document Doc and closes it.
|
---|
| 1039 | /// </summary>
|
---|
| 1040 | public void CloseAllViews(CGDocument doc)
|
---|
| 1041 | {
|
---|
| 1042 | //iterate through all views and call update.
|
---|
| 1043 | Hashtable h = CGDocumentManager.Current.Views;
|
---|
| 1044 |
|
---|
| 1045 | CGDocument d;
|
---|
| 1046 | int nTempCount = h.Count;
|
---|
| 1047 | do
|
---|
| 1048 | {
|
---|
| 1049 | nTempCount = h.Count;
|
---|
| 1050 | foreach (CGView v in h.Keys)
|
---|
| 1051 | {
|
---|
| 1052 | d = (CGDocument) h[v];
|
---|
| 1053 | if (d == doc)
|
---|
| 1054 | {
|
---|
| 1055 | v.Close();
|
---|
| 1056 | break;
|
---|
| 1057 | }
|
---|
| 1058 | }
|
---|
| 1059 | } while ((h.Count > 0) && (nTempCount != h.Count));
|
---|
| 1060 | }
|
---|
| 1061 |
|
---|
| 1062 | /// <summary>
|
---|
| 1063 | /// Calls each view associated with Availability Doc and closes it.
|
---|
| 1064 | /// </summary>
|
---|
| 1065 | public void CloseAllViews(CGAVDocument doc)
|
---|
| 1066 | {
|
---|
| 1067 | //iterate through all views and call update.
|
---|
| 1068 | Hashtable h = CGDocumentManager.Current.AvailabilityViews;
|
---|
| 1069 |
|
---|
| 1070 | CGAVDocument d;
|
---|
| 1071 | int nTempCount = h.Count;
|
---|
| 1072 | do
|
---|
| 1073 | {
|
---|
| 1074 | nTempCount = h.Count;
|
---|
| 1075 | foreach (CGAVView v in h.Keys)
|
---|
| 1076 | {
|
---|
| 1077 | d = (CGAVDocument) h[v];
|
---|
| 1078 | if (d == doc)
|
---|
| 1079 | {
|
---|
| 1080 | v.Close();
|
---|
| 1081 | break;
|
---|
| 1082 | }
|
---|
| 1083 | }
|
---|
| 1084 | } while ((h.Count > 0) && (nTempCount != h.Count));
|
---|
| 1085 |
|
---|
| 1086 |
|
---|
| 1087 | }
|
---|
| 1088 |
|
---|
[1071] | 1089 | /// <summary>
|
---|
| 1090 | /// Accomplishes Changing the Server to which you connect
|
---|
| 1091 | /// </summary>
|
---|
| 1092 | /// <remarks>
|
---|
| 1093 | /// Parameter relog-in for InitializeApp forces initialize app to use
|
---|
| 1094 | /// 1. The server the user just picked and then BMX saved off to User Preferences
|
---|
| 1095 | /// 2. A new access and verify code pair
|
---|
| 1096 | /// </remarks>
|
---|
| 1097 | /// <param name="sender">unused</param>
|
---|
| 1098 | /// <param name="e">unused</param>
|
---|
[614] | 1099 | private void mnuRPMSServer_Click(object sender, EventArgs e)
|
---|
| 1100 | {
|
---|
| 1101 | //Warn that changing servers will close all schedules
|
---|
[627] | 1102 | if (MessageBox.Show("Are you sure you want to close all schedules and connect to a different VistA server?", "Clinical Scheduling", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) != DialogResult.OK)
|
---|
[614] | 1103 | return;
|
---|
| 1104 |
|
---|
| 1105 | //Reconnect to RPMS and recreate all global recordsets
|
---|
| 1106 | try
|
---|
| 1107 | {
|
---|
[1071] | 1108 | // Close All, but tell the Close All method not to call Applicaiton.Exit since we still plan to continue.
|
---|
| 1109 | // Close All does not call Application.Exit, but CGView_Close handler does
|
---|
[614] | 1110 | m_bExitOK = false;
|
---|
[1071] | 1111 | CloseAll();
|
---|
| 1112 | m_bExitOK = true;
|
---|
| 1113 |
|
---|
| 1114 | //Used in Do loop
|
---|
| 1115 | bool bRetry = true;
|
---|
| 1116 |
|
---|
| 1117 | // Do Loop to deal with changing the server and the vagaries of user choices.
|
---|
[614] | 1118 | do
|
---|
| 1119 | {
|
---|
| 1120 | try
|
---|
| 1121 | {
|
---|
[1071] | 1122 | //ChangeServerInfo does not re-login the user
|
---|
| 1123 | //It only changes the saved server information in the %APPDATA% folder
|
---|
| 1124 | //so it can be re-used when BMX tries to log in again.
|
---|
| 1125 | //Access and Verify code are prompted for in InitializeApp
|
---|
| 1126 | m_ConnectInfo.ChangeServerInfo();
|
---|
[614] | 1127 | bRetry = false;
|
---|
| 1128 | }
|
---|
| 1129 | catch (Exception ex)
|
---|
| 1130 | {
|
---|
| 1131 | if (ex.Message == "User cancelled.")
|
---|
| 1132 | {
|
---|
| 1133 | bRetry = false;
|
---|
[1071] | 1134 | Application.Exit();
|
---|
[614] | 1135 | return;
|
---|
| 1136 | }
|
---|
[627] | 1137 | if (MessageBox.Show("Unable to connect to VistA. " + ex.Message , "Clinical Scheduling", MessageBoxButtons.RetryCancel) == DialogResult.Retry)
|
---|
[614] | 1138 | {
|
---|
| 1139 | bRetry = true;
|
---|
| 1140 | }
|
---|
| 1141 | else
|
---|
| 1142 | {
|
---|
| 1143 | bRetry = false;
|
---|
[1071] | 1144 | Application.Exit();
|
---|
[614] | 1145 | return;
|
---|
| 1146 | }
|
---|
| 1147 | }
|
---|
| 1148 | } while (bRetry == true);
|
---|
| 1149 |
|
---|
[1071] | 1150 | //Parameter for initialize app tells it that this is a re-login and forces a new access and verify code.
|
---|
| 1151 | bool isEverythingOkay = this.InitializeApp(true);
|
---|
[614] | 1152 |
|
---|
[1071] | 1153 | //if an error occurred, break out. This time we need to call Application.Exit since it's already running.
|
---|
| 1154 | if (!isEverythingOkay)
|
---|
| 1155 | {
|
---|
| 1156 | Application.Exit();
|
---|
| 1157 | return;
|
---|
| 1158 | }
|
---|
[614] | 1159 |
|
---|
[1071] | 1160 | //Otherwise, everything is okay. So open document and view, then show and activate view.
|
---|
| 1161 | CGDocument doc = new CGDocument();
|
---|
| 1162 | doc.DocManager = _current;
|
---|
[614] | 1163 |
|
---|
[1071] | 1164 | CGView view = new CGView();
|
---|
[1073] | 1165 | view.InitializeDocView(doc, _current, doc.StartDate, _current.WindowText);
|
---|
[1071] | 1166 |
|
---|
| 1167 | view.Show();
|
---|
| 1168 | view.Activate();
|
---|
| 1169 |
|
---|
| 1170 | //Application.Run need not be called b/c it is already running.
|
---|
[614] | 1171 | }
|
---|
| 1172 | catch (Exception ex)
|
---|
| 1173 | {
|
---|
| 1174 | throw ex;
|
---|
| 1175 | }
|
---|
| 1176 |
|
---|
| 1177 | }
|
---|
| 1178 |
|
---|
[1071] | 1179 | /// <summary>
|
---|
| 1180 | /// Accomplishes Re-login into RPMS/VISTA. Now all logic is in this event handler.
|
---|
| 1181 | /// </summary>
|
---|
| 1182 | /// <param name="sender">not used</param>
|
---|
| 1183 | /// <param name="e">not used</param>
|
---|
[614] | 1184 | private void mnuRPMSLogin_Click(object sender, EventArgs e)
|
---|
| 1185 | {
|
---|
| 1186 | //Warn that changing login will close all schedules
|
---|
[627] | 1187 | if (MessageBox.Show("Are you sure you want to close all schedules and login to VistA?", "Clinical Scheduling", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) != DialogResult.OK)
|
---|
[614] | 1188 | return;
|
---|
| 1189 |
|
---|
| 1190 | //Reconnect to RPMS and recreate all global recordsets
|
---|
| 1191 | try
|
---|
| 1192 | {
|
---|
[1071] | 1193 | // Close All, but tell the Close All method not to call Applicaiton.Exit since we still plan to continue.
|
---|
| 1194 | // Close All does not call Application.Exit, but CGView_Close handler does
|
---|
[614] | 1195 | m_bExitOK = false;
|
---|
| 1196 | CloseAll();
|
---|
| 1197 | m_bExitOK = true;
|
---|
[1071] | 1198 |
|
---|
| 1199 | //Parameter for initialize app tells it that this is a re-login and forces a new access and verify code.
|
---|
| 1200 | bool isEverythingOkay = this.InitializeApp(true);
|
---|
| 1201 |
|
---|
| 1202 | //if an error occurred, break out. This time we need to call Application.Exit since it's already running.
|
---|
| 1203 | if (!isEverythingOkay)
|
---|
| 1204 | {
|
---|
| 1205 | Application.Exit();
|
---|
| 1206 | return;
|
---|
| 1207 | }
|
---|
| 1208 |
|
---|
| 1209 | //Otherwise, everything is okay. So open document and view, then show and activate view.
|
---|
| 1210 | CGDocument doc = new CGDocument();
|
---|
| 1211 | doc.DocManager = _current;
|
---|
| 1212 |
|
---|
| 1213 | CGView view = new CGView();
|
---|
[1073] | 1214 | view.InitializeDocView(doc, _current, doc.StartDate, _current.WindowText);
|
---|
[1071] | 1215 |
|
---|
| 1216 | view.Show();
|
---|
| 1217 | view.Activate();
|
---|
| 1218 |
|
---|
| 1219 | //Application.Run need not be called b/c it is already running.
|
---|
[614] | 1220 | }
|
---|
| 1221 | catch (Exception ex)
|
---|
| 1222 | {
|
---|
| 1223 | throw ex;
|
---|
| 1224 | }
|
---|
| 1225 |
|
---|
| 1226 | }
|
---|
| 1227 |
|
---|
| 1228 | delegate void CloseAllDelegate(string sMsg);
|
---|
| 1229 |
|
---|
| 1230 | private void CloseAll(string sMsg)
|
---|
| 1231 | {
|
---|
| 1232 | if (sMsg == "")
|
---|
| 1233 | {
|
---|
| 1234 | sMsg = "Scheduling System Shutting Down Immediately for Maintenance.";
|
---|
| 1235 | }
|
---|
| 1236 |
|
---|
[620] | 1237 | MessageBox.Show(sMsg, "Clinical Scheduling Administrator -- System Shutdown Notification", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
---|
[614] | 1238 |
|
---|
| 1239 | CloseAll();
|
---|
| 1240 | }
|
---|
| 1241 |
|
---|
| 1242 | private void CloseAll()
|
---|
| 1243 | {
|
---|
| 1244 | //Close all documents, views and connections
|
---|
| 1245 | Hashtable h = CGDocumentManager.Current.Views;
|
---|
| 1246 | int nTempCount = h.Count;
|
---|
| 1247 | do
|
---|
| 1248 | {
|
---|
| 1249 | nTempCount = h.Count;
|
---|
| 1250 | foreach (CGView v in h.Keys)
|
---|
| 1251 | {
|
---|
| 1252 | v.Close();
|
---|
| 1253 | break;
|
---|
| 1254 | }
|
---|
| 1255 | } while ((h.Count > 0) && (nTempCount != h.Count));
|
---|
| 1256 |
|
---|
| 1257 | h = CGDocumentManager.Current.AvailabilityViews;
|
---|
| 1258 | nTempCount = h.Count;
|
---|
| 1259 | do
|
---|
| 1260 | {
|
---|
| 1261 | nTempCount = h.Count;
|
---|
| 1262 | foreach (CGAVView v in h.Keys)
|
---|
| 1263 | {
|
---|
| 1264 | v.Close();
|
---|
| 1265 | break;
|
---|
| 1266 | }
|
---|
| 1267 | } while ((h.Count > 0) && (nTempCount != h.Count));
|
---|
| 1268 |
|
---|
| 1269 | }
|
---|
| 1270 |
|
---|
[1011] | 1271 | public delegate DataTable RPMSDataTableDelegate(string CommandString, string TableName);
|
---|
[614] | 1272 |
|
---|
| 1273 | public DataTable RPMSDataTable(string sSQL, string sTableName)
|
---|
| 1274 | {
|
---|
| 1275 | //Retrieves a recordset from RPMS
|
---|
| 1276 | string sErrorMessage = "";
|
---|
[843] | 1277 | DataTable dtOut;
|
---|
| 1278 |
|
---|
[614] | 1279 | try
|
---|
| 1280 | {
|
---|
[1011] | 1281 | //System.IntPtr pHandle = this.Handle;
|
---|
[614] | 1282 | RPMSDataTableDelegate rdtd = new RPMSDataTableDelegate(ConnectInfo.RPMSDataTable);
|
---|
[1050] | 1283 | //dtOut = (DataTable) this.Invoke(rdtd, new object[] {sSQL, sTableName});
|
---|
| 1284 | dtOut = rdtd.Invoke(sSQL, sTableName);
|
---|
[614] | 1285 | }
|
---|
[843] | 1286 |
|
---|
[614] | 1287 | catch (Exception ex)
|
---|
| 1288 | {
|
---|
| 1289 | sErrorMessage = "CGDocumentManager.RPMSDataTable error: " + ex.Message;
|
---|
| 1290 | throw ex;
|
---|
| 1291 | }
|
---|
[843] | 1292 |
|
---|
| 1293 | return dtOut;
|
---|
| 1294 |
|
---|
[614] | 1295 | }
|
---|
| 1296 |
|
---|
| 1297 | public void ChangeDivision(System.Windows.Forms.Form frmCaller)
|
---|
| 1298 | {
|
---|
| 1299 | this.ConnectInfo.ChangeDivision(frmCaller);
|
---|
| 1300 | foreach (CGView v in _views.Keys)
|
---|
| 1301 | {
|
---|
| 1302 | v.InitializeDocView(v.Document.DocName);
|
---|
| 1303 | v.Document.RefreshDocument();
|
---|
| 1304 | }
|
---|
| 1305 | }
|
---|
| 1306 |
|
---|
| 1307 | public void ViewRefresh()
|
---|
| 1308 | {
|
---|
| 1309 | foreach (CGView v in _views.Keys)
|
---|
| 1310 | {
|
---|
| 1311 | try
|
---|
| 1312 | {
|
---|
| 1313 | v.Document.RefreshDocument();
|
---|
| 1314 | }
|
---|
| 1315 | catch (Exception ex)
|
---|
| 1316 | {
|
---|
| 1317 | Debug.Write("CGDocumentManager.ViewRefresh Exception: " + ex.Message + "\n");
|
---|
| 1318 | }
|
---|
| 1319 | finally
|
---|
| 1320 | {
|
---|
| 1321 | }
|
---|
| 1322 | }
|
---|
| 1323 | Debug.Write("DocManager refreshed all views.\n");
|
---|
| 1324 | }
|
---|
| 1325 |
|
---|
| 1326 | #endregion Methods & Events
|
---|
| 1327 |
|
---|
| 1328 | }
|
---|
| 1329 | }
|
---|