private static bool IsDBAlive() { Event clsEvent = new Event(); try { clsEvent.AddEvent("Checking connections to server."); if (IPAddress.IsOpen(AceSoft.RetailPlus.DBConnection.ServerIP(), DBConnection.DBPort()) == false) { clsEvent.AddEvent("Cannot connect to server please check."); return(false); } clsEvent.AddEvent("Checking connections to database."); Data.Database clsDatabase = new Data.Database(); bool boIsDBAlive = clsDatabase.IsAlive(); clsEvent.AddEventLn("Done! Connected to " + clsDatabase.Connection.ConnectionString, false); clsEvent.AddEventLn("Updating version to " + Application.ProductVersion, true); Data.Terminal clsTerminal = new Data.Terminal(clsDatabase.Connection, clsDatabase.Transaction); clsTerminal.UpdateFEVersion(Constants.TerminalBranchID, CompanyDetails.TerminalNo, Application.ProductVersion); clsDatabase.CommitAndDispose(); return(boIsDBAlive); } catch (Exception ex) { clsEvent.AddErrorEventLn(ex); return(false); } }
private static bool IsDateLastInitializationOK() { Event clsEvent = new Event(); try { clsEvent.AddEvent("Checking last initialization date"); Data.Database clsDatabase = new Data.Database(); DateTime dtDateLastInitialized = clsDatabase.DateLastInitialized(Constants.TerminalBranchID, CompanyDetails.TerminalNo); clsDatabase.CommitAndDispose(); bool boReturn = false; if (DateTime.Now > dtDateLastInitialized) { boReturn = true; clsEvent.AddEventLn("OK: Last initialization is smaller than system date. DateLastInitialized=" + dtDateLastInitialized.ToString("yyyy-MM-dd hh:mm") + " SystemDate=" + DateTime.Now.ToString("yyyy-MM-dd hh:mm")); } else { clsEvent.AddEventLn("Error: Last initialization is greater than system date. DateLastInitialized=" + dtDateLastInitialized.ToString("yyyy-MM-dd hh:mm") + " SystemDate=" + DateTime.Now.ToString("yyyy-MM-dd hh:mm")); } return(boReturn); } catch (Exception ex) { clsEvent.AddErrorEventLn(ex); return(false); } }
private static bool IsDemoExpired() { Event clsEvent = new Event(); try { clsEvent.AddEvent("Checking if product is demo and has expired. "); AceSoft.RetailPlus.Key clsKey = new AceSoft.RetailPlus.Key(); string SerialNumber = null; RegistrationType regIsDemoExpired = clsKey.IsDemoExpired(out SerialNumber); bool boIsDemoExpired = false; switch (regIsDemoExpired) { case RegistrationType.Error: boIsDemoExpired = true; break; case RegistrationType.DEMO_Unexpired: boIsDemoExpired = false; break; case RegistrationType.DEMO_Expired: boIsDemoExpired = true; break; case RegistrationType.Registered: clsEvent.AddEventLn("Done! Product is registered to HD Serial No: " + SerialNumber); return(false); default: boIsDemoExpired = false; break; } clsEvent.AddEventLn("Done! return code: " + regIsDemoExpired.ToString("G") + " for HDD: " + SerialNumber); return(boIsDemoExpired); } catch (Exception ex) { clsEvent.AddErrorEventLn(ex); return(false); } }
static void Main() { AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); System.Windows.Forms.Application.ThreadException += new ThreadExceptionEventHandler(MainWnd_UIThreadException); Event clsEvent = new Event(); clsEvent.AddEvent("starting.... loading splash screen..."); SplashWnd appsplash = new SplashWnd(); clsEvent.AddEventLn("Done!"); appsplash.prgBar.Maximum = 100; appsplash.lblStatus.Text = "Checking OS Version... "; appsplash.prgBar.Value = 10; appsplash.Show(); appsplash.Refresh(); // get the windows version clsEvent.AddEvent("Checking windows current version"); OSVersion osVersion = OSInformation.getOSVersion(); switch (osVersion) { case OSVersion.Windows95: case OSVersion.WindowsMe: clsEvent.AddEventLn(": " + osVersion.ToString("G")); clsEvent.AddEventLn("This OS platform is not supported. Application will now close."); MessageBox.Show("FATAL ERROR Level 1.!!! The Operating System : '" + osVersion.ToString("G") + "' is not supported. Application will now close.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Stop); Application.Exit(); return; case OSVersion.Windows98: case OSVersion.Windows98SecondEdition: case OSVersion.WindowsNT351: case OSVersion.WindowsNT4: case OSVersion.Windows2000: case OSVersion.WindowsXP: case OSVersion.WindowsVista: case OSVersion.Windows7: clsEvent.AddEventLn(": " + osVersion.ToString("G")); break; case OSVersion.Unknown: System.OperatingSystem osInfo = System.Environment.OSVersion; clsEvent.AddEventLn(": Unidentified: Platform=" + osInfo.Platform.ToString() + " Major Version=" + osInfo.VersionString); clsEvent.AddEventLn("This OS platform is not supported. Application will now close."); MessageBox.Show("FATAL ERROR Level 1.!!! The Operating System is unidentified by Retailplus Application. System will now close. Platform=" + osInfo.Platform.ToString() + " Version=" + osInfo.VersionString, "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Stop); Application.Exit(); return; } // get the running version appsplash.lblStatus.Text = "Checking application Version... "; appsplash.prgBar.Value = 20; appsplash.Show(); appsplash.Refresh(); clsEvent.AddEvent("Checking application current version"); Version curVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; clsEvent.AddEventLn(":" + curVersion.ToString()); #region CopySubGroupsImages // this should be available only for resto appsplash.lblStatus.Text = "Copying subgroup images from server... "; appsplash.prgBar.Value = 25; getSubGroupImages(); #endregion Version verNewVersion = GetLatestVersion(); clsEvent.AddEventLn("latest version is " + verNewVersion.ToString(), true); // compare the versions if (curVersion.CompareTo(verNewVersion) < 0) { clsEvent.AddEventLn("system will now exit then download the latest version.", true); System.Diagnostics.Process.Start("RetailPlus.VersionChecker.exe", "RestoPlus.exe"); Application.Exit(); return; } clsEvent.AddEventLn("This application version is updated.", true); appsplash.lblStatus.Text = "Checking connections to database... "; appsplash.prgBar.Value = 30; appsplash.Refresh(); if (!IsDBAlive()) { MessageBox.Show("FATAL ERROR Level 1.!!! Cannot connect to database. Please consult your system administrator immediately...", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); return; } appsplash.lblStatus.Text += "DONE!"; appsplash.Refresh(); appsplash.lblStatus.Text = "Checking Last Initialization of ZREAD... "; appsplash.prgBar.Value = 50; appsplash.Show(); appsplash.Refresh(); if (!IsDateLastInitializationOK()) { MessageBox.Show("FATAL ERROR Level 2.!!! System date is behind ZREAD last initialization date. Please adjust SYSTEM DATE!!!", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); return; } appsplash.lblStatus.Text += "DONE!"; appsplash.Refresh(); appsplash.prgBar.Value = 70; appsplash.lblStatus.Text = "Checking terminal if exist in the database... "; appsplash.Refresh(); string ErrorMessage; if (!IsTerminalExist(out ErrorMessage)) { MessageBox.Show(ErrorMessage, "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); return; } appsplash.lblStatus.Text += "DONE!"; appsplash.Refresh(); appsplash.prgBar.Value = 100; appsplash.lblStatus.Text = "Checking terminal if demo is expired... "; appsplash.Refresh(); if (IsDemoExpired()) { string stHDSeriano = Key.GetHDSerialNo(); MessageBox.Show( "This copy has been expired. Please contact your nearest software distributor" + Environment.NewLine + "Or call RBS Sales @: " + Environment.NewLine + " Philippines: +63.947.3215979" + Environment.NewLine + " Philippines: +63.918.9390926" + Environment.NewLine + " Philippines: +632.998.7722" + Environment.NewLine + " Singapore: +658.6519601" + Environment.NewLine + "Or email [email protected]" + Environment.NewLine + "Your HD Serial No. is: " + stHDSeriano, "RetailPlus™ Demo Version", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly); Application.Exit(); return; } appsplash.lblStatus.Text += "DONE!"; appsplash.Refresh(); appsplash.Dispose(); appsplash.Close(); Security.AuditTrailDetails clsAuditDetails = new Security.AuditTrailDetails(); clsAuditDetails.BranchID = Constants.TerminalBranchID; clsAuditDetails.TerminalNo = CompanyDetails.TerminalNo; clsAuditDetails.ActivityDate = DateTime.Now; clsAuditDetails.User = "******"; clsAuditDetails.IPAddress = System.Net.Dns.GetHostName(); clsAuditDetails.Activity = "Open Terminal"; clsAuditDetails.Remarks = "FE:" + "Open terminal no.:'" + CompanyDetails.TerminalNo + "' @ Branch:" + Constants.TerminalBranchID.ToString(); Security.AuditTrail clsAuditTrail = new Security.AuditTrail(); clsAuditTrail.Insert(clsAuditDetails); Data.Terminal clsTerminal = new Data.Terminal(clsAuditTrail.Connection, clsAuditTrail.Transaction); Data.TerminalDetails clsTerminalDetails = clsTerminal.Details(Constants.TerminalBranchID, CompanyDetails.TerminalNo); //overwrite the companydetails from the database Data.SysConfig clsSysConfig = new Data.SysConfig(clsAuditTrail.Connection, clsAuditTrail.Transaction); Data.SysConfigDetails clsSysConfigDetails = clsSysConfig.get_SysConfigDetails(); clsAuditTrail.CommitAndDispose(); CompanyDetails.CompanyCode = string.IsNullOrEmpty(clsSysConfigDetails.CompanyCode) ? CompanyDetails.CompanyCode : clsSysConfigDetails.CompanyCode; CompanyDetails.CompanyName = string.IsNullOrEmpty(clsSysConfigDetails.CompanyName) ? CompanyDetails.CompanyName : clsSysConfigDetails.CompanyName; CompanyDetails.Currency = string.IsNullOrEmpty(clsSysConfigDetails.Currency) ? CompanyDetails.Currency : clsSysConfigDetails.Currency; CompanyDetails.TIN = string.IsNullOrEmpty(clsSysConfigDetails.TIN) ? CompanyDetails.TIN : clsSysConfigDetails.TIN; CompanyDetails.Address1 = string.IsNullOrEmpty(clsSysConfigDetails.Address1) ? CompanyDetails.Address1 : clsSysConfigDetails.Address1; CompanyDetails.Address2 = string.IsNullOrEmpty(clsSysConfigDetails.Address2) ? CompanyDetails.Address2 : clsSysConfigDetails.Address2; CompanyDetails.City = string.IsNullOrEmpty(clsSysConfigDetails.City) ? CompanyDetails.City : clsSysConfigDetails.City; CompanyDetails.State = string.IsNullOrEmpty(clsSysConfigDetails.State) ? CompanyDetails.State : clsSysConfigDetails.State; CompanyDetails.Zip = string.IsNullOrEmpty(clsSysConfigDetails.Zip) ? CompanyDetails.Zip : clsSysConfigDetails.Zip; CompanyDetails.Country = string.IsNullOrEmpty(clsSysConfigDetails.Country) ? CompanyDetails.Country : clsSysConfigDetails.Country; CompanyDetails.OfficePhone = string.IsNullOrEmpty(clsSysConfigDetails.OfficePhone) ? CompanyDetails.OfficePhone : clsSysConfigDetails.OfficePhone; CompanyDetails.DirectPhone = string.IsNullOrEmpty(clsSysConfigDetails.DirectPhone) ? CompanyDetails.DirectPhone : clsSysConfigDetails.DirectPhone; CompanyDetails.FaxPhone = string.IsNullOrEmpty(clsSysConfigDetails.FaxPhone) ? CompanyDetails.FaxPhone : clsSysConfigDetails.FaxPhone; CompanyDetails.MobilePhone = string.IsNullOrEmpty(clsSysConfigDetails.MobilePhone) ? CompanyDetails.MobilePhone : clsSysConfigDetails.MobilePhone; CompanyDetails.EmailAddress = string.IsNullOrEmpty(clsSysConfigDetails.EmailAddress) ? CompanyDetails.EmailAddress : clsSysConfigDetails.EmailAddress; CompanyDetails.WebSite = string.IsNullOrEmpty(clsSysConfigDetails.WebSite) ? CompanyDetails.WebSite : clsSysConfigDetails.WebSite; try { clsEvent.AddEventLn("Running Main Window.", true); MainRestoWnd appmain = new MainRestoWnd(); appmain.Text = " RestoPlus ™"; /******************************** * Added December 21, 2008 * Enable 2 windows in one computer * *****************************/ try { if (clsTerminalDetails.MultiInstanceEnabled) { Application.Run(appmain); } else { SingleInstance.Run(appmain); } } catch (Exception exMain) { clsEvent.AddEventLn("System has excountered an error while loading main screen!" + Environment.NewLine + exMain.ToString(), true); clsEvent.AddEventLn("System has been exited!", true); throw (exMain); } clsEvent.AddEventLn("System has been exited!", true); clsAuditDetails = new Security.AuditTrailDetails(); clsAuditDetails.BranchID = Constants.TerminalBranchID; clsAuditDetails.TerminalNo = CompanyDetails.TerminalNo; clsAuditDetails.ActivityDate = DateTime.Now; clsAuditDetails.User = "******"; clsAuditDetails.IPAddress = System.Net.Dns.GetHostName(); clsAuditDetails.Activity = "Close Terminal"; clsAuditDetails.Remarks = "FE:" + "Close terminal no.:'" + CompanyDetails.TerminalNo + "' @ Branch:" + Constants.TerminalBranchID.ToString() + "."; clsAuditTrail = new Security.AuditTrail(); clsAuditTrail.Insert(clsAuditDetails); clsAuditTrail.CommitAndDispose(); } catch (Exception ex) { clsEvent.AddErrorEventLn(ex); MessageBox.Show("FATAL ERROR Level 1.!!! An internal error has occurred in the system. Please consult your system administrator immediately...", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); } }
private static bool IsTerminalExist(out string ErrorMessage) { ErrorMessage = ""; Event clsEvent = new Event(); try { clsEvent.AddEvent("Checking terminal if exist in the database. [" + CompanyDetails.TerminalNo + "]"); Data.Terminal clsTerminal = new Data.Terminal(); Data.TerminalDetails clsDetails = new Data.TerminalDetails(); Int32 iBranchCount = clsTerminal.BranchCount(CompanyDetails.TerminalNo); bool boIsTerminalExist = false; if (iBranchCount == 1) { clsDetails = clsTerminal.Details(CompanyDetails.TerminalNo); boIsTerminalExist = true; CONFIG.SaveConfig(clsDetails); } else { boIsTerminalExist = clsTerminal.IsExist(Constants.TerminalBranchID, CompanyDetails.TerminalNo, out clsDetails); } clsTerminal.CommitAndDispose(); if (!boIsTerminalExist) { ErrorMessage = "FATAL ERROR Level 1.!!! " + Environment.NewLine + "Terminal No:[" + CompanyDetails.TerminalNo + "] @ BranchID:[" + Constants.TerminalBranchID.ToString() + "] does not exist in the database." + Environment.NewLine + "Please consult your system administrator immediately..."; clsEvent.AddEventLn("FATAL ERROR!!! " + Environment.NewLine + "Terminal No:[" + CompanyDetails.TerminalNo + "] @ BranchID:[" + Constants.TerminalBranchID.ToString() + "] does not exist in the database. TRACE: Procedure IsTerminalExist returns false."); } else { clsEvent.AddEventLn("Done!"); clsEvent.AddEvent("Product Version suited for DB Version [" + clsDetails.DBVersion + "] =? Product Version[" + Application.ProductVersion + "]"); if (clsDetails.DBVersion != Application.ProductVersion) { ErrorMessage = "FATAL ERROR Level 1.!!! The Product Version [" + Application.ProductVersion + "] is not compatible with Database Version [" + clsDetails.DBVersion + "]." + Environment.NewLine + "Please consult your system administrator immediately..."; clsEvent.AddEventLn("FATAL ERROR!!! The Product Version is not compatible with database version. TRACE: Product Version returns false."); return(false); } clsEvent.AddEventLn("Done!"); clsEvent.AddEvent("Checking Machine Serial No. [" + CONFIG.MachineSerialNo + "]"); if (clsDetails.MachineSerialNo != CONFIG.MachineSerialNo) { //bypass this //ErrorMessage = "FATAL ERROR Level 1.!!! The Machine Serial No. in the database and configuration file does not match." + Environment.NewLine + "Please consult your system administrator immediately..."; //clsEvent.AddEventLn("FATAL ERROR!!! The Machine Serial No. in the database and configuration file does not match. TRACE: Procedure IsTerminalExist returns false."); //return false; clsEvent.AddEventLn("BYPASS-FATAL ERROR!!! The Machine Serial No. in the database and configuration file does not match. TRACE: Procedure IsTerminalExist returns false."); } clsEvent.AddEventLn("Done!"); clsEvent.AddEvent("Checking accreditation no. [" + CONFIG.AccreditationNo + "]"); if (clsDetails.AccreditationNo != CONFIG.AccreditationNo) { //ErrorMessage = "FATAL ERROR Level 1.!!! The Accreditation No. in the database and configuration file does not match." + Environment.NewLine + "Please consult your system administrator immediately..."; //clsEvent.AddEventLn("FATAL ERROR!!! The Accreditation No. in the database and configuration file does not match. TRACE: Procedure IsTerminalExist returns false."); //return false; clsEvent.AddEventLn("BY-PASS FATAL ERROR!!! The Accreditation No. in the database and configuration file does not match. TRACE: Procedure IsTerminalExist returns false."); } clsEvent.AddEventLn("Done!"); } return(boIsTerminalExist); } catch (Exception ex) { ErrorMessage = "FATAL ERROR!!! TRACE: " + ex.Message; clsEvent.AddEventLn("FATAL ERROR!!! TRACE:" + ex.Message); return(false); } }
private static bool IsDemoExpired() { Event clsEvent = new Event(); try { clsEvent.AddEvent("Checking if product is demo and has expired. "); AceSoft.RetailPlus.Key clsKey = new AceSoft.RetailPlus.Key(); string SerialNumber = null; RegistrationType regIsDemoExpired = clsKey.IsDemoExpired(out SerialNumber); bool boIsDemoExpired = false; switch (regIsDemoExpired) { case RegistrationType.Error: boIsDemoExpired = true; break; case RegistrationType.DEMO_Unexpired: boIsDemoExpired = false; break; case RegistrationType.DEMO_Expired: boIsDemoExpired = true; break; case RegistrationType.Registered: clsEvent.AddEventLn("Done! Product is registered to HD Serial No: " + SerialNumber); return false; default: boIsDemoExpired = false; break; } clsEvent.AddEventLn("Done! return code: " + regIsDemoExpired.ToString("G") + " for HDD: " + SerialNumber); return boIsDemoExpired; } catch (Exception ex) { clsEvent.AddErrorEventLn(ex); return false; } }
private static bool IsTerminalExist(out string ErrorMessage) { ErrorMessage = ""; Event clsEvent = new Event(); try { clsEvent.AddEvent("Checking terminal if exist in the database. [" + CompanyDetails.TerminalNo + "]"); Data.Terminal clsTerminal = new Data.Terminal(); Data.TerminalDetails clsDetails = new Data.TerminalDetails(); Int32 iBranchCount = clsTerminal.BranchCount(CompanyDetails.TerminalNo); bool boIsTerminalExist = false; if (iBranchCount == 1) { clsDetails = clsTerminal.Details(CompanyDetails.TerminalNo); boIsTerminalExist = true; CONFIG.SaveConfig(clsDetails); } else { boIsTerminalExist = clsTerminal.IsExist(Constants.TerminalBranchID, CompanyDetails.TerminalNo, out clsDetails); } clsTerminal.CommitAndDispose(); if (!boIsTerminalExist) { ErrorMessage = "FATAL ERROR Level 1.!!! " + Environment.NewLine + "Terminal No:[" + CompanyDetails.TerminalNo + "] @ BranchID:[" + Constants.TerminalBranchID.ToString() + "] does not exist in the database." + Environment.NewLine + "Please consult your system administrator immediately..."; clsEvent.AddEventLn("FATAL ERROR!!! " + Environment.NewLine + "Terminal No:[" + CompanyDetails.TerminalNo + "] @ BranchID:[" + Constants.TerminalBranchID.ToString() + "] does not exist in the database. TRACE: Procedure IsTerminalExist returns false."); } else { clsEvent.AddEventLn("Done!"); clsEvent.AddEvent("Product Version suited for DB Version [" + clsDetails.DBVersion + "] =? Product Version[" + Application.ProductVersion + "]"); if (clsDetails.DBVersion != Application.ProductVersion) { ErrorMessage = "FATAL ERROR Level 1.!!! The Product Version [" + Application.ProductVersion + "] is not compatible with Database Version [" + clsDetails.DBVersion + "]." + Environment.NewLine + "Please consult your system administrator immediately..."; clsEvent.AddEventLn("FATAL ERROR!!! The Product Version is not compatible with database version. TRACE: Product Version returns false."); return false; } clsEvent.AddEventLn("Done!"); clsEvent.AddEvent("Checking Machine Serial No. [" + CONFIG.MachineSerialNo + "]"); if (clsDetails.MachineSerialNo != CONFIG.MachineSerialNo) { //bypass this //ErrorMessage = "FATAL ERROR Level 1.!!! The Machine Serial No. in the database and configuration file does not match." + Environment.NewLine + "Please consult your system administrator immediately..."; //clsEvent.AddEventLn("FATAL ERROR!!! The Machine Serial No. in the database and configuration file does not match. TRACE: Procedure IsTerminalExist returns false."); //return false; clsEvent.AddEventLn("BYPASS-FATAL ERROR!!! The Machine Serial No. in the database and configuration file does not match. TRACE: Procedure IsTerminalExist returns false."); } clsEvent.AddEventLn("Done!"); clsEvent.AddEvent("Checking accreditation no. [" + CONFIG.AccreditationNo + "]"); if (clsDetails.AccreditationNo != CONFIG.AccreditationNo) { //ErrorMessage = "FATAL ERROR Level 1.!!! The Accreditation No. in the database and configuration file does not match." + Environment.NewLine + "Please consult your system administrator immediately..."; //clsEvent.AddEventLn("FATAL ERROR!!! The Accreditation No. in the database and configuration file does not match. TRACE: Procedure IsTerminalExist returns false."); //return false; clsEvent.AddEventLn("BY-PASS FATAL ERROR!!! The Accreditation No. in the database and configuration file does not match. TRACE: Procedure IsTerminalExist returns false."); } clsEvent.AddEventLn("Done!"); } return boIsTerminalExist; } catch (Exception ex) { ErrorMessage = "FATAL ERROR!!! TRACE: " + ex.Message; clsEvent.AddEventLn("FATAL ERROR!!! TRACE:" + ex.Message); return false; } }
private static bool IsDateLastInitializationOK() { Event clsEvent = new Event(); try { clsEvent.AddEvent("Checking last initialization date"); Data.Database clsDatabase = new Data.Database(); DateTime dtDateLastInitialized = clsDatabase.DateLastInitialized(Constants.TerminalBranchID, CompanyDetails.TerminalNo); clsDatabase.CommitAndDispose(); bool boReturn = false; if (DateTime.Now > dtDateLastInitialized) { boReturn = true; clsEvent.AddEventLn("OK: Last initialization is smaller than system date. DateLastInitialized=" + dtDateLastInitialized.ToString("yyyy-MM-dd hh:mm") + " SystemDate=" + DateTime.Now.ToString("yyyy-MM-dd hh:mm")); } else { clsEvent.AddEventLn("Error: Last initialization is greater than system date. DateLastInitialized=" + dtDateLastInitialized.ToString("yyyy-MM-dd hh:mm") + " SystemDate=" + DateTime.Now.ToString("yyyy-MM-dd hh:mm")); } return boReturn; } catch (Exception ex) { clsEvent.AddErrorEventLn(ex); return false; } }
private static bool IsDBAlive() { Event clsEvent = new Event(); try { clsEvent.AddEvent("Checking connections to server."); if (IPAddress.IsOpen(AceSoft.RetailPlus.DBConnection.ServerIP(), DBConnection.DBPort()) == false) { clsEvent.AddEvent("Cannot connect to server please check."); return false; } clsEvent.AddEvent("Checking connections to database."); Data.Database clsDatabase = new Data.Database(); bool boIsDBAlive = clsDatabase.IsAlive(); clsEvent.AddEventLn("Done! Connected to " + clsDatabase.Connection.ConnectionString, false); clsEvent.AddEventLn("Updating version to " + Application.ProductVersion, true); Data.Terminal clsTerminal = new Data.Terminal(clsDatabase.Connection, clsDatabase.Transaction); clsTerminal.UpdateFEVersion(Constants.TerminalBranchID, CompanyDetails.TerminalNo, Application.ProductVersion); clsDatabase.CommitAndDispose(); return boIsDBAlive; } catch (Exception ex) { clsEvent.AddErrorEventLn(ex); return false; } }