Beispiel #1
0
        public static string GetHDSerialNo()
        {
            string stRetValue = Constants.ERROR;

            try
            {
                OSVersion osVersion = OSInformation.getOSVersion();
                switch (osVersion)
                {
                case OSVersion.Windows95:
                case OSVersion.WindowsMe:
                case OSVersion.Windows98:
                case OSVersion.Windows98SecondEdition:
                case OSVersion.WindowsNT351:
                case OSVersion.WindowsNT4:
                case OSVersion.Windows2000:
                case OSVersion.WindowsXP:
                    const string RegCode  = "NW5KF-49VU2-CW1VD-EH32P-UFEL2";
                    DiskInfo     diskInfo = new DiskInfo();

                    HDiskInfo.GetIdeDiskInfo(0, ref diskInfo, RegCode);
                    stRetValue = diskInfo.pSerialNumber;
                    break;

                case OSVersion.WindowsVista:
                case OSVersion.Windows7:
                    ManagementClass            mc  = new ManagementClass("Win32_PhysicalMedia");
                    ManagementObjectCollection moc = mc.GetInstances();
                    foreach (ManagementObject mo in moc)
                    {
                        if (mo.ToString().ToUpper().IndexOf("PHYSICALDRIVE0") != -1)
                        {
                            stRetValue = mo["SerialNumber"].ToString().Trim();
                            mo.Dispose();
                            break;
                        }
                        mo.Dispose();
                    }
                    break;

                case OSVersion.Unknown:
                    break;
                }

                return(stRetValue);
            }
            catch (Exception ex)
            {
                return(stRetValue + ":" + ex.Message);
            }
        }
Beispiel #2
0
        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();
            }
        }
Beispiel #3
0
		public static OSInformation GetComputerDescription ()
		{
			if (_osInfo == null) {
				OSInformation info = new OSInformation ();
				if (OSHelper.IsUnix) {
					if (OSHelper.IsMacOSX) {
						string[] resultLines = new string[3];
						int i = 0;
						var versionProcess = Process.Start (new ProcessStartInfo ("bash", "-c \"sw_vers\"") { UseShellExecute = false, CreateNoWindow = true, RedirectStandardOutput = true, RedirectStandardError = true, RedirectStandardInput = true }); 
						versionProcess.OutputDataReceived += (object sender, DataReceivedEventArgs e) => {
							if (i >= resultLines.Length)
								return;
							resultLines [i] += e.Data;
							i++;
						};
						versionProcess.BeginOutputReadLine ();
						versionProcess.WaitForExit ();
						info.ProductName = FixSwVersString (resultLines [0]);
						info.Version = FixSwVersString (resultLines [1]);
						info.BuildNumber = FixSwVersString (resultLines [2]);
					} else {
						info.ProductName = "UNIX";
						info.Version = "Undefined Version";
						/* TODO: Complete with uname */
					}
				} else {
					//Get Operating system information.
					OperatingSystem os = Environment.OSVersion;
					//Get version information about the os.
					Version vs = os.Version;
					
					//Variable to hold our return value
					string operatingSystem = "";
					info.ProductName = "Windows";
					if (os.Platform == PlatformID.Win32Windows) {
						//This is a pre-NT version of Windows
						switch (vs.Minor) {
						case 0:
							operatingSystem = "95";
							break;
						case 10:
							if (vs.Revision.ToString () == "2222A")
								operatingSystem = "98SE";
							else
								operatingSystem = "98";
							break;
						case 90:
							operatingSystem = "Me";
							break;
						default:
							break;
						}
					} else if (os.Platform == PlatformID.Win32NT) {
						switch (vs.Major) {
						case 3:
							operatingSystem = "NT 3.51";
							break;
						case 4:
							operatingSystem = "NT 4.0";
							break;
						case 5:
							if (vs.Minor == 0)
								operatingSystem = "2000";
							else
								operatingSystem = "XP";
							break;
						case 6:
							if (vs.Minor == 0)
								operatingSystem = "Vista";
							else if (vs.Minor == 1)
								operatingSystem = "7";
							else
								operatingSystem = "8";
							break;
						default:
							break;
						}
					}
					//Make sure we actually got something in our OS check
					//We don't want to just return " Service Pack 2" or " 32-bit"
					//That information is useless without the OS version.
					if (operatingSystem != "") {
						//Got something.  Let's prepend "Windows" and get more info.
						info.Version = operatingSystem;
						//See if there's a service pack installed.
						if (os.ServicePack != "") {
							//Append it to the OS name.  i.e. "Windows XP Service Pack 3"
							info.BuildNumber = os.ServicePack;
						}
						//Append the OS architecture.  i.e. "Windows XP Service Pack 3 32-bit"
						//operatingSystem += " " + getOSArchitecture().ToString() + "-bit";
					}
				}
				_osInfo = info;
			}
			return _osInfo;
		}
Beispiel #4
0
        public static OSInformation GetComputerDescription()
        {
            if (_osInfo == null)
            {
                OSInformation info = new OSInformation();
                if (OSHelper.IsUnix)
                {
                    if (OSHelper.IsMacOSX)
                    {
                        string[] resultLines    = new string[3];
                        int      i              = 0;
                        var      versionProcess = Process.Start(new ProcessStartInfo("bash", "-c \"sw_vers\"")
                        {
                            UseShellExecute = false, CreateNoWindow = true, RedirectStandardOutput = true, RedirectStandardError = true, RedirectStandardInput = true
                        });
                        versionProcess.OutputDataReceived += (object sender, DataReceivedEventArgs e) => {
                            if (i >= resultLines.Length)
                            {
                                return;
                            }
                            resultLines [i] += e.Data;
                            i++;
                        };
                        versionProcess.BeginOutputReadLine();
                        versionProcess.WaitForExit();
                        info.ProductName = FixSwVersString(resultLines [0]);
                        info.Version     = FixSwVersString(resultLines [1]);
                        info.BuildNumber = FixSwVersString(resultLines [2]);
                    }
                    else
                    {
                        info.ProductName = "UNIX";
                        info.Version     = "Undefined Version";
                        /* TODO: Complete with uname */
                    }
                }
                else
                {
                    //Get Operating system information.
                    OperatingSystem os = Environment.OSVersion;
                    //Get version information about the os.
                    Version vs = os.Version;

                    //Variable to hold our return value
                    string operatingSystem = "";
                    info.ProductName = "Windows";
                    if (os.Platform == PlatformID.Win32Windows)
                    {
                        //This is a pre-NT version of Windows
                        switch (vs.Minor)
                        {
                        case 0:
                            operatingSystem = "95";
                            break;

                        case 10:
                            if (vs.Revision.ToString() == "2222A")
                            {
                                operatingSystem = "98SE";
                            }
                            else
                            {
                                operatingSystem = "98";
                            }
                            break;

                        case 90:
                            operatingSystem = "Me";
                            break;

                        default:
                            break;
                        }
                    }
                    else if (os.Platform == PlatformID.Win32NT)
                    {
                        switch (vs.Major)
                        {
                        case 3:
                            operatingSystem = "NT 3.51";
                            break;

                        case 4:
                            operatingSystem = "NT 4.0";
                            break;

                        case 5:
                            if (vs.Minor == 0)
                            {
                                operatingSystem = "2000";
                            }
                            else
                            {
                                operatingSystem = "XP";
                            }
                            break;

                        case 6:
                            if (vs.Minor == 0)
                            {
                                operatingSystem = "Vista";
                            }
                            else if (vs.Minor == 1)
                            {
                                operatingSystem = "7";
                            }
                            else
                            {
                                operatingSystem = "8";
                            }
                            break;

                        default:
                            break;
                        }
                    }
                    //Make sure we actually got something in our OS check
                    //We don't want to just return " Service Pack 2" or " 32-bit"
                    //That information is useless without the OS version.
                    if (operatingSystem != "")
                    {
                        //Got something.  Let's prepend "Windows" and get more info.
                        info.Version = operatingSystem;
                        //See if there's a service pack installed.
                        if (os.ServicePack != "")
                        {
                            //Append it to the OS name.  i.e. "Windows XP Service Pack 3"
                            info.BuildNumber = os.ServicePack;
                        }
                        //Append the OS architecture.  i.e. "Windows XP Service Pack 3 32-bit"
                        //operatingSystem += " " + getOSArchitecture().ToString() + "-bit";
                    }
                }
                _osInfo = info;
            }
            return(_osInfo);
        }