Joins implemented in MySQLConnector; UserReplies page implemented

main
Inga 🏳‍🌈 14 years ago
parent b84630abc5
commit 462a07e6e2
  1. 2
      Builder/IISMainHandler/build.txt
  2. 2
      Builder/IISUploadHandler/build.txt
  3. 28
      Common/dataobjects/User.cs
  4. 12
      Core/DB/JoinSpec.cs
  5. 2
      IISMainHandler/HandlersFactory.cs
  6. 1
      IISMainHandler/IISMainHandler.csproj
  7. 45
      IISMainHandler/handlers/response/UserRepliesHandler.cs
  8. 13
      MySQLConnector/Connection.cs
  9. 11
      templates/Full/Boards.xslt
  10. 7
      templates/Full/UserInfo.xslt
  11. 81
      templates/Full/UserReplies.xslt

@ -224,5 +224,33 @@ namespace FLocal.Common.dataobjects {
);
}
public IEnumerable<Post> getReplies(Diapasone diapasone) {
JoinSpec parent = new JoinSpec(
Post.TableSpec.instance.getColumnSpec(Post.TableSpec.FIELD_PARENTPOSTID),
Post.TableSpec.instance,
"parent"
);
return Post.LoadByIds(
from stringId in Config.instance.mainConnection.LoadIdsByConditions(
Post.TableSpec.instance,
new ComparisonCondition(
parent.additionalTable.getColumnSpec(Post.TableSpec.FIELD_POSTERID),
ComparisonType.EQUAL,
this.id.ToString()
),
diapasone,
new JoinSpec[] {
parent
},
new SortSpec[] {
new SortSpec(
Post.TableSpec.instance.getIdSpec(),
false
),
}
) select int.Parse(stringId)
);
}
}
}

@ -8,8 +8,10 @@ namespace FLocal.Core.DB {
private class TableSpec : ITableSpec {
private readonly string _name;
public TableSpec(string name) {
private readonly string _idName;
public TableSpec(ITableSpec raw, string name) {
this._name = name;
this._idName = raw.idName;
}
public string name {
get {
@ -18,7 +20,7 @@ namespace FLocal.Core.DB {
}
public string idName {
get {
throw new NotImplementedException();
return this._idName;
}
}
}
@ -26,12 +28,12 @@ namespace FLocal.Core.DB {
public readonly ColumnSpec mainColumn;
public readonly ITableSpec additionalTable;
public readonly ITableSpec additionalTableJoin;
public readonly ITableSpec additionalTableRaw;
public JoinSpec(ColumnSpec mainColumn, ITableSpec additionalTable, string alias) {
this.mainColumn = mainColumn;
this.additionalTableJoin = additionalTable;
this.additionalTable = new TableSpec(alias);
this.additionalTableRaw = additionalTable;
this.additionalTable = new TableSpec(additionalTable, alias);
}
}

@ -93,6 +93,8 @@ namespace FLocal.IISHandler {
switch(context.requestParts[2].ToLower()) {
case "posts":
return new handlers.response.UserPostsHandler();
case "replies":
return new handlers.response.UserRepliesHandler();
default:
return new handlers.WrongUrlHandler();
}

@ -93,6 +93,7 @@
<Compile Include="handlers\response\UploadNewHandler.cs" />
<Compile Include="handlers\response\UserInfoHandler.cs" />
<Compile Include="handlers\response\UserPostsHandler.cs" />
<Compile Include="handlers\response\UserRepliesHandler.cs" />
<Compile Include="handlers\response\WhoIsOnlineHandler.cs" />
<Compile Include="handlers\RootHandler.cs" />
<Compile Include="handlers\StaticHandler.cs" />

@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Xml.Linq;
using FLocal.Common;
using FLocal.Common.dataobjects;
using FLocal.Core;
using FLocal.Core.DB;
using FLocal.Core.DB.conditions;
namespace FLocal.IISHandler.handlers.response {
class UserRepliesHandler : AbstractGetHandler {
override protected string templateName {
get {
return "UserReplies.xslt";
}
}
override protected XElement[] getSpecificData(WebContext context) {
User user = User.LoadById(int.Parse(context.requestParts[1]));
PageOuter pageOuter = PageOuter.createFromGet(
context.requestParts,
context.userSettings.postsPerPage,
3
);
IEnumerable<Post> posts = user.getReplies(pageOuter);
XElement[] result = new XElement[] {
user.exportToXmlForViewing(context),
new XElement("posts",
from post in posts select post.exportToXmlWithoutThread(context, true),
pageOuter.exportToXml(2, 5, 2)
)
};
return result;
}
}
}

@ -91,10 +91,17 @@ namespace FLocal.MySQLConnector {
if(conditionsCompiled.Key != "") queryConditions = "WHERE " + conditionsCompiled.Key;
ParamsHolder paramsHolder = conditionsCompiled.Value;
string queryJoins = "";
StringBuilder queryJoins = new StringBuilder();
{
if(joins.Length > 0) {
throw new NotImplementedException();
foreach(var join in joins) {
queryJoins.Append(" JOIN ");
queryJoins.Append(join.additionalTableRaw.compile(this.traits));
queryJoins.Append(" ");
queryJoins.Append(join.additionalTable.compile(this.traits));
queryJoins.Append(" ON ");
queryJoins.Append(join.mainColumn.compile(this.traits));
queryJoins.Append(" = ");
queryJoins.Append(join.additionalTable.getIdSpec().compile(this.traits));
}
}

@ -25,7 +25,11 @@
<td width="45%" class="small" valign="top">
<xsl:choose>
<xsl:when test="session/user">
<xsl:text>Вы вошли в форум как </xsl:text><xsl:value-of select="session/user/name"/>
<xsl:text>Âû âîøëè â ôîðóì êàê </xsl:text>
<a>
<xsl:attribute name="href">/User/<xsl:value-of select="session/user/id"/>/</xsl:attribute>
<xsl:value-of select="session/user/name"/>
</a>
</xsl:when>
<xsl:otherwise>
<xsl:text>Âû íå âîøëè â ôîðóì</xsl:text>
@ -52,7 +56,10 @@
<br />
<a>Ïîñëåäíèå 7 äíåé</a>
<br />
<a>Последние ответы на мои сообщения</a>
<a>
<xsl:attribute name="href">/User/<xsl:value-of select="session/user/id"/>/Replies/</xsl:attribute>
<xsl:text>Ïîñëåäíèå îòâåòû íà ìîè ñîîáùåíèÿ</xsl:text>
</a>
<br />
<a>Ìîè ñîîáùåíèÿ ñ îöåíêàìè</a>
<br />

@ -205,7 +205,12 @@
<a>
<xsl:attribute name="href">/User/<xsl:value-of select="user/id"/>/Posts/</xsl:attribute>
<img src="/static/images/viewposts.gif" align="top" style="vertical-align: text-bottom" />
<xsl:text> Показать все сообщения пользователя</xsl:text>
<xsl:text> Ñîîáùåíèÿ</xsl:text>
</a>
<xsl:text> | </xsl:text>
<a>
<xsl:attribute name="href">/User/<xsl:value-of select="user/id"/>/Replies/</xsl:attribute>
<xsl:text>Îòâåòû</xsl:text>
</a>
<xsl:text> | </xsl:text>
<a>

@ -0,0 +1,81 @@
<?xml version="1.0" encoding="Windows-1251"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml">
<xsl:import href="elems\Main.xslt"/>
<xsl:import href="elems\PostInfo.xslt"/>
<xsl:template name="specificTitle">
<xsl:text>Îòâåòû - </xsl:text>
<xsl:value-of select="user/name"/>
</xsl:template>
<xsl:template name="specific">
<table width="95%" align="center" cellpadding="1" cellspacing="1" class="tablesurround">
<tr>
<td>
<table cellpadding="3" cellspacing="1" width="100%" class="tableborders">
<tr class="darktable">
<td>
<table width="100%" cellpadding="0" cellspacing="0">
<tr class="darktable">
<td align="left" width="33%">
<font class="catandforum">
<a>
<xsl:attribute name="href">/Users/</xsl:attribute>
<xsl:text>Ïîëüçîâàòåëè</xsl:text>
</a>
<xsl:text> &gt;&gt; </xsl:text>
<a>
<xsl:attribute name="href">/User/<xsl:value-of select="user/id"/></xsl:attribute>
<xsl:value-of select="user/name"/>
</a>
<xsl:text> &gt;&gt; </xsl:text>
<xsl:text>Îòâåòû</xsl:text>
</font>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
<br />
<table width="95%" align="center" cellpadding="1" cellspacing="1" class="tablesurround">
<tr>
<td>
<table cellpadding="0" cellspacing="1" width="100%" class="tableborders">
<tr class="tdheader">
<td>
<table width="100%" cellspacing="1" cellpadding="3" border="0">
<tr>
<td>
<xsl:text>ñòðàíèöû:</xsl:text>
<xsl:apply-templates select="posts/pageOuter" mode="withCurrent">
<xsl:with-param name="baseLink">/User/<xsl:value-of select="user/id"/>/Replies/</xsl:with-param>
</xsl:apply-templates>
</td>
</tr>
</table>
</td>
</tr>
<xsl:apply-templates select="posts/post"/>
<tr class="tdheader">
<td>
<table width="100%" cellspacing="1" cellpadding="3" border="0">
<tr>
<td>
<xsl:text>ñòðàíèöû:</xsl:text>
<xsl:apply-templates select="posts/pageOuter" mode="withCurrent">
<xsl:with-param name="baseLink">/User/<xsl:value-of select="user/id"/>/Replies/</xsl:with-param>
</xsl:apply-templates>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</xsl:template>
</xsl:stylesheet>
Loading…
Cancel
Save