/// <summary> /// The import statics. /// </summary> private void ImportStatics() { var loadWrapper = new Action <string, Action <Stream> >( (file, streamAction) => { var fullFile = this.Get <HttpRequestBase>().MapPath(file); if (!File.Exists(fullFile)) { return; } // import into board... using (var stream = new StreamReader(fullFile)) { streamAction(stream.BaseStream); stream.Close(); } }); this.Get <IRaiseEvent>().Raise(new ImportStaticDataEvent(this.PageBoardID)); // load default bbcode if available... loadWrapper(_BbcodeImport, s => DataImport.BBCodeExtensionImport(this.PageBoardID, s)); // load default extensions if available... loadWrapper(_FileImport, s => DataImport.FileExtensionImport(this.PageBoardID, s)); // load default topic status if available... loadWrapper(_TopicStatusImport, s => DataImport.TopicStatusImport(this.PageBoardID, s)); // load default spam word if available... loadWrapper(_SpamWordsImport, s => DataImport.SpamWordsImport(this.PageBoardID, s)); }
/// <summary> /// Try to Import from selected File /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void Import_OnClick([NotNull] object sender, [NotNull] EventArgs e) { // import selected file (if it's the proper format)... if (!this.importFile.PostedFile.ContentType.StartsWith("text")) { this.PageContext.AddLoadMessage( this.GetText("ADMIN_TOPICSTATUS_IMPORT", "IMPORT_FAILED").FormatWith( "Invalid upload format specified: " + this.importFile.PostedFile.ContentType)); return; } try { int importedCount = DataImport.TopicStatusImport( this.PageContext.PageBoardID, this.importFile.PostedFile.InputStream); this.PageContext.LoadMessage.AddSession( importedCount > 0 ? this.GetText("ADMIN_TOPICSTATUS_IMPORT", "IMPORT_SUCESS").FormatWith(importedCount) : this.GetText("ADMIN_TOPICSTATUS_IMPORT", "IMPORT_NOTHING"), importedCount > 0 ? MessageTypes.Success : MessageTypes.Warning); YafBuildLink.Redirect(ForumPages.admin_topicstatus); } catch (Exception x) { this.PageContext.AddLoadMessage( this.GetText("ADMIN_TOPICSTATUS_IMPORT", "IMPORT_FAILED").FormatWith(x.Message)); } }
/// <summary> /// Creates the board in the database. /// </summary> /// <param name="boardName">Name of the board.</param> /// <param name="boardMembershipAppName">Name of the board membership application.</param> /// <param name="boardRolesAppName">Name of the board roles application.</param> /// <param name="langFile">The language file.</param> /// <param name="newAdmin">The new admin.</param> /// <returns>Returns the Board ID of the new Board.</returns> private int CreateBoardDatabase( string boardName, string boardMembershipAppName, string boardRolesAppName, string langFile, MembershipUser newAdmin) { var newBoardId = YafContext.Current.GetRepository <Board>() .Create( boardName, "en-US", langFile, boardMembershipAppName, boardRolesAppName, newAdmin.UserName, newAdmin.Email, newAdmin.ProviderUserKey.ToString(), this.PortalSettings.UserInfo.IsSuperUser, global::YAF.Classes.Config.CreateDistinctRoles && global::YAF.Classes.Config.IsAnyPortal ? "YAF " : string.Empty); var loadWrapper = new Action <string, Action <Stream> >( (file, streamAction) => { var fullFile = YafContext.Current.Get <HttpRequestBase>().MapPath(file); if (!File.Exists(fullFile)) { return; } // import into board... using (var stream = new StreamReader(fullFile)) { streamAction(stream.BaseStream); stream.Close(); } }); // load default bbcode if available... loadWrapper("install/bbCodeExtensions.xml", s => DataImport.BBCodeExtensionImport(newBoardId, s)); // load default extensions if available... loadWrapper("install/fileExtensions.xml", s => DataImport.FileExtensionImport(newBoardId, s)); // load default topic status if available... loadWrapper("install/TopicStatusList.xml", s => DataImport.TopicStatusImport(newBoardId, s)); // load default spam word if available... loadWrapper("install/SpamWords.xml", s => DataImport.SpamWordsImport(newBoardId, s)); return(newBoardId); }
/// <summary> /// Creates the board in the database. /// </summary> /// <param name="boardName">Name of the board.</param> /// <param name="boardMembershipAppName">Name of the board membership application.</param> /// <param name="boardRolesAppName">Name of the board roles application.</param> /// <param name="langFile">The language file.</param> /// <param name="newAdmin">The new admin.</param> /// <returns></returns> private int DbCreateBoard( string boardName, string boardMembershipAppName, string boardRolesAppName, string langFile, MembershipUser newAdmin) { int newBoardID = this.GetRepository <Board>() .Create( boardName, this.Culture.SelectedItem.Value, langFile, boardMembershipAppName, boardRolesAppName, newAdmin.UserName, newAdmin.Email, newAdmin.ProviderUserKey.ToString(), this.PageContext().IsHostAdmin, Config.CreateDistinctRoles && Config.IsAnyPortal ? "YAF " : string.Empty); var loadWrapper = new Action <string, Action <Stream> >( (file, streamAction) => { var fullFile = this.Get <HttpRequestBase>().MapPath(file); if (!File.Exists(fullFile)) { return; } // import into board... using (var stream = new StreamReader(fullFile)) { streamAction(stream.BaseStream); stream.Close(); } }); // load default bbcode if available... loadWrapper("install/bbCodeExtensions.xml", s => DataImport.BBCodeExtensionImport(newBoardID, s)); // load default extensions if available... loadWrapper("install/fileExtensions.xml", s => DataImport.FileExtensionImport(newBoardID, s)); // load default topic status if available... loadWrapper("install/TopicStatusList.xml", s => DataImport.TopicStatusImport(newBoardID, s)); // load default spam word if available... loadWrapper("install/SpamWords.xml", s => DataImport.SpamWordsImport(newBoardID, s)); return(newBoardID); }