Exemplo n.º 1
0
        public static void CreateNhmUpdateInfoUpdate()
        {
            var notification = new Notification(NotificationsType.Info, NotificationsGroup.NhmUpdate, Tr("NiceHash Miner Update"), Tr("New version of NiceHash Miner is available."));

            if (!Configs.UpdateSettings.Instance.AutoUpdateNiceHashMiner)
            {
                notification.Action = new NotificationAction
                {
                    Info   = Tr("Start updater"),
                    Action = () =>
                    {
                        ApplicationStateManager.App.Dispatcher.Invoke(async() => {
                            var ok = await UpdateHelpers.StartUpdateProcess();
                            if (!ok)
                            {
                                CreateNhmUpdateAttemptFail();
                            }
                        });
                    },
                    IsSingleShotAction = true,
                };
            }

            NotificationsManager.Instance.AddNotificationToList(notification);
        }
        private async Task HandleUpdateAsync(Update update, CancellationToken ct)
        {
            using var scope = this.scopeFactory.CreateScope();
            var context = (MarketplaceContext)scope.ServiceProvider.GetService(typeof(MarketplaceContext));

            var(userId, command, messageId) = UpdateHelpers.GetUserAndCommand(update);
            var user = await context.Users.FirstOrDefaultAsync(u => u.TelegramId == userId);

            if (user != null && user.IsBanned)
            {
                return;
            }

            var userContext = this.userContextService.GetUserContext(user, userId);

            PersonifiedUpdate personifiedUpdate = new PersonifiedUpdate()
            {
                Update      = update,
                UserContext = userContext,
                Command     = command,
                MessageId   = messageId,
            };

            var updateHandler = (IBotUpdateService)scope.ServiceProvider.GetService(typeof(IBotUpdateService));
            await updateHandler.ProceedUpdate(personifiedUpdate);
        }
Exemplo n.º 3
0
        public static void CreateNhmUpdateInfoDownload(bool isInstallerVersion)
        {
            var notification = new Notification(NotificationsType.Info, NotificationsGroup.NhmUpdate, Tr("NiceHash Miner Update"), Tr("New version of NiceHash Miner is available."));

            if (!Configs.UpdateSettings.Instance.AutoUpdateNiceHashMiner)
            {
                notification.Action = new NotificationAction
                {
                    Info   = Tr("Download updater"),
                    Action = () =>
                    {
                        ApplicationStateManager.App.Dispatcher.Invoke(async() => {
                            var ok = await UpdateHelpers.StartDownloadingUpdater(isInstallerVersion);
                            if (!ok)
                            {
                                CreateNhmUpdateAttemptFail();
                            }
                            else
                            {
                                NotificationsManager.Instance.RemoveNotificationFromList(notification);
                                CreateNhmUpdateInfoUpdate();
                            }
                        });
                    },
                    IsSingleShotAction = true,
                    BindProgress       = true,
                };
            }

            NotificationsManager.Instance.AddNotificationToList(notification);
        }
Exemplo n.º 4
0
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            bool updateNow = true;

            while (updateNow)
            {
                Thread.Sleep(1000);
                if (UpdateHelpers.InstallUpdateSyncWithInfo())
                {
                    this.Invoke(new Action(() =>
                    {
                        updateNow       = false;
                        lblTime.Caption = @"OFMIS: Update available(the system is updating)";
                        UpdateHelpers.applicationDeployment.UpdateCompleted += (se, ev) =>
                        {
                            new frmUpdateNotification().ShowDialog(this);
                        };
                        UpdateHelpers.applicationDeployment.UpdateProgressChanged += (se, ev) =>
                        {
                            lblTime.Caption = $@"OFMIS: Update available(the system is updating) {ev.ProgressPercentage}%";
                        };
                        UpdateHelpers.applicationDeployment.UpdateAsync();
                    }));
                }
            }
        }
Exemplo n.º 5
0
        private async void UpdaterBtn_Click(object sender, EventArgs e)
        {
            UpdaterBtn.Enabled = false;
            GithubBtn.Enabled  = false;
            ProgressBarVisible = true;
            try
            {
                var progressDownload = new Progress <(string loadMessageText, int perc)>(p =>
                {
                    progressBar1.Value = p.perc;
                    label1.Text        = p.loadMessageText;
                });
                IProgress <(string loadMessageText, int prog)> progress = progressDownload;
                var downloadProgress = new Progress <int>(perc => progress?.Report((Translations.Tr($"Downloading updater: %{perc}"), perc)));

                await UpdateHelpers.DownloadUpdaterAsync(downloadProgress);
            }
            catch (Exception ex)
            {
                Logger.Error("Updater", $"Updating failed: {ex.Message}");
            }

            ProgressBarVisible = false;
            UpdaterBtn.Enabled = true;
            GithubBtn.Enabled  = true;

            Close();
        }
Exemplo n.º 6
0
        private void LinkLabelNewVersion_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            var isInstalled = UpdateHelpers.IsNHMInstalled();

            if (!isInstalled)
            {
                ApplicationStateManager.VisitNewVersionUrl();
                return;
            }
            using (var updaterForm = new Form_ChooseUpdate())
            {
                SetChildFormCenter(updaterForm);
                ApplicationStateManager.CurrentForm = ApplicationStateManager.CurrentFormState.Update;
                updaterForm.ShowDialog();
                ApplicationStateManager.CurrentForm = ApplicationStateManager.CurrentFormState.Main;
            }
        }
        private async Task CheckUpdate()
        {
            UserConfig userConfig = Configuration.getConfigAsYAML();

            var client = new WebClient();

            client.Headers.Add("User-Agent", "request");

            dynamic release_info  = UpdateHelpers.GitReleaseInfo(ADDONS_REPO_URL);
            string  latestVersion = release_info.tag_name;

            if (latestVersion == userConfig.version["addon_list"])
            {
                return;
            }

            string download_link = release_info.assets[0].browser_download_url;

            await Download(download_link, client);
        }
Exemplo n.º 8
0
        public IActionResult EmployeeUpdate(int id, XMLUpdEmployee employee)
        {
            if (UpdateHelpers.IsNull(employee))
            {
                ModelState.AddModelError("Error", "The model body cannot be empty or null");
                return(BadRequest(ModelState));
            }
            var emp = _repo.GetAll().Where(x => x.ID == id);

            if (emp.Count() < 1)
            {
                return(BadRequest("Cant find matching ID"));
            }
            var newemp = UpdateHelpers.XmlEmployeeToEmployee(employee, emp.First());

            newemp.ID = id;

            _repo.Update(newemp);

            return(Ok(newemp));
        }
        public async Task <IActionResult> Post([FromBody] Update update)
        {
            var(userId, command, messageId) = UpdateHelpers.GetUserAndCommand(update);
            var user = await this.context.Users.FirstOrDefaultAsync(u => u.TelegramId == userId);

            if (user != null && user.IsBanned)
            {
                return(this.Ok());
            }

            var userContext = this.userContextService.GetUserContext(user, userId);

            PersonifiedUpdate personifiedUpdate = new PersonifiedUpdate()
            {
                Update      = update,
                UserContext = userContext,
                Command     = command,
                MessageId   = messageId,
            };

            await this.botUpdate.ProceedUpdate(personifiedUpdate);

            return(this.Ok());
        }
        public static void CreateNhmUpdateInfo(bool isInstallerVersion)
        {
            var notification = new Notification(NotificationsType.Info, NotificationsGroup.NhmUpdate, Tr("NiceHash Miner Update"), Tr("New version of NiceHash Miner is available."));

            if (!Configs.UpdateSettings.Instance.AutoUpdateNiceHashMiner)
            {
                if (isInstallerVersion)
                {
                    notification.Actions.Add(new NotificationAction
                    {
                        Info   = Tr("Start updater"),
                        Action = () =>
                        {
                            ApplicationStateManager.App.Dispatcher.Invoke(async() => await UpdateHelpers.StartUpdateProcess(isInstallerVersion));
                        }
                    });
                }
                else
                {
                    notification.Actions.Add(new NotificationAction
                    {
                        Info   = Tr("Visit release Page"),
                        Action = () => { Process.Start(Links.VisitReleasesUrl); }
                    });
                }
            }

            NotificationsManager.Instance.AddNotificationToList(notification);
        }