示例#1
0
        private void frmDataIntegrityNoUI_Load(object sender, EventArgs e)
        {
            Application.ApplicationExit += this.Application_Exit;

            try
            {
                try
                {   // Try to connect to an existing COM Customisationwhich is
                    // Registered in the Windows Running Objects Table
                    this.enterpriseObject = Marshal.GetActiveObject("Enterprise.COMCustomisation") as COMCustomisation;
                }
                catch
                {
                    // This is a specifc exception. GetActiveObject will not return null, it will throw
                    // an Operation Unavailable exception
                    this.enterpriseObject = new Enterprise.COMCustomisation();
                }

                if (this.enterpriseObject == null)
                {
                    throw new NullReferenceException("Enterprise COM object could not be created");
                }
            }
            catch (Exception systemException)
            {
                MessageBox.Show("The application was terminated." + Environment.NewLine +
                                "Details: " + Environment.NewLine +
                                systemException.Message);
                Application.Exit();
            }

            string ExVersion = "";

            // Set root Exchequer Path
            ExchequerPath = (string)Registry.GetValue("HKEY_CURRENT_USER\\SOFTWARE\\EXCHEQUER\\ENTERPRISE", "SystemDir", "");

            GetCompanies();

            // Get _Admin Connection String
            ConnectionStringBuilder oConn = new ConnectionStringBuilder(ExchequerPath, "wmie@iris!");
            string ex;
            bool   validconnection = oConn.GetNewConnectionString(out ex);

            if (ex != "")
            {
                MessageBox.Show(ex);
            }

            if (validconnection)
            {
                SQLCommonConnectionString = oConn.DecryptedString;

                // Set shared SQL Connection String
                //RB 20/02/2018 2018-R1 ABSEXCH-19790: Check SQL Posting Compatibility: Unhandled exception is occurred when running check for Single Daybook posting.
                SetSQLCommonConnectionString(oConn);

                string assemblyVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString();
                GetExchequerVersion(out ExVersion, oConn);

                tssVersion.Text = ExVersion + "  -  Integrity Checker Version: " + assemblyVersion;
            }
            else
            {
                MessageBox.Show("This utility can only be run on Exchequer SQL Edition installations", "Exchequer SQL Data Validation Tool", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Exit();
            }

            // Check Exchequer Toolkit Version
            if (FileVersionInfo.GetVersionInfo(Path.Combine(ExchequerPath, "enttoolk.dll")).FileMajorPart < 10)
            {
                MessageBox.Show("This utility can only be run on Exchequer 2017 R1 and above", "Exchequer SQL Data Validation Tool", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Exit();
            }
        }