private void InitializeForumIfNotExist() { var logger = LoggerSource.Instance.GetLogger(typeof(YafDnnModule)); try { var isForumInstalled = this.Get <InstallUpgradeService>().IsForumInstalled; if (!isForumInstalled) { var userInfo = UserController.Instance.GetUserById( this.PortalSettings.PortalId, this.PortalSettings.AdministratorId); this.Get <InstallUpgradeService>().InitializeForum( Guid.NewGuid(), $"{this.PortalSettings.PortalName} Forum", "en-US", null, "YAFLogo.svg", BaseUrlBuilder.GetBaseUrlFromVariables(), userInfo.Username, userInfo.Email, userInfo.UserID.ToString()); } } catch (Exception exception) { logger.Error(exception); } var scriptFile = HttpContext.Current.Request.MapPath( Path.Combine( "DesktopModules", "YetAnotherForumDotNet", "03.00.006100.sql")); // read script file for installation var script = FileSystemUtils.ReadFile(scriptFile); // execute SQL installation script var exceptions = DataProvider.Instance().ExecuteScript(CommandTextHelpers.GetCommandTextReplaced(script)); logger.Error(exceptions); }
/// <summary> /// Save DNN Avatar as YAF Remote Avatar with relative Path. /// </summary> /// <param name="fileId">The file id.</param> /// <param name="yafUserId">The YAF user id.</param> /// <param name="portalGUID">The portal GUID.</param> private static void SaveDnnAvatar(string fileId, int yafUserId, Guid portalGUID) { var basePath = BaseUrlBuilder.GetBaseUrlFromVariables() + BaseUrlBuilder.AppPath; if (!basePath.EndsWith("/")) { basePath = "{0}/".FormatWith(basePath); } if (!basePath.EndsWith("/")) { basePath = "{0}/".FormatWith(basePath); } LegacyDb.user_saveavatar( yafUserId, "{0}LinkClick.aspx?fileticket={1}".FormatWith( basePath, UrlUtils.EncryptParameter(UrlUtils.GetParameterValue(fileId), portalGUID.ToString())), null, null); }
/// <summary> /// The upgrade database. /// </summary> /// <param name="fullText"> /// The full text. /// </param> /// <param name="upgradeExtensions"> /// The upgrade Extensions. /// </param> /// <returns> /// The <see cref="bool"/>. /// </returns> public bool UpgradeDatabase(bool fullText, bool upgradeExtensions) { this._messages.Clear(); { var isForumInstalled = this.IsForumInstalled; // try this.FixAccess(false); var isAzureEngine = this.Get <IDbFunction>().GetSQLEngine().Equals("Azure"); if (!isForumInstalled) { this.ExecuteInstallScripts(isAzureEngine); } else { this.ExecuteUpgradeScripts(isAzureEngine); } this.FixAccess(true); var prevVersion = LegacyDb.GetDBVersion(); LegacyDb.system_updateversion(YafForumInfo.AppVersion, YafForumInfo.AppVersionName); // Ederon : 9/7/2007 // resync all boards - necessary for propr last post bubbling this.GetRepository <Board>().Resync(); this.RaiseEvent.RaiseIssolated( new AfterUpgradeDatabaseEvent(prevVersion, YafForumInfo.AppVersion), null); if (isForumInstalled) { if (prevVersion < 30 || upgradeExtensions) { this.ImportStatics(); } if (prevVersion < 42) { // un-html encode all topic subject names... LegacyDb.unencode_all_topics_subjects(HttpUtility.HtmlDecode); } if (prevVersion < 49) { // Reset The UserBox Template try { this.Get <YafBoardSettings>().UserBox = Constants.UserBox.DisplayTemplateDefault; ((YafLoadBoardSettings)this.Get <YafBoardSettings>()).SaveRegistry(); } catch (Exception) { LegacyDb.registry_save("userbox", Constants.UserBox.DisplayTemplateDefault); } } try { // Check if BaskeUrlMask is set and if not automatically write it if (this.Get <YafBoardSettings>().BaseUrlMask.IsNotSet()) { this.Get <YafBoardSettings>().BaseUrlMask = BaseUrlBuilder.GetBaseUrlFromVariables(); ((YafLoadBoardSettings)this.Get <YafBoardSettings>()).SaveRegistry(); } } catch (Exception) { LegacyDb.registry_save("baseurlmask", BaseUrlBuilder.GetBaseUrlFromVariables()); } } // vzrus: uncomment it to not keep install/upgrade objects in DB and for better security // DB.system_deleteinstallobjects(); } // attempt to apply fulltext support if desired if (fullText && this.DbAccess.Information.FullTextScript.IsSet()) { try { this.ExecuteScript(this.DbAccess.Information.FullTextScript, false); } catch (Exception x) { // just a warning... this._messages.Add("Warning: FullText Support wasn't installed: {0}".FormatWith(x.Message)); } } // run custom script... this.ExecuteScript("custom/custom.sql", true); if (Config.IsDotNetNuke) { // run dnn custom script... this.ExecuteScript("custom/dnn.sql", true); } return(true); }
/// <summary> /// The upgrade database. /// </summary> /// <param name="upgradeExtensions"> /// The upgrade Extensions. /// </param> /// <returns> /// The <see cref="bool"/>. /// </returns> public bool UpgradeDatabase(bool upgradeExtensions) { var isForumInstalled = this.IsForumInstalled; // try this.FixAccess(false); var isAzureEngine = this.Get <IDbFunction>().GetSQLEngine().Equals("Azure"); if (!isForumInstalled) { this.ExecuteInstallScripts(isAzureEngine); } else { this.ExecuteUpgradeScripts(isAzureEngine); } this.FixAccess(true); var prevVersion = this.GetRepository <Registry>().GetDbVersion(); this.GetRepository <Registry>().Save("version", BoardInfo.AppVersion.ToString()); this.GetRepository <Registry>().Save("versionname", BoardInfo.AppVersionName); // Handle Tables this.DbAccess.Execute(db => db.Connection.CreateTableIfNotExists <Tag>()); this.DbAccess.Execute(db => db.Connection.CreateTableIfNotExists <TopicTag>()); // Ederon : 9/7/2007 // re-sync all boards - necessary for proper last post bubbling this.GetRepository <Board>().ReSync(); this.RaiseEvent.RaiseIssolated(new AfterUpgradeDatabaseEvent(prevVersion, BoardInfo.AppVersion), null); if (isForumInstalled) { if (prevVersion < 30 || upgradeExtensions) { this.ImportStatics(); } if (prevVersion < 42) { // un-html encode all topic subject names... this.GetRepository <Topic>().UnencodeAllTopicsSubjects(HttpUtility.HtmlDecode); } // initialize search index if (this.Get <BoardSettings>().LastSearchIndexUpdated.IsNotSet()) { this.GetRepository <Registry>().Save("forceupdatesearchindex", "1"); } // Check if BaseUrlMask is set and if not automatically write it if (this.Get <BoardSettings>().BaseUrlMask.IsNotSet()) { this.GetRepository <Registry>().Save("baseurlmask", BaseUrlBuilder.GetBaseUrlFromVariables()); } this.GetRepository <Registry>().Save("cdvversion", this.Get <BoardSettings>().CdvVersion++); } if (this.IsForumInstalled) { this.ExecuteScript(this.DbAccess.Information.FullTextUpgradeScript, false); } // run custom script... this.ExecuteScript("custom/custom.sql", true); if (Config.IsDotNetNuke) { // run dnn custom script... this.ExecuteScript("custom/dnn.sql", true); } return(true); }
public TelemetryClient() { baseUrlBuilder = new BaseUrlBuilder(); }
/// <summary> /// Handles the Load event of the Page control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> private void Page_Load([NotNull] object sender, [NotNull] EventArgs e) { var errorMessage = this.InstallWizard.FindControlAs <PlaceHolder>("ErrorMessage"); if (this._loadMessage.IsNotSet()) { errorMessage.Visible = false; } if (this.IsPostBack) { return; } if (this.Session["InstallWizardFinal"] != null) { this.CurrentWizardStepID = "WizFinished"; this.Session.Remove("InstallWizardFinal"); } else { this.Cache["DBVersion"] = LegacyDb.GetDBVersion(); this.CurrentWizardStepID = this.IsConfigPasswordSet && this.IsForumInstalled ? "WizEnterPassword" : "WizWelcome"; // "WizCreatePassword" if (!this.IsConfigPasswordSet) { // fake the board settings YafContext.Current.BoardSettings = new YafBoardSettings(); } this.FullTextSupport.Visible = this.DbAccess.Information.FullTextScript.IsSet() && this.Get <IDbFunction>().IsFullTextSupported(); this.TimeZones.DataSource = StaticDataHelper.TimeZones(); this.Culture.DataSource = StaticDataHelper.Cultures(); this.Culture.DataValueField = "CultureTag"; this.Culture.DataTextField = "CultureNativeName"; this.DataBind(); this.TimeZones.Items.FindByValue(TimeZoneInfo.Local.Id).Selected = true; if (this.Culture.Items.Count > 0) { this.Culture.Items.FindByValue("en-US").Selected = true; } this.ForumBaseUrlMask.Text = BaseUrlBuilder.GetBaseUrlFromVariables(); this.DBUsernamePasswordHolder.Visible = LegacyDb.PasswordPlaceholderVisible; // Connection string parameters text boxes foreach (var paramNumber in Enumerable.Range(1, 20)) { var dbParam = this.DbAccess.Information.DbConnectionParameters.FirstOrDefault(p => p.ID == paramNumber); var label = this.FindControlRecursiveAs <Label>("Parameter{0}_Name".FormatWith(paramNumber)); if (label != null) { label.Text = dbParam != null ? dbParam.Name : string.Empty; } var control = this.FindControlRecursive("Parameter{0}_Value".FormatWith(paramNumber)); if (control is TextBox) { var textBox = control as TextBox; if (dbParam != null) { textBox.Text = dbParam.Value; textBox.Visible = true; } else { textBox.Text = string.Empty; textBox.Visible = false; } } else if (control is CheckBox) { var checkBox = control as CheckBox; if (dbParam != null) { checkBox.Checked = dbParam.Value.ToType <bool>(); checkBox.Visible = true; } else { checkBox.Checked = false; checkBox.Visible = false; } } } // Hide New User on DNN if (!Config.IsDotNetNuke) { return; } this.UserChoice.SelectedIndex = 1; this.UserChoice.Items[0].Enabled = false; this.ExistingUserHolder.Visible = true; this.CreateAdminUserHolder.Visible = false; } }
/// <summary> /// The upgrade database. /// </summary> /// <param name="upgradeExtensions"> /// The upgrade Extensions. /// </param> /// <returns> /// The <see cref="bool"/>. /// </returns> public bool UpgradeDatabase(bool upgradeExtensions) { var isForumInstalled = this.IsForumInstalled; // try this.FixAccess(false); if (!isForumInstalled) { this.ExecuteInstallScripts(); } else { this.ExecuteUpgradeScripts(); } this.FixAccess(true); var prevVersion = this.GetRepository <Registry>().GetDbVersion(); this.GetRepository <Registry>().Save("version", BoardInfo.AppVersion.ToString()); this.GetRepository <Registry>().Save("versionname", BoardInfo.AppVersionName); // Handle Tables this.DbAccess.Execute(db => db.Connection.CreateTableIfNotExists <Tag>()); this.DbAccess.Execute(db => db.Connection.CreateTableIfNotExists <TopicTag>()); this.DbAccess.Execute(db => db.Connection.CreateTableIfNotExists <ProfileDefinition>()); this.DbAccess.Execute(db => db.Connection.CreateTableIfNotExists <ProfileCustom>()); // Ederon : 9/7/2007 // re-sync all boards - necessary for proper last post bubbling this.GetRepository <Board>().ReSync(); if (isForumInstalled) { if (prevVersion < 80) { // Upgrade to ASPNET Identity this.DbAccess.Information.IdentityUpgradeScripts.ForEach(script => this.ExecuteScript(script, true)); this.Get <ITaskModuleManager>().StartTask(MigrateAttachmentsTask.TaskName, () => new MigrateAttachmentsTask()); while (this.Get <ITaskModuleManager>().IsTaskRunning(MigrateAttachmentsTask.TaskName)) { Thread.Sleep(100); } } if (prevVersion < 30 || upgradeExtensions) { this.ImportStatics(); } if (prevVersion < 42) { // un-html encode all topic subject names... this.GetRepository <Topic>().UnEncodeAllTopicsSubjects(HttpUtility.HtmlDecode); } // initialize search index if (this.Get <BoardSettings>().LastSearchIndexUpdated.IsNotSet()) { this.GetRepository <Registry>().Save("forceupdatesearchindex", "1"); } // Check if BaseUrlMask is set and if not automatically write it if (this.Get <BoardSettings>().BaseUrlMask.IsNotSet()) { this.GetRepository <Registry>().Save("baseurlmask", BaseUrlBuilder.GetBaseUrlFromVariables()); } this.GetRepository <Registry>().Save("cdvversion", this.Get <BoardSettings>().CdvVersion++); this.Get <IDataCache>().Remove(Constants.Cache.Version); } if (this.IsForumInstalled) { this.ExecuteScript(this.DbAccess.Information.FullTextUpgradeScript, false); } // run custom script... this.ExecuteScript("custom/custom.sql", true); if (Config.IsDotNetNuke) { // run dnn custom script... this.ExecuteScript("custom/dnn.sql", true); } return(true); }
/// <summary> /// The render. /// </summary> /// <param name="output"> /// The output. /// </param> protected override void Render([NotNull] HtmlTextWriter output) { var displayName = this.ReplaceName.IsNotSet() ? this.Get <IUserDisplayName>().GetName(this.UserID) : this.ReplaceName; if (this.UserID == -1 || !displayName.IsSet()) { return; } // is this the guest user? If so, guest's don't have a profile. var isGuest = this.IsGuest ? this.IsGuest : UserMembershipHelper.IsGuestUser(this.UserID); output.BeginRender(); if (!isGuest) { output.WriteBeginTag("a"); output.WriteAttribute("href", YafBuildLink.GetLink(ForumPages.profile, "u={0}&name={1}", this.UserID, displayName)); if (this.CanViewProfile && this.IsHoverCardEnabled) { if (this.CssClass.IsSet()) { this.CssClass += " userHoverCard"; } else { this.CssClass = "userHoverCard"; } output.WriteAttribute( "data-hovercard", "{0}resource.ashx?userinfo={1}&boardId={2}&type=json&forumUrl={3}".FormatWith( Config.IsDotNetNuke ? BaseUrlBuilder.GetBaseUrlFromVariables() + BaseUrlBuilder.AppPath : YafForumInfo.ForumClientFileRoot, this.UserID, YafContext.Current.PageBoardID, HttpUtility.UrlEncode(YafBuildLink.GetBasePath()))); } else { output.WriteAttribute("title", this.GetText("COMMON", "VIEW_USRPROFILE")); } if (this.Get <YafBoardSettings>().UseNoFollowLinks) { output.WriteAttribute("rel", "nofollow"); } if (this.BlankTarget) { output.WriteAttribute("target", "_blank"); } } else { output.WriteBeginTag("span"); } this.RenderMainTagAttributes(output); output.Write(HtmlTextWriter.TagRightChar); // Replace Name with Crawler Name if Set, otherwise use regular display name or Replace Name if set if (this.CrawlerName.IsSet()) { output.WriteEncodedText(this.CrawlerName); } else if (!this.CrawlerName.IsSet() && this.ReplaceName.IsSet() && isGuest) { output.WriteEncodedText(this.ReplaceName); } else { output.WriteEncodedText(displayName); } output.WriteEndTag(!isGuest ? "a" : "span"); if (this.PostfixText.IsSet()) { output.Write(this.PostfixText); } output.EndRender(); }
/// <summary> /// Initialize Or Upgrade the Database /// </summary> /// <param name="updateExtensions"> /// update Extensions ?!. /// </param> /// <returns> /// The <see cref="bool"/>. /// </returns> public bool InitializeOrUpgradeDatabase(bool updateExtensions) { var isForumInstalled = this.IsForumInstalled; this.CreateOrUpdateTables(); if (!isForumInstalled) { this.ExecuteInstallScripts(); } var prevVersion = this.GetRepository <Registry>().GetDbVersion(); this.GetRepository <Registry>().Save("version", BoardInfo.AppVersion.ToString()); this.GetRepository <Registry>().Save("versionname", BoardInfo.AppVersionName); if (isForumInstalled) { if (prevVersion >= 80) { this.ExecuteNewUpgradeScripts(); } else { this.ExecuteUpgradeScripts(); this.ExecuteScript(this.DbAccess.Information.FullTextUpgradeScript, false); } if (prevVersion < 80) { // Upgrade to ASPNET Identity this.DbAccess.Information.IdentityUpgradeScripts.ForEach(script => this.ExecuteScript(script, true)); this.Get <ITaskModuleManager>().StartTask(MigrateAttachmentsTask.TaskName, () => new MigrateAttachmentsTask()); while (this.Get <ITaskModuleManager>().IsTaskRunning(MigrateAttachmentsTask.TaskName)) { Thread.Sleep(100); } // Delete old registry Settings this.GetRepository <Registry>().DeleteLegacy(); } if (prevVersion < 30 || updateExtensions) { this.AddOrUpdateExtensions(); } if (prevVersion < 42) { // un-html encode all topic subject names... this.GetRepository <Topic>().UnEncodeAllTopicsSubjects(HttpUtility.HtmlDecode); } // initialize search index if (this.Get <BoardSettings>().LastSearchIndexUpdated.IsNotSet()) { this.GetRepository <Registry>().Save("forceupdatesearchindex", "1"); } // Check if BaseUrlMask is set and if not automatically write it if (this.Get <BoardSettings>().BaseUrlMask.IsNotSet()) { this.GetRepository <Registry>().Save("baseurlmask", BaseUrlBuilder.GetBaseUrlFromVariables()); } this.GetRepository <Registry>().Save("cdvversion", this.Get <BoardSettings>().CdvVersion++); this.Get <IDataCache>().Remove(Constants.Cache.Version); } // run custom script... this.ExecuteScript("custom/custom.sql", true); if (Config.IsDotNetNuke) { // run dnn custom script... this.ExecuteScript("custom/dnn.sql", true); } return(true); }
/// <summary> /// The upgrade database. /// </summary> /// <param name="upgradeExtensions"> /// The upgrade Extensions. /// </param> /// <returns> /// The <see cref="bool"/>. /// </returns> public bool UpgradeDatabase(bool upgradeExtensions) { this.messages.Clear(); { var isForumInstalled = this.IsForumInstalled; // try this.FixAccess(false); var isAzureEngine = this.Get <IDbFunction>().GetSQLEngine().Equals("Azure"); if (!isForumInstalled) { this.ExecuteInstallScripts(isAzureEngine); } else { this.ExecuteUpgradeScripts(isAzureEngine); } this.FixAccess(true); var prevVersion = this.GetRepository <Registry>().GetDbVersion(); this.GetRepository <Registry>().Save("version", YafForumInfo.AppVersion.ToString()); this.GetRepository <Registry>().Save("versionname", YafForumInfo.AppVersionName); // Ederon : 9/7/2007 // re-sync all boards - necessary for proper last post bubbling this.GetRepository <Board>().ReSync(); this.RaiseEvent.RaiseIssolated( new AfterUpgradeDatabaseEvent(prevVersion, YafForumInfo.AppVersion), null); if (isForumInstalled) { if (prevVersion < 30 || upgradeExtensions) { this.ImportStatics(); } if (prevVersion < 42) { // un-html encode all topic subject names... this.GetRepository <Topic>().UnencodeAllTopicsSubjects(HttpUtility.HtmlDecode); } if (prevVersion < 70) { // Reset The UserBox Template try { this.Get <YafBoardSettings>().UserBox = Constants.UserBox.DisplayTemplateDefault; this.Get <YafBoardSettings>().UserBoxAvatar = @"<li class=""list-group-item"">{0}</li>"; this.Get <YafBoardSettings>().UserBoxMedals = @"<li class=""list-group-item""><strong>{0}</strong><br /> {1}{2}</li>"; this.Get <YafBoardSettings>().UserBoxRankImage = @"<li class=""list-group-item"">{0}</li>"; this.Get <YafBoardSettings>().UserBoxRank = @"<li class=""list-group-item""><strong>{0}:</strong> {1}</li>"; this.Get <YafBoardSettings>().UserBoxGroups = @"<li class=""list-group-item""><strong>{0}:</strong><br /> {1}</li>"; this.Get <YafBoardSettings>().UserBoxJoinDate = @"<li class=""list-group-item""><strong>{0}:</strong> {1}</li>"; this.Get <YafBoardSettings>().UserBoxPosts = @"<li class=""list-group-item""><strong>{0}:</strong> {1:N0}</li>"; this.Get <YafBoardSettings>().UserBoxReputation = @"<li class=""list-group-item""><strong>{0}:</strong> {1:N0}</li>"; this.Get <YafBoardSettings>().UserBoxCountryImage = @"{0}"; this.Get <YafBoardSettings>().UserBoxLocation = @"<li class=""list-group-item""><strong>{0}:</strong> {1}</li>"; this.Get <YafBoardSettings>().UserBoxGender = @"{0} "; this.Get <YafBoardSettings>().UserBoxThanksFrom = @"<li class=""list-group-item"">{0}</li>"; this.Get <YafBoardSettings>().UserBoxThanksTo = @"<li class=""list-group-item"">{0}</li>"; } catch (Exception) { this.GetRepository <Registry>().Save("userbox", Constants.UserBox.DisplayTemplateDefault); } } // Check if BaseUrlMask is set and if not automatically write it if (this.Get <YafBoardSettings>().BaseUrlMask.IsNotSet()) { this.GetRepository <Registry>().Save("baseurlmask", BaseUrlBuilder.GetBaseUrlFromVariables()); } this.GetRepository <Registry>().Save("cdvversion", this.Get <YafBoardSettings>().CdvVersion++); } } if (this.IsForumInstalled) { this.ExecuteScript(this.DbAccess.Information.FullTextUpgradeScript, false); } // run custom script... this.ExecuteScript("custom/custom.sql", true); if (Config.IsDotNetNuke) { // run dnn custom script... this.ExecuteScript("custom/dnn.sql", true); } return(true); }