/// <summary> /// unloads all memory /// </summary> protected override void OnUnload() { stateMachine.FreeResources(); singleton = null; instance = null; }
static void Main(string[] args) { try { // Reset starting search directory GameCore.Utility.FileSearch.SetStartingSearchDirectory(""); using (Bingo app = new Bingo(args)) { Application.DoEvents(); if (app._Load() == false) { MessageBox.Show("ERROR LOADING GAME\n\rAPPLICATION NOW CLOSING!!!\n\rCONTACT TECH", "ERROR"); return; } Bingo.singleton.logError(app.appTitle + " Loaded & Beginning to Run"); Application.Run(app); app.Close(); } } catch (Exception ex) { Bingo.singleton.logError("\n\r=====================\n\rUnhandled Error\n\r" + ex.ToString()); MessageBox.Show("An error occured and this application needs to close: " + ex.ToString()); } GC.Collect(); GC.WaitForPendingFinalizers(); }
//public void parseGameSettingsData() //{ // // Commented temporarly by EG // try // { // if (gameSettings.data != "") // { // // parse the nData into variables // string[] parts = gameSettings.data.Split(','); // if (parts.Length != 17) // { // throw new Exception("Invalid number of parameters in settings.data string(" // + parts.Length.ToString() + ", should be 17)"); // } // maxCardDisplayMode = int.Parse(parts[0]); // bPPatternIndex = int.Parse(parts[1]); // bPPatternCount = int.Parse(parts[2]); // bPPercent = double.Parse(parts[3]); // bPSeed = decimal.Parse(parts[4]); // levelInfo[0].POSetNum = int.Parse(parts[5]); // levelInfo[1].POSetNum = int.Parse(parts[6]); // levelInfo[2].POSetNum = int.Parse(parts[7]); // levelInfo[3].POSetNum = int.Parse(parts[8]); // levelInfo[0].costMulti = int.Parse(parts[9]); // levelInfo[1].costMulti = int.Parse(parts[10]); // levelInfo[2].costMulti = int.Parse(parts[11]); // levelInfo[3].costMulti = int.Parse(parts[12]); // levelInfo[0].prizeMulti = int.Parse(parts[13]); // levelInfo[1].prizeMulti = int.Parse(parts[14]); // levelInfo[2].prizeMulti = int.Parse(parts[15]); // levelInfo[3].prizeMulti = int.Parse(parts[16]); // } // else // { // string tmpErr = "This Game has not been configured by the POS, can not continue!"; // logError(tmpErr); // MessageBox.Show(tmpErr); // Application.Exit(); // } // } // catch (Exception ex) // { // string tmpErr = "Invalid Data String in GameSettings, " + ex.Message; // logError(tmpErr); // MessageBox.Show(tmpErr); // Application.Exit(); // } //} /// <summary> /// constructor /// </summary> /// <param name="standAlone">run in standalone mode.. no db connection required</param> public Bingo(string[] args) { singleton = this; // hide the cursor //Cursor.Hide(); // new generic gameSettings data this.FormClosing += new FormClosingEventHandler(Bingo_FormClosing); Screen Srn = Screen.PrimaryScreen; tempWidth = Srn.Bounds.Width; tempHeight = Srn.Bounds.Height; StartScreen stScr = new StartScreen(); System.Console.WriteLine("OSVersion: {0}", Environment.OSVersion.ToString()); isXP = (Environment.OSVersion.Version.Major == 5 && Environment.OSVersion.Version.Minor <= 1); if (isXP) { FixWidth = 1366; } stScr.Show(); if (!(args.Length > 3 && args[3] == "NR")) { //try to change resolution... bool success = false; int i = 0; do { if (i >= resArray.Length) { MessageBox.Show("None of resolutions worked for this hardware..."); Application.Exit(); return; } Resolution.CResolution ChangeRes = new Resolution.CResolution(resArray[i].X, resArray[i].Y, ref success); i++; }while (!success); } moneySymbol = String.Format("{0:C}", 1.00f); moneySymbol = moneySymbol.Substring(0, moneySymbol.IndexOf("1")); terminalID = GameCore.Utility.Functions.GetMachineID(); string tmpStartupPath = Application.StartupPath; FileSearch.SetStartingSearchDirectory(tmpStartupPath + "\\Media\\"); string tmpErr = ""; //PARSE COMMAND LINE ARGS int commandLinePIN = 0; string webServiceAddress = ""; if (args.Length >= 3) { if (args[1].Contains("http")) { webServiceAddress = args[1].ToString(); } else { tmpErr = "Invalid command line WEB Service Address: " + args[1].Trim() + ", terminating Program!"; Logger.Log(tmpErr); Bingo.singleton.CloseApplication(tmpErr); return; } // get the installed Game ID from the command line try { commandLinePIN = int.Parse(args[0].Trim()); } catch { tmpErr = "Invalid command line PIN: " + args[0].Trim() + ", terminating Program!"; Logger.Log(tmpErr); commandLinePIN = 0; Bingo.singleton.CloseApplication(tmpErr); return; } } else { tmpErr = "Invalid command line Params, terminating Program!"; Logger.Log(tmpErr); Bingo.singleton.CloseApplication(tmpErr); return; } //=============================== global::BreakTheBankTabs1063.Properties.Settings.Default.MagicTouchTabs1034_WEBService_Service = webServiceAddress; // ******* CONNECT TO THE DATABASE... *********************** // CONNECT TO DATABASE SERVICE if (service == null) { int tries = 0; while (tries < 5) { service = new WEBService.Service(); if (service != null) { service.Timeout = 10000; break; } Logger.Log("Attempt to connect to WEB Service #" + tries.ToString() + " failed!"); tries++; } if (service == null) { Logger.Log("ALL Attempts to connect to WEB Service failed, Closing Application!"); Bingo.singleton.CloseApplication("Error Connecting to WEB Service"); } } try { // sync with server date and time setLocalTime.SYSTEMTIME tmpTime = new setLocalTime.SYSTEMTIME(); tmpTime.FromDateTime(service.getServerDateTime()); setLocalTime.SetLocalTime(ref tmpTime); } catch (Exception ex) { tmpErr = "Exception connecting to WEB Service calling 'service.getServerDateTime()' " + "Possibly Launcher passed incorrect WEB Service Address, CANNOT CONTINUE!\n\r" + ex.Message; Logger.Log(tmpErr); Bingo.singleton.CloseApplication(tmpErr); return; } // get the EGM status curEGMData = service.getMachineStatus(terminalID.ToString()); // get serial number from command line serialNum = args[2]; curEGMData.serialNum = serialNum; if (curEGMData.terminalID == "0") { // could not get just created EGMTerminals record tmpErr = service.lastError(); if (tmpErr == "") { tmpErr = "Could not get EGMTerminals record for this Unit (TerminalID = " + terminalID.ToString() + "), terminating Program!"; } logError(tmpErr); Bingo.singleton.CloseApplication(tmpErr); return; } // now get the system settings settings = service.getSettings(); gameSettings = service.getGameSettings(gameSystemID); //parseGameSettingsData(); // now get command line PIN data if (commandLinePIN == settings.demoPIN) { usingDemoPIN = true; curPIN.PIN = settings.demoPIN; curPIN.balance = settings.demoAmt; curPIN.playing = true; curPIN.playingAt = curEGMData.terminalID; curPIN.transactionID = 0; curPIN.netSeconds = (int)Math.Round((settings.demoAmt * 100) / settings.penniesPerMinute); curPIN.winBalance = 0M; } else { curPIN = service.getPINData(commandLinePIN); ////////////////////////////////////////////////////////////////////// // curPIN.netSeconds = 0; // curPIN.winBalance = 0M; //////////////////////////////////////////////////////////////////// if (curPIN.PIN == 0) { // command line PIN not found tmpErr = service.lastError(); if (tmpErr == "") { tmpErr = "Could not get PINs record for PIN " + commandLinePIN.ToString() + ", can not continue!"; } logError(tmpErr); Bingo.singleton.CloseApplication(tmpErr); return; } } guiManager = new GuiManager(); // frmWinVerification = new WinVerification(); // Logger.Log("Finished 'Bingo(string[] args)'"); }