Exemple #1
0
        public override void Execute(object parameter)
        {
            _SilentUpdate = (bool)parameter;

            if (_Updater != null)
            {
                return;
            }

            _Updater = new SelfUpdate();
            _Updater.UpdateCompleted += (s, e) =>
                                        OnUpdateCompleted(e.SuccessfulCheck, e.HasNewVersion, e.Message);
            _Updater.NeedCloseApp += (s, e) =>
                                     _WorkItem.Commands.Quit.Execute(null);

            _WorkItem.UpdateRunning = true;
            _Updater.UpdateAppAsync(
                "AppManager",
                Strings.APP_TITLE,
                _WorkItem.AppPath,
                new string[] { Assembly.GetExecutingAssembly().Location },
                new string[] { Process.GetCurrentProcess().ProcessName },
                "http://dimanick.ru/MySoft/AppManager/Update"
                );
        }
Exemple #2
0
        private static int Main(string[] args)
        {
            LogManager.SetDebugLoggingLevel();

            logger = LogManager.GetLogger(typeof(EntryPoint));

            ThreadPoolSetUp(Helper.MaxDegreeOfParallelism);
            args = FixArgs(args);
            var exitCode = TryRun(args);

            ConsoleWriter.ResetProgress();

            var command = args[0];

            if (command != "complete" && command != "check-pre-commit" &&
                (command != "help" || !args.Contains("--gen")))
            {
                SelfUpdate.UpdateIfOld();
            }

            logger.LogInformation($"Exit code: {exitCode}");

            LogManager.DisposeLoggers();

            return(exitCode == 0 ? 0 : 13);
        }
Exemple #3
0
        public string GetVersionString()
        {
            var ver = SelfUpdate.GetCurrentVersion(_WorkItem.AppPath);

            if (ver == null)
            {
                ver = Assembly.GetEntryAssembly().GetName().Version;
            }

            return(Strings.APP_TITLE + " " + ver);
        }
Exemple #4
0
        private static int Main(string[] args)
        {
            args = FixArgs(args);
            var exitCode = TryRun(args);

            ConsoleWriter.ResetProgress();

            var command = args[0];

            if (command != "complete" && command != "check-pre-commit")
            {
                SelfUpdate.UpdateIfOld();
            }

            return(exitCode == 0 ? 0 : 13);
        }
Exemple #5
0
        private static int Main(string[] args)
        {
            ThreadPoolSetUp(Helper.MaxDegreeOfParallelism);
            args = FixArgs(args);
            var exitCode = TryRun(args);

            ConsoleWriter.ResetProgress();

            var command = args[0];

            if (command != "complete" && command != "check-pre-commit")
            {
                SelfUpdate.UpdateIfOld();
            }

            return(exitCode == 0 ? 0 : 13);
        }
Exemple #6
0
        protected void OnUpdateCompleted(bool successfulCheck, bool hasNewVersion, string message)
        {
            _WorkItem.UpdateRunning = false;
            _WorkItem.NotifyUpdateCompleted();
            _Updater = null;

            //Updater can consume a lot of memory
            GC.Collect();
            Kernel32.GropWorkingSet();

            if (_SilentUpdate)
            {
                _SilentUpdate = false;
                return;
            }

            var wnd = _WorkItem.FindActiveWindow();

            if (!successfulCheck)
            {
                ErrorBox.Show(
                    Strings.APP_TITLE,
                    Strings.UPDATE_CHECK_FAILED,
                    message
                    );

                return;
            }

            if (!hasNewVersion)
            {
                MsgBox.Show(
                    wnd,
                    Strings.APP_TITLE,
                    String.Format(Strings.NO_NEW_VERSION, Strings.APP_TITLE),
                    false);
            }
        }
Exemple #7
0
        public static async Task <int> Main(string[] args)
        {
            try
            {
                // Remove old copy of self after an update
                SelfUpdate.Cleanup();
            }
            catch
            {
                // ignored
            }

            try
            {
                NetworkUtilities.ConfigureSupportedSecurityProtocols();
            }
            catch
            {
                // ignored
            }

            try
            {
                NetworkUtilities.SetConnectionLimit();
            }
            catch
            {
                // ignored
            }

            try
            {
                return(await Parser
                       .Default
                       .ParseArguments <
                           CleanCache,
                           Install,
                           List,
                           Migrate,
                           Outdated,
                           Pack,
                           Rcon,
                           Remove,
                           Scaffold,
                           Search,
                           SelfUpdate,
                           Setup,
                           Start,
                           Status,
                           Update
                           >(args)
                       .MapResult(
                           (Module m) => m.Run(),
                           e => Task.FromResult(1)
                           ));
            }
            catch (Exception ex)
            {
                Console.WriteLine("An unhandled application error has occured:".DarkRed());
                Console.WriteLine(ex.Message.Red());
                if (ex.InnerException != null)
                {
                    Console.WriteLine(ex.InnerException.Message.Red());
                }

                return(1);
            }
        }
Exemple #8
0
        static void Main(string[] args)
        {
            try
            {
                using (EntityDb context = new EntityDb())
                {
                    EntityConnection ec = new EntityConnection(context.ConnectionString);
                    try
                    {
                        ec.Open();
                        ec.Close();
                    }
                    catch (Exception ex)
                    {
                        MLogger.Error(ex.ToString());
                        MessageBox.Show($"Ошибка подключения к базе заданий. Original: EntityException: {ex.Message}", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
            }
            catch (Exception ex)
            {
                MLogger.Error(ex.ToString());
                MessageBox.Show($"Ошибка подключения к базе заданий. Original: EntityException: {ex.Message}", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            string currentExePath = Application.ExecutablePath;
            string exeName        = Path.GetFileName(currentExePath);

            if (Path.Combine(MQueryCommand.GetSetting("MonitorSelfUpdatePath").Value, exeName).Trim().ToUpper() == currentExePath.Trim().ToUpper())
            {
                new DialogTimerForm($"Невозможно запустить MagicUpdaterMonitor из общей папки обновления!{Environment.NewLine}Скачайте папку с программой на локальный компьютер.").ShowDialog();
                return;
            }

            bool forceStart = false;

            forceStart = args.Length > 0 && args[0] == "force";

            if (forceStart)
            {
                Process process1 = Process.GetCurrentProcess();
                if (process1 != null)
                {
                    foreach (Process pr in Process.GetProcessesByName(process1.ProcessName))
                    {
                        if (pr.Id != process1.Id)
                        {
                            pr.Kill();
                        }
                    }
                }
            }

            MainForm.HwId = HWID.Value();

            //Создаем пользователя в базе, если его нет
            MQueryCommand.CreateUser(Environment.UserName, MainForm.HwId);
            MainForm.UserId = MQueryCommand.GetUserId(Environment.UserName, MainForm.HwId);
            if (MainForm.UserId == 0)
            {
                MessageBox.Show($"Ошибка получения UserId по имени {Environment.UserName}", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                Environment.Exit(0);
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

#if !DEBUG && !NO_UPDATE
            if (SelfUpdate.IsUpdateNeeded())
            {
                SelfUpdate.Update(new UpdatingForm());
            }
            else
            {
                StartApplication();
            }
#endif
#if DEBUG || NO_UPDATE
            StartApplication();
#endif
        }