public static void InitializeDatabase()
        {
            bool   isVet    = PatientUtilities.IsVetProduct;
            string initData = "InitCheckUpdateVersion";
            string rootPath = ServiceManager.RootPath;
            string filePath = Path.Combine(rootPath, "SqlUpgrade/Vinno.SqlRestore.exe");

            if (VinnoFile.Exists(filePath) && DigitalSignatureChecker.VerifySignature(filePath))
            {
                var startInfo = new ProcessStartInfo(filePath, $"\"{initData}\" {isVet}")
                {
                    WorkingDirectory       = rootPath,
                    UseShellExecute        = false,
                    CreateNoWindow         = true,
                    RedirectStandardError  = true,
                    RedirectStandardOutput = true
                };

                using (var proc = new Process {
                    StartInfo = startInfo
                })
                {
                    proc.Start();
                    proc.BeginOutputReadLine();

                    //Wait for the data updating process to end.
                    while (!proc.HasExited)
                    {
                        proc.WaitForExit(1000);
                    }

                    Initialize(proc.ExitCode, isVet);
                }
            }
        }
Beispiel #2
0
        private static void StartSystem()
        {
            const string workingDirectory = @"C:\App\Shipped\bin\";
            const string fileName         = workingDirectory + ".MainMonitor.exe";

            if (!File.Exists(fileName))
            {
                throw new Exception(string.Format(Translator.GetValue("File not Exists: '{0}'."), fileName));
            }

            if (!DigitalSignatureChecker.VerifySignature(fileName))
            {
                throw new Exception(string.Format(Translator.GetValue("Failed to verify digital signature of the module '{0}'."), fileName));
            }

            new Process
            {
                StartInfo =
                {
                    FileName         = fileName,
                    CreateNoWindow   = true,
                    WorkingDirectory = workingDirectory,
                    UseShellExecute  = false
                }
            }.Start();
        }
        private static void UpdateIsVetNoCorrectDatabase(bool isTrue)
        {
            bool   isVet          = PatientUtilities.IsVetProduct;
            string deleteDataBase = "DeleteDatabase";
            string rootPath       = ServiceManager.RootPath;
            string filePath       = Path.Combine(rootPath, "SqlUpgrade/Vinno.SqlRestore.exe");

            if (VinnoFile.Exists(filePath) && DigitalSignatureChecker.VerifySignature(filePath))
            {
                ProcessStartInfo startInfo;
                if (isTrue)
                {
                    startInfo = new ProcessStartInfo(filePath, $"\"{deleteDataBase}\" {isVet}")
                    {
                        WorkingDirectory       = rootPath,
                        UseShellExecute        = false,
                        CreateNoWindow         = true,
                        RedirectStandardError  = true,
                        RedirectStandardOutput = true
                    };
                }
                else
                {
                    startInfo = new ProcessStartInfo(filePath, "IsVetSaveAndDeleteDatabase")
                    {
                        WorkingDirectory       = rootPath,
                        UseShellExecute        = false,
                        CreateNoWindow         = true,
                        RedirectStandardError  = true,
                        RedirectStandardOutput = true
                    };
                }

                using (var proc = new Process {
                    StartInfo = startInfo
                })
                {
                    proc.Start();
                    proc.BeginOutputReadLine();

                    //Wait for the data updating process to end.
                    while (!proc.HasExited)
                    {
                        proc.WaitForExit(1000);
                    }
                }
            }
        }
Beispiel #4
0
        private void OnStartUpgrade()
        {
            IsInUpgrading = true;
            string upgradeDescription = string.Empty;
            string stepDes            = Translator.GetValue("Working on updates\nPart 4 of 4: Upgrading to new version");

            try
            {
                string destAssembly = Path.Combine(_upgradeFolder, "UpgradeHost.DLL");

                if (!File.Exists(destAssembly) || !DigitalSignatureChecker.VerifySignature(destAssembly))
                {
                    throw new Exception();
                }

                UpgradeProxy proxy = new UpgradeProxy(destAssembly);
                upgradeDescription = proxy.Description();
                _wizardService.UpdateStates(_title, upgradeDescription, stepDes, DoNotTrunOff);
                string message;
                if (!proxy.CanExecute(out message))
                {
                    throw new Exception(message);
                }
                try
                {
                    Thread.Sleep(2000);
                    proxy.Execute(_upgradeFolder, out message);
                }
                catch (Exception e)
                {
                    throw new Exception(e.InnerException != null?e.InnerException.Message:e.Message);
                }

                try
                {
                    //delete upgrade folder
                    //todo KnowIssue ,UpgradeHost.dll can't be delete,as it has been loaded  into AppDomain
                    Directory.Delete(_upgradeFolder, true);
                }
                catch (Exception e)
                {
                }

                const string shutdownMessage     = "Upgrade done successfully.\nSystem will continue automatically after";
                string       shutdownAdditionDes = string.Empty;
                var          buttons             = new WizardButton[1];
                buttons[0] = new WizardButton(WizardButtonEnum.Ok, null, "Continue");
                int timeoutTicks = ResourceManager.GetValue("Upgrade", "TimeoutTicks", 10);
                _wizardService.UpdateStates(_title, upgradeDescription, shutdownMessage, shutdownAdditionDes, -1, true, buttons, timeoutTicks, buttons[0]);

                //Decide to start Main.exe or continue upgrade.
                StartOrContinue();
            }
            catch (Exception e)
            {
                var buttons = new WizardButton[1];
                buttons[0] = new WizardButton(WizardButtonEnum.Ok, null, "Shut Down");
                _wizardService.UpdateStates(_title, upgradeDescription, Translator.GetValue("Upgrade failed.\nSystem will shut down."), e.Message, -1, true, buttons);
                HostManager.ShutDown(RestartType.ShutdownOS);
            }
            finally
            {
                IsInUpgrading = false;
                HostManager.ShutDown(RestartType.None);
            }
        }