/// <summary> /// The list_ item command. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> private void list_ItemCommand([NotNull] object sender, [NotNull] RepeaterCommandEventArgs e) { switch (e.CommandName) { case "add": YafBuildLink.Redirect(ForumPages.admin_topicstatus_edit); break; case "edit": YafBuildLink.Redirect(ForumPages.admin_topicstatus_edit, "i={0}", e.CommandArgument); break; case "delete": LegacyDb.TopicStatus_Delete(e.CommandArgument); this.BindData(); break; case "export": { // export this list as XML... var topicStatusList = LegacyDb.TopicStatus_List(this.PageContext.PageBoardID); topicStatusList.DataSet.DataSetName = "YafTopicStatusList"; topicStatusList.TableName = "YafTopicStatus"; topicStatusList.Columns.Remove("TopicStatusID"); topicStatusList.Columns.Remove("BoardID"); this.Response.ContentType = "text/xml"; this.Response.AppendHeader("Content-Disposition", "attachment; filename=YafTopicStatusList.xml"); topicStatusList.DataSet.WriteXml(this.Response.OutputStream); this.Response.End(); } break; case "import": YafBuildLink.Redirect(ForumPages.admin_topicstatus_import); break; } }
/// <summary> /// Topics the status import. /// </summary> /// <param name="boardId"> /// The board id. /// </param> /// <param name="inputStream"> /// The input stream. /// </param> /// <exception cref="Exception"> /// Import stream is not expected format. /// </exception> /// <returns> /// Returns the Number of Imported Items. /// </returns> public static int TopicStatusImport(int boardId, Stream inputStream) { var importedCount = 0; // import extensions... var dsStates = new DataSet(); dsStates.ReadXml(inputStream); if (dsStates.Tables["YafTopicStatus"] != null && dsStates.Tables["YafTopicStatus"].Columns["TopicStatusName"] != null && dsStates.Tables["YafTopicStatus"].Columns["DefaultDescription"] != null) { var topicStatusList = LegacyDb.TopicStatus_List(boardId); // import any topic status that don't exist... foreach ( var row in dsStates.Tables["YafTopicStatus"].Rows.Cast <DataRow>().Where( row => topicStatusList.Select("TopicStatusName = '{0}'".FormatWith(row["TopicStatusName"])).Length == 0)) { // add this... LegacyDb.TopicStatus_Save( null, boardId, row["TopicStatusName"].ToString(), row["DefaultDescription"].ToString()); importedCount++; } } else { throw new Exception("Import stream is not expected format."); } return(importedCount); }
/// <summary> /// The bind data. /// </summary> private void BindData() { this.list.DataSource = LegacyDb.TopicStatus_List(this.PageContext.PageBoardID); this.DataBind(); }