Esempio n. 1
0
        public void InstallUpdates()
        {
            if (!this.IsValidRequest())
            {
                this.Notify("Cannot Update", Warnings.AccessIsDenied);
                return;
            }

            string downloadUrl = string.Empty;
            string[] toBackup =
            {
                DbConfig.GetAttachmentParameter(AppUsers.GetCurrentUserDB(), "AttachmentsDirectory"),
                ConfigurationHelper.GetDbServerParameter("DatabaseBackupDirectory")
            };

            Release release = new Release();

            try
            {
                UpdateManager updater = new UpdateManager();
                Task task = Task.Run(async () => { release = await updater.GetLatestReleaseAsync(); });
                task.Wait();
            }
            catch
            {
                this.Notify("Cannot Update", "Cannot start the update because no release was found.");
                return;
            }


            string keyword = Config.UpdateKeyword;

            Asset ass = release.Assets.FirstOrDefault(a => a.Name.ToUpperInvariant().Contains(keyword.ToUpperInvariant()));

            if (ass != null)
            {
                downloadUrl = ass.DownloadUrl;
            }

            if (string.IsNullOrWhiteSpace(downloadUrl))
            {
                this.Notify("Cannot Update", "Cannot start the update because no download was found on the release.");
                return;
            }

            this.InstallUpdate(downloadUrl, toBackup);
        }
Esempio n. 2
0
        private async void CheckForUpdates()
        {
            bool autoSuggestUpdate = Conversion.TryCastBoolean(ConfigurationHelper.GetUpdaterParameter("AutoSuggestUpdate"));

            if (autoSuggestUpdate)
            {
                UpdateManager updater = new UpdateManager();
                Release release = await updater.GetLatestRelease();

                if (release != null)
                {
                    Application["UpdateAvailable"] = true;
                }
            }
        }
Esempio n. 3
0
        protected void Page_Init(object sender, EventArgs e)
        {
            string userName = AppUsers.GetCurrent().View.UserName;
            string ipAddress = AppUsers.GetCurrent().View.IpAddress;

            bool isDevelopmentMode = DbConfig.GetMixERPParameter(AppUsers.GetCurrentUserDB(), "Mode").ToUpperInvariant().Equals("DEVELOPMENT");
            bool isLocalHost = PageUtility.IsLocalhost(this.Page);
            bool isAdmin = AppUsers.GetCurrent().View.IsAdmin.ToBool();

            //isLocalHost = false;

            bool hasAccess = false;

            if (isAdmin)
            {
                if (isDevelopmentMode && isLocalHost)
                {
                    hasAccess = true;
                }

                if (!isDevelopmentMode)
                {
                    hasAccess = true;
                }
            }

            if (!hasAccess)
            {
                Log.Information("Access to {Page} is denied to {User} from {IP}.", this,
                    userName, ipAddress);
                this.ReleasePanel.Visible = false;
                this.Page.Server.Transfer("~/Site/AccessIsDenied.aspx", false);
                return;
            }

            UpdateManager updater = new UpdateManager();

            try
            {
                Task<Release> task = Task.Run(() => updater.GetLatestReleaseAsync());
                this._release = task.Result;
            }
            catch
            {
                this.ReleasePanel.Visible = false;
                this.UpToDatePanel.Visible = true;
                return;
            }

            if (this._release == null)
            {
                this._release = new Release();
            }
            else
            {
                string keyword = Config.UpdateKeyword;

                Asset ass =
                    this._release.Assets.FirstOrDefault(a => a.Name.ToUpperInvariant().Contains(keyword.ToUpperInvariant()));

                if (ass != null)
                {
                    this._downloadUrl = ass.DownloadUrl;
                }
            }

            if (string.IsNullOrWhiteSpace(this._downloadUrl))
            {
                this.ErrorLabel.Text = "This release does not contain any update.";
            }

            this.OverridePath = "/Dashboard/Index.aspx";
        }