Exemple #1
0
        internal async Task InstallStatus(bool isCompleted, string errorMsg)
        {
            try
            {
                var userAgent = _httpContext.Request.UserAgent;

                // Check for current install Id
                var installId = Guid.NewGuid();

                var installCookie = _httpContext.Request.GetCookieValue(Constants.Web.InstallerCookieName);
                if (string.IsNullOrEmpty(installCookie) == false)
                {
                    if (Guid.TryParse(installCookie, out installId))
                    {
                        // check that it's a valid Guid
                        if (installId == Guid.Empty)
                        {
                            installId = Guid.NewGuid();
                        }
                    }
                    else
                    {
                        installId = Guid.NewGuid(); // Guid.TryParse will have reset installId to Guid.Empty
                    }
                }
                _httpContext.Response.Cookies.Set(new HttpCookie(Constants.Web.InstallerCookieName, installId.ToString()));

                var dbProvider = string.Empty;
                if (IsBrandNewInstall == false)
                {
                    // we don't have DatabaseProvider anymore... doing it differently
                    //dbProvider = ApplicationContext.Current.DatabaseContext.DatabaseProvider.ToString();
                    dbProvider = GetDbProviderString(Current.SqlContext);
                }

                var installLog = new InstallLog(installId: installId, isUpgrade: IsBrandNewInstall == false,
                                                installCompleted: isCompleted, timestamp: DateTime.Now, versionMajor: UmbracoVersion.Current.Major,
                                                versionMinor: UmbracoVersion.Current.Minor, versionPatch: UmbracoVersion.Current.Build,
                                                versionComment: UmbracoVersion.Comment, error: errorMsg, userAgent: userAgent,
                                                dbProvider: dbProvider);

                await _installationService.LogInstall(installLog);
            }
            catch (Exception ex)
            {
                _logger.Error <InstallHelper>(ex, "An error occurred in InstallStatus trying to check upgrades");
            }
        }
Exemple #2
0
        public async Task SetInstallStatusAsync(bool isCompleted, string errorMsg)
        {
            try
            {
                var userAgent = _userAgentProvider.GetUserAgent();

                // Check for current install ID
                var installCookie = _cookieManager.GetCookieValue(Constants.Web.InstallerCookieName);
                if (!Guid.TryParse(installCookie, out Guid installId))
                {
                    installId = Guid.NewGuid();

                    _cookieManager.SetCookieValue(Constants.Web.InstallerCookieName, installId.ToString());
                }

                var dbProvider = string.Empty;
                if (IsBrandNewInstall == false)
                {
                    // we don't have DatabaseProvider anymore... doing it differently
                    //dbProvider = ApplicationContext.Current.DatabaseContext.DatabaseProvider.ToString();
                    dbProvider = _umbracoDatabaseFactory.SqlContext.SqlSyntax.DbProvider;
                }

                var installLog = new InstallLog(
                    installId: installId,
                    isUpgrade: IsBrandNewInstall == false,
                    installCompleted: isCompleted,
                    timestamp: DateTime.Now,
                    versionMajor: _umbracoVersion.Version.Major,
                    versionMinor: _umbracoVersion.Version.Minor,
                    versionPatch: _umbracoVersion.Version.Build,
                    versionComment: _umbracoVersion.Comment,
                    error: errorMsg,
                    userAgent: userAgent,
                    dbProvider: dbProvider);

                _fireAndForgetRunner.RunFireAndForget(() => _installationService.LogInstall(installLog));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "An error occurred in InstallStatus trying to check upgrades");
            }
        }